Function: TeX-error

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

Signature

(TeX-error &optional STORE)

Documentation

Display an error.

If optional argument STORE is non-nil, store the error information in TeX-error-list instead of displaying the error.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-error (&optional store)
  "Display an error.

If optional argument STORE is non-nil, store the error
information in `TeX-error-list' instead of displaying the error."

  (let* ( ;; We need the error message to show the user.
         (error (progn
                  (re-search-forward "\\(.*\\)")
                  (TeX-match-buffer 1)))

         ;; And the context for the help window.
         (context-start (point))
         context-available

         ;; And the line number to position the cursor.
         (line (cond
                ;; regular style
                ((re-search-forward "l\\.\\([0-9]+\\)" nil t)
                 (setq context-available t)
                 (string-to-number (TeX-match-buffer 1)))
                ;; file:line:error style
                ((save-excursion
                   (re-search-backward ":\\([0-9]+\\): "
                                       (line-beginning-position) t))
                 (string-to-number (TeX-match-buffer 1)))
                ;; nothing found
                (t 1)))

         ;; And a string of the context to search for.
         (string (progn
                   (beginning-of-line)
                   (re-search-forward " \\(\\([^ \t]*$\\)\\|\\($\\)\\)")
                   (TeX-match-buffer 1)))

         ;; And we have now found to the end of the context.
         (context (if context-available
                      (buffer-substring context-start (progn (forward-line 1)
                                                             (end-of-line)
                                                             (point)))
                    ;; There is no real context available, so we
                    ;; simply show the line with the error message.
                    (buffer-substring (1- (line-beginning-position))
                                      context-start)))
         ;; We may use these in another buffer.
         (offset (or (car TeX-error-offset) 0))
         (file (car TeX-error-file))
         info-list)

    ;; Remember where we was.
    (setq TeX-error-point (point)
          info-list (list 'error file line error offset context string nil nil
                          TeX-error-point nil))
    (if store
        ;; Store the error information.
        (add-to-list 'TeX-error-list info-list t)
      ;; Find the error point and display the help.
      (apply #'TeX-find-display-help info-list))))