+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.
((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
: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