Function: TeX-parse-error
TeX-parse-error is a byte-compiled function defined in tex.el.
Signature
(TeX-parse-error OLD &optional STORE)
Documentation
Goto next error. Pop to OLD buffer if no more errors are found.
If the optional argument STORE is non-nil, the function will
store the found warning or error in TeX-error-list instead of
displaying the issue.
Return non-nil if an error or warning is found.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.2.0/tex.el
(defun TeX-parse-error (old &optional store)
"Goto next error. Pop to OLD buffer if no more errors are found.
If the optional argument STORE is non-nil, the function will
store the found warning or error in `TeX-error-list' instead of
displaying the issue.
Return non-nil if an error or warning is found."
(let ((regexp
(concat
;; TeX error: (1) or
;; LaTeX error: grab (2) filename
"^\\(! \\)\\|^\\(.+?\\):[0-9]+: \\|"
;; New file (or parenthesized comment): match 3
"(\n?\\([^\n()]+\\)\\|"
;; End of file (or comment): "match" 4
"\\()\\)\\|"
;; Hook to change line numbers: match 5
" !\\(?:offset(\\([---0-9]+\\))\\|"
;; Hook to change file name: match 6
"name(\\([^)]+\\))\\)\\|"
;; Start of LaTeX bad box: match 7
"^\\(\\(?:Overfull\\|Underfull\\|Tight\\|Loose\\) "
;; Horizontal bad box
"\\(?:\\\\hbox.* at lines? [0-9]+\\(?:--[0-9]+\\)?$\\|"
;; Vertical bad box. See also `TeX-warning'.
"\\\\vbox ([ a-z0-9]+) has occurred while \\\\output is active \\[[^]]+\\]\\)\\)\\|"
;; LaTeX warning: match 8
"^\\(" LaTeX-warnings-regexp ".*\\)"
;; ConTeXt LMTX error; sample output line:
;; tex error > tex error on line 5 in file ./bbb.tex: ! Undefined control sequence
;; Grab (9) entire line and (10) filename
"\\|^\\(tex error .* in file \\([^:]*\\): \\)"))
(error-found nil))
(while
(cond
((null
(re-search-forward regexp nil t))
;; No more errors.
(unless store
(message "No more errors.")
(beep)
(TeX-pop-to-buffer old))
nil)
;; TeX (1), LaTeX (2) or ConTeXt LMTX (9) error:
((or (match-beginning 1) (match-beginning 2) (match-beginning 9))
(if (or
;; When we have "! " at BOL, treat it as an error
;; unconditionally.
(match-beginning 1)
;; Ignore non-error warning. (bug#55065)
(file-exists-p (TeX-match-buffer
(if (match-beginning 2)
2 10))))
(progn
(when (or (match-beginning 2)
(match-beginning 10))
(unless TeX-error-file
(push nil TeX-error-file)
(push nil TeX-error-offset))
(unless (car TeX-error-offset)
;; match 2 or 10 is the .tex file name.
(rplaca TeX-error-file
(TeX-match-buffer
(if (match-beginning 2)
2 10)))))
(setq error-found t)
(if (looking-at "Preview ")
t
(TeX-error store)
nil))
;; This wasn't an actual TeX error. Go to the least
;; possible point to search again.
(goto-char (1+ (or (match-beginning 2)
(match-beginning 9))))
t))
;; LaTeX bad box
((match-beginning 7)
;; In `TeX-error-list' we collect all warnings, also if they're going
;; to be actually skipped.
(if (or store TeX-debug-bad-boxes)
(progn
(setq error-found t)
(TeX-warning (TeX-match-buffer 7) (match-beginning 7) t store)
nil)
(re-search-forward "\r?\n\
\\(?:.\\{79\\}\r?\n\
\\)*.*\r?$")
t))
;; LaTeX warning
((match-beginning 8)
;; In `TeX-error-list' we collect all warnings, also if they're going
;; to be actually skipped.
(if (or store TeX-debug-warnings)
(progn
(setq error-found t)
(TeX-warning (TeX-match-buffer 8) (match-beginning 8) nil store)
nil)
t))
;; New file -- Push on stack
((match-beginning 3)
(let ((file (TeX-match-buffer 3))
(end (match-end 3)))
;; Strip quotation marks and remove newlines if necessary
(when (or (eq (string-to-char file) ?\")
(string-match "[ \t\n]" file))
(setq file (mapconcat #'identity (split-string file "[\"\n]+") "")))
;; Polish `file' string
(setq file
(let ((string file))
(setq string
(if (string-match "\\`[ \t\n\r]+" string)
(replace-match "" t t string)
string))
;; Sometimes `file' is something like
;; "./path/to/file.tex [9] [10 <./path/to/file>] "
;; where "[9]" and "[10 <./path/to/file>]" are pages of the
;; output file, with path to an included file. Remove these
;; numbers together with whitespaces at the end of the
;; string.
(if (string-match "\\( *\\(\\[[^]]+\\]\\)? *\\)*\\'" string)
(replace-match "" t t string)
string)))
(push file TeX-error-file)
(push nil TeX-error-offset)
(goto-char end))
t)
;; End of file -- Pop from stack
((match-beginning 4)
(when (> (length TeX-error-file) 0)
(pop TeX-error-file)
(pop TeX-error-offset))
(goto-char (match-end 4))
t)
;; Hook to change line numbers
((match-beginning 5)
(setq TeX-error-offset
(list (string-to-number (TeX-match-buffer 5))))
t)
;; Hook to change file name
((match-beginning 6)
(setq TeX-error-file
(list (TeX-match-buffer 6)))
t)))
error-found))