Adding Hyper and Super Keys for Emacs

I’ve written about this before but it was a few years ago so it’s worth repeating for new Emacs and/or Mac users. One problem with Emacs is that it’s hard to find enough shortcut keys. Having Hyper and Super keys helps a lot but, of course, modern keyboards don’t have them. Fortunately, modern keyboards do have keys that are otherwise unused in Emacs and they can be drafted as substitutes for Hyper and Super.

Xah Lee has has a page that shows how to set Hyper and Super keys for Linux, Windows, and macOS. For the Mac, he recommends setting the ⌘ Cmd key as Meta and the ⌥ Opt key as Super. That’s common advice but I’ve never understood it. Emacs already considers the ⌘ Cmd key to be Super and, at least on my Mac keyboards the ⌥ Opt key has a sublabel of Alt so it makes sense to me to use the ⌥ Opt key as Meta and the ⌘ Cmd key as Super.

That leaves the Hyper key which, following Magnar Sveen’s advice, I map onto the fn key. It seem like begging for trouble to use fn and ⌘ Cmd this way since they have important OS functions that you might want to access from within Emacs but it turns out that they still perform those functions despite the mapping. For example, fn+F8 still pauses/restarts music even when fn is mapped to Hyper.

It’s really useful to have these extra modifier keys to use with 3rd party packages or even obscure standard Emacs functions. Take a look at Lee’s page to see ways of getting them on your platform.

This entry was posted in General and tagged . Bookmark the permalink.
  • hmelman

    I also set ⌘ to Super and then bind things like ⌘-V to clipboard-yank so that my regular mac muscle memory still works in emacs. It still leaves plenty of ⌘-keys to bind. I've also made the right ⌘ be Hyper but I haven't used it much yet.

    • jcs

      I’m just the opposite. I use hyper all the time and mostly don’t bother with super.

  • Using Fn for Hyper make your config not portable. Mostly. So it is easier to avoid using it.

  • Technically Super is wide open 100% for your custom key space. In practice a lot of packages are bindings things in there because C-x c is hassle. Control and Meta don't provide enough key space. It has nearly run out forcing complicated chords that are "yucky".

  • It is convenient to pass modifiers through to macOS, or not, depending on what you are doing. Here are my helpers:

    (defun help/toggle-mac-right-option-modifier ()
    "Toggle between passing option modifier either to Emacs or OS X."
    (interactive)
    (let ((old-ropt mac-right-option-modifier))
    (setq mac-right-option-modifier
    (if (eq mac-right-option-modifier 'left)
    'none
    'left))
    (message "Toggled `mac-right-option-modifier' from %s to %s."
    old-ropt
    mac-right-option-modifier)))
    (defun help/toggle-mac-function-modifier ()
    "Toggle between passing function modifier either to Emacs or OS X."
    (interactive)
    (let ((old-func mac-function-modifier))
    (setq mac-function-modifier
    (if (eq mac-function-modifier 'hyper)
    'none
    'hyper))
    (message "Toggled `mac-function-modifier' from %s to %s."
    old-func
    mac-function-modifier)))