summaryrefslogtreecommitdiff
path: root/devdocs/elisp/active-keymaps.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/active-keymaps.html')
-rw-r--r--devdocs/elisp/active-keymaps.html14
1 files changed, 14 insertions, 0 deletions
diff --git a/devdocs/elisp/active-keymaps.html b/devdocs/elisp/active-keymaps.html
new file mode 100644
index 00000000..f1eebcb5
--- /dev/null
+++ b/devdocs/elisp/active-keymaps.html
@@ -0,0 +1,14 @@
+ <h3 class="section">Active Keymaps</h3> <p>Emacs contains many keymaps, but at any time only a few keymaps are <em>active</em>. When Emacs receives user input, it translates the input event (see <a href="translation-keymaps">Translation Keymaps</a>), and looks for a key binding in the active keymaps. </p> <p>Usually, the active keymaps are: (i) the keymap specified by the <code>keymap</code> property, (ii) the keymaps of enabled minor modes, (iii) the current buffer’s local keymap, and (iv) the global keymap, in that order. Emacs searches for each input key sequence in all these keymaps. </p> <p>Of these usual keymaps, the highest-precedence one is specified by the <code>keymap</code> text or overlay property at point, if any. (For a mouse input event, Emacs uses the event position instead of point; see <a href="searching-keymaps">Searching Keymaps</a>.) </p> <p>Next in precedence are keymaps specified by enabled minor modes. These keymaps, if any, are specified by the variables <code>emulation-mode-map-alists</code>, <code>minor-mode-overriding-map-alist</code>, and <code>minor-mode-map-alist</code>. See <a href="controlling-active-maps">Controlling Active Maps</a>. </p> <p>Next in precedence is the buffer’s <em>local keymap</em>, containing key bindings specific to the buffer. The minibuffer also has a local keymap (see <a href="intro-to-minibuffers">Intro to Minibuffers</a>). If there is a <code>local-map</code> text or overlay property at point, that specifies the local keymap to use, in place of the buffer’s default local keymap. </p> <p>The local keymap is normally set by the buffer’s major mode, and every buffer with the same major mode shares the same local keymap. Hence, if you call <code>local-set-key</code> (see <a href="key-binding-commands">Key Binding Commands</a>) to change the local keymap in one buffer, that also affects the local keymaps in other buffers with the same major mode. </p> <p>Finally, the <em>global keymap</em> contains key bindings that are defined regardless of the current buffer, such as <kbd>C-f</kbd>. It is always active, and is bound to the variable <code>global-map</code>. </p> <p>Apart from the above usual keymaps, Emacs provides special ways for programs to make other keymaps active. Firstly, the variable <code>overriding-local-map</code> specifies a keymap that replaces the usual active keymaps, except for the global keymap. Secondly, the terminal-local variable <code>overriding-terminal-local-map</code> specifies a keymap that takes precedence over <em>all</em> other keymaps (including <code>overriding-local-map</code>); this is normally used for modal/transient keybindings (the function <code>set-transient-map</code> provides a convenient interface for this). See <a href="controlling-active-maps">Controlling Active Maps</a>, for details. </p> <p>Making keymaps active is not the only way to use them. Keymaps are also used in other ways, such as for translating events within <code>read-key-sequence</code>. See <a href="translation-keymaps">Translation Keymaps</a>. </p> <p>See <a href="standard-keymaps">Standard Keymaps</a>, for a list of some standard keymaps. </p> <dl> <dt id="current-active-maps">Function: <strong>current-active-maps</strong> <em>&amp;optional olp position</em>
+</dt> <dd><p>This returns the list of active keymaps that would be used by the command loop in the current circumstances to look up a key sequence. Normally it ignores <code>overriding-local-map</code> and <code>overriding-terminal-local-map</code>, but if <var>olp</var> is non-<code>nil</code> then it pays attention to them. <var>position</var> can optionally be either an event position as returned by <code>event-start</code> or a buffer position, and may change the keymaps as described for <code>key-binding</code>. </p></dd>
+</dl> <dl> <dt id="key-binding">Function: <strong>key-binding</strong> <em>key &amp;optional accept-defaults no-remap position</em>
+</dt> <dd>
+<p>This function returns the binding for <var>key</var> according to the current active keymaps. The result is <code>nil</code> if <var>key</var> is undefined in the keymaps. </p> <p>The argument <var>accept-defaults</var> controls checking for default bindings, as in <code>lookup-key</code> (see <a href="functions-for-key-lookup">Functions for Key Lookup</a>). </p> <p>When commands are remapped (see <a href="remapping-commands">Remapping Commands</a>), <code>key-binding</code> normally processes command remappings so as to return the remapped command that will actually be executed. However, if <var>no-remap</var> is non-<code>nil</code>, <code>key-binding</code> ignores remappings and returns the binding directly specified for <var>key</var>. </p> <p>If <var>key</var> starts with a mouse event (perhaps following a prefix event), the maps to be consulted are determined based on the event’s position. Otherwise, they are determined based on the value of point. However, you can override either of them by specifying <var>position</var>. If <var>position</var> is non-<code>nil</code>, it should be either a buffer position or an event position like the value of <code>event-start</code>. Then the maps consulted are determined based on <var>position</var>. </p> <p>Emacs signals an error if <var>key</var> is not a string or a vector. </p> <div class="example"> <pre class="example">(key-binding "\C-x\C-f")
+ ⇒ find-file
+</pre>
+</div> </dd>
+</dl><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Active-Keymaps.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Active-Keymaps.html</a>
+ </p>
+</div>