[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 29.0.60; keymap-local-set and keymap-global-set became less strict
From: |
Robert Pluim |
Subject: |
Re: 29.0.60; keymap-local-set and keymap-global-set became less strict |
Date: |
Tue, 31 Jan 2023 10:05:15 +0100 |
Dropping bug-gnu-emacs, adding emacs-devel
>>>>> On Tue, 31 Jan 2023 04:42:25 +0100, Lars Ingebrigtsen <larsi@gnus.org>
>>>>> said:
Lars> In addition, having one single syntax allows people to grep for
bindings
Lars> etc -- when exploring the source code, they can isearch for `C-c C-k'
Lars> (or whatever) exactly and reliably find the command they're looking
for
Lars> that way (eventually).
We have bindings in emacs currently that are Not Compliant™, thatʼs
for sure.
Lars> So keymap-local-set and keymap-global-set should be fixed to be strict
Lars> again, otherwise there's not much point to the entire `keymap-*'
Lars> exercise.
OK. How about this then (why are the `cursor-in-echo-area' shenanigans
necessary? I wonder if thatʼs a bug, since without them we either get
the cursor not showing in the minibuffer for
`read-key-sequence-vector', or we get an extra space displayed by
`read-command')
diff --git i/lisp/keymap.el w/lisp/keymap.el
index caabedd5aec..0c1aa412e35 100644
--- i/lisp/keymap.el
+++ w/lisp/keymap.el
@@ -76,9 +76,14 @@ keymap-global-set
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 "KSet key globally:\nCSet key %s globally to command: ")
- (unless (stringp key)
- (setq key (key-description key)))
+ (interactive
+ (let* ((menu-prompting nil)
+ (cursor-in-echo-area t)
+ (key (key-description (read-key-sequence-vector "Set key globally:"
nil t))))
+ (list key
+ (let ((cursor-in-echo-area nil))
+ (read-command (format "Set key %s to command: "
+ key))))))
(keymap-set (current-global-map) key command))
(defun keymap-local-set (key command)
@@ -91,12 +96,17 @@ keymap-local-set
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
+ (let* ((menu-prompting nil)
+ (cursor-in-echo-area t)
+ (key (key-description (read-key-sequence-vector "Set key locally:"
nil t))))
+ (list key
+ (let ((cursor-in-echo-area nil))
+ (read-command (format "Set key %s to command: "
+ key))))))
(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)))
- Re: 29.0.60; keymap-local-set and keymap-global-set became less strict,
Robert Pluim <=