summaryrefslogtreecommitdiff
path: root/lisp/imenu.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/imenu.el')
-rw-r--r--lisp/imenu.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 8363956355b..08e6338b39e 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -800,7 +800,17 @@ depending on PATTERNS."
(goto-char (point-max))
(while (and (if (functionp regexp)
(funcall regexp)
- (re-search-backward regexp nil t))
+ (and
+ (re-search-backward regexp nil t)
+ ;; Do not count invisible definitions.
+ (let ((invis (invisible-p (point))))
+ (or (not invis)
+ (progn
+ (while (and invis
+ (not (bobp)))
+ (setq invis (not (re-search-backward
+ regexp nil 'move))))
+ (not invis))))))
;; Exit the loop if we get an empty match,
;; because it means a bad regexp was specified.
(not (= (match-beginning 0) (match-end 0))))
@@ -963,7 +973,8 @@ See the command `imenu' for more information."
imenu-generic-expression
(not (eq imenu-create-index-function
'imenu-default-create-index-function)))
- (unless (keymapp (lookup-key (current-local-map) [menu-bar index]))
+ (unless (and (current-local-map)
+ (keymapp (lookup-key (current-local-map) [menu-bar index])))
(let ((newmap (make-sparse-keymap)))
(set-keymap-parent newmap (current-local-map))
(setq imenu--last-menubar-index-alist nil)