187 |
return a menu items list (without menu name and keywords). |
return a menu items list (without menu name and keywords). |
188 |
This function returns the right thing in the two cases. |
This function returns the right thing in the two cases. |
189 |
If NAME is provided, it is used for the keymap." |
If NAME is provided, it is used for the keymap." |
190 |
(when (and (not (keymapp menu)) (consp menu)) |
(cond |
191 |
|
((and (not (keymapp menu)) (consp menu)) |
192 |
;; If it's a cons but not a keymap, then it can't be right |
;; If it's a cons but not a keymap, then it can't be right |
193 |
;; unless it's an XEmacs menu. |
;; unless it's an XEmacs menu. |
194 |
(setq menu (easy-menu-create-menu (or name "") menu))) |
(setq menu (easy-menu-create-menu (or name "") menu))) |
195 |
(easy-menu-get-map menu nil)) ; Get past indirections. |
((vectorp menu) |
196 |
|
;; It's just a menu entry. |
197 |
|
(setq menu (cdr (easy-menu-convert-item menu))))) |
198 |
|
menu) |
199 |
|
|
200 |
;;;###autoload |
;;;###autoload |
201 |
(defun easy-menu-create-menu (menu-name menu-items) |
(defun easy-menu-create-menu (menu-name menu-items) |
466 |
(defalias 'easy-menu-remove 'ignore) |
(defalias 'easy-menu-remove 'ignore) |
467 |
|
|
468 |
(defun easy-menu-add (menu &optional map) |
(defun easy-menu-add (menu &optional map) |
469 |
"Maybe precalculate equivalent key bindings. |
"Add the menu to the menubar. |
470 |
|
This is a nop on Emacs since menus are automatically activated when the |
471 |
|
corresponding keymap is activated. On XEmacs this is needed to actually |
472 |
|
add the menu to the current menubar. |
473 |
|
Maybe precalculate equivalent key bindings. |
474 |
Do it only if `easy-menu-precalculate-equivalent-keybindings' is on." |
Do it only if `easy-menu-precalculate-equivalent-keybindings' is on." |
475 |
(when easy-menu-precalculate-equivalent-keybindings |
(when easy-menu-precalculate-equivalent-keybindings |
476 |
(if (and (symbolp menu) (not (keymapp menu)) (boundp menu)) |
(if (and (symbolp menu) (not (keymapp menu)) (boundp menu)) |
573 |
(setq submap (cdr submap))) |
(setq submap (cdr submap))) |
574 |
submap) |
submap) |
575 |
|
|
|
;; This should really be in keymap.c |
|
|
(defun easy-menu-current-active-maps () |
|
|
(let ((maps (list (current-local-map) global-map))) |
|
|
(dolist (minor minor-mode-map-alist) |
|
|
(when (and (boundp (car minor)) |
|
|
(symbol-value (car minor))) |
|
|
(push (cdr minor) maps))) |
|
|
(delq nil maps))) |
|
|
|
|
576 |
(defun easy-menu-get-map (map path &optional to-modify) |
(defun easy-menu-get-map (map path &optional to-modify) |
577 |
"Return a sparse keymap in which to add or remove an item. |
"Return a sparse keymap in which to add or remove an item. |
578 |
MAP and PATH are as defined in `easy-menu-add-item'. |
MAP and PATH are as defined in `easy-menu-add-item'. |
593 |
(list (if (and (symbolp map) |
(list (if (and (symbolp map) |
594 |
(not (keymapp map))) |
(not (keymapp map))) |
595 |
(symbol-value map) map)) |
(symbol-value map) map)) |
596 |
(easy-menu-current-active-maps))))) |
(current-active-maps))))) |
597 |
;; Prefer a map that already contains the to-be-modified entry. |
;; Prefer a map that already contains the to-be-modified entry. |
598 |
(when to-modify |
(when to-modify |
599 |
(dolist (map maps) |
(dolist (map maps) |