summaryrefslogtreecommitdiff
path: root/devdocs/elisp/alias-menu-items.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/alias-menu-items.html
new repository
Diffstat (limited to 'devdocs/elisp/alias-menu-items.html')
-rw-r--r--devdocs/elisp/alias-menu-items.html14
1 files changed, 14 insertions, 0 deletions
diff --git a/devdocs/elisp/alias-menu-items.html b/devdocs/elisp/alias-menu-items.html
new file mode 100644
index 00000000..30c0020f
--- /dev/null
+++ b/devdocs/elisp/alias-menu-items.html
@@ -0,0 +1,14 @@
+ <h4 class="subsubsection">Alias Menu Items</h4> <p>Sometimes it is useful to make menu items that use the same command but with different enable conditions. The best way to do this in Emacs now is with extended menu items; before that feature existed, it could be done by defining alias commands and using them in menu items. Here’s an example that makes two aliases for <code>read-only-mode</code> and gives them different enable conditions: </p> <div class="example"> <pre class="example">(defalias 'make-read-only 'read-only-mode)
+(put 'make-read-only 'menu-enable '(not buffer-read-only))
+(defalias 'make-writable 'read-only-mode)
+(put 'make-writable 'menu-enable 'buffer-read-only)
+</pre>
+</div> <p>When using aliases in menus, often it is useful to display the equivalent key bindings for the real command name, not the aliases (which typically don’t have any key bindings except for the menu itself). To request this, give the alias symbol a non-<code>nil</code> <code>menu-alias</code> property. Thus, </p> <div class="example"> <pre class="example">(put 'make-read-only 'menu-alias t)
+(put 'make-writable 'menu-alias t)
+</pre>
+</div> <p>causes menu items for <code>make-read-only</code> and <code>make-writable</code> to show the keyboard bindings for <code>read-only-mode</code>. </p><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/Alias-Menu-Items.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Alias-Menu-Items.html</a>
+ </p>
+</div>