mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
* lisp/imenu.el (imenu--menubar-keymap): New var.
(imenu-add-to-menubar): Set it to remember the keymap we used. (imenu-update-menubar): Use it instead of asking lookup-key.
This commit is contained in:
parent
eed18bf1fd
commit
e538605e4c
2 changed files with 23 additions and 14 deletions
|
|
@ -1,5 +1,9 @@
|
|||
2014-10-21 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* imenu.el (imenu--menubar-keymap): New var.
|
||||
(imenu-add-to-menubar): Set it to remember the keymap we used.
|
||||
(imenu-update-menubar): Use it instead of asking lookup-key.
|
||||
|
||||
* obsolete/cc-compat.el: Make obsolete (bug#18561).
|
||||
|
||||
* epg-config.el (epg-gpg-program): Don't use absolute names by default.
|
||||
|
|
@ -26,6 +30,13 @@
|
|||
(newsticker--image-download-by-url-callback): Make this function
|
||||
actually work: Check status properly, then save image.
|
||||
|
||||
2014-10-20 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* mouse.el (mouse--down-1-maybe-follows-link): Remove unused var
|
||||
`this-event'.
|
||||
(mouse-drag-line): Use there's no actual mouse, use the event's
|
||||
position info.
|
||||
|
||||
2014-10-20 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* textmodes/css-mode.el (scss-mode): New major-mode.
|
||||
|
|
|
|||
|
|
@ -936,6 +936,8 @@ The returned value is of the form (INDEX-NAME . INDEX-POSITION)."
|
|||
(setq result t imenu--index-alist nil)))
|
||||
result))
|
||||
|
||||
(defvar-local imenu--menubar-keymap nil)
|
||||
|
||||
;;;###autoload
|
||||
(defun imenu-add-to-menubar (name)
|
||||
"Add an `imenu' entry to the menu bar for the current buffer.
|
||||
|
|
@ -952,8 +954,9 @@ See the command `imenu' for more information."
|
|||
(let ((newmap (make-sparse-keymap)))
|
||||
(set-keymap-parent newmap (current-local-map))
|
||||
(setq imenu--last-menubar-index-alist nil)
|
||||
(setq imenu--menubar-keymap (make-sparse-keymap "Imenu"))
|
||||
(define-key newmap [menu-bar index]
|
||||
`(menu-item ,name ,(make-sparse-keymap "Imenu")))
|
||||
`(menu-item ,name ,imenu--menubar-keymap))
|
||||
(use-local-map newmap)
|
||||
(add-hook 'menu-bar-update-hook 'imenu-update-menubar)))
|
||||
(user-error "The mode `%s' does not support Imenu"
|
||||
|
|
@ -975,28 +978,23 @@ to `imenu-update-menubar'.")
|
|||
|
||||
(defun imenu-update-menubar ()
|
||||
(when (and (current-local-map)
|
||||
(keymapp (lookup-key (current-local-map) [menu-bar index]))
|
||||
imenu--menubar-keymap
|
||||
(/= (buffer-chars-modified-tick) imenu-menubar-modified-tick))
|
||||
(setq imenu-menubar-modified-tick (buffer-chars-modified-tick))
|
||||
(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.
|
||||
(unless (equal index-alist imenu--last-menubar-index-alist)
|
||||
(let (menu menu1 old)
|
||||
(setq imenu--last-menubar-index-alist index-alist)
|
||||
(setq index-alist (imenu--split-submenus index-alist))
|
||||
(setq menu (imenu--split-menu index-alist
|
||||
(buffer-name)))
|
||||
(setq menu1 (imenu--create-keymap (car menu)
|
||||
(setq imenu--last-menubar-index-alist index-alist)
|
||||
(setq index-alist (imenu--split-submenus index-alist))
|
||||
(let* ((menu (imenu--split-menu index-alist
|
||||
(buffer-name)))
|
||||
(menu1 (imenu--create-keymap (car menu)
|
||||
(cdr (if (< 1 (length (cdr menu)))
|
||||
menu
|
||||
(car (cdr menu))))
|
||||
'imenu--menubar-select))
|
||||
(setq old (lookup-key (current-local-map) [menu-bar index]))
|
||||
;; This should never happen, but in some odd cases, potentially,
|
||||
;; lookup-key may return a dynamically composed keymap.
|
||||
(if (keymapp (cadr old)) (setq old (cadr old)))
|
||||
(setcdr old (cdr menu1)))))))
|
||||
'imenu--menubar-select)))
|
||||
(setcdr imenu--menubar-keymap (cdr menu1)))))))
|
||||
|
||||
(defun imenu--menubar-select (item)
|
||||
"Use Imenu to select the function or variable named in this menu ITEM."
|
||||
|
|
|
|||
Loading…
Reference in a new issue