From 2130ed48ceb0db955b942b942bac82a5b6aee57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 10 Feb 2020 17:00:59 +0100 Subject: Add neomutt patch for empty mailboxes --- overlays/neomutt/commands.patch | 87 +++++++++++++++++++++++++++++++++++++++++ overlays/neomutt/default.nix | 1 + 2 files changed, 88 insertions(+) create mode 100644 overlays/neomutt/commands.patch diff --git a/overlays/neomutt/commands.patch b/overlays/neomutt/commands.patch new file mode 100644 index 00000000..6c910cfb --- /dev/null +++ b/overlays/neomutt/commands.patch @@ -0,0 +1,87 @@ +commit 763056828abe9716c4dfce754a47d8ecdefb3029 +Author: Ismaël Bouya +Date: Mon Feb 10 16:13:33 2020 +0100 + + Fix commands that don’t need to have a non-empty mailbox to be valid + + Some commands act on the whole mailbox (tag-pattern, delete-pattern, + search), and even though they don’t do anything when the mailbox is + empty, there is no reason to fail when it happens. This commit removes + the check that the mailbox is non-empty before doing said actions. + +diff --git a/index.c b/index.c +index 0f4b9f99f..0adfc19f1 100644 +--- a/index.c ++++ b/index.c +@@ -1642,7 +1642,7 @@ int mutt_index_menu(struct MuttWindow *dlg) + case OP_JUMP: + { + int msg_num = 0; +- if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE)) ++ if (!prereq(Context, menu, CHECK_IN_MAILBOX)) + break; + if (isdigit(LastKey)) + mutt_unget_event(LastKey, 0); +@@ -1687,7 +1687,7 @@ int mutt_index_menu(struct MuttWindow *dlg) + + case OP_MAIN_DELETE_PATTERN: + if (!prereq(Context, menu, +- CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE | CHECK_READONLY | CHECK_ATTACH)) ++ CHECK_IN_MAILBOX | CHECK_READONLY | CHECK_ATTACH)) + { + break; + } +@@ -1852,12 +1852,17 @@ int mutt_index_menu(struct MuttWindow *dlg) + menu->redraw = REDRAW_FULL; + break; + +- case OP_SEARCH: ++ // Initiating a search can happen on an empty mailbox, but ++ // searching for next/previous/... needs to be on a message and ++ // thus a non-empty mailbox + case OP_SEARCH_REVERSE: + case OP_SEARCH_NEXT: + case OP_SEARCH_OPPOSITE: + if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE)) + break; ++ case OP_SEARCH: ++ if (!prereq(Context, menu, CHECK_IN_MAILBOX)) ++ break; + menu->current = mutt_search_command(menu->current, op); + if (menu->current == -1) + menu->current = menu->oldcurrent; +@@ -1926,14 +1931,14 @@ int mutt_index_menu(struct MuttWindow *dlg) + } + + case OP_MAIN_TAG_PATTERN: +- if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE)) ++ if (!prereq(Context, menu, CHECK_IN_MAILBOX)) + break; + mutt_pattern_func(MUTT_TAG, _("Tag messages matching: ")); + menu->redraw |= REDRAW_INDEX | REDRAW_STATUS; + break; + + case OP_MAIN_UNDELETE_PATTERN: +- if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE | CHECK_READONLY)) ++ if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_READONLY)) + break; + /* L10N: CHECK_ACL */ + /* L10N: Due to the implementation details we do not know whether we +@@ -1950,7 +1955,7 @@ int mutt_index_menu(struct MuttWindow *dlg) + break; + + case OP_MAIN_UNTAG_PATTERN: +- if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE)) ++ if (!prereq(Context, menu, CHECK_IN_MAILBOX)) + break; + if (mutt_pattern_func(MUTT_UNTAG, _("Untag messages matching: ")) == 0) + menu->redraw |= REDRAW_INDEX | REDRAW_STATUS; +@@ -3189,7 +3194,7 @@ int mutt_index_menu(struct MuttWindow *dlg) + } + + case OP_MAIN_COLLAPSE_ALL: +- if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE)) ++ if (!prereq(Context, menu, CHECK_IN_MAILBOX)) + break; + + if ((C_Sort & SORT_MASK) != SORT_THREADS) diff --git a/overlays/neomutt/default.nix b/overlays/neomutt/default.nix index ec563e28..0b237342 100644 --- a/overlays/neomutt/default.nix +++ b/overlays/neomutt/default.nix @@ -9,6 +9,7 @@ self: super: { rev = version; sha256 = "16xr7wdmjw0i72xbnyyh098wx4cr0m8w2cr1szdi1b14p4kpgr67"; }; + patches = old.patches or [] ++ [ ./commands.patch ]; buildInputs = old.buildInputs ++ [ self.gdbm ]; configureFlags = old.configureFlags ++ [ "--gdbm" ]; doCheck = false; -- cgit v1.2.3