aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-02-24 01:42:31 +0000
committerRichard M. Stallman1996-02-24 01:42:31 +0000
commitd17570268da4f06b891d0c034b1c0abd62845272 (patch)
treeb1db25f1368541b028acb6992eca0bf504704c42
parent7bf09e90d7a02eba8d8c08a11dfd26f2de7fb06c (diff)
downloademacs-d17570268da4f06b891d0c034b1c0abd62845272.tar.gz
emacs-d17570268da4f06b891d0c034b1c0abd62845272.zip
(imenu-add-to-menubar): Add menu item for current buf only.
(imenu-update-menubar): Never add menu item here.
-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)."
785 785
786;;;###autoload 786;;;###autoload
787(defun imenu-add-to-menubar (name) 787(defun imenu-add-to-menubar (name)
788 "Adds an \"imenu\" entry to the menu bar for the current major mode. 788 "Adds an `imenu' entry to the menu bar for the current buffer.
789NAME is a string used to name the menu bar item. 789NAME is a string used to name the menu bar item.
790See `imenu' for more information." 790See the command `imenu' for more information."
791 (interactive "sImenu menu item name: ") 791 (interactive "sImenu menu item name: ")
792 (define-key (current-local-map) [menu-bar index] 792 (let ((newmap (make-sparse-keymap))
793 (cons name (nconc (make-sparse-keymap "Imenu") 793 (menu-bar (lookup-key (current-local-map) [menu-bar])))
794 (make-sparse-keymap)))) 794 (define-key newmap [menu-bar]
795 (append (make-sparse-keymap) menu-bar))
796 (define-key newmap [menu-bar index]
797 (cons name (nconc (make-sparse-keymap "Imenu")
798 (make-sparse-keymap))))
799 (use-local-map (append newmap (current-local-map))))
795 (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) 800 (add-hook 'menu-bar-update-hook 'imenu-update-menubar))
796 801
797(defvar imenu-buffer-menubar nil) 802(defvar imenu-buffer-menubar nil)
@@ -799,17 +804,6 @@ See `imenu' for more information."
799(defun imenu-update-menubar () 804(defun imenu-update-menubar ()
800 (and (current-local-map) 805 (and (current-local-map)
801 (keymapp (lookup-key (current-local-map) [menu-bar index])) 806 (keymapp (lookup-key (current-local-map) [menu-bar index]))
802 (progn
803 (or (local-variable-p 'imenu-buffer-menubar)
804 ;; Make a buffer-specific copy of the local map
805 ;; so that we don't affect other buffers with the same major mode.
806 (let ((newmap (make-sparse-keymap)))
807 (define-key (current-local-map) [menu-bar index]
808 (cons name (nconc (make-sparse-keymap "Imenu")
809 (make-sparse-keymap))))
810 (use-local-map (append newmap (current-local-map)))))
811 (make-local-variable 'imenu-buffer-menubar)
812 t)
813 (let ((index-alist (imenu--make-index-alist t))) 807 (let ((index-alist (imenu--make-index-alist t)))
814 ;; Don't bother updating if the index-alist has not changed 808 ;; Don't bother updating if the index-alist has not changed
815 ;; since the last time we did it. 809 ;; since the last time we did it.