Number of new mails in a maildir
Hi,
I've been playing with maildir mailboxes (I usually use IMAP), and
noticed that mutt can't show the number of unread messages in the
browser (only that there are unread messages).
The following patch seems to do the right thing for me. It's quite
simple, so am I missing any obvious problems?
Regards,
Kristof
diff -r 5302767aa6aa browser.c
--- a/browser.c Wed Aug 25 00:30:49 2010 +0100
+++ b/browser.c Sun Sep 12 00:15:25 2010 +0200
@@ -147,6 +147,7 @@
unsigned long data, format_flag flags)
{
char fn[SHORT_STRING], tmp[SHORT_STRING], permission[11];
+ char tmpfile[_POSIX_PATH_MAX];
char date[16], *t_fmt;
time_t tnow;
FOLDER *folder = (FOLDER *) data;
@@ -262,8 +263,13 @@
break;
case 'N':
+ strncpy(tmpfile, folder->ff->name, _POSIX_PATH_MAX);
+ mutt_expand_path(tmpfile, _POSIX_PATH_MAX);
+ if (mx_is_maildir(tmpfile)
#ifdef USE_IMAP
- if (mx_is_imap (folder->ff->desc))
+ || mx_is_imap (folder->ff->desc)
+#endif
+ )
{
if (!optional)
{
@@ -272,11 +278,12 @@
}
else if (!folder->ff->new)
optional = 0;
- break;
}
-#endif
- snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
- snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : ' ');
+ else
+ {
+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
+ snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : ' ');
+ }
break;
case 's':
diff -r 5302767aa6aa buffy.c
--- a/buffy.c Wed Aug 25 00:30:49 2010 +0100
+++ b/buffy.c Sun Sep 12 00:15:25 2010 +0200
@@ -307,12 +307,8 @@
if (*de->d_name == '.')
continue;
- if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
- /* one new and undeleted message is enough */
- mailbox->new = 1;
- rc = 1;
- break;
- }
+ if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T'))
+ mailbox->new++;
}
closedir (dirp);