1

This code binds "Super-c" to lambda:

(global-set-key (kbd "s-c")
      (lambda () (interactive) (jump-to-register 'q)))

How can I bind Super-s? They are both denoted as "s": (kbd "s-s"). I need to escape one of them somehow.

My Emacs version: GNU Emacs 26.3 (build 1, i586-slackware-linux-gnu, GTK+ Version 3.18.9) of 2019-08-29. Running on Linux Slackware 14.2.

3 Answers 3

3

(kbd "s-s") works just fine for me. Verified in both 27.1 and 26.3.

I suspect your window manager is capturing this sequence, and Emacs never sees it at all.

What does typing C-hks-s tell you?

If Emacs doesn't register the s-s, then I think you'll find that never actually reached Emacs, and you should start looking at your window manager's keybindings.

1
  • Typing C-h k s-s shows nothing. I'll check the window manager.
    – user4035
    Sep 4, 2020 at 7:07
2

Did you try just (kbd "s-s")? Does that not work? (I don't have a Super key, so I can't check.)

There should be no problem with the two s occurrences meaning different things. As a modifier, s- is realized by the Super key.

But it's a good question, considering that you can also define plain s as a prefix key, in which case, for example, you could have the key sequence s s, which would be the prefix key s followed by s (same key). That's different from s-s, however.


UPDATE

The Emacs manual Glossary says this about a Super key:

Super is the name of a modifier bit that a keyboard input character may have. To make a character Super, type it while holding down the <SUPER> key. Such characters are given names that start with Super- (usually written s- for short). See Modifier Keys.

So maybe try (kbd "Super-s"). Or even (I doubt it) (kbd "<SUPER>-s").

And the Elisp manual, node Other Char Bits says:

The X Window System defines three other modifier bits that can be set in a character: “hyper”, “super” and “alt”. The syntaxes for these bits are \H-, \s- and \A-. (Case is significant in these prefixes.) Thus, ?\H-\M-\A-x represents Alt-Hyper-Meta-x. (Note that \s with no following - represents the space character.) Numerically, the bit values are 222 for alt, 223 for super and 2**24 for hyper.

So maybe try [?\s-s]? E.g. (global-set-key [?\s-s] 'forward-word)

5
  • "Did you try just (kbd "s-s")? Does that not work?" - I tried, it doesn't work.
    – user4035
    Sep 3, 2020 at 19:38
  • Odd, seems that it's impossible to create a keybinding: "Super - s".
    – user4035
    Sep 3, 2020 at 19:49
  • 1
    What key is supposed to be the Super key? It may be that the key is hijacked be the DE so emacs never sees it. That's what happens in Gnome e.g. where the Windoze key is supposed to be the Super key, but is used by the DE for various tasks.
    – NickD
    Sep 3, 2020 at 20:16
  • @NickD: No idea. Haven't used a Lisp machine in a long time... ;-)
    – Drew
    Sep 4, 2020 at 1:08
  • (global-set-key [?\s-s] 'forward-word) - doesn't work. Seems, that Super-s combo is being captured by KDE.
    – user4035
    Sep 15, 2020 at 7:28
1

Here is one way to do it -- I'm using a generic example because I don't have any prior experience playing with the function jump-to-register:

(define-key global-map [?\s-s] (lambda () (interactive) (message "hello-world")))
4
  • It sounds strange, but it doesn't work. Maybe, it's a limitation of Emacs?
    – user4035
    Sep 3, 2020 at 19:40
  • I can assure you that the code in the answer above works 100% in GUI versions of Emacs, built --with-ns, using either Emacs 25, Emacs 26, or Emacs 27 on an Apple/Mac computer. I just tested it on all three (3) of the above-mentioned public releases -- testing without any user-configuration, aka emacs -Q
    – lawlist
    Sep 3, 2020 at 19:51
  • My Emacs is this: GNU Emacs 26.3 (build 1, i586-slackware-linux-gnu, GTK+ Version 3.18.9) of 2019-08-29. Seems ok. Launched emacs -Q, tried your code, but it still doesn't work: no message in the minibuffer.
    – user4035
    Sep 3, 2020 at 20:04
  • Ah ... Please add that information to your question by editing the question so that everyone knows you're running on a Linux machine and the Emacs version information, etc.
    – lawlist
    Sep 3, 2020 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.