1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<h3 class="section">Searching the Active Keymaps</h3> <p>Here is a pseudo-Lisp summary of how Emacs searches the active keymaps: </p> <div class="lisp"> <pre class="lisp">(or (if overriding-terminal-local-map
(<var>find-in</var> overriding-terminal-local-map))
(if overriding-local-map
(<var>find-in</var> overriding-local-map)
(or (<var>find-in</var> (get-char-property (point) 'keymap))
(<var>find-in-any</var> emulation-mode-map-alists)
(<var>find-in-any</var> minor-mode-overriding-map-alist)
(<var>find-in-any</var> minor-mode-map-alist)
(if (get-text-property (point) 'local-map)
(<var>find-in</var> (get-char-property (point) 'local-map))
(<var>find-in</var> (current-local-map)))))
(<var>find-in</var> (current-global-map)))
</pre>
</div> <p>Here, <var>find-in</var> and <var>find-in-any</var> are pseudo functions that search in one keymap and in an alist of keymaps, respectively. Note that the <code>set-transient-map</code> function works by setting <code>overriding-terminal-local-map</code> (see <a href="controlling-active-maps">Controlling Active Maps</a>). </p> <p>In the above pseudo-code, if a key sequence starts with a mouse event (see <a href="mouse-events">Mouse Events</a>), that event’s position is used instead of point, and the event’s buffer is used instead of the current buffer. In particular, this affects how the <code>keymap</code> and <code>local-map</code> properties are looked up. If a mouse event occurs on a string embedded with a <code>display</code>, <code>before-string</code>, or <code>after-string</code> property (see <a href="special-properties">Special Properties</a>), and the string has a non-<code>nil</code> <code>keymap</code> or <code>local-map</code> property, that overrides the corresponding property in the underlying buffer text (i.e., the property specified by the underlying text is ignored). </p> <p>When a key binding is found in one of the active keymaps, and that binding is a command, the search is over—the command is executed. However, if the binding is a symbol with a value or a string, Emacs replaces the input key sequences with the variable’s value or the string, and restarts the search of the active keymaps. See <a href="key-lookup">Key Lookup</a>. </p> <p>The command which is finally found might also be remapped. See <a href="remapping-commands">Remapping Commands</a>. </p><div class="_attribution">
<p class="_attribution-p">
Copyright © 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/Searching-Keymaps.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Searching-Keymaps.html</a>
</p>
</div>
|