On 18Jul2015 22:12, Martin Sandsmark <martin.sandsm...@kde.org> wrote:
Because dovecot apparently refuses to let my mail stay in new/ when I try to
fetch mail over IMAP, I sat down and implemented support for treating the
cur/ folder similar to new/ in buffy. I also had to change the check for
maildir tags a bit, so it treats both S and T as read, instead of just T.

I added a new configuration option "maildir_cur_as_new" to toggle this, as I
assume not everyone wants this.

Nice!

I'll inline the patch here for easier review:

My first question, which kind of predates this patch, is why do we treat "T" (trashed) as "read" at all? Or is that not what mutt is using it for anyway; as I read the code it is just using it as something to skip, because ostensably the message is deleted in some sense. Is this just misterminology in your description above?

Either way, treating "S" (see) as skippable seems correct in this context.

In other respects the patch seems fine to me.

Disclaimer: not a mutt internals guy.

Cheers,
Cameron Simpson <c...@zip.com.au>

# HG changeset patch
# User Martin Sandsmark <martin@sandsmark.ninja>
# Date 1437237632 -7200
#      Sat Jul 18 18:40:32 2015 +0200
# Node ID 2166c90c26410297cbc0316259cb343566c7360a
# Parent  2ca89bed64480780d0a435e89c13dba06c748094
Add support for treating cur/ as new/ in buffy

diff -r 2ca89bed6448 -r 2166c90c2641 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(OPTMAILDIRCURASNEW)) {
+      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 2166c90c2641 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,13 @@
  ** to maildir-style mailboxes.  Setting it will have no effect on other
  ** mailbox types.
  */
+  { "maildir_cur_as_new", DT_BOOL, R_NONE, OPTMAILDIRCURASNEW, 0 },
+  /*
+  ** .pp
+  ** If \fIset\fP, mutt will treat messages in cur the same way as in new.
+  ** \fBNote:\fP this only applies to maildir-style mailboxes.  Setting it
+  ** will have no effect on other mailbox types.
+  */
  { "mark_old",               DT_BOOL, R_BOTH, OPTMARKOLD, 1 },
  /*
  ** .pp
diff -r 2ca89bed6448 -r 2166c90c2641 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,
+  OPTMAILDIRCURASNEW,
  OPTMARKERS,
  OPTMARKOLD,
  OPTMENUSCROLL,        /* scroll menu instead of implicit next-page */

Reply via email to