]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/imenu.el (imenu-generic-skip-comments-and-strings):
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 24 Nov 2013 21:23:47 +0000 (23:23 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 24 Nov 2013 21:23:47 +0000 (23:23 +0200)
New option.
(imenu--generic-function): Use it.

Fixes: debbugs:15560
etc/NEWS
lisp/ChangeLog
lisp/imenu.el

index dcb2e614d465cbaaaadcc6ba21f7e94f01e449c9..6cff14d27423b4c77ee73f34b6a76c1b3c021abd 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -639,6 +639,10 @@ whether it is safe to use Bash's --noediting option.  These days
 +++
 ** There is a new macro `skip-unless' for skipping ERT tests.  See the manual.
 
+** Imenu
+
+*** New option `imenu-generic-skip-comments-and-strings'.
+
 \f
 * New Modes and Packages in Emacs 24.4
 
index 286a32cbf7dfedbfc3592bb5e38ab8ac341d066a..36c4c6ae4e8dc03526c17dddd171b20f264deb2d 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-24  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * imenu.el (imenu-generic-skip-comments-and-strings):
+       New option (Bug#15560).
+       (imenu--generic-function): Use it.
+
 2013-11-24  Jorgen Schaefer  <contact@jorgenschaefer.de>
 
        * minibuffer.el (completion--in-region-1): Scroll the correct
index d79b0abeebcbbe5f63f90992530613175be54c71..f41fcda2713df71f99c2149b98217578cd37e9a6 100644 (file)
@@ -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