From: Richard M. Stallman Date: Sun, 27 Mar 1994 07:36:35 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: emacs-19.34~9310 X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/a8226f6724e0804eac44a5f4731e96984b75d023 *** empty log message *** --- diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el index d87f134e9b..0a48984013 100644 --- a/lisp/emacs-lisp/easymenu.el +++ b/lisp/emacs-lisp/easymenu.el @@ -26,40 +26,39 @@ ;;; Code: -;;;###autoload. +;;;###autoload (defun easy-menu-define (symbol maps doc menu) "Define a menu bar submenu in maps MAPS, according to MENU. The arguments SYMBOL and DOC are ignored; they are present for -compatibility only. +compatibility only. In other Emacs versions they may be used +as a variable to hold the menu data, and a doc string for that variable. The first element of MENU must be a string. It is the menu bar item name. The rest of the elements are menu items. -A menu item is a vector of three elements: +A menu item is usually a vector of three elements: [NAME CALLBACK t] - - the name of the menu item (a string); - - the `callback' of that item; - - t. +NAME is a string--the menu item name. -If the `callback' of a menu item is a symbol, then it must name a -command. It will be invoked with `call-interactively'. If it is a -list, then it is evaluated with `eval'. +CALLBACK is a command to run when the item is chosen, +or a list to evaluate when the item is chosen. -If an element of a menu is a string, then that string appears in the -menu as unselectable text. +A menu item can be a string. Then that string appears in the menu as +unselectable text. A string consisting solely of hyphens is displayed +as a solid horizontal line. -If an element of a menu is a string consisting solely of hyphens, then that -item is displayed as a solid horizontal line. - -If an element of a menu is a list, it is treated as a submenu. +A menu item can be a list. It is treated as a submenu. The first element should be the submenu name. That's used as the menu item in the top-level menu. The cdr of the submenu list is a list of menu items, as above." + (or (keymapp maps) (setq maps (list maps))) (let ((keymap (easy-menu-keymap (car menu) (cdr menu)))) - (mapcar (function (lambda (map) - (define-key map (vector 'menu-bar (intern (car menu))) - (cons (car menu) keymap)))) - (if (keymapp maps) (list maps) maps)))) + (while maps + (define-key (car maps) (vector 'menu-bar (intern (car menu))) + (cons (car menu) keymap)) + (setq maps (cdr maps))))) + +(defvar easy-menu-item-count 0) ;; Return a menu keymap corresponding to a Lucid-style menu list ;; MENU-ITEMS, and with name MENU-NAME. @@ -76,14 +75,14 @@ is a list of menu items, as above." (setq command nil) (setq name (if (string-match "^-+$" item) "" item))) ((consp item) - (setq command (make-lucid-menu-keymap (car item) (cdr item))) + (setq command (easy-menu-keymap (car item) (cdr item))) (setq name (car item))) ((vectorp item) (setq command (make-symbol (format "menu-function-%d" - add-menu-item-count))) + easy-menu-item-count))) (setq enabler (make-symbol (format "menu-function-%d-enabler" - add-menu-item-count))) - (setq add-menu-item-count (1+ add-menu-item-count)) + easy-menu-item-count))) + (setq easy-menu-item-count (1+ easy-menu-item-count)) (put command 'menu-enable enabler) (set enabler (aref item 2)) (setq name (aref item 0))