summaryrefslogtreecommitdiff
path: root/devdocs/elisp/modifying-menus.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/modifying-menus.html
new repository
Diffstat (limited to 'devdocs/elisp/modifying-menus.html')
-rw-r--r--devdocs/elisp/modifying-menus.html15
1 files changed, 15 insertions, 0 deletions
diff --git a/devdocs/elisp/modifying-menus.html b/devdocs/elisp/modifying-menus.html
new file mode 100644
index 00000000..7c9c4cd7
--- /dev/null
+++ b/devdocs/elisp/modifying-menus.html
@@ -0,0 +1,15 @@
+ <h4 class="subsection">Modifying Menus</h4> <p>When you insert a new item in an existing menu, you probably want to put it in a particular place among the menu’s existing items. If you use <code>define-key</code> to add the item, it normally goes at the front of the menu. To put it elsewhere in the menu, use <code>define-key-after</code>: </p> <dl> <dt id="define-key-after">Function: <strong>define-key-after</strong> <em>map key binding &amp;optional after</em>
+</dt> <dd>
+<p>Define a binding in <var>map</var> for <var>key</var>, with value <var>binding</var>, just like <code>define-key</code>, but position the binding in <var>map</var> after the binding for the event <var>after</var>. The argument <var>key</var> should be of length one—a vector or string with just one element. But <var>after</var> should be a single event type—a symbol or a character, not a sequence. The new binding goes after the binding for <var>after</var>. If <var>after</var> is <code>t</code> or is omitted, then the new binding goes last, at the end of the keymap. However, new bindings are added before any inherited keymap. </p> <p>Here is an example: </p> <div class="example"> <pre class="example">(define-key-after my-menu [drink]
+ '("Drink" . drink-command) 'eat)
+</pre>
+</div> <p>makes a binding for the fake function key <tt class="key">DRINK</tt> and puts it right after the binding for <tt class="key">EAT</tt>. </p> <p>Here is how to insert an item called ‘<samp>Work</samp>’ in the ‘<samp>Signals</samp>’ menu of Shell mode, after the item <code>break</code>: </p> <div class="example"> <pre class="example">(define-key-after shell-mode-map [menu-bar signals work]
+ '("Work" . work-command) 'break)
+</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/Modifying-Menus.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Modifying-Menus.html</a>
+ </p>
+</div>