Contents
When to add a new binding to a key?
If some prefix of key is undefined, then define-key defines it as a prefix key so that the rest of key can be defined as specified. If there was previously no binding for key in keymap, the new binding is added at the beginning of keymap.
What does a prefix key do in a keymap?
A prefix key is a key sequence whose binding is a keymap. The keymap defines what to do with key sequences that extend the prefix key.
When to use default key binding in Emacs?
When an event has no binding of its own, the Emacs command loop uses the keymap’s default binding, if there is one. Every prefix of key must be a prefix key (i.e., bound to a keymap) or undefined; otherwise an error is signaled.
What to do if key is not in keymap?
The functions below signal an error if keymap is not a keymap, or if key is not a string or vector representing a key sequence. You can use event types (symbols) as shorthand for events that are lists. The kbd function (see Key Sequences) is a convenient way to specify the key sequence. This function sets the binding for key in keymap.
Is there a way to rebind a key in GNU?
The way to rebind a key is to change its entry in a keymap. If you change a binding in the global keymap, the change is effective in all buffers (though it has no direct effect in buffers that shadow the global binding with a local one). If you change the current buffer’s local map, that usually affects all buffers using the same major mode.
When does a prefix key need to be defined?
Every prefix of key must be a prefix key (i.e., bound to a keymap) or undefined; otherwise an error is signaled. If some prefix of key is undefined, then define-key defines it as a prefix key so that the rest of key can be defined as specified.
How to create new instance of keybinding class?
Initializes a new instance of the KeyBinding class. Initializes a new instance of the KeyBinding class using the specified ICommand and the specified Key and ModifierKeys which will be converted into a KeyGesture. Initializes a new instance of the KeyBinding class using the specified ICommand and KeyGesture.
What happens if the bindings in oldmap are non nil?
If oldmap is non- nil, that changes the behavior of substitute-key-definition: the bindings in oldmap determine which keys to rebind. The rebindings still happen in keymap, not in oldmap. Thus, you can change one map under the control of the bindings in another.
What’s the difference between define-key and bind-key?
Binds a key to the local keymap used by the active buffer, unlike define-key which takes an explicit keymap to bind a key against. Binds a key to the global keymap, making it available in all buffers (with a caveat – see below.)