# HG changeset patch # User Richard M. Stallman # Date 914972077 0 # Node ID 9f9e1b450ff5939ba5fe3937118100d14e155231 # Parent 7a8677cdf2bdb8ae1ada82fc1c913eed8fb7b0ff (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. diff -r 7a8677cdf2bd -r 9f9e1b450ff5 lisp/emacs-lisp/easymenu.el --- a/lisp/emacs-lisp/easymenu.el Tue Dec 29 22:53:54 1998 +0000 +++ b/lisp/emacs-lisp/easymenu.el Tue Dec 29 22:54:37 1998 +0000 @@ -269,7 +269,7 @@ (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 @@ ;; 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)