]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't add a key binding when REMOVE is non-nil
authorRobert Pluim <rpluim@gmail.com>
Fri, 17 Mar 2023 08:50:38 +0000 (09:50 +0100)
committerRobert Pluim <rpluim@gmail.com>
Fri, 17 Mar 2023 13:18:02 +0000 (14:18 +0100)
* src/keymap.c (store_in_keymap): Don't add a nil keybinding if we've
been asked to remove a non-existent binding.  (Bug#62207)

src/keymap.c

index 23453eaa9a6eec368e6531ff0e54da5c74f1a355..efac410d317d768adc5c1c9a032e5431ca7430c6 100644 (file)
@@ -887,22 +887,23 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx,
   keymap_end:
     /* We have scanned the entire keymap, and not found a binding for
        IDX.  Let's add one.  */
-    {
-      Lisp_Object elt;
+    if (!remove)
+      {
+       Lisp_Object elt;
 
-      if (CONSP (idx) && CHARACTERP (XCAR (idx)))
-       {
-         /* IDX specifies a range of characters, and not all of them
-            were handled yet, which means this keymap doesn't have a
-            char-table.  So, we insert a char-table now.  */
-         elt = Fmake_char_table (Qkeymap, Qnil);
-         Fset_char_table_range (elt, idx, NILP (def) ? Qt : def);
-       }
-      else
-       elt = Fcons (idx, def);
-      CHECK_IMPURE (insertion_point, XCONS (insertion_point));
-      XSETCDR (insertion_point, Fcons (elt, XCDR (insertion_point)));
-    }
+       if (CONSP (idx) && CHARACTERP (XCAR (idx)))
+         {
+           /* IDX specifies a range of characters, and not all of them
+              were handled yet, which means this keymap doesn't have a
+              char-table.  So, we insert a char-table now.  */
+           elt = Fmake_char_table (Qkeymap, Qnil);
+           Fset_char_table_range (elt, idx, NILP (def) ? Qt : def);
+         }
+       else
+         elt = Fcons (idx, def);
+       CHECK_IMPURE (insertion_point, XCONS (insertion_point));
+       XSETCDR (insertion_point, Fcons (elt, XCDR (insertion_point)));
+      }
   }
 
   return def;