diff options
| author | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
| commit | 82ba818ff456bcd6d56a06226e3f27e98fbb55c3 (patch) | |
| tree | 158cfc17b2f644a10f063cb546752cfaae12c97f /devdocs/elisp/inheritance-and-keymaps.html | |
| parent | 9278ddd4ea1a8b1a4c1edaa8894516e3f48d245b (diff) | |
| download | dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.tar.gz dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.zip | |
removing all downloaded devdocs files
Diffstat (limited to 'devdocs/elisp/inheritance-and-keymaps.html')
| -rw-r--r-- | devdocs/elisp/inheritance-and-keymaps.html | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/devdocs/elisp/inheritance-and-keymaps.html b/devdocs/elisp/inheritance-and-keymaps.html deleted file mode 100644 index 52141eee..00000000 --- a/devdocs/elisp/inheritance-and-keymaps.html +++ /dev/null @@ -1,26 +0,0 @@ - <h3 class="section">Inheritance and Keymaps</h3> <p>A keymap can inherit the bindings of another keymap, which we call the <em>parent keymap</em>. Such a keymap looks like this: </p> <div class="example"> <pre class="example">(keymap <var>elements</var>… . <var>parent-keymap</var>) -</pre> -</div> <p>The effect is that this keymap inherits all the bindings of <var>parent-keymap</var>, whatever they may be at the time a key is looked up, but can add to them or override them with <var>elements</var>. </p> <p>If you change the bindings in <var>parent-keymap</var> using <code>define-key</code> or other key-binding functions, these changed bindings are visible in the inheriting keymap, unless shadowed by the bindings made by <var>elements</var>. The converse is not true: if you use <code>define-key</code> to change bindings in the inheriting keymap, these changes are recorded in <var>elements</var>, but have no effect on <var>parent-keymap</var>. </p> <p>The proper way to construct a keymap with a parent is to use <code>set-keymap-parent</code>; if you have code that directly constructs a keymap with a parent, please convert the program to use <code>set-keymap-parent</code> instead. </p> <dl> <dt id="keymap-parent">Function: <strong>keymap-parent</strong> <em>keymap</em> -</dt> <dd><p>This returns the parent keymap of <var>keymap</var>. If <var>keymap</var> has no parent, <code>keymap-parent</code> returns <code>nil</code>. </p></dd> -</dl> <dl> <dt id="set-keymap-parent">Function: <strong>set-keymap-parent</strong> <em>keymap parent</em> -</dt> <dd> -<p>This sets the parent keymap of <var>keymap</var> to <var>parent</var>, and returns <var>parent</var>. If <var>parent</var> is <code>nil</code>, this function gives <var>keymap</var> no parent at all. </p> <p>If <var>keymap</var> has submaps (bindings for prefix keys), they too receive new parent keymaps that reflect what <var>parent</var> specifies for those prefix keys. </p> -</dd> -</dl> <p>Here is an example showing how to make a keymap that inherits from <code>text-mode-map</code>: </p> <div class="example"> <pre class="example">(let ((map (make-sparse-keymap))) - (set-keymap-parent map text-mode-map) - map) -</pre> -</div> <p>A non-sparse keymap can have a parent too, but this is not very useful. A non-sparse keymap always specifies something as the binding for every numeric character code without modifier bits, even if it is <code>nil</code>, so these character’s bindings are never inherited from the parent keymap. </p> <p>Sometimes you want to make a keymap that inherits from more than one map. You can use the function <code>make-composed-keymap</code> for this. </p> <dl> <dt id="make-composed-keymap">Function: <strong>make-composed-keymap</strong> <em>maps &optional parent</em> -</dt> <dd><p>This function returns a new keymap composed of the existing keymap(s) <var>maps</var>, and optionally inheriting from a parent keymap <var>parent</var>. <var>maps</var> can be a single keymap or a list of more than one. When looking up a key in the resulting new map, Emacs searches in each of the <var>maps</var> in turn, and then in <var>parent</var>, stopping at the first match. A <code>nil</code> binding in any one of <var>maps</var> overrides any binding in <var>parent</var>, but it does not override any non-<code>nil</code> binding in any other of the <var>maps</var>. </p></dd> -</dl> <p>For example, here is how Emacs sets the parent of <code>help-mode-map</code>, such that it inherits from both <code>button-buffer-map</code> and <code>special-mode-map</code>: </p> <div class="example"> <pre class="example">(defvar help-mode-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map - (make-composed-keymap button-buffer-map special-mode-map)) - ... map) ... ) -</pre> -</div><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/Inheritance-and-Keymaps.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Inheritance-and-Keymaps.html</a> - </p> -</div> |
