aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-03-27 07:36:35 +0000
committerRichard M. Stallman1994-03-27 07:36:35 +0000
commita8226f6724e0804eac44a5f4731e96984b75d023 (patch)
treed6903fc9049d5a6b82e2ed6d59707fbc3208f0b8
parentdf28eb7b38be1a96163b3849962c4a6343e6d2f2 (diff)
downloademacs-a8226f6724e0804eac44a5f4731e96984b75d023.tar.gz
emacs-a8226f6724e0804eac44a5f4731e96984b75d023.zip
*** empty log message ***
-rw-r--r--lisp/emacs-lisp/easymenu.el45
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.
32The arguments SYMBOL and DOC are ignored; they are present for 32The arguments SYMBOL and DOC are ignored; they are present for
33compatibility only. 33compatibility only. In other Emacs versions they may be used
34as a variable to hold the menu data, and a doc string for that variable.
34 35
35The first element of MENU must be a string. It is the menu bar item name. 36The first element of MENU must be a string. It is the menu bar item name.
36The rest of the elements are menu items. 37The rest of the elements are menu items.
37 38
38A menu item is a vector of three elements: 39A menu item is usually a vector of three elements: [NAME CALLBACK t]
39 40
40 - the name of the menu item (a string); 41NAME is a string--the menu item name.
41 - the `callback' of that item;
42 - t.
43 42
44If the `callback' of a menu item is a symbol, then it must name a 43CALLBACK is a command to run when the item is chosen,
45command. It will be invoked with `call-interactively'. If it is a 44or a list to evaluate when the item is chosen.
46list, then it is evaluated with `eval'.
47 45
48If an element of a menu is a string, then that string appears in the 46A menu item can be a string. Then that string appears in the menu as
49menu as unselectable text. 47unselectable text. A string consisting solely of hyphens is displayed
48as a solid horizontal line.
50 49
51If an element of a menu is a string consisting solely of hyphens, then that 50A menu item can be a list. It is treated as a submenu.
52item is displayed as a solid horizontal line.
53
54If an element of a menu is a list, it is treated as a submenu.
55The first element should be the submenu name. That's used as the 51The first element should be the submenu name. That's used as the
56menu item in the top-level menu. The cdr of the submenu list 52menu item in the top-level menu. The cdr of the submenu list
57is a list of menu items, as above." 53is 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))