Search code examples
emacshotkeysemacs24

Find a good hotkey for new emacs commands


In Emacs everything is about hotkeys. Everybody who creates new shortcuts knows the problem:

  1. Which hotkeys should be used?
  2. Which hotkeys are used by the most popular Emacs extensions (org-mode...) and should be avoided?
  3. Are there reserved hotkeys for "users" that will never be used by extensions?
  4. Which hotkeys should be avoided, if the code should be public? (Some keys like right/left Win are sometimes missing on keyboards, M-TAB will be catched by the windowmanager)

Is there a list of all reserved hotkeys?


Solution

  • Sticking to the reserved C-c <letter> sequences is as close as you'll get to guaranteeing that you won't conflict with any other code (although it's still just a convention; sometimes you'll see people making code available that uses one of those sequences, but you can report those cases as bugs to the author).

    I would suggest using some of the C-c <letter> sequences as prefix bindings for grouping related functionality together. For instance, you might use C-c w <key> as the pattern for window-related functionality. That gives you a dramatically larger number of reserved bindings, probably with better mnemonic properties, and of course the subsequent <key> can be anything at all, not just a letter.

    That also lets you use C-c <letter> C-h to list everything you've bound under that prefix, which can be convenient.