Function: TeX-TeX-sentinel-check

TeX-TeX-sentinel-check is a byte-compiled function defined in tex.el.

Signature

(TeX-TeX-sentinel-check PROCESS NAME)

Documentation

Cleanup TeX output buffer after running TeX.

Return nil only if no errors were found.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-TeX-sentinel-check (process name)
  "Cleanup TeX output buffer after running TeX.
Return nil only if no errors were found."
  (save-excursion
    (goto-char (point-max))
    (cond
     ((and (string-match "ConTeXt" name) (boundp 'ConTeXt-Mark-version)
           (with-current-buffer TeX-command-buffer
             (string= ConTeXt-Mark-version "IV")))
      (when (re-search-backward " > result saved in file: \\(.*?\\), " nil t)
        (let ((output-file (TeX-match-buffer 1)))
          ;; Shave off quotation marks if present.
          (when (string-match "\\`\"\\(.*\\)\"\\'" output-file)
            (setq output-file (match-string 1 output-file)))
          (setq TeX-output-extension
                (if (string-match "\\.\\([^.]*\\)$" output-file)
                    (match-string 1 output-file)
                  "dvi")))
        (if (re-search-forward ", \\([0-9]+\\) shipped pages, " nil t)
            (setq TeX-current-page (concat "{" (TeX-match-buffer 1) "}")))))
     (t
      (if (re-search-backward "^Output written on \\(.*?\\) (\\([0-9]+\\) page"
                              nil t)
          (let ((output-file (TeX-match-buffer 1)))
            (setq TeX-current-page (concat "{" (TeX-match-buffer 2) "}"))
            ;; Shave off quotation marks if present.
            (when (string-match "\\`\"\\(.*\\)\"\\'" output-file)
              (setq output-file (match-string 1 output-file)))
            (setq TeX-output-extension
                  (if (string-match "\\.\\([^.]*\\)$" output-file)
                      (match-string 1 output-file)
                    "dvi")))))))
  (if process (TeX-format-mode-line process))
  (if (catch 'found
        (while (and (re-search-forward "^\\(?:!\\|\\(.+?\\):[0-9]+:\\) " nil t)
                    (not (looking-at-p
                          (mapconcat #'identity
                                     '("ignored error: "
                                       "Infinite glue shrinkage found in box being split")
                                     "\\|"))))
          (if (or (not (match-beginning 1))
                  ;; Ignore non-error warning. (bug#55065)
                  (file-exists-p (TeX-match-buffer 1)))
              (throw 'found t))))
      (progn
        (if TeX-error-overview-open-after-TeX-run
            ;; Don't leave inconsistent message.
            (message nil)
          (message "%s errors in `%s'. Use %s to display." name (buffer-name)
                   (substitute-command-keys
                    "\\<TeX-mode-map>\\[TeX-next-error]")))
        (setq TeX-command-next TeX-command-default)
        ;; error reported to TeX-error-report-switches
        (setq TeX-error-report-switches
              (plist-put TeX-error-report-switches
                         (intern (plist-get TeX-error-report-switches
                                            'TeX-current-master))
                         t))
        t)
    ;; In case that there were only non-error warnings of type
    ;; bug#55065, restore point to the initial position.
    (goto-char (point-min))
    (let (dvi2pdf)
      (if (with-current-buffer TeX-command-buffer
            (and TeX-PDF-mode (setq dvi2pdf (TeX-PDF-from-DVI))))
          (setq TeX-command-next dvi2pdf)
        (setq TeX-command-next TeX-command-Show)))
    nil))