changeset 14642:01e8fdb45deb

(imenu-buffer-menubar): Add defvar. (imenu-update-menubar): Make a buffer-specific copy of the local map.
author Karl Heuer <kwzh@gnu.org>
date Wed, 21 Feb 1996 21:44:28 +0000
parents 4706508583bd
children 9a31b6a37efd
files lisp/imenu.el
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/imenu.el	Wed Feb 21 21:39:11 1996 +0000
+++ b/lisp/imenu.el	Wed Feb 21 21:44:28 1996 +0000
@@ -790,12 +790,26 @@
 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.