about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--man/mlist.16
-rw-r--r--mlist.c18
2 files changed, 18 insertions, 6 deletions
diff --git a/man/mlist.1 b/man/mlist.1
index e776433..5c7ea64 100644
--- a/man/mlist.1
+++ b/man/mlist.1
@@ -1,4 +1,4 @@
-.Dd December 13, 2016
+.Dd April 30, 2020
 .Dt MLIST 1
 .Os
 .Sh NAME
@@ -77,8 +77,10 @@ Don't print filenames.
 Instead, print a one-line summary for each folder,
 showing the number of unseen, flagged and total messages,
 along with the folder name.
+If any of the message selection flags are used,
+the number of matching messages is printed as well.
 If two or more folders are specified,
-a total for all folders will also be printed.
+a total for all folders will also be printed at the end.
 .El
 .Pp
 Multiple options are regarded as a conjunction.
diff --git a/mlist.c b/mlist.c
index e03d7ba..fd4fde1 100644
--- a/mlist.c
+++ b/mlist.c
@@ -47,6 +47,7 @@ static long tdirs;
 static long tunseen;
 static long tflagged;
 static long tcount;
+static long tmatched;
 
 void
 list(char *prefix, char *file)
@@ -86,6 +87,7 @@ list(char *prefix, char *file)
 		if (!f)
 			return;
 		imatched++;
+		tmatched++;
 		if (!flagset)
 			icount++, tcount++;
 		if (!strchr(f, 'S'))
@@ -215,8 +217,12 @@ listarg(char *arg)
 
 		if (iflag && (imatched || (maildir && !flagset))) {
 			tdirs++;
-			printf("%6ld unseen  %3ld flagged  %6ld msg  %s\n",
-			    iunseen, iflagged, icount, arg);
+			if (flagset && imatched)
+				printf("%6ld matched  %6ld unseen  %3ld flagged  %6ld msg  %s\n",
+				    imatched, iunseen, iflagged, icount, arg);
+			else
+				printf("%6ld unseen  %3ld flagged  %6ld msg  %s\n",
+				    iunseen, iflagged, icount, arg);
 		}
 
 		icount = gcount;
@@ -283,8 +289,12 @@ usage:
 	}
 
 	if (iflag && tdirs > 1)
-		printf("%6ld unseen  %3ld flagged  %6ld msg\n",
-		    tunseen, tflagged, tcount);
+		if (flagset)
+			printf("%6ld matched  %6ld unseen  %3ld flagged  %6ld msg\n",
+			    tmatched, tunseen, tflagged, tcount);
+		else
+			printf("%6ld unseen  %3ld flagged  %6ld msg\n",
+			    tunseen, tflagged, tcount);
 
 	return 0;
 }