Subject: bug#59130: Inconsistent behaviour with key-translation-map

From: Stefan Monnier <[email-masked]>
Date: Tue, 08 Nov 2022 16:41:59 -0500

>> 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