I am working with Emacs on Cygwin, which actually has 3 types of Emacsen:
- Win32 Emacs, which is a graphical Emacs compiled to use native Windows GUI (so no X windows is required)
- Terminal Emacs, which displays in the mintty terminal by default
- X Windows Emacs (requires X, and not relevant to this question)
I am trying to bind the APPS key (the one with the little menu on it, usually to the right of the right-hand Windows key, I think it is properly known as the MENU key, https://en.wikipedia.org/wiki/Menu_key) to the "super" modifier (gotta love those short key sequences). In Win32 Emacs this is pretty easy:
(when (equal window-system 'w32)
(setq w32-pass-apps-to-system nil
w32-apps-modifier 'super))
This makes Emacs treat APPS as super and stops it passing it onto the OS. It then becomes trivial to make bindings such as
(define-key global-map (kbd "s-r") 'recentf-open-files)
Problem
How to make terminal mode Emacs also treat APPS as super? Firstly it was necessary to have mintty changed to pass through the APPS key to Emacs; this has been done already by the maintainer (see https://github.com/mintty/mintty/issues/494) and we can now configure mintty to send any escape sequence we want through to Emacs.
As I said in the issue, the initial suggestion of Key_Menu=29
(which results in ESC [ 2 9 ~
appearing in the view-lossage
log), appears to be interpreted by Emacs as the "<print>" key, so that I can succesfully bind using
(global-set-key (kbd "<print> r") 'recentf-open-files)
The above, while it is a great advance, is not ideal because 2 sets of bindings would be required, one for terminal mode and one for graphical windowed mode.
Things that I don't know
- How does Emacs translate a sequence of input characters into a logical key?
- Why does terminal Emacs think the ESC 29 sequence is the print key?
- Does terminal Emacs even know about the APPS key?
Question
- How can I configure W32 Emacs and terminal Emacs so that they both treat APPS/MENU as the
super
modifier, thus enabling a single set of keybindings to be used in both cases?
print
key. There is a line in list\term\xterm.el.gz which maps that sequence to print:(define-key map "\e[29~" [print])