diff options
| author | Chong Yidong | 2012-10-24 11:48:50 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-10-24 11:48:50 +0800 |
| commit | 75e8f9d2decbbebf7ffc20d17ff8676077071255 (patch) | |
| tree | 7f70f1b78780777c9417a4498be0892402599272 /lisp | |
| parent | 5c78877693213f57d4d0a079fd9554c46eb35c6f (diff) | |
| download | emacs-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/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/easymenu.el | 147 |
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 @@ | |||
| 1 | 2012-10-24 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * emacs-lisp/easymenu.el (easy-menu-define): Doc fix (Bug#12628). | ||
| 4 | |||
| 1 | 2012-10-24 Stefan Monnier <monnier@iro.umontreal.ca> | 5 | 2012-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. |
| 48 | If SYMBOL is non-nil, define SYMBOL as a function to pop up the | ||
| 49 | submenu defined by MENU, with DOC as its doc string. | ||
| 48 | 50 | ||
| 49 | If SYMBOL is non-nil, store the menu keymap in the value of SYMBOL, | 51 | MAPS, if non-nil, should be a keymap or a list of keymaps; add |
| 50 | and define SYMBOL as a function to pop up the menu, with DOC as its doc string. | 52 | the submenu defined by MENU to the keymap or each of the keymaps, |
| 51 | If SYMBOL is nil, just store the menu keymap into MAPS. | 53 | as a top-level menu bar item. |
| 52 | 54 | ||
| 53 | The first element of MENU must be a string. It is the menu bar item name. | 55 | The first element of MENU must be a string. It is the menu bar |
| 54 | It may be followed by the following keyword argument pairs | 56 | item name. It may be followed by the following keyword argument |
| 57 | pairs: | ||
| 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 | ||
| 58 | FUNCTION is a function with one argument, the rest of menu items. | 64 | :visible INCLUDE |
| 59 | It 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 | ||
| 63 | INCLUDE is an expression; this menu is only visible if this | 74 | The rest of the elements in MENU are menu items. |
| 64 | expression has a non-nil value. `:included' is an alias for `:visible'. | 75 | A menu item can be a vector of three elements: |
| 65 | 76 | ||
| 66 | :active ENABLE | 77 | [NAME CALLBACK ENABLE] |
| 67 | |||
| 68 | ENABLE is an expression; the menu is enabled for selection whenever | ||
| 69 | this expression's value is non-nil. `:enable' is an alias for `:active'. | ||
| 70 | |||
| 71 | The rest of the elements in MENU, are menu items. | ||
| 72 | |||
| 73 | A menu item is usually a vector of three elements: [NAME CALLBACK ENABLE] | ||
| 74 | 78 | ||
| 75 | NAME is a string--the menu item name. | 79 | NAME is a string--the menu item name. |
| 76 | 80 | ||
| 77 | CALLBACK is a command to run when the item is chosen, | 81 | CALLBACK is a command to run when the item is chosen, or an |
| 78 | or a list to evaluate when the item is chosen. | 82 | expression to evaluate when the item is chosen. |
| 79 | 83 | ||
| 80 | ENABLE is an expression; the item is enabled for selection | 84 | ENABLE is an expression; the item is enabled for selection if the |
| 81 | whenever this expression's value is non-nil. | 85 | expression evaluates to a non-nil value. |
| 82 | 86 | ||
| 83 | Alternatively, a menu item may have the form: | 87 | Alternatively, a menu item may have the form: |
| 84 | 88 | ||
| 85 | [ NAME CALLBACK [ KEYWORD ARG ] ... ] | 89 | [ NAME CALLBACK [ KEYWORD ARG ]... ] |
| 86 | |||
| 87 | Where KEYWORD is one of the symbols defined below. | ||
| 88 | |||
| 89 | :keys KEYS | ||
| 90 | |||
| 91 | KEYS is a string; a complex keyboard equivalent to this menu item. | ||
| 92 | This is normally not needed because keyboard equivalents are usually | ||
| 93 | computed automatically. | ||
| 94 | KEYS is expanded with `substitute-command-keys' before it is used. | ||
| 95 | |||
| 96 | :key-sequence KEYS | ||
| 97 | |||
| 98 | KEYS is nil, a string or a vector; nil or a keyboard equivalent to this | ||
| 99 | menu item. | ||
| 100 | This is a hint that will considerably speed up Emacs's first display of | ||
| 101 | a menu. Use `:key-sequence nil' when you know that this menu item has no | ||
| 102 | keyboard equivalent. | ||
| 103 | |||
| 104 | :active ENABLE | ||
| 105 | |||
| 106 | ENABLE is an expression; the item is enabled for selection whenever | ||
| 107 | this expression's value is non-nil. `:enable' is an alias for `:active'. | ||
| 108 | |||
| 109 | :visible INCLUDE | ||
| 110 | |||
| 111 | INCLUDE is an expression; this item is only visible if this | ||
| 112 | expression has a non-nil value. `:included' is an alias for `:visible'. | ||
| 113 | |||
| 114 | :label FORM | ||
| 115 | 90 | ||
| 116 | FORM is an expression that will be dynamically evaluated and whose | 91 | where NAME and CALLBACK have the same meanings as above, and each |
| 117 | value will be used for the menu entry's text label (the default is NAME). | 92 | optional 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 | ||
| 121 | FORM is an expression that will be dynamically evaluated and whose | 100 | :key-sequence KEYS |
| 122 | value 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 | ||
| 126 | STYLE is a symbol describing the type of menu item. The following are | 111 | :visible INCLUDE |
| 127 | defined: | 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 | ||
| 129 | toggle: 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 |
| 131 | radio: 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. | ||
| 133 | button: Surround the name with `[' and `]'. Use this for an item in the | ||
| 134 | menu bar itself. | ||
| 135 | anything 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 | ||
| 139 | SELECTED is an expression; the checkbox or radio button is selected | 124 | :style STYLE |
| 140 | whenever 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 | ||
| 144 | HELP 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 | ||
| 146 | A menu item can be a string. Then that string appears in the menu as | 136 | Alternatively, a menu item can be a string. Then that string |
| 147 | unselectable text. A string consisting solely of hyphens is displayed | 137 | appears in the menu as unselectable text. A string consisting |
| 148 | as a solid horizontal line. | 138 | solely of dashes is displayed as a menu separator. |
| 149 | 139 | ||
| 150 | A menu item can be a list with the same format as MENU. This is a submenu." | 140 | Alternatively, a menu item can be a list with the same format as |
| 141 | MENU. 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)) |