tl;dr
Your best option would be to find a way to bind CapsLock directly to Super at the Operating System level. Assuming that is not possible, you can create a "sticky" super modifier key that will allow you to use keybindings requiring a super modifier. As an example, try C-x @ s
followed by some other key.
What you are trying to do is more difficult than you might expect. The reason is that Emacs most likely does not even see the modifier keys until they have actually modified a key. In other words, you can't bind a raw Ctrl to anything in Emacs, because the OS does not even notify Emacs that Ctrl has been pressed.
To understand part of the reason for this, look at the difference between pressing z and pressing Ctrl+z. The first one sends the ascii code 122, while the second one sends ascii code 26. Note that it does not send two codes in the second case, rather the Ctrl key modified what was sent when pressing z.
One potential workaround to your problem is to create a "sticky" modifier key. This will work much like the ESC
key does now. If you press ESC followed by z, Emacs will interpret it as M-z
. The code below turns C-]
into a "sticky" super key, so that pressing Ctrl+] followed by z will be interpreted as s-z
(also known as Super+z):
;; Turn `C-]' into a sticky "super" modifier.
(define-key local-function-key-map [?\C-\]] 'event-apply-super-modifier)
;; Move the global binding for C-] to C-s-]
(define-key global-map [?\C-\s-\]] (lookup-key global-map [?\C-\]] t))
(define-key global-map [?\C-\]] nil)
(It turns out that such a binding to event-apply-super-modifier
already exists using C-x @ s
. You can try that out to get a feel for how a sticky super modifier might behave.)
Finally, you could make CapsLock work as a sticky "super" key by defining it at the Operating System level (with Seil and Karabiner in your case), to something that is available for binding by Emacs. For example, <pause>
or <Scroll_Lock>
C-M-s
? In traditional emacs key notationC-M-s
actually meansCtrl+Alt+s
, but I suspect that you are seeing something different.C-M-s-x
for example would meanCtrl+Alt+Super+x
. Did you do something like that, and then strip off the final-x
?