[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 e444115d026: Improve keymap-global-set and keymap-local-set int
From: |
Robert Pluim |
Subject: |
emacs-29 e444115d026: Improve keymap-global-set and keymap-local-set interactive use fix |
Date: |
Fri, 3 Feb 2023 04:16:42 -0500 (EST) |
branch: emacs-29
commit e444115d026c809395d4d248a99bb467bc87bb1d
Author: Robert Pluim <rpluim@gmail.com>
Commit: Robert Pluim <rpluim@gmail.com>
Improve keymap-global-set and keymap-local-set interactive use fix
* lisp/keymap.el (keymap-global-set, keymap-local-set): Add optional
`interactive' arg and use it to decide when to convert the key
specification to a string. Add `advertised-calling-convention'
declarations. (Bug#61149)
---
lisp/keymap.el | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/lisp/keymap.el b/lisp/keymap.el
index 201a49cef8c..4f02639ffe2 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -65,7 +65,7 @@ DEFINITION is anything that can be a key's definition:
(setq definition (key-parse definition)))
(define-key keymap (key-parse key) definition))
-(defun keymap-global-set (key command)
+(defun keymap-global-set (key command &optional interactive)
"Give KEY a global binding as COMMAND.
COMMAND is the command definition to use; usually it is
a symbol naming an interactively-callable function.
@@ -75,13 +75,14 @@ KEY is a string that satisfies `key-valid-p'.
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 "KSet key globally:\nCSet key %s globally to command: ")
- (unless (stringp key)
+ (declare (compiler-macro (lambda (form) (keymap--compile-check key) form))
+ (advertised-calling-convention (key command) "29.1"))
+ (interactive "KSet key globally: \nCSet key %s globally to command: \np")
+ (when interactive
(setq key (key-description key)))
(keymap-set (current-global-map) key command))
-(defun keymap-local-set (key command)
+(defun keymap-local-set (key command &optional interactive)
"Give KEY a local binding as COMMAND.
COMMAND is the command definition to use; usually it is
a symbol naming an interactively-callable function.
@@ -90,12 +91,13 @@ 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: ")
+ (declare (compiler-macro (lambda (form) (keymap--compile-check key) form))
+ (advertised-calling-convention (key command) "29.1"))
+ (interactive "KSet key locally: \nCSet key %s locally to command: \np")
(let ((map (current-local-map)))
(unless map
(use-local-map (setq map (make-sparse-keymap))))
- (unless (stringp key)
+ (when interactive
(setq key (key-description key)))
(keymap-set map key command)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 e444115d026: Improve keymap-global-set and keymap-local-set interactive use fix,
Robert Pluim <=