summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/easymenu.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1998-12-29 22:54:37 +0000
committerRichard M. Stallman <rms@gnu.org>1998-12-29 22:54:37 +0000
commita2c896c3c4b92b5d796d3be56fb3f76fd8ac77c1 (patch)
treeb1976b482d5004aaec46915b52632088438fd89b /lisp/emacs-lisp/easymenu.el
parentbf7f4e9066f5bd53ca8d7ac448b53aae3bd092bc (diff)
downloademacs-a2c896c3c4b92b5d796d3be56fb3f76fd8ac77c1.tar.gz
(easy-menu-get-map): Change global map only if this menu exists in the
global map already, and not in the local map. (easy-menu-do-add-item): Fix error message.
Diffstat (limited to 'lisp/emacs-lisp/easymenu.el')
-rw-r--r--lisp/emacs-lisp/easymenu.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index e88db0952cc..f29279c7876 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -269,7 +269,7 @@ shadow\\(Double\\)?Etched\\(In\\|Out\\)\\(Dash\\)?\\)\\)$"
(if (and (or no-name cache-specified)
(or (null cache) (stringp cache) (vectorp cache)))
(setq prop (cons :key-sequence (cons cache prop))))))
- (t (error "Invalid menu item in easymenu.")))
+ (t (error "Invalid menu item in easymenu")))
(easy-menu-define-key menu (if (stringp name) (intern name) name)
(and (not remove)
(cons 'menu-item
@@ -403,13 +403,21 @@ NAME should be a string, the name of the element to be removed."
;; Return a sparse keymap in which to add or remove an item.
;; MAP and PATH are as defined in `easy-menu-add-item'.
(if (null map)
- (setq map (lookup-key global-map
- (vconcat '(menu-bar) (mapcar 'intern path))))
+ (setq map (or (lookup-key (current-local-map)
+ (vconcat '(menu-bar) (mapcar 'intern path)))
+ (lookup-key global-map
+ (vconcat '(menu-bar) (mapcar 'intern path)))
+ (let ((new (make-sparse-keymap)))
+ (define-key (current-local-map)
+ (vconcat '(menu-bar) (mapcar 'intern path)) new)
+ new)))
(if (and (symbolp map) (not (keymapp map)))
(setq map (symbol-value map)))
(if path (setq map (lookup-key map (vconcat (mapcar 'intern path))))))
(while (and (symbolp map) (keymapp map))
(setq map (symbol-function map)))
+ (unless map
+ (error "Menu specified in easy-menu is not defined"))
(or (keymapp map) (error "Malformed menu in easy-menu: (%s)" map))
map)