]> granicus.if.org Git - neomutt/commitdiff
Change OptIgnoreMacroEvents to ignore macros
authorOneric <Nyff@protonmail.ch>
Fri, 26 Jul 2019 11:54:12 +0000 (13:54 +0200)
committerRichard Russon <rich@flatcap.org>
Mon, 5 Aug 2019 09:50:29 +0000 (10:50 +0100)
Change OptIgnoreMacroEvents to actuallly ignore macros instead of
throwing errors.

Add a comment to the OptIgnoreMacroEvents km_dokey() change

The option was added in commit 53900afa, and its actual purpose was
to separate out an "unget" event buffer from the "macro" buffer, to
solve a problem with certificate prompts.

The safest approach in a low-level function like km_dokey() was to
return an error if new macros were generated when the option is set.
However, this results in an unbuffered username/password prompt being
aborted.

Currently the only users of unbuffered input are the SSL certificate
prompts, which use menu->dialog mode (and thus mutt_getch() directly)
and username/password prompts.  So the only affected cases are
editor-menu prompts, and returning the pressed keys is likely less
surprising than aborting the prompt.

If other unbuffered menus are created in the future, we may want to
add a check for which menu mode is being used.

Co-authored-by: Richard Russon <rich@flatcap.org>
keymap.c

index 082e7af71fefb371144e47dc970f00a825a7fd79..4596e5c9201984ae38e66da2524f1fa406177fcd 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -687,10 +687,19 @@ int km_dokey(int menu)
       if (map->op != OP_MACRO)
         return map->op;
 
+      /* OptIgnoreMacroEvents turns off processing the MacroEvents buffer
+       * in mutt_getch().  Generating new macro events during that time would
+       * result in undesired behavior once the option is turned off.
+       *
+       * Originally this returned -1, however that results in an unbuffered
+       * username or password prompt being aborted.  Returning OP_NULL allows
+       * mutt_enter_string_full() to display the keybinding pressed instead.
+       *
+       * It may be unexpected for a macro's keybinding to be returned,
+       * but less so than aborting the prompt.  */
       if (OptIgnoreMacroEvents)
       {
-        mutt_error(_("Macros are currently disabled"));
-        return -1;
+        return OP_NULL;
       }
 
       if (n++ == 10)