unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* emacs term-keys,  and describe-prefix-translations
@ 2024-12-03  6:51 Madhu
  0 siblings, 0 replies; only message in thread
From: Madhu @ 2024-12-03  6:51 UTC (permalink / raw)
  To: help-gnu-emacs


When trying to use term-keys <https://github.com/CyberShadow/term-keys>
(actually my gh clone of it) to handle Super- bindings in the terminal,
I run into behaviour that I do not understand, which I detail below
where "s-s" works but "s-d" doesn't.

term-keys works by arranging for "xterm" (and other terms) to send
escape codes and setting up input-decode-map on emacs terminal frames to
handle them.

for xterm my config sets up these overrides via Xresources
*VT100.Translations:#override

```
~Shift ~Ctrl ~Meta  Super ~Hyper ~Alt <Key> s          : string(0x1b) string(0x1f) string(0x3e) string(0x68) string(0x1f) \n\
~Shift ~Ctrl ~Meta  Super ~Hyper ~Alt <Key> d          : string(0x1b) string(0x1f) string(0x3f) string(0x48) string(0x1f) \n\
```

and typing "Super-s" and "Super-d" under "showkeys -a" in any terminal
produces the following.

```
$ showkey -a
Press any keys - Ctrl-D will terminate this program

^[^_>h^_         27 0033 0x1b
         31 0037 0x1f
         62 0076 0x3e
        104 0150 0x68
         31 0037 0x1f
^[^_?H^_         27 0033 0x1b
         31 0037 0x1f
         63 0077 0x3f
         72 0110 0x48
         31 0037 0x1f
```

On the emacs side, term-keys-init does the equivalent of calling

```
(define-key input-decode-map (string #x1b #x1f #x3e #x68 #x1f)
       (kbd "s-s"))
(define-key input-decode-map (string #x1b #x1f #x3f #x48 #x1f)
       (kbd "s-d"))

```

And can is verified with lookup-key.

**HERE**
Now calling Super-s on the terminal correctly produces "s-s is
undefined"

but calling Super-d produces a help screen with the input decoding map
translations for C-M-_

view-lossage has an entry:
ESC C-_ ?      ;; describe-prefix-bindings

and the (info "(elisp) Help Functions") has

```
The help character is special after prefix keys, too.  If it has no
binding as a subcommand of the prefix key, it runs
‘describe-prefix-bindings’, which displays a list of all the subcommands
of the prefix key.
```

Is the input keymap machinery doing the right thing here in
interpreting the escape sequence for "d"

(lookup-key input-decode-map (string #x1b #x1f #x3e #x68))
 => (keymap (31 . [8388723]))

as a key sequence which calls the prefix-help-command?

Should I avoid the use of #x68 in the encoding used by the term-keys
protocol or is there some other solution? Any comments welcome, thanks





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-03  6:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03  6:51 emacs term-keys, and describe-prefix-translations Madhu

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