aboutsummaryrefslogtreecommitdiff
path: root/overlays/neomutt/commands.patch
blob: 6c910cfbb7d88edbc2185ef874ca4fcfaa6739ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
commit 763056828abe9716c4dfce754a47d8ecdefb3029
Author: Ismaël Bouya <ismael.bouya@normalesup.org>
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)