shithub: Nail

Download patch

ref: 155d5bd828718252ce38b483a0928413d1bf87f3
parent: 239c96346ae241b9625cd59ca574be5f017cef9e
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Nov 6 11:24:13 EST 2020

flip seen flag for consistent treatment

--- a/mail.h
+++ b/mail.h
@@ -17,7 +17,7 @@
 	Fopen	= 1<<2,	/* opened for viewing */
 
 	Fresp	= 1<<3,	/* has been responded to */
-	Funseen	= 1<<4,	/* has been viewed */
+	Fseen	= 1<<4,	/* has been viewed */
 	Fdel	= 1<<5, /* was deleted */
 	Ftodel	= 1<<6,	/* pending deletion */
 };
--- a/mbox.c
+++ b/mbox.c
@@ -313,9 +313,9 @@
 		return nil;
 	free(m->mflags);
 	m->mflags = f;
-	m->flags = Funseen;
+	m->flags = 0;
 	if(strchr(m->mflags, 'd')) m->flags |= Fdel;
-	if(strchr(m->mflags, 's')) m->flags &= ~Funseen;
+	if(strchr(m->mflags, 's')) m->flags |= Fseen;
 	if(strchr(m->mflags, 'a')) m->flags |= Fresp;
 	return m;
 }
@@ -429,10 +429,10 @@
 
 	if(!(m->flags & Fdummy)){
 		dots = "";
-		flag = " ";
+		flag = "★";
 		sep = depth ? "\t" : "";
 		width = depth ? Subjlen - 4 : Subjlen;
-		if(m->flags & Funseen)	flag = "★";
+		if(m->flags & Fseen)	flag = " ";
 		if(m->flags & Fresp)	flag = "←";
 		if(m->flags & Fdel)	flag = "∉";
 		if(m->flags & Ftodel)	flag = "∉";
--- a/mesg.c
+++ b/mesg.c
@@ -117,9 +117,9 @@
 	m->fromcolon = fc(m, line(p, &p, 1));
 	free(info);
 
-	m->flags = Funseen;
+	m->flags = 0;
 	if(strchr(m->mflags, 'd')) m->flags |= Fdel;
-	if(strchr(m->mflags, 's')) m->flags &= ~Funseen;
+	if(strchr(m->mflags, 's')) m->flags |= Fseen;
 	if(strchr(m->mflags, 'a')) m->flags |= Fresp;
 
 	m->time = time(nil);
@@ -303,7 +303,7 @@
 qreply(Mesg *m, char **f, int nf)
 {
 	if(nf >= 3
-	|| nf >= 2 && strcmp(f[1], "All") != 0
+	|| nf >= 2 && strcmp(f[1], "all") != 0
 	|| nf >= 1 && strcmp(f[0], "Reply") != 0
 	|| nf == 0){
 		fprint(2, "Q: invaid args\n");
@@ -461,8 +461,8 @@
 
 	assert(!(m->flags & Fdummy));
 	m->flags |= Fopen;
-	if(m->flags & Funseen){
-		m->flags &= ~Funseen;
+	if(!(m->flags & Fseen)){
+		m->flags |= Fseen;
 		path = estrjoin(mbox.path, "/", m->name, "/flags", nil);
 		if((fd = open(path, OWRITE)) != -1){
 			fprint(fd, "+s");