Commit 9fb980fc authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(imenu-menubar-modified-tick): Renamed from

imenu-update-menubar-modified-tick.
(imenu-update-menubar): Update imenu-menubar-modified-tick
whenever outer condition succeeds.
parent 43711c22
...@@ -980,33 +980,32 @@ A trivial interface to `imenu-add-to-menubar' suitable for use in a hook." ...@@ -980,33 +980,32 @@ A trivial interface to `imenu-add-to-menubar' suitable for use in a hook."
(defvar imenu-buffer-menubar nil) (defvar imenu-buffer-menubar nil)
(defvar imenu-update-menubar-modified-tick 0 (defvar imenu-menubar-modified-tick 0
"The value of (buffer-modified-tick) as of last call to `imenu-update-menubar'. "The value of (buffer-modified-tick) as of last call to `imenu-update-menubar'.
This value becomes local in every buffer when it is set.") This value becomes local in every buffer when it is set.")
(make-variable-buffer-local 'imenu-update-menubar-modified-tick) (make-variable-buffer-local 'imenu-menubar-modified-tick)
(defun imenu-update-menubar () (defun imenu-update-menubar ()
(and (current-local-map) (when (and (current-local-map)
(keymapp (lookup-key (current-local-map) [menu-bar index])) (keymapp (lookup-key (current-local-map) [menu-bar index]))
(not (eq (buffer-modified-tick) (not (eq (buffer-modified-tick)
imenu-update-menubar-modified-tick)) imenu-menubar-modified-tick)))
(let ((index-alist (imenu--make-index-alist t))) (setq imenu-menubar-modified-tick (buffer-modified-tick))
;; Don't bother updating if the index-alist has not changed (let ((index-alist (imenu--make-index-alist t)))
;; since the last time we did it. ;; Don't bother updating if the index-alist has not changed
(or (equal index-alist imenu--last-menubar-index-alist) ;; since the last time we did it.
(let (menu menu1 old) (unless (equal index-alist imenu--last-menubar-index-alist)
(setq imenu--last-menubar-index-alist index-alist) (let (menu menu1 old)
(setq index-alist (imenu--split-submenus index-alist)) (setq imenu--last-menubar-index-alist index-alist)
(setq menu (imenu--split-menu index-alist (setq index-alist (imenu--split-submenus index-alist))
(buffer-name))) (setq menu (imenu--split-menu index-alist
(setq menu1 (imenu--create-keymap-1 (car menu) (buffer-name)))
(if (< 1 (length (cdr menu))) (setq menu1 (imenu--create-keymap-1 (car menu)
(cdr menu) (if (< 1 (length (cdr menu)))
(cdr (car (cdr menu)))))) (cdr menu)
(setq imenu-update-menubar-modified-tick (cdr (car (cdr menu))))))
(buffer-modified-tick)) (setq old (lookup-key (current-local-map) [menu-bar index]))
(setq old (lookup-key (current-local-map) [menu-bar index])) (setcdr old (cdr menu1)))))))
(setcdr old (cdr menu1)))))))
(defun imenu--menubar-select (item) (defun imenu--menubar-select (item)
"Use Imenu to select the function or variable named in this menu ITEM." "Use Imenu to select the function or variable named in this menu ITEM."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment