* bug#59130: Inconsistent behaviour with key-translation-map
@ 2022-11-08 19:37 João Guerra
2022-11-08 20:21 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: João Guerra @ 2022-11-08 19:37 UTC (permalink / raw)
To: 59130
It's possible to remap keys into other keys or sequence of keys via
key-translation-map
(https://www.gnu.org/software/emacs/manual/html_node/elisp/Translation-Keymaps.html).
For example,
setting
(define-key key-translation-map (kbd "<apps>") (kbd "C-x C-f"))
and pressing <apps> will execute command find-file,
setting
(define-key key-translation-map (kbd "<apps>") (kbd "C-x"))
and pressing <apps> C-f will execute command find-file.
However, setting
(define-key key-translation-map (kbd "<apps>") (kbd "C-x @ h"))
and pressing <apps> p will not execute H-p.
(C-x @ h adds prefix hyper
https://www.gnu.org/software/emacs/manual/html_node/emacs/Modifier-Keys.html)
Is this an issue or as expected?
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#59130: Inconsistent behaviour with key-translation-map
2022-11-08 19:37 bug#59130: Inconsistent behaviour with key-translation-map João Guerra
@ 2022-11-08 20:21 ` Eli Zaretskii
2022-11-08 21:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2022-11-08 20:21 UTC (permalink / raw)
To: João Guerra, Stefan Monnier; +Cc: 59130
> From: João Guerra <joca.bt@gmail.com>
> Date: Tue, 8 Nov 2022 20:37:36 +0100
>
> It's possible to remap keys into other keys or sequence of keys via
> key-translation-map
> (https://www.gnu.org/software/emacs/manual/html_node/elisp/Translation-Keymaps.html).
>
> For example,
>
> setting
> (define-key key-translation-map (kbd "<apps>") (kbd "C-x C-f"))
> and pressing <apps> will execute command find-file,
>
> setting
> (define-key key-translation-map (kbd "<apps>") (kbd "C-x"))
> and pressing <apps> C-f will execute command find-file.
>
> However, setting
> (define-key key-translation-map (kbd "<apps>") (kbd "C-x @ h"))
> and pressing <apps> p will not execute H-p.
>
> (C-x @ h adds prefix hyper
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Modifier-Keys.html)
>
> Is this an issue or as expected?
Adding Stefan to CC, in the hope that he knows the answer.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#59130: Inconsistent behaviour with key-translation-map
2022-11-08 20:21 ` Eli Zaretskii
@ 2022-11-08 21:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-09 17:17 ` João Guerra
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-08 21:41 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 59130, João Guerra
>> However, setting
>> (define-key key-translation-map (kbd "<apps>") (kbd "C-x @ h"))
>> and pressing <apps> p will not execute H-p.
>>
>> (C-x @ h adds prefix hyper
>> https://www.gnu.org/software/emacs/manual/html_node/emacs/Modifier-Keys.html)
>>
>> Is this an issue or as expected?
It's expected because the remapping of `C-x @ h` to a hyper prefix is
done with:
(define-key function-key-map [?\C-x ?@ ?h] 'event-apply-hyper-modifier)
and `function-key-map` is applied *before* `key-translation-map` and hence
doesn't apply to the result of `key-translation-map` remapping.
(define-key input-decode-map (kbd "<apps>") (kbd "C-x @ h"))
might work, OTOH, since `input-decode-map` applies before those
other two.
Note that `event-apply-hyper-modifier` has various limitations
(e.g. you can't use `?\C-x ?@ ?h ?\C-x ?@ ?m a` to make a `H-M-a` event)
so even if the above works it may not satisfy all your use cases.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#59130: Inconsistent behaviour with key-translation-map
2022-11-08 21:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-09 17:17 ` João Guerra
2022-11-10 21:15 ` João Guerra
0 siblings, 1 reply; 6+ messages in thread
From: João Guerra @ 2022-11-09 17:17 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 59130, Eli Zaretskii
> Note that `event-apply-hyper-modifier` has various limitations
> (e.g. you can't use `?\C-x ?@ ?h ?\C-x ?@ ?m a` to make a `H-M-a` event)
> so even if the above works it may not satisfy all your use cases.
Thanks for the clarification. Indeed I can do (define-key
key-translation-map (kbd "<apps>") #'event-apply-hyper-modifier).
However it has the limitations you described, as I cannot use Meta or
other modifiers with it.
Any suggestions on how to support this via lisp with something like
event-apply-hyper-modifier or hiperify (the example in the manual)?
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#59130: Inconsistent behaviour with key-translation-map
2022-11-09 17:17 ` João Guerra
@ 2022-11-10 21:15 ` João Guerra
2022-11-11 7:01 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: João Guerra @ 2022-11-10 21:15 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 59130, Stefan Monnier
After some analysis it looks like what I want to do cannot be done
totally in lisp. I'll just define hyper via xdb. Please close this
issue.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#59130: Inconsistent behaviour with key-translation-map
2022-11-10 21:15 ` João Guerra
@ 2022-11-11 7:01 ` Eli Zaretskii
0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2022-11-11 7:01 UTC (permalink / raw)
To: João Guerra; +Cc: 59130-done, monnier
> From: João Guerra <joca.bt@gmail.com>
> Date: Thu, 10 Nov 2022 22:15:28 +0100
> Cc: 59130@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
>
> After some analysis it looks like what I want to do cannot be done
> totally in lisp. I'll just define hyper via xdb. Please close this
> issue.
Thanks, closed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-11 7:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-08 19:37 bug#59130: Inconsistent behaviour with key-translation-map João Guerra
2022-11-08 20:21 ` Eli Zaretskii
2022-11-08 21:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-09 17:17 ` João Guerra
2022-11-10 21:15 ` João Guerra
2022-11-11 7:01 ` Eli Zaretskii
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.