Xah Lee on Defining Super and Hyper Keys

If, like me, you are always writing little pieces of Elisp to do some task or another or if you have a lot of ELPA packages installed, chances are it's hard to find key sequences for them. In theory, 【Ctrl+c】 is reserved for just this purpose but in practice rather than being reserved for users it gets used by almost every package. Even my beloved Org mode is guilty of this. 1 On the other hand, what choice do they have? There just aren't enough key sequences based on the 【Ctrl】 and 【Meta】 keys.

Emacs, of course, can also make use of the 【Super】 and 【Hyper】 keys but modern keyboards no longer have these keys. All is not lost, though, because you can map some otherwise unused key to 【Hyper】 or 【Super】. Xah Lee has a useful post on defining hyper and super keys for Windows, OS X, and Linux. One trick that he misses for OS X is using the 【fn】 key for this. That's something I learned from Magnar Sveen. I wrote about that here (don't worry, you can still control music and the other special functions).

I have mapped several key sequence that begin with 【Hyper】. You almost never trip over a predefined sequence and even if you do that command invariably has some other key sequence assigned to it too. Take a look at Lee's post and experience the joy of a whole new key sequence space.

Update: Corrected my misinterpretation of the reserved key rules. See the comments for further information.

Footnotes:

1 My understanding of the reserved key rules was faulty. In the comments, Phil points out that only 【Ctrl+c】 and a letter are reserved for users. Control characters and numbers are not reserved.

This entry was posted in General and tagged . Bookmark the permalink.
  • Thanks! add the info to my site with link back now.

  • Phil

    Super and hyper keys are, of course, awesome.

    Do note that C-c is only reserved for users when followed by a letter. Sometimes libraries do violate the convention, but those can be reported as bugs to the author (and with org-mode being core Emacs nowadays, I'm almost positive that it is not one of those libraries).

    Other uses of the C-c prefix are reserved for major modes or minor modes. Details are in the manual:

    C-h i g (elisp) Key Binding Conventions RET

    • jcs

      Thanks for setting me straight on this. I've corrected the body of the post.

  • davf

    How can I make my left ctrl key on my mac laptop the super key? I have caps lock as ctrl and fn key as hyper, which work great for me.

    • jcs

      (setq mac-control-modifier 'super)

      If you want to set the right control to something else, use mac-right-control-modifier.

  • Derek Upham

    Assuming that you have C-z still bound to suspend-frame, turn it into a new keymap and bind C-z C-z to run suspend-frame. You end up with a vast keyspace for you to play with. For example, I bind C-z C-x, C-z C-c, and C-z C-v to clipboard cut, copy, and paste.