diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2013-11-24 23:23:47 +0200 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2013-11-24 23:23:47 +0200 |
commit | ee4f026188438f2531364fb042af91b427c0b944 (patch) | |
tree | 9906d9a6dbd4c40e1a4b816df02ecfdf66c78fc5 /lisp/imenu.el | |
parent | 740bcff0c1de06859c8139dd8e23e82aa28401a0 (diff) | |
download | emacs-ee4f026188438f2531364fb042af91b427c0b944.tar.gz |
* lisp/imenu.el (imenu-generic-skip-comments-and-strings):
New option.
(imenu--generic-function): Use it.
Fixes: debbugs:15560
Diffstat (limited to 'lisp/imenu.el')
-rw-r--r-- | lisp/imenu.el | 11 |
1 files changed, 10 insertions, 1 deletions
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 |