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.1.2/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
          "^\\(!\\|\\(.+?\\):[0-9]+:\\) \\|"
          ;; New file
          "(\n?\\([^\n()]+\\)\\|"
          ;; End of file.
          "\\()\\)\\|"
          ;; Hook to change line numbers
          " !\\(?:offset(\\([---0-9]+\\))\\|"
          ;; Hook to change file name
          "name(\\([^)]+\\))\\)\\|"
          ;; Start of LaTeX bad box
          "^\\(\\(?: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
          "^\\(" LaTeX-warnings-regexp ".*\\)"))
        (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 error
         ((match-beginning 1)
          (if (or (not (match-beginning 2))
                  ;; Ignore non-error warning. (bug#55065)
                  (file-exists-p (TeX-match-buffer 2)))
              (progn
                (when (match-beginning 2)
                  (unless TeX-error-file
                    (push nil TeX-error-file)
                    (push nil TeX-error-offset))
                  (unless (car TeX-error-offset)
                    (rplaca TeX-error-file (TeX-match-buffer 2))))
                (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+ (match-beginning 1)))
            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))