From: Robert Pluim <rpluim@gmail.com>
To: Daniel Mendler <mail@daniel-mendler.de>
Cc: Eli Zaretskii <eliz@gnu.org>, 60867@debbugs.gnu.org
Subject: bug#60867: 29.0.60; keymap-set-after does not accept the AFTER=t argument
Date: Thu, 19 Jan 2023 10:55:49 +0100 [thread overview]
Message-ID: <87o7qualwa.fsf@gmail.com> (raw)
In-Reply-To: Robert Pluim's message of "(unknown date)"
The nice thing about keymaps in Emacs is that everything is so
consistent :-).
The bare minimum to fix this bug:
diff --git c/lisp/keymap.el i/lisp/keymap.el
index 315eaab7560..2caaafabb94 100644
--- c/lisp/keymap.el
+++ i/lisp/keymap.el
@@ -186,6 +186,7 @@ keymap-set-after
(declare (indent defun)
(compiler-macro (lambda (form) (keymap--compile-check key) form)))
(keymap--check key)
+ (when (eq after t) (setq after nil)) ; nil and t are treated the same
(when after
(keymap--check after))
(define-key-after keymap (key-parse key) definition
However, `keymap-set' and `keymap-set-after' donʼt behave the same:
(let ((k (make-sparse-keymap)))
(keymap-set k "a" "a")
(keymap-set-after k "b" "b")
k)
=> (keymap (97 . [97]) (98 . "b"))
so for consistency Iʼd want to put the following in emacs-29:
diff --git c/lisp/keymap.el i/lisp/keymap.el
index 315eaab7560..19faae5c493 100644
--- c/lisp/keymap.el
+++ i/lisp/keymap.el
@@ -188,6 +188,11 @@ keymap-set-after
(keymap--check key)
(when after
(keymap--check after))
+ ;; If we're binding this key to another key, then parse that other
+ ;; key, too.
+ (when (stringp definition)
+ (keymap--check definition)
+ (setq definition (key-parse definition)))
(define-key-after keymap (key-parse key) definition
(and after (key-parse after))))
And of course the following for consistency for `keymap-lookup' as
well. I now firmly believe that the new keymap functions should use
`key-parse' and not `kbd'.
diff --git c/lisp/keymap.el i/lisp/keymap.el
index 315eaab7560..da71d48c86e 100644
--- c/lisp/keymap.el
+++ i/lisp/keymap.el
@@ -404,7 +404,7 @@ keymap-lookup
(symbolp value))
(or (command-remapping value) value)
value))
- (key-binding (kbd key) accept-default no-remap position)))
+ (key-binding (key-parse key) accept-default no-remap position)))
(defun keymap-local-lookup (keys &optional accept-default)
"Return the binding for command KEYS in current local keymap only.
Eli, is this too much for emacs-29?
Robert
--
next prev parent reply other threads:[~2023-01-19 9:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-16 18:20 bug#60867: 29.0.60; keymap-set-after does not accept the AFTER=t argument Daniel Mendler
2023-01-17 17:13 ` Robert Pluim
2023-01-17 17:18 ` Daniel Mendler
2023-01-18 8:36 ` Robert Pluim
2023-01-18 10:29 ` Daniel Mendler
2023-01-19 9:55 ` Robert Pluim [this message]
2023-01-19 10:08 ` Daniel Mendler
2023-01-19 10:16 ` Robert Pluim
2023-01-19 10:39 ` Daniel Mendler
2023-01-19 11:05 ` Robert Pluim
2023-01-19 11:19 ` Daniel Mendler
2023-01-19 15:27 ` Robert Pluim
2023-01-19 15:38 ` Daniel Mendler
2023-01-19 10:23 ` Eli Zaretskii
2023-01-19 10:40 ` Robert Pluim
2023-01-19 11:27 ` Eli Zaretskii
2023-01-19 15:20 ` Robert Pluim
2023-01-20 16:11 ` 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=87o7qualwa.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=60867@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=mail@daniel-mendler.de \
/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.