]> granicus.if.org Git - neomutt/commitdiff
extend <change-vfolder> to accept folder name/uri
authorKarel Zak <kzak@redhat.com>
Fri, 4 Oct 2013 18:34:57 +0000 (11:34 -0700)
committerRichard Russon <rich@flatcap.org>
Mon, 4 Apr 2016 15:30:07 +0000 (16:30 +0100)
Suvayu Ali <fatkasuvayu+linux@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
curs_lib.c
curs_main.c
mutt_notmuch.c
mutt_notmuch.h

index a3c82514bdf951711b69c0c0801c5177cf5ea91b..9320fdc9793c9562b4df1ed25eaed70d9d00231c 100644 (file)
 #include <langinfo.h>
 #endif
 
+#ifdef USE_NOTMUCH
+#include "mutt_notmuch.h"
+#endif
+
 /* not possible to unget more than one char under some curses libs, and it
  * is impossible to unget function keys in SLang, so roll our own input
  * buffering routines.
@@ -655,10 +659,6 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen,
     _mutt_select_file (buf, blen, flags, files, numfiles);
     *redraw = REDRAW_FULL;
   }
-  else if (flags & M_SEL_VFOLDER) {
-    _mutt_select_file (buf, blen, flags, files, numfiles);
-    *redraw = REDRAW_FULL;
-  }
   else
   {
     char *pc = safe_malloc (mutt_strlen (prompt) + 3);
@@ -670,6 +670,10 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen,
       buf[0] = 0;
     MAYBE_REDRAW (*redraw);
     FREE (&pc);
+#ifdef USE_NOTMUCH
+    if ((flags & M_SEL_VFOLDER) && buf[0] && strncmp(buf, "notmuch://", 10) != 0)
+      nm_description_to_path(buf, buf, blen);
+#endif
   }
 
   return 0;
index 11ca9f755768749f79f264cd9a9fde87c39500b6..b67fae3fe54837efacb0898d8d175587c25af5c6 100644 (file)
@@ -1532,6 +1532,16 @@ int mutt_index_menu (void)
            break;
          }
        }
+#ifdef USE_NOTMUCH
+       else if (op == OP_MAIN_CHANGE_VFOLDER) {
+         mutt_enter_vfolder (cp, buf, sizeof (buf), &menu->redraw, 1);
+         if (!buf[0])
+         {
+           CLEARLINE (LINES-1);
+           break;
+         }
+       }
+#endif
        else
        {
          mutt_buffy (buf, sizeof (buf));
@@ -1543,11 +1553,6 @@ int mutt_index_menu (void)
              break;
            strncpy (buf, path, sizeof (buf));
          } else
-#endif
-#ifdef USE_NOTMUCH
-         if (op == OP_MAIN_CHANGE_VFOLDER)
-           mutt_enter_vfolder (cp, buf, sizeof (buf), &menu->redraw, 1);
-         else
 #endif
          if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
          {
index 5be51ebb3a708665a735d1b0286fbbbc2409aa89..a9a11edad070f6852cf89c93d6d8d83f42ac5eed 100644 (file)
@@ -1664,6 +1664,23 @@ char *nm_get_description(CONTEXT *ctx)
        return NULL;
 }
 
+int nm_description_to_path(const char *desc, char *buf, size_t bufsz)
+{
+       BUFFY *p;
+
+       if (!desc || !buf || !bufsz)
+               return -EINVAL;
+
+       for (p = VirtIncoming; p; p = p->next)
+               if (p->path && p->desc && strcmp(desc, p->desc) == 0) {
+                       strncpy(buf, p->path, bufsz);
+                       buf[bufsz - 1] = '\0';
+                       return 0;
+               }
+
+       return -1;
+}
+
 /*
  * returns header from mutt context
  */
index e964af4408702e56a7e36cb808c96418dca98c7d..df4baa20afaf2e866e57bc16be06b22ff277da76 100644 (file)
@@ -20,6 +20,7 @@ void nm_longrun_init(CONTEXT *cxt, int writable);
 void nm_longrun_done(CONTEXT *cxt);
 
 char *nm_get_description(CONTEXT *ctx);
+int nm_description_to_path(const char *desc, char *buf, size_t bufsz);
 
 int nm_record_message(CONTEXT *ctx, char *path, HEADER *h);