unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org,  mail@daniel-mendler.de,  emacs-devel@gnu.org,
	monnier@iro.umontreal.ca
Subject: Re: 29.0.60; keymap-local-set and keymap-global-set became less strict
Date: Wed, 01 Feb 2023 13:52:19 +0100	[thread overview]
Message-ID: <87bkmdo8e4.fsf@gmail.com> (raw)
In-Reply-To: <83mt5y1r5u.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 31 Jan 2023 20:43:09 +0200")

>>>>> On Tue, 31 Jan 2023 20:43:09 +0200, Eli Zaretskii <eliz@gnu.org> said:

    Eli> What's wrong with the first method described in the node "Distinguish
    Eli> Interactive" in the ELisp reference?

You mean like this? Itʼs definitely a smaller change.

diff --git i/lisp/keymap.el w/lisp/keymap.el
index de90b03ba64..5897418c7ab 100644
--- i/lisp/keymap.el
+++ w/lisp/keymap.el
@@ -65,7 +65,7 @@ keymap-set
     (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.
@@ -76,12 +76,12 @@ 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)
+  (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.
@@ -91,11 +91,11 @@ 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: \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)))


Robert
-- 



  reply	other threads:[~2023-02-01 12:52 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5876987d-2479-f512-5767-218c8c16a909@daniel-mendler.de>
     [not found] ` <875ycngyji.fsf@gnus.org>
2023-01-31  9:05   ` 29.0.60; keymap-local-set and keymap-global-set became less strict Robert Pluim
2023-01-31 10:08     ` Stephen Berman
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 [this message]
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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87bkmdo8e4.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).