I connect to a headless Ubuntu server (no X) over SSH and run Emacs. In my ~/.emacs file I have defined a keyboard shortcut using the 's' (Super) modifier. This shortcut works when I run Emacs in a GUI but does not work over SSH. I have searched for an explanation but have not found one yet. I assume that the Super key is not passed over the SSH link?
-
don't know really, haven't used either much, but are you logging into the ssh server as the same user? i.e. when you use ubuntu is your username there when the superkey works, the same as the one you use when you ssh to the ssh server when the superkey doesn't work? If you try the pwd command in cd ~/, does it show the same home directory– barlopApr 1, 2012 at 20:46
-
Not sure I follow what you're saying. I login as ABC on the GUI machine where ~/.emacs has a Super-key shortcut defined. I sometimes login via SSH into a headless machine as user XYZ where the same .emacs file is in ~, so the Super-key definition exists on both machines, but only works on the GUI machine.– SabreWolfyApr 2, 2012 at 19:47
3 Answers
The GUI version of Emacs can listen for any keypress using the X11 protocol. The terminal version is a bit more limited – it can only receive keypresses the terminal program forwards; modifier keys only work as modifiers, never as separate keys; finally, the Super key is just not forwarded by any emulator, simply because it is generally thought to be reserved to the OS for such things as window management.
If you really need to use the less standard modifier keys from a terminal emulator, emacs has keybindings for these:
C-x @ S event-apply-shift-modifier
C-x @ a event-apply-alt-modifier
C-x @ c event-apply-control-modifier
C-x @ h event-apply-hyper-modifier
C-x @ m event-apply-meta-modifier
C-x @ s event-apply-super-modifier
So in your case, use C-x @ s
for the super modifier.
-
Awesome, thanks. That's very useful to know. Tested it now and it even works through PuTTY. (I wish I could accept your answer too, but grawity's answer specifically addressed my question, so I've accepted that answer.) Apr 2, 2012 at 19:51
Terminal emulators convert certain modifier keys to sequences and forward these sequences to the terminal programs. Usually these modifier keys don't include Super
(Win key).
The Konsole
terminal emulator does convert this modifier into the sequence ^X@s
though. Therefore in Emacs, you can add an entry to local-function-key-map
mapping that to event-apply-super-modifier
. However such entry already exists, so there is nothing to do, just use Konsole
and your s-
bindings will work, even through SSH!
A caveat: bindings like C-x s-o
will not work, because Emacs will see it as C-x C-x @ s o
.