all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 61149@debbugs.gnu.org, Robert Pluim <rpluim@gmail.com>
Subject: bug#61149: 29.0.60; keymap-local-set rejects key sequences
Date: Sun, 29 Jan 2023 16:28:44 +0100	[thread overview]
Message-ID: <871qndbbrn.fsf@rub.de> (raw)
In-Reply-To: <875ycpbe8l.fsf@rub.de> (Stephen Berman's message of "Sun, 29 Jan 2023 15:35:22 +0100")

[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]

On Sun, 29 Jan 2023 15:35:22 +0100 Stephen Berman <stephen.berman@gmx.net> wrote:

> On Sun, 29 Jan 2023 15:44:44 +0200 Eli Zaretskii <eliz@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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: keymap-local-set patch --]
[-- Type: text/x-patch, Size: 438 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


Steve Berman

  reply	other threads:[~2023-01-29 15:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-29 13:44 bug#61149: 29.0.60; keymap-local-set rejects key sequences Eli Zaretskii
2023-01-29 14:35 ` Stephen Berman
2023-01-29 15:28   ` Stephen Berman [this message]
2023-01-30  7:59     ` Robert Pluim
2023-01-30  8:46       ` Stephen Berman
2023-01-30  9:47         ` Robert Pluim
2023-01-30 13:14           ` Eli Zaretskii
2023-01-30 13:25             ` 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=871qndbbrn.fsf@rub.de \
    --to=stephen.berman@gmx.net \
    --cc=61149@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rpluim@gmail.com \
    /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.