]> granicus.if.org Git - neomutt/commitdiff
<change-vfolder> default to the next unread folder
authorKarel Zak <kzak@redhat.com>
Fri, 4 Oct 2013 18:34:57 +0000 (11:34 -0700)
committerRichard Russon <rich@flatcap.org>
Mon, 14 Mar 2016 23:11:42 +0000 (23:11 +0000)
It means that for example:

 macro index R <change-vfolder><enter>

will for as expected.

Signed-off-by: Karel Zak <kzak@redhat.com>
buffy.c
buffy.h
curs_main.c

diff --git a/buffy.c b/buffy.c
index a5bbda9d92406b329cf0beddf9bf89f71da5dabf..1151547d146aed9c1498a7003c311948a0590563 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -669,8 +669,11 @@ static void buffy_check(BUFFY *tmp, struct stat *contex_sb)
        tmp->msg_unread = 0;
        tmp->msg_flagged = 0;
        nm_nonctx_get_count(tmp->path, &tmp->msg_count, &tmp->msg_unread);
-       if (tmp->msg_unread > 0)
+       if (tmp->msg_unread > 0) {
          BuffyCount++;
+         tmp->new = 1;
+       }
+       sb_set_update_time();
        break;
 #endif
       }
@@ -857,6 +860,35 @@ void mutt_buffy (char *s, size_t slen)
   *s = '\0';
 }
 
+#ifdef USE_NOTMUCH
+void mutt_buffy_vfolder (char *s, size_t slen)
+{
+  BUFFY *tmp;
+  int pass, found = 0;
+
+  if (mutt_buffy_check (0))
+  {
+    for (pass = 0; pass < 2; pass++) {
+      for (tmp = VirtIncoming; tmp; tmp = tmp->next)
+      {
+       if ((found || pass) && tmp->new)
+       {
+         strfcpy (s, tmp->desc, slen);
+         return;
+       }
+       if (mutt_strcmp (s, tmp->path) == 0)
+         found = 1;
+      }
+    }
+
+    mutt_buffy_check (1); /* buffy was wrong - resync things */
+  }
+
+  /* no folders with new mail */
+  *s = '\0';
+}
+#endif
+
 /* fetch buffy object for given path, if present */
 static BUFFY* buffy_get (const char *path)
 {
diff --git a/buffy.h b/buffy.h
index 9e3053c7f3f39f5bb727a0cdc420c84bac3bd813..0c491d959c19921d81d39a33288b9150dfe040de 100644 (file)
--- a/buffy.h
+++ b/buffy.h
@@ -54,6 +54,7 @@ WHERE short BuffyTimeout INITVAL (3);
 
 #ifdef USE_NOTMUCH
 WHERE BUFFY *VirtIncoming INITVAL (0);
+void mutt_buffy_vfolder (char *s, size_t slen);
 #endif
 
 extern time_t BuffyDoneTime;   /* last time we knew for sure how much mail there was */
index 5765217ad0d20f3e8c0cbfad486c10193b63964a..00c2e6adb78a88a84eaa7e8c647f61ca2c74cb3e 100644 (file)
@@ -1536,6 +1536,10 @@ int mutt_index_menu (void)
        }
 #ifdef USE_NOTMUCH
        else if (op == OP_MAIN_CHANGE_VFOLDER) {
+         if (Context->magic == M_NOTMUCH) {
+                 strfcpy(buf, Context->path, sizeof (buf));
+                 mutt_buffy_vfolder (buf, sizeof (buf));
+         }
          mutt_enter_vfolder (cp, buf, sizeof (buf), &menu->redraw, 1);
          if (!buf[0])
          {