summaryrefslogtreecommitdiff
path: root/lisp/imenu.el
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1996-02-21 21:44:28 +0000
committerKarl Heuer <kwzh@gnu.org>1996-02-21 21:44:28 +0000
commit384d43d6a06ddbd5650acd47818f007c09e86f47 (patch)
tree2ea821828224c718e2a665ce664428e3454c00cd /lisp/imenu.el
parentd1d2f4f73c40888f097c4d232382c772c3170792 (diff)
downloademacs-384d43d6a06ddbd5650acd47818f007c09e86f47.tar.gz
(imenu-buffer-menubar): Add defvar.
(imenu-update-menubar): Make a buffer-specific copy of the local map.
Diffstat (limited to 'lisp/imenu.el')
-rw-r--r--lisp/imenu.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 2e9d9be1cbb..d3f66b3e610 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -790,12 +790,26 @@ NAME is a string used to name the menu bar item.
See `imenu' for more information."
(interactive "sImenu menu item name: ")
(define-key (current-local-map) [menu-bar index]
- (cons name (nconc (make-sparse-keymap "Imenu") (make-sparse-keymap))))
+ (cons name (nconc (make-sparse-keymap "Imenu")
+ (make-sparse-keymap))))
(add-hook 'menu-bar-update-hook 'imenu-update-menubar))
+(defvar imenu-buffer-menubar nil)
+
(defun imenu-update-menubar ()
(and (current-local-map)
(keymapp (lookup-key (current-local-map) [menu-bar index]))
+ (progn
+ (or (local-variable-p 'imenu-buffer-menubar)
+ ;; Make a buffer-specific copy of the local map
+ ;; so that we don't affect other buffers with the same major mode.
+ (let ((newmap (make-sparse-keymap)))
+ (define-key (current-local-map) [menu-bar index]
+ (cons name (nconc (make-sparse-keymap "Imenu")
+ (make-sparse-keymap)))))
+ (use-local-map (append newmap (current-local-map))))
+ (make-local-variable 'imenu-buffer-menubar)
+ t)
(let ((index-alist (imenu--make-index-alist t)))
;; Don't bother updating if the index-alist has not changed
;; since the last time we did it.