aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-08-30 21:55:07 +0000
committerStefan Monnier2002-08-30 21:55:07 +0000
commite899e3de1e316c32a840db8b494001917f871f94 (patch)
treecf035a90abd881343923c61d0128a24de4964173
parent3b2f3d306efc27458662cb3572c90a68cd4b99fa (diff)
downloademacs-e899e3de1e316c32a840db8b494001917f871f94.tar.gz
emacs-e899e3de1e316c32a840db8b494001917f871f94.zip
(easy-menu-filter-return):
Handle the case where the filter returns a single menu entry. (easy-menu-add): Improve docstring. (easy-menu-current-active-maps): Remove. (easy-menu-get-map): Use current-active-maps.
-rw-r--r--lisp/emacs-lisp/easymenu.el25
1 files changed, 12 insertions, 13 deletions
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index bf2e190e489..971e420d7e4 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -187,11 +187,15 @@ In Emacs a menu filter must return a menu (a keymap), in XEmacs a filter must
187return a menu items list (without menu name and keywords). 187return a menu items list (without menu name and keywords).
188This function returns the right thing in the two cases. 188This function returns the right thing in the two cases.
189If NAME is provided, it is used for the keymap." 189If NAME is provided, it is used for the keymap."
190 (when (and (not (keymapp menu)) (consp menu)) 190 (cond
191 ((and (not (keymapp menu)) (consp menu))
191 ;; If it's a cons but not a keymap, then it can't be right 192 ;; If it's a cons but not a keymap, then it can't be right
192 ;; unless it's an XEmacs menu. 193 ;; unless it's an XEmacs menu.
193 (setq menu (easy-menu-create-menu (or name "") menu))) 194 (setq menu (easy-menu-create-menu (or name "") menu)))
194 (easy-menu-get-map menu nil)) ; Get past indirections. 195 ((vectorp menu)
196 ;; It's just a menu entry.
197 (setq menu (cdr (easy-menu-convert-item menu)))))
198 menu)
195 199
196;;;###autoload 200;;;###autoload
197(defun easy-menu-create-menu (menu-name menu-items) 201(defun easy-menu-create-menu (menu-name menu-items)
@@ -462,7 +466,11 @@ to implement dynamic menus."
462(defalias 'easy-menu-remove 'ignore) 466(defalias 'easy-menu-remove 'ignore)
463 467
464(defun easy-menu-add (menu &optional map) 468(defun easy-menu-add (menu &optional map)
465 "Maybe precalculate equivalent key bindings. 469 "Add the menu to the menubar.
470This is a nop on Emacs since menus are automatically activated when the
471corresponding keymap is activated. On XEmacs this is needed to actually
472add the menu to the current menubar.
473Maybe precalculate equivalent key bindings.
466Do it only if `easy-menu-precalculate-equivalent-keybindings' is on." 474Do it only if `easy-menu-precalculate-equivalent-keybindings' is on."
467 (when easy-menu-precalculate-equivalent-keybindings 475 (when easy-menu-precalculate-equivalent-keybindings
468 (if (and (symbolp menu) (not (keymapp menu)) (boundp menu)) 476 (if (and (symbolp menu) (not (keymapp menu)) (boundp menu))
@@ -565,15 +573,6 @@ If item is an old format item, a new format item is returned."
565 (setq submap (cdr submap))) 573 (setq submap (cdr submap)))
566 submap) 574 submap)
567 575
568;; This should really be in keymap.c
569(defun easy-menu-current-active-maps ()
570 (let ((maps (list (current-local-map) global-map)))
571 (dolist (minor minor-mode-map-alist)
572 (when (and (boundp (car minor))
573 (symbol-value (car minor)))
574 (push (cdr minor) maps)))
575 (delq nil maps)))
576
577(defun easy-menu-get-map (map path &optional to-modify) 576(defun easy-menu-get-map (map path &optional to-modify)
578 "Return a sparse keymap in which to add or remove an item. 577 "Return a sparse keymap in which to add or remove an item.
579MAP and PATH are as defined in `easy-menu-add-item'. 578MAP and PATH are as defined in `easy-menu-add-item'.
@@ -594,7 +593,7 @@ In some cases we use that to select between the local and global maps."
594 (list (if (and (symbolp map) 593 (list (if (and (symbolp map)
595 (not (keymapp map))) 594 (not (keymapp map)))
596 (symbol-value map) map)) 595 (symbol-value map) map))
597 (easy-menu-current-active-maps))))) 596 (current-active-maps)))))
598 ;; Prefer a map that already contains the to-be-modified entry. 597 ;; Prefer a map that already contains the to-be-modified entry.
599 (when to-modify 598 (when to-modify
600 (dolist (map maps) 599 (dolist (map maps)