]> granicus.if.org Git - neomutt/commitdiff
notmuch: implement read-only vfolder-from-query
authorAustin Ray <austin@austinray.io>
Sat, 12 Jan 2019 17:37:14 +0000 (12:37 -0500)
committerRichard Russon <rich@flatcap.org>
Sat, 12 Jan 2019 20:12:09 +0000 (20:12 +0000)
Implemented a read-only variant of vfolder-from-query for users who want
to have an immutable window. This ensures no accidental tag changes
occur.

doc/manual.xml.head
functions.h
index.c
opcodes.h

index 6fee8e4db0b0bd647e554c19ea35eddf154f6e5c..e84a09251ccb1bf76991c02a73ba4c17835c1e62 100644 (file)
@@ -14929,6 +14929,14 @@ virtual-mailboxes "My INBOX" "notmuch://?query=tag:inbox"
                   completion of 'tag:' names is available.
                 </entry>
               </row>
+              <row>
+                <entry>index,pager</entry>
+                <entry><literal>&lt;vfolder-from-query-readonly&gt;</literal></entry>
+                <entry>
+                  The same as <literal>&lt;vfolder-from-query&gt;</literal>; however, the mailbox
+                  will be read-only.
+                </entry>
+              </row>
               <row>
                 <entry>index</entry>
                 <entry><literal>&lt;vfolder-window-forward&gt;</literal></entry>
index 3666479f45c878f57c490e51e21e834a6b8ad2b6..e6bc9001712c198a65cee3ffbceed340bb899a4d 100644 (file)
@@ -238,6 +238,7 @@ const struct Binding OpMain[] = { /* map: index */
   { "untag-pattern",             OP_MAIN_UNTAG_PATTERN,             "\024" },
 #ifdef USE_NOTMUCH
   { "vfolder-from-query",        OP_MAIN_VFOLDER_FROM_QUERY,        NULL },
+  { "vfolder-from-query-readonly", OP_MAIN_VFOLDER_FROM_QUERY_READONLY, NULL },
   { "vfolder-window-backward",   OP_MAIN_WINDOWED_VFOLDER_BACKWARD, NULL },
   { "vfolder-window-forward",    OP_MAIN_WINDOWED_VFOLDER_FORWARD,  NULL },
 #endif
@@ -390,6 +391,7 @@ const struct Binding OpPager[] = { /* map: pager */
   { "undelete-thread",           OP_UNDELETE_THREAD,              "\025" },
 #ifdef USE_NOTMUCH
   { "vfolder-from-query",        OP_MAIN_VFOLDER_FROM_QUERY,      NULL },
+  { "vfolder-from-query-readonly", OP_MAIN_VFOLDER_FROM_QUERY_READONLY, NULL },
 #endif
   { "view-attachments",          OP_VIEW_ATTACHMENTS,             "v" },
   { "view-raw-message",          OP_VIEW_RAW_MESSAGE,             NULL },
diff --git a/index.c b/index.c
index 9f76869cde60880e907545e7b8367e894dc96c83..c113b74d3bb3a7526b56556074d84b3d9b3b5517 100644 (file)
--- a/index.c
+++ b/index.c
@@ -636,7 +636,14 @@ static int main_change_folder(struct Menu *menu, int op, struct Mailbox *m,
   mutt_folder_hook(buf, m ? m->desc : NULL);
 
   const int flags =
-      (ReadOnly || (op == OP_MAIN_CHANGE_FOLDER_READONLY)) ? MUTT_READONLY : 0;
+    (ReadOnly || (op == OP_MAIN_CHANGE_FOLDER_READONLY)
+#ifdef USE_NOTMUCH
+     || (op == OP_MAIN_VFOLDER_FROM_QUERY_READONLY)
+#endif
+     )
+    ? MUTT_READONLY
+    : 0;
+
   Context = mx_mbox_open(m, buf, flags);
   if (Context)
   {
@@ -2090,6 +2097,7 @@ int mutt_index_menu(void)
 
 #ifdef USE_NOTMUCH
       case OP_MAIN_VFOLDER_FROM_QUERY:
+      case OP_MAIN_VFOLDER_FROM_QUERY_READONLY:
         buf[0] = '\0';
         if (mutt_get_field("Query: ", buf, sizeof(buf), MUTT_NM_QUERY) != 0 || !buf[0])
         {
index e925e8343f74f77d01cf26c571b81adf155cbe98..74f871976e1cd498430e7b6cdc7de9b17073df56 100644 (file)
--- a/opcodes.h
+++ b/opcodes.h
   _fmt(OP_MAIN_CHANGE_VFOLDER,            N_("open a different virtual folder")) \
   _fmt(OP_MAIN_ENTIRE_THREAD,             N_("read entire thread of the current message")) \
   _fmt(OP_MAIN_VFOLDER_FROM_QUERY,        N_("generate virtual folder from query")) \
+  _fmt(OP_MAIN_VFOLDER_FROM_QUERY_READONLY, N_("generate a read-only virtual folder from query")) \
   _fmt(OP_MAIN_WINDOWED_VFOLDER_BACKWARD, N_("shifts virtual folder time window backwards")) \
   _fmt(OP_MAIN_WINDOWED_VFOLDER_FORWARD,  N_("shifts virtual folder time window forwards"))
 #else