From: Robert Pluim <rpluim@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Lars Ingebrigtsen <larsi@gnus.org>,
59305@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>,
Stefan Kangas <stefankangas@gmail.com>
Subject: bug#59305: 29.0.50; keymap-global-set handling of string bindings different from global-set-key
Date: Mon, 06 May 2024 16:34:18 +0200 [thread overview]
Message-ID: <87jzk7ko0l.fsf@gmail.com> (raw)
In-Reply-To: <jwva5l33wyg.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 06 May 2024 09:24:56 -0400")
>>>>> On Mon, 06 May 2024 09:24:56 -0400, Stefan Monnier <monnier@iro.umontreal.ca> said:
Stefan> `key-parse` always returns a vector.
>> You want us to recommend this?
>> (keymap-global-set "C-a" (key-parse "hello"))
Stefan> Sorry, I was not thinking right. The function you'd need to use to
Stefan> convert "hello" into the proper form for `keymap-global-set` is either:
Stefan> - `key-description`: does the "reverse" of `kbd` and `key-parse`.
Stefan> - `kmacro--to-vector`: turns an old-style string of events to a vector
Stefan> of events.
`key-description' does the wrong thing with multibyte strings:
(key-description "olá") => "o l M-a"
`kmacro--to-vector' does the right thing:
(kmacro--to-vector "hello") => [104 101 108 108 111]
(kmacro--to-vector "olá") => [111 108 225]
We could invent 'YetAnotherName'™ or we could just use `kmacro'
(kmacro "hello") => #[256 "\301\242\302%1b\x1c\305\300%2\306#\210\301\f\240*\207" [[104 101 108 108 111] (0) "%d" kmacro-counter-format-start kmacro-counter execute-kbd-macro kmacro-loop-setup-function] 5 kmacro]
(kmacro "olá") => #[256 "\301\242\302%1b\x1c\305\300%2\306#\210\301\f\240*\207" [[111 108 225] (0) "%d" kmacro-counter-format-start kmacro-counter execute-kbd-macro kmacro-loop-setup-function] 5 kmacro]
although that *also* has the caveat about `key-valid-p'
Thatʼs the thing about Emacs: so many options to choose from :-)
>> so Iʼd still worry about future regressions caused by `key-parse'
>> being changed to enforce `key-valid-p'
Stefan> Indeed. Not only that, but it'll mis-interpret `C-a` to mean a single
Stefan> event instead of 3 events.
Right.
Robert
--
next prev parent reply other threads:[~2024-05-06 14:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 8:47 bug#59305: 29.0.50; keymap-global-set handling of string bindings different from global-set-key Robert Pluim
2022-11-22 16:58 ` Robert Pluim
2022-11-25 0:14 ` Stefan Kangas
2022-11-25 8:01 ` Robert Pluim
2022-11-25 8:25 ` Stefan Kangas
2022-12-15 8:42 ` Robert Pluim
2024-04-26 14:34 ` Robert Pluim
2024-05-02 9:01 ` Eli Zaretskii
2024-05-02 13:13 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 10:03 ` Robert Pluim
2024-05-06 13:24 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 14:34 ` Robert Pluim [this message]
2024-05-06 15:20 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=87jzk7ko0l.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=59305@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
--cc=stefankangas@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 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).