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)