GNU bug report logs -
#59130
Inconsistent behaviour with key-translation-map
Previous Next
Reported by: João Guerra <joca.bt <at> gmail.com>
Date: Tue, 8 Nov 2022 19:39:02 UTC
Severity: normal
Tags: notabug
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59130 in the body.
You can then email your comments to 59130 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59130
; Package
emacs
.
(Tue, 08 Nov 2022 19:39:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
João Guerra <joca.bt <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 08 Nov 2022 19:39:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59130
; Package
emacs
.
(Tue, 08 Nov 2022 20:23:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 59130 <at> debbugs.gnu.org (full text, mbox):
> From: João Guerra <joca.bt <at> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59130
; Package
emacs
.
(Tue, 08 Nov 2022 21:43:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 59130 <at> debbugs.gnu.org (full text, mbox):
>> 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
Added tag(s) notabug.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 09 Nov 2022 14:24:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59130
; Package
emacs
.
(Wed, 09 Nov 2022 17:18:03 GMT)
Full text and
rfc822 format available.
Message #16 received at 59130 <at> debbugs.gnu.org (full text, mbox):
> 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)?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59130
; Package
emacs
.
(Thu, 10 Nov 2022 21:17:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 59130 <at> debbugs.gnu.org (full text, mbox):
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.
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Fri, 11 Nov 2022 07:03:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
João Guerra <joca.bt <at> gmail.com>
:
bug acknowledged by developer.
(Fri, 11 Nov 2022 07:03:02 GMT)
Full text and
rfc822 format available.
Message #24 received at 59130-done <at> debbugs.gnu.org (full text, mbox):
> From: João Guerra <joca.bt <at> gmail.com>
> Date: Thu, 10 Nov 2022 22:15:28 +0100
> Cc: 59130 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> 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.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 09 Dec 2022 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 251 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.