From 3d1634c64adf1e62d51e050e3300e682d2e20790 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 17 Sep 2007 07:04:46 +0000 Subject: [PATCH] (tex-compilation-parse-errors): Prefer the filename from `--file-line-error', if it is available. --- lisp/textmodes/tex-mode.el | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 85cb77b69c..5999586bd1 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -2032,30 +2032,37 @@ for the error messages." (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)))) -- 2.20.1