changeset 78818:7f83f178a5ef

(tex-compilation-parse-errors): Prefer the filename from `--file-line-error', if it is available.
author Glenn Morris <rgm@gnu.org>
date Mon, 17 Sep 2007 07:01:53 +0000
parents 2ae770e0113d
children 9390b3d333bb
files lisp/textmodes/tex-mode.el
diffstat 1 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/tex-mode.el	Mon Sep 17 07:01:41 2007 +0000
+++ b/lisp/textmodes/tex-mode.el	Mon Sep 17 07:01:53 2007 +0000
@@ -2011,30 +2011,37 @@
 	  (file-name-directory (buffer-file-name tex-last-buffer-texed)))
 	found-desired (num-errors-found 0)
 	last-filename last-linenum last-position
-	begin-of-error end-of-error)
+	begin-of-error end-of-error errfilename)
     ;; Don't reparse messages already seen at last parse.
     (goto-char compilation-parsing-end)
     ;; Parse messages.
     (while (and (not (or found-desired (eobp)))
+		;; First alternative handles the newer --file-line-error style:
+		;; ./test2.tex:14: Too many }'s.
+		;; Second handles the old-style:
+		;; ! Too many }'s.
 		(prog1 (re-search-forward
-			"^\\(?:[^:\n]+:[[:digit:]]+:\\|!\\) " nil 'move)
+			"^\\(?:\\([^:\n]+\\):[[:digit:]]+:\\|!\\) " nil 'move)
 		  (setq begin-of-error (match-beginning 0)
-			end-of-error (match-end 0)))
+			end-of-error (match-end 0)
+			errfilename (match-string 1)))
 		(re-search-forward
 		 "^l\\.\\([0-9]+\\) \\(\\.\\.\\.\\)?\\(.*\\)$" nil 'move))
       (let* ((this-error (copy-marker begin-of-error))
 	     (linenum (string-to-number (match-string 1)))
 	     (error-text (regexp-quote (match-string 3)))
 	     (filename
-	      (save-excursion
-		(with-syntax-table tex-error-parse-syntax-table
-		  (backward-up-list 1)
-		  (skip-syntax-forward "(_")
-		  (while (not (file-readable-p (thing-at-point 'filename)))
-		    (skip-syntax-backward "(_")
-		    (backward-up-list 1)
-		    (skip-syntax-forward "(_"))
-		  (thing-at-point 'filename))))
+	      ;; Prefer --file-liner-error filename if we have it.
+	      (or errfilename
+		  (save-excursion
+		    (with-syntax-table tex-error-parse-syntax-table
+		      (backward-up-list 1)
+		      (skip-syntax-forward "(_")
+		      (while (not (file-readable-p (thing-at-point 'filename)))
+			(skip-syntax-backward "(_")
+			(backward-up-list 1)
+			(skip-syntax-forward "(_"))
+		      (thing-at-point 'filename)))))
 	     (new-file
 	      (or (null last-filename)
 		  (not (string-equal last-filename filename))))