Re: Number of new mails in a maildir
On 2010-09-12 01:48:39 (+0200), Christian Ebert <blacktrash@xxxxxxx> wrote:
> * Kristof Provost on Sunday, September 12, 2010 at 00:17:43 +0200
> > 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).
>
> A nice to have! Wish: instead of display 0 for no new messages,
> could there be nothing? That way mailboxes with new mail would
> stand out more.
>
That's possible, but it's different from what was always done for IMAP.
It seems sensible to have the same behavior for IMAP and maildir.
> > The following patch seems to do the right thing for me. It's quite
> > simple, so am I missing any obvious problems?
>
> It breaks the change-folder prompt: usually this shows the next
> mailbox with new mail. Also cycling through the mailboxes with
> new mail with <Space> in the menu does not work anymore. At least
> here.
>
Ah yes. Thanks for testing.
I removed a little too much from buffy_maildir_hasnew.
It no longer returned 1 if there was some new mail.
Can you test the updated patch?
Regards,
Kristof
diff -r 0f962f1a6bbb browser.c
--- a/browser.c Sat Sep 11 07:34:26 2010 -0700
+++ b/browser.c Sun Sep 12 20:26:26 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 0f962f1a6bbb buffy.c
--- a/buffy.c Sat Sep 11 07:34:26 2010 -0700
+++ b/buffy.c Sun Sep 12 20:26:26 2010 +0200
@@ -308,10 +308,8 @@
continue;
if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
- /* one new and undeleted message is enough */
- mailbox->new = 1;
+ mailbox->new++;
rc = 1;
- break;
}
}