diff options
author | Robert Pluim <rpluim@gmail.com> | 2023-01-30 10:51:30 +0100 |
---|---|---|
committer | Robert Pluim <rpluim@gmail.com> | 2023-01-30 13:44:39 +0100 |
commit | f67a9a12b7b0cdd6030cb080a6d6838255789a08 (patch) | |
tree | 5bb6c5f4585cb87c875581b1bdd2b1b687198e03 /lisp/keymap.el | |
parent | dda4baa58b7e6a5c70f4c40c80463221b3c479c1 (diff) | |
download | emacs-f67a9a12b7b0cdd6030cb080a6d6838255789a08.tar.gz emacs-f67a9a12b7b0cdd6030cb080a6d6838255789a08.tar.bz2 emacs-f67a9a12b7b0cdd6030cb080a6d6838255789a08.zip |
Fix interactive use of `keymap-local-set' and `keymap-global-set'
* lisp/keymap.el (keymap-global-set, keymap-local-set): Convert the
read key sequence to a string when called interactively. Based on a
patch from Stephen Berman <stephen.berman@gmx.net>. (Bug#61149)
Diffstat (limited to 'lisp/keymap.el')
-rw-r--r-- | lisp/keymap.el | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lisp/keymap.el b/lisp/keymap.el index 791221f2459..caabedd5aec 100644 --- a/lisp/keymap.el +++ b/lisp/keymap.el @@ -76,12 +76,9 @@ Note that if KEY has a local binding in the current buffer, that local binding will continue to shadow any global binding that you make with this function." (declare (compiler-macro (lambda (form) (keymap--compile-check key) form))) - (interactive - (let* ((menu-prompting nil) - (key (read-key-sequence "Set key globally: " nil t))) - (list key - (read-command (format "Set key %s to command: " - (key-description key)))))) + (interactive "KSet key globally:\nCSet key %s globally to command: ") + (unless (stringp key) + (setq key (key-description key))) (keymap-set (current-global-map) key command)) (defun keymap-local-set (key command) @@ -94,10 +91,12 @@ KEY is a string that satisfies `key-valid-p'. The binding goes in the current buffer's local map, which in most cases is shared with all other buffers in the same major mode." (declare (compiler-macro (lambda (form) (keymap--compile-check key) form))) - (interactive "KSet key locally: \nCSet key %s locally to command: ") + (interactive "KSet key locally:\nCSet key %s locally to command: ") (let ((map (current-local-map))) (unless map (use-local-map (setq map (make-sparse-keymap)))) + (unless (stringp key) + (setq key (key-description key))) (keymap-set map key command))) (defun keymap-global-unset (key &optional remove) |