* [Patch] show read flags in acme.
@ 2019-11-18 21:28 ori
2019-11-19 19:18 ` [9front] " Pavel Renev
0 siblings, 1 reply; 3+ messages in thread
From: ori @ 2019-11-18 21:28 UTC (permalink / raw)
To: 9front
Not sure how many people still use acme Mail, or are as bad at remembering what
they've already read as I am (especially in long threads), but this has been
bugging me for a while, so I patched it.
Using it now, if I dont' find bugs, and nobody objects, I'll commit in the
next day or two.
diff -r 9ad06889a5d1 sys/src/cmd/upas/Mail/dat.h
--- a/sys/src/cmd/upas/Mail/dat.h Mon Nov 18 01:06:02 2019 -0800
+++ b/sys/src/cmd/upas/Mail/dat.h Mon Nov 18 13:17:50 2019 -0800
@@ -70,6 +70,7 @@
char *disposition;
char *filename;
char *digest;
+ char *flags;
Message *next; /* next in this mailbox */
Message *prev; /* prev in this mailbox */
diff -r 9ad06889a5d1 sys/src/cmd/upas/Mail/mesg.c
--- a/sys/src/cmd/upas/Mail/mesg.c Mon Nov 18 01:06:02 2019 -0800
+++ b/sys/src/cmd/upas/Mail/mesg.c Mon Nov 18 13:17:50 2019 -0800
@@ -132,7 +132,7 @@
/* m->messageid = */ free(line(p, &p));
/* m->lines = */ free(line(p, &p));
/* m->size = */ free(line(p, &p));
- /* m->flags = */ free(line(p, &p));
+ m->flags = line(p, &p);
/* m->fileid = */ free(line(p, &p));
m->fromcolon = fc(m, line(p, &p));
@@ -308,14 +308,36 @@
return s == e? 0: -1;
}
+
void
setflags(Message *m, char *f)
{
- char *t;
+ char *flgchar = "aDdfrsS";
+ char *t, *p;
+ int rm;
t = smprint("%s/%s", mbox.name, m->name);
writefile(t, "flags", f);
free(t);
+ for(; *f; f++){
+ rm = 0;
+ if(*f == '-'){
+ rm = 1;
+ f++;
+ }
+ if((p = strchr(flgchar, *f)) != nil)
+ m->flags[p - flgchar] = rm ? '-' : *f;
+ }
+}
+
+void
+fmtflags(char *b, char *flg)
+{
+ *b++ = '[';
+ *b++ = (strchr(flg, 's') == nil) ? '*' : ' ';
+ *b++ = (strchr(flg, 'a') == nil) ? ' ' : 'R';
+ *b++ = ']';
+ *b = '\0';
}
char*
@@ -324,13 +346,14 @@
char *i;
int j, len, lens;
char *p;
- char fmt[80], s[80];
+ char fmt[80], s[80], flg[16];
if (ogf)
p=m->to;
else
p=m->fromcolon;
+ fmtflags(flg, m->flags);
if(ind==0 && altmenu){
len = 12;
lens = 20;
@@ -369,6 +392,7 @@
}
i = estrdup("");
+ i = eappend(i, " ", flg);
i = eappend(i, "\t", p);
i = egrow(i, "\t", stripdate(m->date));
if(ind == 0){
@@ -538,6 +562,25 @@
}
void
+mesgmenureflag(Window *w, Message *m)
+{
+ char *buf, flg[16];
+
+ fmtflags(flg, m->flags);
+ print("flags: %s\n", flg);
+ buf = name2regexp(deletedrx01, m->name);
+ strcat(buf, "+/\\[[^\\]]*\\]/");
+ if(w->data < 0)
+ w->data = winopenfile(w, "data");
+ if(winselect(w, buf, 1))
+ write(w->data, flg, strlen(flg));
+ free(buf);
+
+ close(w->data);
+ w->data = -1;
+}
+
+void
mesgmenumark(Window *w, char *which, char *mark)
{
char *buf;
@@ -570,6 +613,7 @@
free(m->type);
free(m->disposition);
free(m->filename);
+ free(m->flags);
free(m->digest);
}
@@ -1312,6 +1356,7 @@
winclean(m->w);
m->opened = 1;
setflags(m, "s");
+ mesgmenureflag(mbox->w, m);
if(ndirelem == 1){
free(u);
return 1;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9front] [Patch] show read flags in acme.
2019-11-18 21:28 [Patch] show read flags in acme ori
@ 2019-11-19 19:18 ` Pavel Renev
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Renev @ 2019-11-19 19:18 UTC (permalink / raw)
To: 9front
On Mon, Nov 18, 2019 at 01:28:13PM -0800, ori@eigenstate.org wrote:
> Not sure how many people still use acme Mail, or are as bad at remembering what
> they've already read as I am (especially in long threads)
When I used acme Mail, I deleted mail after reading it.
All existing mail is unread mail.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9front] [Patch] show read flags in acme.
@ 2019-11-21 2:47 ori
0 siblings, 0 replies; 3+ messages in thread
From: ori @ 2019-11-21 2:47 UTC (permalink / raw)
To: ori, 9front
> Not sure how many people still use acme Mail, or are as bad at remembering what
> they've already read as I am (especially in long threads), but this has been
> bugging me for a while, so I patched it.
>
> Using it now, if I dont' find bugs, and nobody objects, I'll commit in the
> next day or two.
This is working well for me, but for imap users, you're also really
going to want the imap patches I posted, otherwise the flags end up a
bit wonky.
I'll hold off committing this until after the imap patches are good
and baked.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-21 2:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 21:28 [Patch] show read flags in acme ori
2019-11-19 19:18 ` [9front] " Pavel Renev
2019-11-21 2:47 ori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).