]> granicus.if.org Git - neomutt/commitdiff
Warn on bindkey aliasing
authorsomini <somini@users.noreply.github.com>
Wed, 15 Mar 2017 14:17:47 +0000 (14:17 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 11 May 2017 11:26:07 +0000 (12:26 +0100)
On binding a key sequence that alias an existing mapping, warn the user.

keymap.c

index a470476074f8bd37b6e140ad2ee48bd54ec91442..df54ea5b7e063a0535b33eba52ddc40267851efc 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -243,17 +243,26 @@ void km_bind(char *s, int menu, int op, char *macro, char *descr)
   {
     if (pos >= len || pos >= tmp->len)
     {
-      /* map and tmp match, but have different lengths, so overwrite */
+      /* map and tmp match so overwrite */
       do
       {
+        if (tmp->len != len) {
+          /* Overwrite with the different lengths, warn*/
+          char old_binding[MAX_SEQ];
+          char new_binding[MAX_SEQ];
+          km_expand_key( old_binding, MAX_SEQ, map );
+          km_expand_key( new_binding, MAX_SEQ, tmp );
+          mutt_error (_("Warning: For menu '%s', binding '%s' will alias '%s'"), mutt_getnamebyvalue(menu, Menus), old_binding, new_binding);
+        }
         len = tmp->eq;
         next = tmp->next;
-        FREE(&tmp->macro);
-        FREE(&tmp->keys);
-        FREE(&tmp->descr);
-        FREE(&tmp);
+        FREE (&tmp->macro);
+        FREE (&tmp->keys);
+        FREE (&tmp->descr);
+        FREE (&tmp);
         tmp = next;
-      } while (tmp && len >= pos);
+      }
+      while (tmp && len >= pos);
       map->eq = len;
       break;
     }