diff options
| -rw-r--r-- | lisp/emacs-lisp/easymenu.el | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el index 80011694296..43ff02e1b22 100644 --- a/lisp/emacs-lisp/easymenu.el +++ b/lisp/emacs-lisp/easymenu.el | |||
| @@ -49,8 +49,10 @@ menus, turn this variable off, otherwise it is probably better to keep it on." | |||
| 49 | ;;;###autoload | 49 | ;;;###autoload |
| 50 | (defmacro easy-menu-define (symbol maps doc menu) | 50 | (defmacro easy-menu-define (symbol maps doc menu) |
| 51 | "Define a menu bar submenu in maps MAPS, according to MENU. | 51 | "Define a menu bar submenu in maps MAPS, according to MENU. |
| 52 | The menu keymap is stored in symbol SYMBOL, both as its value | 52 | |
| 53 | and as its function definition. DOC is used as the doc string for SYMBOL. | 53 | If SYMBOL is non-nil, store the menu keymap in the value of SYMBOL, |
| 54 | and define SYMBOL as a function to pop up the menu, with DOC as its doc string. | ||
| 55 | If SYMBOL is nil, just store the menu keymap into MAPS. | ||
| 54 | 56 | ||
| 55 | The first element of MENU must be a string. It is the menu bar item name. | 57 | The first element of MENU must be a string. It is the menu bar item name. |
| 56 | It may be followed by the following keyword argument pairs | 58 | It may be followed by the following keyword argument pairs |
| @@ -156,19 +158,20 @@ A menu item can be a list with the same format as MENU. This is a submenu." | |||
| 156 | ;; compatible. Therefore everything interesting is done in this | 158 | ;; compatible. Therefore everything interesting is done in this |
| 157 | ;; function. | 159 | ;; function. |
| 158 | (let ((keymap (easy-menu-create-menu (car menu) (cdr menu)))) | 160 | (let ((keymap (easy-menu-create-menu (car menu) (cdr menu)))) |
| 159 | (set symbol keymap) | 161 | (when symbol |
| 160 | (fset symbol | 162 | (set symbol keymap) |
| 161 | `(lambda (event) ,doc (interactive "@e") | 163 | (fset symbol |
| 162 | ;; FIXME: XEmacs uses popup-menu which calls the binding | 164 | `(lambda (event) ,doc (interactive "@e") |
| 163 | ;; while x-popup-menu only returns the selection. | 165 | ;; FIXME: XEmacs uses popup-menu which calls the binding |
| 164 | (x-popup-menu event | 166 | ;; while x-popup-menu only returns the selection. |
| 165 | (or (and (symbolp ,symbol) | 167 | (x-popup-menu event |
| 166 | (funcall | 168 | (or (and (symbolp ,symbol) |
| 167 | (or (plist-get (get ,symbol 'menu-prop) | 169 | (funcall |
| 168 | :filter) | 170 | (or (plist-get (get ,symbol 'menu-prop) |
| 169 | 'identity) | 171 | :filter) |
| 170 | (symbol-function ,symbol))) | 172 | 'identity) |
| 171 | ,symbol)))) | 173 | (symbol-function ,symbol))) |
| 174 | ,symbol))))) | ||
| 172 | (mapcar (lambda (map) | 175 | (mapcar (lambda (map) |
| 173 | (define-key map (vector 'menu-bar (easy-menu-intern (car menu))) | 176 | (define-key map (vector 'menu-bar (easy-menu-intern (car menu))) |
| 174 | (cons 'menu-item | 177 | (cons 'menu-item |