From ee4f026188438f2531364fb042af91b427c0b944 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 24 Nov 2013 23:23:47 +0200 Subject: * lisp/imenu.el (imenu-generic-skip-comments-and-strings): New option. (imenu--generic-function): Use it. Fixes: debbugs:15560 --- lisp/imenu.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lisp/imenu.el') diff --git a/lisp/imenu.el b/lisp/imenu.el index d79b0abeebc..f41fcda2713 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -185,6 +185,13 @@ with name concatenation." :type 'string :group 'imenu) +(defcustom imenu-generic-skip-comments-and-strings t + "When non-nil, ignore text inside comments and strings. +Only affects `imenu--generic-function'." + :type 'boolean + :group 'imenu + :version "24.4") + ;;;###autoload (defvar imenu-generic-expression nil "List of definition matchers for creating an Imenu index. @@ -796,7 +803,9 @@ depending on PATTERNS." ;; starting with its title (or nil). (menu (assoc menu-title index-alist))) ;; Insert the item unless it is already present. - (unless (member item (cdr menu)) + (unless (or (member item (cdr menu)) + (and imenu-generic-skip-comments-and-strings + (nth 8 (syntax-ppss)))) (setcdr menu (cons item (cdr menu))))) ;; Go to the start of the match, to make sure we -- cgit v1.2.1