On Sun, Jul 19, 2015 at 09:43:27AM -0700, Kevin J. McCarthy wrote:
> My only comment would be to improve the name and documentation for the
> option a bit.  With your explanation above, I understand what (and why)
> you are trying to do.  But both the option name and the description
> "treat cur the same as new" are a little vague when read on their own.

Yeah, that was pretty bad and not easy to understand in retrospective.

I stole your improved description, here's an updated patch:

# HG changeset patch
# User Martin Sandsmark <[email protected]>
# Date 1437237632 -7200
#      Sat Jul 18 18:40:32 2015 +0200
# Node ID b1a2d500b2166af6bd93f249c4cb960e4363b32d
# Parent  2ca89bed64480780d0a435e89c13dba06c748094
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 -r 2ca89bed6448 -r b1a2d500b216 buffy.c
--- a/buffy.c   Sat Jul 11 14:36:51 2015 -0700
+++ b/buffy.c   Sat Jul 18 18:40:32 2015 +0200
@@ -285,8 +285,8 @@
   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 @@
   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 @@
     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 @@
   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 -r 2ca89bed6448 -r b1a2d500b216 init.h
--- a/init.h    Sat Jul 11 14:36:51 2015 -0700
+++ b/init.h    Sat Jul 18 18:40:32 2015 +0200
@@ -1420,6 +1420,15 @@
   ** to maildir-style mailboxes.  Setting it will have no effect on other
   ** mailbox types.
   */
+  { "maildir_check_cur", DT_BOOL, R_NONE, OPTMAILDIRCHECKCUR, 0 },
+  /*
+  ** 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 -r 2ca89bed6448 -r b1a2d500b216 mutt.h
--- a/mutt.h    Sat Jul 11 14:36:51 2015 -0700
+++ b/mutt.h    Sat Jul 18 18:40:32 2015 +0200
@@ -387,6 +387,7 @@
   OPTMAILCAPSANITIZE,
   OPTMAILCHECKRECENT,
   OPTMAILDIRTRASH,
+  OPTMAILDIRCHECKCUR,
   OPTMARKERS,
   OPTMARKOLD,
   OPTMENUSCROLL,       /* scroll menu instead of implicit next-page */

-- 
Martin Sandsmark

Reply via email to