bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#59305: 29.0.50; keymap-global-set handling of string bindings differ


From: Robert Pluim
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

>>>>> 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\305\300%2\306#\210\301\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\305\300%2\306#\210\301\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
-- 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]