Subject: 29.0.60; Is xterm modifyOtherKeys support broken?

From: Len Trigg <[email-masked]>
Date: Thu, 15 Dec 2022 10:48:35 +1300

I often run emacs in the terminal, and usually this is inside wezterm as my
terminal emulator. Recently wezterm has added support for the
modifyOtherKeys xterm extension, and since then emacs M-SPC has stopped
working in the terminal (instead it inserts "~32").

I can get M-SPC working again in wezterm by preventing emacs from enabling
modifyOtherKeys, either by setting xterm-extra-capabilities to nil or by
stubbing out xterm--init-modify-other-keys. Initially we thought that
this may be a problem with wezterm, but then I tried replicating with
xterm and exactly the same thing happens. This suggests to me that the
issue is with emacs rather than xterm or wezterm.

To replicate:

1) run: xterm -e emacs -nw -Q
2) in say *scratch* check whether M-SPC works or whether it inserts ~32
(for me it inserts ~32)

To replicate disabling modifyOtherKeys:

1) put the following into $HOME/test-dir/init.el
------
;; Dirty hack to not use xterm modifyOtherKeys feature
(defun my-disable-xterm--init-modify-other-keys (orig-fun &rest args))
(advice-add #'xterm--init-modify-other-keys :around
            #'my-disable-xterm--init-modify-other-keys)
------
2) run: xterm -e emacs -nw --init-dir=$HOME/test-dir
3) in say *scratch* check whether M-SPC works or whether it inserts ~32
(for me it works correctly)

This seems to demonstrate the out of the box behaviour being broken, but
I don't understand enough about terminals etc to know whether there is
some other factor at play.

Relevant link where this was discussed:
https://github.com/CyberShadow/term-keys/issues/14

Cheers,
Len.