summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2014-10-20 21:33:44 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2014-10-20 21:33:44 -0400
commite538605e4cbc504a0481b2aad0eaf7b9529294d3 (patch)
tree65765fa6b8847c3040bd98e632dfbb8298449462
parenteed18bf1fd1162872e196091ab795a773f277e8e (diff)
* 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.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/imenu.el26
2 files changed, 23 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 448a2e2a75..6e40eab2c1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -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.
@@ -28,6 +32,13 @@
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.
(css-mode-syntax-table): Use d style comment, to ease the scss case.
(css-ident-re): Allow things like @-moz-keyframes.
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 5bad4c09c4..bad3dd1173 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -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."