all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Daniel Mendler <mail@daniel-mendler.de>,
	 emacs-devel@gnu.org,  Stefan Monnier <monnier@iro.umontreal.ca>,
	Eli Zaretskii <eliz@gnu.org>
Subject: Re: 29.0.60; keymap-local-set and keymap-global-set became less strict
Date: Tue, 31 Jan 2023 10:05:15 +0100	[thread overview]
Message-ID: <87zg9zvzuc.fsf@gmail.com> (raw)
In-Reply-To: <875ycngyji.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 31 Jan 2023 04:42:25 +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)))



  reply	other threads:[~2023-01-31  9:05 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 20:52 bug#61184: 29.0.60; keymap-local-set and keymap-global-set became less strict Daniel Mendler
2023-01-30 21:00 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-30 21:06   ` Daniel Mendler
2023-01-30 21:45     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-30 22:03       ` Daniel Mendler
2023-01-31  3:42 ` Lars Ingebrigtsen
2023-01-31  9:05   ` Robert Pluim [this message]
2023-01-31 10:08     ` Stephen Berman
2023-01-31 10:23       ` bug#61184: " Robert Pluim
2023-01-31 10:31         ` Stephen Berman
2023-01-31 10:37           ` Robert Pluim
2023-01-31 10:44             ` Stephen Berman
2023-01-31 16:06             ` Eli Zaretskii
2023-01-31 14:27       ` [External] : " Drew Adams
2023-01-31 14:30     ` Stefan Monnier
2023-01-31 15:02       ` Robert Pluim
2023-01-31 15:06     ` Eli Zaretskii
2023-01-31 15:48       ` Robert Pluim
2023-01-31 16:37         ` Eli Zaretskii
2023-01-31 16:48           ` Robert Pluim
2023-01-31 18:43             ` Eli Zaretskii
2023-02-01 12:52               ` Robert Pluim
2023-02-01 13:06                 ` Eli Zaretskii
2023-02-01 13:13                   ` Daniel Mendler
2023-02-01 13:44                     ` Robert Pluim
2023-02-01 14:11                       ` Daniel Mendler
2023-02-01 13:50                     ` Eli Zaretskii
2023-02-01 13:57                       ` Daniel Mendler
2023-02-01 17:30                         ` Eli Zaretskii
2023-02-01 18:20                           ` Daniel Mendler
2023-02-01 18:54                             ` Stefan Monnier
2023-02-01 20:22                               ` Daniel Mendler
2023-02-01 22:42                                 ` Stefan Monnier
2023-02-01 22:56                                   ` Daniel Mendler
2023-02-02  6:58                                     ` Eli Zaretskii
2023-02-02  9:29                                       ` Daniel Mendler
2023-02-02  9:40                                       ` Robert Pluim
2023-02-02 10:17                                         ` Eli Zaretskii
2023-02-03  9:17                                           ` Robert Pluim
2023-02-03  9:56                                   ` Richard Stallman
2023-02-04  9:55                                     ` Daniel Mendler
2023-02-03  9:56                           ` Richard Stallman
2023-02-03 12:11                             ` Eli Zaretskii
2023-02-05  4:27                               ` Richard Stallman
2023-02-05  7:11                                 ` Eli Zaretskii
2023-01-31 12:10 ` bug#61184: " Eli Zaretskii
2023-01-31 12:49   ` Daniel Mendler
2023-01-31 14:16     ` Eli Zaretskii
2023-01-31 14:53       ` Daniel Mendler
2023-02-03  9:19         ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zg9zvzuc.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=mail@daniel-mendler.de \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.