GNU bug report logs - #61149
29.0.60; keymap-local-set rejects key sequences

Previous Next

Package: emacs;

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 #20 received at 61149 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 61149 <at> debbugs.gnu.org
Subject: Re: bug#61149: 29.0.60; keymap-local-set rejects key sequences
Date: Mon, 30 Jan 2023 10:47:35 +0100
>>>>> On Mon, 30 Jan 2023 09:46:49 +0100, Stephen Berman <stephen.berman <at> gmx.net> said:

    Stephen> This also DTRT, but it also gives keymap-local-set the same UI as that
    Stephen> of keymap-global-set, which is that at the first prompt the cursor jumps
    Stephen> out of the minibuffer (due to read-key-sequence), and then jumps back at
    Stephen> the second prompt.  I find this quite jarring (and the first time I was
    Stephen> quite surprised and thought I had either mistyped or there was a bug).
    Stephen> I would prefer it if both commands had keymap-local-set's current UI.

Yes, that is quite annoying. So letʼs do it your way (with an
incidental spacing fix :-) )

Eli, emacs-29, I think, if youʼre ok with the fix.

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 @@ 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
-   (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 @@ 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 "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)




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.