From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28002 invoked from network); 28 Jun 2021 00:10:28 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 28 Jun 2021 00:10:28 -0000 Received: from vps1.pmikkelsen.com ([88.198.125.163]) by 1ess; Sun Jun 27 20:03:59 -0400 2021 Received: from thinkpadPM.My_net ([85.203.153.237]) by vps1; Mon Jun 28 02:03:53 +0200 2021 Message-ID: <47675BC155CE07E75793B739EE15ECED@pmikkelsen.com> To: 9front@9front.org Date: Mon, 28 Jun 2021 02:03:52 +0200 From: peter@pmikkelsen.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-xiazjmyvhrwydwekpztxkvvrkg" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: ORM over AJAX descriptor table-aware persistence control Subject: [9front] Patch to add -u flag to faces, so it only shows unread messages Reply-To: 9front@9front.org Precedence: bulk This is a multi-part message in MIME format. --upas-xiazjmyvhrwydwekpztxkvvrkg Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit I don't know if this is something people would want, but I post it here in case someone considers the feature good enough for committing. --upas-xiazjmyvhrwydwekpztxkvvrkg Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit From b09dda741c8b009dbc64729003d847f829127f29 From: Peter Mikkelsen Date: Sun, 27 Jun 2021 22:27:55 +0000 Subject: [PATCH] Add -u flag to faces, making it only show unread messages. --- diff 658757abed7be283e06bae3b1722fc2703334d74 b09dda741c8b009dbc64729003d847f829127f29 --- a/sys/man/1/faces Sun Jun 27 02:13:58 2021 +++ b/sys/man/1/faces Mon Jun 28 00:27:55 2021 @@ -4,7 +4,7 @@ .SH SYNOPSIS .B faces [ -.B -ihc +.B -ihcu ] [ .B -m .I maildir @@ -99,6 +99,15 @@ rather than the current state of the mail box. In particular, faces are not removed from the screen when messages are deleted. Also, in this mode clicking button 1 in the display will clear the window. +.PP +The +.B -u +flag causes +.I faces +to read in the mailbox like with the +.B -i +flag, but it only shows the unread ones. +When right-clicking on a message icon in this mode, the message is both plumbed and removed from the view. .PP .I Seemail is an --- a/sys/src/cmd/faces/main.c Sun Jun 27 02:13:58 2021 +++ b/sys/src/cmd/faces/main.c Mon Jun 28 00:27:55 2021 @@ -10,6 +10,7 @@ int history = 0; /* use old interface, showing history of mailbox rather than current state */ int initload = 0; /* initialize program with contents of mail box */ int clickrm = 0; /* allows removing mail faces by left clicking */ +int onlyunread = 0; /* initialize program with unread messages, remove when clicked */ enum { @@ -358,6 +359,28 @@ unlockdisplay(display); } +int +isunread(char *dir, char *num) +{ + char buf[1024], flags[8]; + int n, fd, unread; + + snprint(buf, 1024, "%s/%s/flags", dir, num); + fd = open(buf, OREAD); + if(fd < 0) + return 0; + n = readn(fd, flags, 7); + close(fd); + if(n != 7) + return 0; + flags[n] = '\0'; + if(strchr(flags, 's') != nil) + unread = 0; + else + unread = 1; + return unread; +} + void loadmboxfaces(char *maildir) { @@ -369,8 +392,10 @@ if(dirfd >= 0){ chdir(maildir); while((n = dirread(dirfd, &d)) > 0){ - for(i=0; i