9front - general discussion about 9front
 help / color / mirror / Atom feed
From: ori@eigenstate.org
To: 9front@9front.org
Subject: [Patch] show read flags in acme.
Date: Mon, 18 Nov 2019 13:28:13 -0800	[thread overview]
Message-ID: <E1401A548E00A34AF052B900A7B5DCD6@eigenstate.org> (raw)

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;



             reply	other threads:[~2019-11-18 21:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-18 21:28 ori [this message]
2019-11-19 19:18 ` [9front] " Pavel Renev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1401A548E00A34AF052B900A7B5DCD6@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).