diff options
author | Robert Pluim <rpluim@gmail.com> | 2023-03-17 09:50:38 +0100 |
---|---|---|
committer | Robert Pluim <rpluim@gmail.com> | 2023-03-17 14:18:02 +0100 |
commit | bb3e0ded9eba71596b34806b302d63977259c3dd (patch) | |
tree | b59985a57d7c68a18ab90531a7cb14cab2c88def | |
parent | a4a9ffdd80a2b8ccd2e6705887d3cae0876a50ab (diff) | |
download | emacs-bb3e0ded9eba71596b34806b302d63977259c3dd.tar.gz |
Don't add a key binding when REMOVE is non-nil
* 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)
-rw-r--r-- | src/keymap.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/keymap.c b/src/keymap.c index 23453eaa9a6..efac410d317 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -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; |