D.2 Key Binding Conventions
Many special major modes, like Dired, Info, Compilation, and Occur, are designed to handle read-only text that contains hyper-links. Such a major mode should redefine
mouse-2andRETto follow the links. It should also set up afollow-linkcondition, so that the link obeysmouse-1-click-follows-link. See Clickable Text. See Buttons, for an easy method of implementing such clickable links.Don’t define
C-c letteras a key in Lisp programs. Sequences consisting ofC-cand a letter (either upper or lower case) are reserved for users; they are the only sequences reserved for users, so do not block them.Changing all the Emacs major modes to respect this convention was a lot of work; abandoning this convention would make that work go to waste, and inconvenience users. Please comply with it.
Function keys
F5throughF9without modifier keys are also reserved for users to define.Sequences consisting of
C-cfollowed by a control character or a digit are reserved for major modes.Sequences consisting of
C-cfollowed by{,},<,>,:or;are also reserved for major modes.Sequences consisting of
C-cfollowed by any other ASCII punctuation or symbol character are allocated for minor modes. Using them in a major mode is not absolutely prohibited, but if you do that, the major mode binding may be shadowed from time to time by minor modes.Don’t bind
C-hfollowing any prefix character (includingC-c). If you don’t bindC-h, it is automatically available as a help character for listing the subcommands of the prefix character.Don’t bind a key sequence ending in
ESCexcept following anotherESC. (That is, it is OK to bind a sequence ending inESC ESC.)The reason for this rule is that a non-prefix binding for
ESCin any context prevents recognition of escape sequences as function keys in that context.Similarly, don’t bind a key sequence ending in
C-g, since that is commonly used to cancel a key sequence.Anything that acts like a temporary mode or state that the user can enter and leave should define
ESC ESCorESC ESC ESCas a way to escape.For a state that accepts ordinary Emacs commands, or more generally any kind of state in which
ESCfollowed by a function key or arrow key is potentially meaningful, then you must not defineESC ESC, since that would preclude recognizing an escape sequence afterESC. In these states, you should defineESC ESC ESCas the way to escape. Otherwise, defineESC ESCinstead.