Subject: Re: bug#74619: macOS: <ns-show-prefs> displayed as keybinding for \\[customize] on emacs -nw

From: Gerd Möllmann <[email-masked]>
Date: Mon, 02 Dec 2024 15:49:18 +0100

Robert Pluim <[email-masked]> writes:

>>>>>> On Sat, 30 Nov 2024 16:40:53 +0900, Yoichi Nakayama <[email-masked]> said:
>
>     Yoichi> I found that bug#55940 (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55940)
>     Yoichi> has not been fixed on Emacs started by "emacs -nw"
>
>     Yoichi> (substitute-command-keys "\\[customize]")
>     Yoichi> #("<ns-show-prefs>" 0 15 (font-lock-face help-key-binding face
>     Yoichi> help-key-binding))
>
>     Yoichi> I think this is because make-non-key-event for ns-* is not called
>     Yoichi> in this situation.
>
> Right, but OTOH typical terminal setups donʼt allow you to use super
> as a modifier anyway (unless Gerd has a magic recipe). I guess it
> couldnʼt do too much harm to call the ns-specific portion of
> `x-setup-function-keys' even when not in a graphical frame, but Iʼm
> not sure where we could hook that into.
>
> Robert

I think I have even 2 magic recipes :-).

1. Use a terminal like iTerm that supports the Kitty Keyboard Protocol,
and use kkp.el in Emacs. Example from my Emacs C-h k Command-M g ives

  s-m runs the command magit-file-dispatch (found in global-map), which
  is an autoloaded interactive native-comp-function in ‘magit-files.el’.

That requires some fiddling with iTerm key settings so that iTerm itself
doesn't use the Command keys one wants to define.

  https://sw.kovidgoyal.net/kitty/keyboard-protocol/
  https://github.com/benjaminor/kkp

2. Use something like Devil

  https://github.com/susam/devil/blob/main/devil.el

In short, that can map input like `. x' to `s-x'. I think there is at
least one other similar package named God, but I haven't tried that.