GNU bug report logs -
#61149
29.0.60; keymap-local-set rejects key sequences
Previous Next
Reported by: Eli Zaretskii <eliz <at> gnu.org>
Date: Sun, 29 Jan 2023 13:45:02 UTC
Severity: normal
Tags: fixed
Found in version 29.0.60
Fixed in version 29.1
Done: Robert Pluim <rpluim <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 61149 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Sun, 29 Jan 2023 15:35:22 +0100 Stephen Berman <stephen.berman <at> gmx.net> wrote:
> On Sun, 29 Jan 2023 15:44:44 +0200 Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> To reproduce:
>>
>> emacs -Q
>> M-x keymap-local-set
>> C-c .
>> forward-line RET
>>
>> Observe the error message:
>>
>> [3 46] is not a valid key definition; see ‘key-valid-p’
>>
>> (The error message comes from keymap--check.)
>>
>> To type the key sequence, I actually pressed Ctrl and typed 'c', then
>> released Ctrl and typed '.'. Isn't that what one is supposed to use?
>>
>> So the above basically makes keymap-local-set useless, or am I missing
>> something? The following does work:
>>
>> M-: (keymap-local-set "C-c ." 'forward-line) RET
>>
>> However, I could find no way of typing the string "C-c ." at the
>> prompt of keymap-local-set.
>
> This patch seems to DTRT:
>
> diff --git a/lisp/keymap.el b/lisp/keymap.el
> index 791221f2459..9643dce5f9c 100644
> --- a/lisp/keymap.el
> +++ b/lisp/keymap.el
> @@ -95,7 +95,8 @@ keymap-local-set
> 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: ")
> - (let ((map (current-local-map)))
> + (let ((map (current-local-map))
> + (key (key-description key)))
> (unless map
> (use-local-map (setq map (make-sparse-keymap))))
> (keymap-set map key command)))
... but not in your non-interactive case; so maybe this instead:
[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/keymap.el b/lisp/keymap.el
index 791221f2459..48ec91d03c8 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -98,6 +98,8 @@ keymap-local-set
(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)
[Message part 3 (text/plain, inline)]
Steve Berman
This bug report was last modified 2 years and 116 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.