Mercurial > emacs
comparison lisp/imenu.el @ 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 | 69a5f0592433 |
children | 4e78b18f1f4f |
comparison
equal
deleted
inserted
replaced
14641:4706508583bd | 14642:01e8fdb45deb |
---|---|
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 major mode. |
789 NAME is a string used to name the menu bar item. | 789 NAME is a string used to name the menu bar item. |
790 See `imenu' for more information." | 790 See `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 (define-key (current-local-map) [menu-bar index] |
793 (cons name (nconc (make-sparse-keymap "Imenu") (make-sparse-keymap)))) | 793 (cons name (nconc (make-sparse-keymap "Imenu") |
794 (make-sparse-keymap)))) | |
794 (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) | 795 (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) |
796 | |
797 (defvar imenu-buffer-menubar nil) | |
795 | 798 |
796 (defun imenu-update-menubar () | 799 (defun imenu-update-menubar () |
797 (and (current-local-map) | 800 (and (current-local-map) |
798 (keymapp (lookup-key (current-local-map) [menu-bar index])) | 801 (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) | |
799 (let ((index-alist (imenu--make-index-alist t))) | 813 (let ((index-alist (imenu--make-index-alist t))) |
800 ;; Don't bother updating if the index-alist has not changed | 814 ;; Don't bother updating if the index-alist has not changed |
801 ;; since the last time we did it. | 815 ;; since the last time we did it. |
802 (or (equal index-alist imenu--last-menubar-index-alist) | 816 (or (equal index-alist imenu--last-menubar-index-alist) |
803 (let (menu menu1 old) | 817 (let (menu menu1 old) |