7

I run emacs in two ways: One as a Mac OS X executable, built from source, and the other as a Linux executable using the Lucid toolkit, in daemon mode, connected to using a graphical emacscient using XQuartz on my mac laptop.

My base configuration is currently Emacs Prelude, and it defines a set of key chords that use a Super key, in addition to some Meta and Ctrl chords. However, I cannot figure out how to send a Super chord at all. This is true both on my OSX build and on my emacsclient/XQuartz setup. Command sends Meta, Option just sends literal keys (in the OSX way, it emits a subset of the extended Unicode space) and obviously Shift and Ctrl do their usual thing.

So, how do I send super-prefixed key chords to my Emacs?

3 Answers 3

5

You might want to have a look at the various ns-*-modifier, like ns-alternate-modifier (for Option) or ns-command-modifier (for Command). They allow to map the native OSX keys to arbitrary modifiers. Note that there exists a ns-function-modifier which is quite handy for laptops.

That should solve the native OSX Emacs part.

As for XQuartz, without testing at all, I would assume that you might get away with some xmodmap invocation, along the line of xmodmap -e 'add Mod2 = Super_L Super_R'

5

You can apply a super modifier with C-x @ s. So to type Super+z, you woule press C-x @ s z. If you find the C-x @ s combo too cumbersome, then you can bind it to something easier to type. Here is an example of binding it to C-]:

;; 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)

Since C-] is most likely already bound to something (abort-recursive-edit by default), I also move whatever is bound to C-] in the global map to C-s-]. You can then invoke abort-recursive-edit when needed by typing C-] twice.

1

After a bit of digging, I located this page by Xah Lee.

The cause of your problem is that your keyboard settings in OSX are not set for any key to send Super. In order to send Super, you need to change that. The document linked above has directions for doing so.

1
  • Please include a summary of what to do, as such a link may break. Oct 13, 2019 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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