summaryrefslogtreecommitdiff
path: root/lisp/imenu.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-02-24 01:42:31 +0000
committerRichard M. Stallman <rms@gnu.org>1996-02-24 01:42:31 +0000
commit6e2ae6ebfccfc9af0128ab0ad8bbab81ddc8bc7e (patch)
tree529cd398bdd17a6a1a4c91be63ea91cbb4abecba /lisp/imenu.el
parent4aa89df3be06995141714768d5178b21f52239c6 (diff)
downloademacs-6e2ae6ebfccfc9af0128ab0ad8bbab81ddc8bc7e.tar.gz
(imenu-add-to-menubar): Add menu item for current buf only.
(imenu-update-menubar): Never add menu item here.
Diffstat (limited to 'lisp/imenu.el')
-rw-r--r--lisp/imenu.el26
1 files changed, 10 insertions, 16 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 70a1b051956..575eae771d4 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -785,13 +785,18 @@ The returned value is on the form (INDEX-NAME . INDEX-POSITION)."
;;;###autoload
(defun imenu-add-to-menubar (name)
- "Adds an \"imenu\" entry to the menu bar for the current major mode.
+ "Adds an `imenu' entry to the menu bar for the current buffer.
NAME is a string used to name the menu bar item.
-See `imenu' for more information."
+See the command `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))))
+ (let ((newmap (make-sparse-keymap))
+ (menu-bar (lookup-key (current-local-map) [menu-bar])))
+ (define-key newmap [menu-bar]
+ (append (make-sparse-keymap) menu-bar))
+ (define-key newmap [menu-bar index]
+ (cons name (nconc (make-sparse-keymap "Imenu")
+ (make-sparse-keymap))))
+ (use-local-map (append newmap (current-local-map))))
(add-hook 'menu-bar-update-hook 'imenu-update-menubar))
(defvar imenu-buffer-menubar nil)
@@ -799,17 +804,6 @@ See `imenu' for more information."
(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.