aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong2012-10-24 11:48:50 +0800
committerChong Yidong2012-10-24 11:48:50 +0800
commit75e8f9d2decbbebf7ffc20d17ff8676077071255 (patch)
tree7f70f1b78780777c9417a4498be0892402599272 /lisp
parent5c78877693213f57d4d0a079fd9554c46eb35c6f (diff)
downloademacs-75e8f9d2decbbebf7ffc20d17ff8676077071255.tar.gz
emacs-75e8f9d2decbbebf7ffc20d17ff8676077071255.zip
Improve documentation of easy-menu-define.
* lisp/emacs-lisp/easymenu.el (easy-menu-define): Doc fix. * doc/lispref/keymaps.texi (Toolkit Differences): Node deleted. (Easy Menu): New node. Fixes: debbugs:12628
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/emacs-lisp/easymenu.el147
2 files changed, 73 insertions, 78 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c84d0110fc7..5b709c76c74 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12012-10-24 Chong Yidong <cyd@gnu.org>
2
3 * emacs-lisp/easymenu.el (easy-menu-define): Doc fix (Bug#12628).
4
12012-10-24 Stefan Monnier <monnier@iro.umontreal.ca> 52012-10-24 Stefan Monnier <monnier@iro.umontreal.ca>
2 6
3 * minibuffer.el (completion--all-sorted-completions-location): New var. 7 * minibuffer.el (completion--all-sorted-completions-location): New var.
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index 939fab78942..26a1fce2309 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -44,110 +44,101 @@ menus, turn this variable off, otherwise it is probably better to keep it on.")
44 44
45;;;###autoload 45;;;###autoload
46(defmacro easy-menu-define (symbol maps doc menu) 46(defmacro easy-menu-define (symbol maps doc menu)
47 "Define a menu bar submenu in maps MAPS, according to MENU. 47 "Define a pop-up menu and/or menu bar menu specified by MENU.
48If SYMBOL is non-nil, define SYMBOL as a function to pop up the
49submenu defined by MENU, with DOC as its doc string.
48 50
49If SYMBOL is non-nil, store the menu keymap in the value of SYMBOL, 51MAPS, if non-nil, should be a keymap or a list of keymaps; add
50and define SYMBOL as a function to pop up the menu, with DOC as its doc string. 52the submenu defined by MENU to the keymap or each of the keymaps,
51If SYMBOL is nil, just store the menu keymap into MAPS. 53as a top-level menu bar item.
52 54
53The first element of MENU must be a string. It is the menu bar item name. 55The first element of MENU must be a string. It is the menu bar
54It may be followed by the following keyword argument pairs 56item name. It may be followed by the following keyword argument
57pairs:
55 58
56 :filter FUNCTION 59 :filter FUNCTION
60 FUNCTION must be a function which, if called with one
61 argument---the list of the other menu items---returns the
62 items to actually display.
57 63
58FUNCTION is a function with one argument, the rest of menu items. 64 :visible INCLUDE
59It returns the remaining items of the displayed menu. 65 INCLUDE is an expression. The menu is visible if the
66 expression evaluates to a non-nil value. `:included' is an
67 alias for `:visible'.
60 68
61 :visible INCLUDE 69 :active ENABLE
70 ENABLE is an expression. The menu is enabled for selection
71 if the expression evaluates to a non-nil value. `:enable' is
72 an alias for `:active'.
62 73
63INCLUDE is an expression; this menu is only visible if this 74The rest of the elements in MENU are menu items.
64expression has a non-nil value. `:included' is an alias for `:visible'. 75A menu item can be a vector of three elements:
65 76
66 :active ENABLE 77 [NAME CALLBACK ENABLE]
67
68ENABLE is an expression; the menu is enabled for selection whenever
69this expression's value is non-nil. `:enable' is an alias for `:active'.
70
71The rest of the elements in MENU, are menu items.
72
73A menu item is usually a vector of three elements: [NAME CALLBACK ENABLE]
74 78
75NAME is a string--the menu item name. 79NAME is a string--the menu item name.
76 80
77CALLBACK is a command to run when the item is chosen, 81CALLBACK is a command to run when the item is chosen, or an
78or a list to evaluate when the item is chosen. 82expression to evaluate when the item is chosen.
79 83
80ENABLE is an expression; the item is enabled for selection 84ENABLE is an expression; the item is enabled for selection if the
81whenever this expression's value is non-nil. 85expression evaluates to a non-nil value.
82 86
83Alternatively, a menu item may have the form: 87Alternatively, a menu item may have the form:
84 88
85 [ NAME CALLBACK [ KEYWORD ARG ] ... ] 89 [ NAME CALLBACK [ KEYWORD ARG ]... ]
86
87Where KEYWORD is one of the symbols defined below.
88
89 :keys KEYS
90
91KEYS is a string; a complex keyboard equivalent to this menu item.
92This is normally not needed because keyboard equivalents are usually
93computed automatically.
94KEYS is expanded with `substitute-command-keys' before it is used.
95
96 :key-sequence KEYS
97
98KEYS is nil, a string or a vector; nil or a keyboard equivalent to this
99menu item.
100This is a hint that will considerably speed up Emacs's first display of
101a menu. Use `:key-sequence nil' when you know that this menu item has no
102keyboard equivalent.
103
104 :active ENABLE
105
106ENABLE is an expression; the item is enabled for selection whenever
107this expression's value is non-nil. `:enable' is an alias for `:active'.
108
109 :visible INCLUDE
110
111INCLUDE is an expression; this item is only visible if this
112expression has a non-nil value. `:included' is an alias for `:visible'.
113
114 :label FORM
115 90
116FORM is an expression that will be dynamically evaluated and whose 91where NAME and CALLBACK have the same meanings as above, and each
117value will be used for the menu entry's text label (the default is NAME). 92optional KEYWORD and ARG pair should be one of the following:
118 93
119 :suffix FORM 94 :keys KEYS
95 KEYS is a string; a keyboard equivalent to the menu item.
96 This is normally not needed because keyboard equivalents are
97 usually computed automatically. KEYS is expanded with
98 `substitute-command-keys' before it is used.
120 99
121FORM is an expression that will be dynamically evaluated and whose 100 :key-sequence KEYS
122value will be concatenated to the menu entry's label. 101 KEYS is a hint for speeding up Emacs's first display of the
102 menu. It should be nil if you know that the menu item has no
103 keyboard equivalent; otherwise it should be a string or
104 vector specifying a keyboard equivalent for the menu item.
123 105
124 :style STYLE 106 :active ENABLE
107 ENABLE is an expression; the item is enabled for selection
108 whenever this expression's value is non-nil. `:enable' is an
109 alias for `:active'.
125 110
126STYLE is a symbol describing the type of menu item. The following are 111 :visible INCLUDE
127defined: 112 INCLUDE is an expression; this item is only visible if this
113 expression has a non-nil value. `:included' is an alias for
114 `:visible'.
128 115
129toggle: A checkbox. 116 :label FORM
130 Prepend the name with `(*) ' or `( ) ' depending on if selected or not. 117 FORM is an expression that is dynamically evaluated and whose
131radio: A radio button. 118 value serves as the menu item's label (the default is NAME).
132 Prepend the name with `[X] ' or `[ ] ' depending on if selected or not.
133button: Surround the name with `[' and `]'. Use this for an item in the
134 menu bar itself.
135anything else means an ordinary menu item.
136 119
137 :selected SELECTED 120 :suffix FORM
121 FORM is an expression that is dynamically evaluated and whose
122 value is concatenated with the menu entry's label.
138 123
139SELECTED is an expression; the checkbox or radio button is selected 124 :style STYLE
140whenever this expression's value is non-nil. 125 STYLE is a symbol describing the type of menu item; it should
126 be `toggle' (a checkbox), or `radio' (a radio button), or any
127 other value (meaning an ordinary menu item).
141 128
142 :help HELP 129 :selected SELECTED
130 SELECTED is an expression; the checkbox or radio button is
131 selected whenever the expression's value is non-nil.
143 132
144HELP is a string, the help to display for the menu item. 133 :help HELP
134 HELP is a string, the help to display for the menu item.
145 135
146A menu item can be a string. Then that string appears in the menu as 136Alternatively, a menu item can be a string. Then that string
147unselectable text. A string consisting solely of hyphens is displayed 137appears in the menu as unselectable text. A string consisting
148as a solid horizontal line. 138solely of dashes is displayed as a menu separator.
149 139
150A menu item can be a list with the same format as MENU. This is a submenu." 140Alternatively, a menu item can be a list with the same format as
141MENU. This is a submenu."
151 (declare (indent defun) (debug (symbolp body))) 142 (declare (indent defun) (debug (symbolp body)))
152 `(progn 143 `(progn
153 ,(if symbol `(defvar ,symbol nil ,doc)) 144 ,(if symbol `(defvar ,symbol nil ,doc))