diff options
| author | Richard M. Stallman | 1994-03-27 07:36:35 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-03-27 07:36:35 +0000 |
| commit | a8226f6724e0804eac44a5f4731e96984b75d023 (patch) | |
| tree | d6903fc9049d5a6b82e2ed6d59707fbc3208f0b8 | |
| parent | df28eb7b38be1a96163b3849962c4a6343e6d2f2 (diff) | |
| download | emacs-a8226f6724e0804eac44a5f4731e96984b75d023.tar.gz emacs-a8226f6724e0804eac44a5f4731e96984b75d023.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/emacs-lisp/easymenu.el | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el index d87f134e9b0..0a489840133 100644 --- a/lisp/emacs-lisp/easymenu.el +++ b/lisp/emacs-lisp/easymenu.el | |||
| @@ -26,40 +26,39 @@ | |||
| 26 | 26 | ||
| 27 | ;;; Code: | 27 | ;;; Code: |
| 28 | 28 | ||
| 29 | ;;;###autoload. | 29 | ;;;###autoload |
| 30 | (defun easy-menu-define (symbol maps doc menu) | 30 | (defun easy-menu-define (symbol maps doc menu) |
| 31 | "Define a menu bar submenu in maps MAPS, according to MENU. | 31 | "Define a menu bar submenu in maps MAPS, according to MENU. |
| 32 | The arguments SYMBOL and DOC are ignored; they are present for | 32 | The arguments SYMBOL and DOC are ignored; they are present for |
| 33 | compatibility only. | 33 | compatibility only. In other Emacs versions they may be used |
| 34 | as a variable to hold the menu data, and a doc string for that variable. | ||
| 34 | 35 | ||
| 35 | The first element of MENU must be a string. It is the menu bar item name. | 36 | The first element of MENU must be a string. It is the menu bar item name. |
| 36 | The rest of the elements are menu items. | 37 | The rest of the elements are menu items. |
| 37 | 38 | ||
| 38 | A menu item is a vector of three elements: | 39 | A menu item is usually a vector of three elements: [NAME CALLBACK t] |
| 39 | 40 | ||
| 40 | - the name of the menu item (a string); | 41 | NAME is a string--the menu item name. |
| 41 | - the `callback' of that item; | ||
| 42 | - t. | ||
| 43 | 42 | ||
| 44 | If the `callback' of a menu item is a symbol, then it must name a | 43 | CALLBACK is a command to run when the item is chosen, |
| 45 | command. It will be invoked with `call-interactively'. If it is a | 44 | or a list to evaluate when the item is chosen. |
| 46 | list, then it is evaluated with `eval'. | ||
| 47 | 45 | ||
| 48 | If an element of a menu is a string, then that string appears in the | 46 | A menu item can be a string. Then that string appears in the menu as |
| 49 | menu as unselectable text. | 47 | unselectable text. A string consisting solely of hyphens is displayed |
| 48 | as a solid horizontal line. | ||
| 50 | 49 | ||
| 51 | If an element of a menu is a string consisting solely of hyphens, then that | 50 | A menu item can be a list. It is treated as a submenu. |
| 52 | item is displayed as a solid horizontal line. | ||
| 53 | |||
| 54 | If an element of a menu is a list, it is treated as a submenu. | ||
| 55 | The first element should be the submenu name. That's used as the | 51 | The first element should be the submenu name. That's used as the |
| 56 | menu item in the top-level menu. The cdr of the submenu list | 52 | menu item in the top-level menu. The cdr of the submenu list |
| 57 | is a list of menu items, as above." | 53 | is a list of menu items, as above." |
| 54 | (or (keymapp maps) (setq maps (list maps))) | ||
| 58 | (let ((keymap (easy-menu-keymap (car menu) (cdr menu)))) | 55 | (let ((keymap (easy-menu-keymap (car menu) (cdr menu)))) |
| 59 | (mapcar (function (lambda (map) | 56 | (while maps |
| 60 | (define-key map (vector 'menu-bar (intern (car menu))) | 57 | (define-key (car maps) (vector 'menu-bar (intern (car menu))) |
| 61 | (cons (car menu) keymap)))) | 58 | (cons (car menu) keymap)) |
| 62 | (if (keymapp maps) (list maps) maps)))) | 59 | (setq maps (cdr maps))))) |
| 60 | |||
| 61 | (defvar easy-menu-item-count 0) | ||
| 63 | 62 | ||
| 64 | ;; Return a menu keymap corresponding to a Lucid-style menu list | 63 | ;; Return a menu keymap corresponding to a Lucid-style menu list |
| 65 | ;; MENU-ITEMS, and with name MENU-NAME. | 64 | ;; MENU-ITEMS, and with name MENU-NAME. |
| @@ -76,14 +75,14 @@ is a list of menu items, as above." | |||
| 76 | (setq command nil) | 75 | (setq command nil) |
| 77 | (setq name (if (string-match "^-+$" item) "" item))) | 76 | (setq name (if (string-match "^-+$" item) "" item))) |
| 78 | ((consp item) | 77 | ((consp item) |
| 79 | (setq command (make-lucid-menu-keymap (car item) (cdr item))) | 78 | (setq command (easy-menu-keymap (car item) (cdr item))) |
| 80 | (setq name (car item))) | 79 | (setq name (car item))) |
| 81 | ((vectorp item) | 80 | ((vectorp item) |
| 82 | (setq command (make-symbol (format "menu-function-%d" | 81 | (setq command (make-symbol (format "menu-function-%d" |
| 83 | add-menu-item-count))) | 82 | easy-menu-item-count))) |
| 84 | (setq enabler (make-symbol (format "menu-function-%d-enabler" | 83 | (setq enabler (make-symbol (format "menu-function-%d-enabler" |
| 85 | add-menu-item-count))) | 84 | easy-menu-item-count))) |
| 86 | (setq add-menu-item-count (1+ add-menu-item-count)) | 85 | (setq easy-menu-item-count (1+ easy-menu-item-count)) |
| 87 | (put command 'menu-enable enabler) | 86 | (put command 'menu-enable enabler) |
| 88 | (set enabler (aref item 2)) | 87 | (set enabler (aref item 2)) |
| 89 | (setq name (aref item 0)) | 88 | (setq name (aref item 0)) |