Merge from emacs-24; up to 2012-12-27T20:09:45Z!juri@jurta.org
[bpt/emacs.git] / lisp / textmodes / reftex-parse.el
index a86b10e..3a64aad 100644 (file)
@@ -234,8 +234,19 @@ 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))
+                           (if (and (fboundp 'TeX-current-macro)
+                                    (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)))
+                             t))
+                  (push (reftex-label-info (reftex-match-string 1) file bound)
+                        docstruct)))
 
                 ((match-end 3)
                  ;; It is a section
@@ -349,9 +360,9 @@ of master file."
 ;           "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
             "\\(^\\)[^%\n\r]*\\\\\\("
             (mapconcat 'identity reftex-bibliography-commands "\\|")
-            "\\){[ \t]*\\([^}]+\\)") nil t)
+            "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)") nil t)
           (setq files
-                (split-string (reftex-match-string 3)
+                (split-string (reftex-match-string 4)
                               "[ \t\n\r]*,[ \t\n\r]*")))))
   (when files
     (setq files