]> code.delx.au - gnu-emacs/commitdiff
* textmodes/reftex-vars.el
authorTassilo Horn <tsdh@gnu.org>
Thu, 25 Apr 2013 12:01:09 +0000 (14:01 +0200)
committerTassilo Horn <tsdh@gnu.org>
Thu, 25 Apr 2013 12:01:09 +0000 (14:01 +0200)
(reftex-label-ignored-macros-and-environments): New defcustom.

* textmodes/reftex-parse.el (reftex-parse-from-file): Use it.

lisp/ChangeLog
lisp/textmodes/reftex-parse.el
lisp/textmodes/reftex-vars.el

index 7bce53d7caf978ba47f0e0b521ea7f454a863b00..e8933ee7c8323a4cc9b0d41093d23a4f57b8d4ac 100644 (file)
@@ -1,3 +1,10 @@
+2013-04-25  Tassilo Horn  <tsdh@gnu.org>
+
+       * textmodes/reftex-vars.el
+       (reftex-label-ignored-macros-and-environments): New defcustom.
+
+       * textmodes/reftex-parse.el (reftex-parse-from-file): Use it.
+
 2013-04-25  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * emacs-lisp/smie.el (smie-indent--hanging-p): Don't burp at EOB.
index a86b10e21cc1a4bc1b788fa01432f025b289e078..6bfc70c5d44278fc61c3e211874b9ee2433fd5bc 100644 (file)
@@ -234,8 +234,18 @@ of master file."
 
                 ((match-end 1)
                  ;; It is a label
-                 (push (reftex-label-info (reftex-match-string 1) file bound)
-                       docstruct))
+                (when (or (null reftex-label-ignored-macros-and-environments)
+                          ;; \label{} defs should always be honored,
+                          ;; just no keyval style [label=foo] defs.
+                          (string-equal "\label{" (substring (reftex-match-string 0) 0 7))
+                          (not (fboundp 'TeX-current-macro))
+                          (not (fboundp 'LaTeX-current-environment))
+                          (not (or (member (save-match-data (TeX-current-macro))
+                                           reftex-label-ignored-macros-and-environments)
+                                   (member (save-match-data (LaTeX-current-environment))
+                                           reftex-label-ignored-macros-and-environments))))
+                  (push (reftex-label-info (reftex-match-string 1) file bound)
+                        docstruct)))
 
                 ((match-end 3)
                  ;; It is a section
index 7343d86b06fc9f6955df7e5f20dc1900bcccc107..ab085a3085a4e7eb59ec982a860625d743cfbe5b 100644 (file)
@@ -885,6 +885,25 @@ effective."
   :group 'reftex-defining-label-environments
   :type '(repeat (regexp :tag "Regular Expression")))
 
+(defcustom reftex-label-ignored-macros-and-environments nil
+  "List of macros and environments to be ignored when searching for labels.
+The purpose is to ignore environments and macros that use keyval
+style label=foo arguments, but the label has a different meaning
+than a \\label{foo}.  Standard \\label{...} definitions are never
+ignored.
+
+E.g., TikZ defines several macros/environments where [label=foo]
+defines the label to be printed at some node or edge, but it's
+not a label used for referencing.
+
+Note that this feature is only supported if you are using AUCTeX
+and the functions `TeX-current-macro' and
+`LaTeX-current-environment' are bound.  Also note that this
+feature might slow down the reftex parsing process for large TeX
+files."
+  :group 'reftex-defining-label-environments
+  :type '(repeat string))
+
 (defcustom reftex-label-illegal-re "[^-a-zA-Z0-9_+=:;,.]"
   "Regexp matching characters not valid in labels."
   :group 'reftex-making-and-inserting-labels