* [9front] Patch to add -u flag to faces, so it only shows unread messages
@ 2021-06-28 0:03 peter
2021-06-28 4:34 ` fulton
2021-06-28 21:48 ` peter
0 siblings, 2 replies; 3+ messages in thread
From: peter @ 2021-06-28 0:03 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 138 bytes --]
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.
[-- Attachment #2: Type: text/plain, Size: 2584 bytes --]
From b09dda741c8b009dbc64729003d847f829127f29
From: Peter Mikkelsen <peter@pmikkelsen.com>
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<n; i++)
- addface(dirface(maildir, d[i].name));
+ for(i=0; i<n; i++){
+ if(onlyunread && isunread(maildir, d[i].name))
+ addface(dirface(maildir, d[i].name));
+ }
free(d);
}
close(dirfd);
@@ -616,6 +641,10 @@
for(i=first; i<last; i++)
if(ptinrect(p, facerect(i-first))){
showmail(faces[i]);
+ if(onlyunread){
+ delface(i);
+ flushimage(display, 1);
+ }
break;
}
unlockdisplay(display);
@@ -698,6 +727,10 @@
break;
case 'c':
clickrm++;
+ break;
+ case 'u':
+ initload++;
+ onlyunread++;
break;
default:
usage();
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9front] Patch to add -u flag to faces, so it only shows unread messages
2021-06-28 0:03 [9front] Patch to add -u flag to faces, so it only shows unread messages peter
@ 2021-06-28 4:34 ` fulton
2021-06-28 21:48 ` peter
1 sibling, 0 replies; 3+ messages in thread
From: fulton @ 2021-06-28 4:34 UTC (permalink / raw)
To: 9front
Oh, I like this a lot.
--
Fulton
Quoth peter@pmikkelsen.com:
> 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.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9front] Patch to add -u flag to faces, so it only shows unread messages
2021-06-28 0:03 [9front] Patch to add -u flag to faces, so it only shows unread messages peter
2021-06-28 4:34 ` fulton
@ 2021-06-28 21:48 ` peter
1 sibling, 0 replies; 3+ messages in thread
From: peter @ 2021-06-28 21:48 UTC (permalink / raw)
To: 9front
Quoth peter@pmikkelsen.com:
> 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.
>
Here is an updated patch which uses sizeof(buf) and removes some unneeded braces.
From 5595dbb332eae353832dbc2ad11ef92aeb8fcab0
From: Peter Mikkelsen <peter@pmikkelsen.com>
Date: Mon, 28 Jun 2021 21:45:53 +0000
Subject: [PATCH] Add -u flag to faces, making it only show unread messages.
---
diff 658757abed7be283e06bae3b1722fc2703334d74 5595dbb332eae353832dbc2ad11ef92aeb8fcab0
--- a/sys/man/1/faces Sun Jun 27 02:13:58 2021
+++ b/sys/man/1/faces Mon Jun 28 23:45:53 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 23:45:53 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, sizeof(buf), "%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)
{
@@ -370,7 +393,8 @@
chdir(maildir);
while((n = dirread(dirfd, &d)) > 0){
for(i=0; i<n; i++)
- addface(dirface(maildir, d[i].name));
+ if(onlyunread && isunread(maildir, d[i].name))
+ addface(dirface(maildir, d[i].name));
free(d);
}
close(dirfd);
@@ -616,6 +640,10 @@
for(i=first; i<last; i++)
if(ptinrect(p, facerect(i-first))){
showmail(faces[i]);
+ if(onlyunread){
+ delface(i);
+ flushimage(display, 1);
+ }
break;
}
unlockdisplay(display);
@@ -698,6 +726,10 @@
break;
case 'c':
clickrm++;
+ break;
+ case 'u':
+ initload++;
+ onlyunread++;
break;
default:
usage();
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-28 22:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 0:03 [9front] Patch to add -u flag to faces, so it only shows unread messages peter
2021-06-28 4:34 ` fulton
2021-06-28 21:48 ` peter
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).