From ce28488956333bae55eef24f0494b91d448dc800 Mon Sep 17 00:00:00 2001 From: Austin Ray Date: Sat, 12 Jan 2019 12:37:14 -0500 Subject: [PATCH] notmuch: implement read-only vfolder-from-query 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 | 8 ++++++++ functions.h | 2 ++ index.c | 10 +++++++++- opcodes.h | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 6fee8e4db..e84a09251 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -14929,6 +14929,14 @@ virtual-mailboxes "My INBOX" "notmuch://?query=tag:inbox" completion of 'tag:' names is available. + + index,pager + <vfolder-from-query-readonly> + + The same as <vfolder-from-query>; however, the mailbox + will be read-only. + + index <vfolder-window-forward> diff --git a/functions.h b/functions.h index 3666479f4..e6bc90017 100644 --- a/functions.h +++ b/functions.h @@ -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 9f76869cd..c113b74d3 100644 --- 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]) { diff --git a/opcodes.h b/opcodes.h index e925e8343..74f871976 100644 --- a/opcodes.h +++ b/opcodes.h @@ -271,6 +271,7 @@ _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 -- 2.40.0