]> granicus.if.org Git - neomutt/commitdiff
fix bind error messages 470/head
authorRichard Russon <rich@flatcap.org>
Fri, 12 May 2017 13:01:34 +0000 (14:01 +0100)
committerRichard Russon <rich@flatcap.org>
Fri, 12 May 2017 13:01:34 +0000 (14:01 +0100)
Some messages were displayed that shouldn't have been (when bind
succeeded).  Some errors weren't getting reported (they were overwritten
by other messages).

keymap.c

index 880c87668c6af94e76b961e228f71a534bc75092..663d44f9580a33ed08e60ea2eec74c525d8746a8 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -1002,9 +1002,12 @@ static int try_bind(char *key, int menu, char *func,
       return km_bindkey_err(key, menu, bindings[i].op, err);
     }
   }
-  snprintf(err->data, err->dsize,
-           _("Function '%s' not available for menu '%s'"), func,
-           mutt_getnamebyvalue(menu, Menus));
+  if (err)
+  {
+    snprintf(err->data, err->dsize,
+             _("Function '%s' not available for menu '%s'"), func,
+             mutt_getnamebyvalue(menu, Menus));
+  }
   return -1; /* Couldn't find an existing function with this name */
 }
 
@@ -1079,22 +1082,24 @@ int mutt_parse_bind(BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
   {
     for (i = 0; i < nummenus; ++i)
     {
-      /* Bind first on the generic (why?), except for this menus */
-      if (menu[i] != MENU_PAGER || menu[i] != MENU_EDITOR || menu[i] != MENU_GENERIC)
+      /* The pager and editor menus don't use the generic map,
+       * however for other menus try generic first. */
+      if ((menu[i] != MENU_PAGER) && (menu[i] != MENU_EDITOR) && (menu[i] != MENU_GENERIC))
       {
         r = try_bind(key, menu[i], buf->data, OpGeneric, err);
+        if (r == 0)
+          continue;
+        if (r == -2)
+          break;
       }
-      else
-      {
-        r = -2; /* If you don't bind on generic, bind on the actual menu*/
-      }
-      if (r != 0)
+
+      /* Clear any error message, we're going to try again */
+      if (err->data)
+        err->data[0] = '\0';
+      bindings = km_get_table(menu[i]);
+      if (bindings)
       {
-        bindings = km_get_table(menu[i]);
-        if (bindings)
-        {
-          r = try_bind(key, menu[i], buf->data, bindings, err);
-        }
+        r = try_bind(key, menu[i], buf->data, bindings, err);
       }
     }
   }