From: Martin Sandsmark Date: Sat, 18 Jul 2015 16:40:32 +0000 (+0200) Subject: Add support for checking cur/ in Maildir for unread mails in buffy. X-Git-Tag: mutt-1-5-24-rel~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ffe468aefd72fbc2e44131b00cf4e83621708ca;p=mutt Add support for checking cur/ in Maildir for unread mails in buffy. Also skip messages with the S flag when checking for unread mails. --- diff --git a/UPDATING b/UPDATING index 4b3559a4..89a8d6db 100644 --- a/UPDATING +++ b/UPDATING @@ -35,6 +35,7 @@ The keys used are: ! sime_keys better handles importing certificate chains. ! sime_keys now records certificate purposes (sign/encrypt). Run "sime_keys refresh" to update smime index files. + + $maildir_check_cur to poll maildir "cur" directory for new mail. 1.5.23 (2014-03-11): diff --git a/buffy.c b/buffy.c index e5a0f798..12a16d17 100644 --- a/buffy.c +++ b/buffy.c @@ -285,8 +285,8 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e return 0; } -/* returns 1 if maildir has new mail */ -static int buffy_maildir_hasnew (BUFFY* mailbox) +/* returns 1 if the specified dir (cur or new) has new mail */ +static int buffy_maildir_dir_hasnew(BUFFY* mailbox, const char *dir_name) { char path[_POSIX_PATH_MAX]; DIR *dirp; @@ -295,7 +295,7 @@ static int buffy_maildir_hasnew (BUFFY* mailbox) int rc = 0; struct stat sb; - snprintf (path, sizeof (path), "%s/new", mailbox->path); + snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir_name); /* when $mail_check_recent is set, if the new/ directory hasn't been modified since * the user last exited the mailbox, then we know there is no recent mail. @@ -317,7 +317,7 @@ static int buffy_maildir_hasnew (BUFFY* mailbox) if (*de->d_name == '.') continue; - if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) + if (!(p = strstr (de->d_name, ":2,")) || !(strchr (p + 3, 'T') || strchr(p + 3, 'S'))) { if (option(OPTMAILCHECKRECENT)) { @@ -340,6 +340,23 @@ static int buffy_maildir_hasnew (BUFFY* mailbox) return rc; } +/* returns 1 if maildir has new mail */ +static int buffy_maildir_hasnew (BUFFY* mailbox) +{ + if (buffy_maildir_dir_hasnew(mailbox, "new")) { + return 1; + } + + if (!option(OPTMAILDIRCHECKCUR)) { + return 0; + } + + if (buffy_maildir_dir_hasnew(mailbox, "cur")) { + return 1; + } + + return 0; +} /* returns 1 if mailbox has new mail */ static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb) { diff --git a/init.h b/init.h index 44bb8933..569f91e6 100644 --- a/init.h +++ b/init.h @@ -1420,6 +1420,16 @@ struct option_t MuttVars[] = { ** to maildir-style mailboxes. Setting it will have no effect on other ** mailbox types. */ + { "maildir_check_cur", DT_BOOL, R_NONE, OPTMAILDIRCHECKCUR, 0 }, + /* + ** .pp + ** If \fIset\fP, mutt will poll both the new and cur directories of + ** a maildir folder for new messages. This might be useful if other + ** programs interacting with the folder (e.g. dovecot) are moving new + ** messages to the cur directory. Note that setting this option may + ** slow down polling for new messages in large folders, since mutt has + ** to scan all cur messages. + */ { "mark_old", DT_BOOL, R_BOTH, OPTMARKOLD, 1 }, /* ** .pp diff --git a/mutt.h b/mutt.h index fa8f3c82..f8565fae 100644 --- a/mutt.h +++ b/mutt.h @@ -387,6 +387,7 @@ enum OPTMAILCAPSANITIZE, OPTMAILCHECKRECENT, OPTMAILDIRTRASH, + OPTMAILDIRCHECKCUR, OPTMARKERS, OPTMARKOLD, OPTMENUSCROLL, /* scroll menu instead of implicit next-page */