Function: TeX-warning
TeX-warning is a byte-compiled function defined in tex.el.
Signature
(TeX-warning WARNING WARNING-START BAD-BOX &optional STORE)
Documentation
Display a warning for WARNING.
WARNING-START is the position where WARNING starts. If BAD-BOX is non-nil, the warning refers to a bad-box, otherwise it is a generic warning.
If optional argument STORE is non-nil, store the warning
information in TeX-error-list instead of displaying the
warning.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-warning (warning warning-start bad-box &optional store)
"Display a warning for WARNING.
WARNING-START is the position where WARNING starts. If BAD-BOX
is non-nil, the warning refers to a bad-box, otherwise it is a
generic warning.
If optional argument STORE is non-nil, store the warning
information in `TeX-error-list' instead of displaying the
warning."
(let* ( ;; line-string: match 1 is beginning line, match 2 is end line
(line-string (if bad-box
"at lines? \\([0-9]*\\)\\(?:--\\([0-9]*\\)\\)?"
;; Traditional messages say "on input line X",
;; the LaTeX3 \msg_line_context:. just reads
;; "on line X".
"on \\(?:input \\)?line \\([0-9]*\\)\\."))
;; word-string: match 1 is the word
(word-string (if bad-box "[][\\W() ---]\\(\\w+\\)[][\\W() ---]*$"
;; Match "ref" in both "Reference `ref' on page NN
;; undefined" and "Citation 'ref' on page NN undefined".
"\\(?:`\\|'\\)\\([-a-zA-Z0-9:]+\\)'"))
;; Get error-line (warning). Don't search before `warning-start' to
;; avoid catching completely unrelated line numbers.
(line (when (save-excursion (re-search-backward line-string
warning-start t))
(string-to-number (TeX-match-buffer 1))))
;; If this is a bad box and the warning ends with "...at lines MM--NN"
;; we can use "NN" as `line-end', in any other case (including bad
;; boxes ending with "...at line NN") just use `line'.
(line-end (if (and bad-box (match-beginning 2))
(string-to-number (TeX-match-buffer 2))
line))
;; Find the context
(context-start (progn (cond
((and bad-box (string-match "\\\\hbox" warning))
;; Horizontal bad box
(end-of-line))
(bad-box
;; Vertical bad box (by exclusion), don't move
;; point. In the output buffer, unlike in the
;; actual *.log file, these warnings do not end
;; with "...is active []", but in the same line
;; there may be something else, including a new
;; file opened. Thus, point shouldn't move
;; from the end of the actual bad box warning.
;; This is why the corresponding regexp in
;; `TeX-parse-error' doesn't match everything
;; until the end of the line.
nil)
(t
;; Generic warning.
(beginning-of-line)))
(point)))
(context (cond ((string-match LaTeX-warnings-regexp warning)
;; The warnings matching `LaTeX-warnings-regexp' are
;; emitted by \GenericWarning macro, or macros based on
;; it (\ClassWarning, \PackageWarning, etc). After
;; such warnings there is an empty line, just look for
;; it to find the end.
(beginning-of-line)
(while (null (eolp))
(forward-line 1))
(buffer-substring context-start (progn (end-of-line)
(point))))
((and bad-box (string-match "\\\\vbox" warning))
;; Vertical bad boxes don't provide any additional
;; information. In this case, reuse the `warning' as
;; `context' and don't move point, so that we avoid
;; eating the next line that may contain another
;; warning. See also comment for `context-start'.
(concat "\n" warning))
(t
;; Horizontal bad boxes.
(forward-line 1)
(end-of-line)
(while (equal (current-column) 79)
(forward-line 1)
(end-of-line))
(buffer-substring context-start (point)))))
;; This is where we want to be.
(error-point (point))
;; Now find the error word.
(string (when (save-excursion
(re-search-backward word-string context-start t))
(TeX-match-buffer 1)))
;; We might use these in another file.
(offset (or (car TeX-error-offset) 0))
(file (car TeX-error-file))
info-list ignore)
;; Second chance to get line number right. If `line' is nil, check whether
;; the reference to the line number is in `context'. For example, this is
;; the case for warnings emitted with \ClassWarning and \PackageWarning.
;; XXX: maybe it suffices to evaluate `line' after `context' above, but I
;; don't know if there are cases in which it's important to get `line'
;; before `context'.
(and (null line)
(string-match line-string context)
(setq line-end
(setq line (and (match-beginning 1)
(string-to-number (match-string 1 context))))))
;; This is where we start next time.
(goto-char error-point)
(setq TeX-error-point (point))
;; Explanation of what follows: we add the warning to `TeX-error-list' even
;; if it has to be ignored, with a flag specifying whether it is ignored.
;; We do so in order to be able to change between "ignore" and "dont-ignore"
;; behavior by just looking to the flag, without the need to reparse the
;; output log.
;; Store the list of information about the warning.
(setq info-list (list (if bad-box 'bad-box 'warning) file line warning
offset context string line-end bad-box
TeX-error-point)
;; Decide whether it should be ignored.
ignore (and TeX-ignore-warnings
(cond
((stringp TeX-ignore-warnings)
(string-match TeX-ignore-warnings warning))
((fboundp TeX-ignore-warnings)
(apply TeX-ignore-warnings info-list))))
;; Update `info-list'.
info-list (append info-list (list ignore)))
(if store
;; Store the warning information.
(add-to-list 'TeX-error-list info-list t)
;; Find the warning point and display the help.
(apply #'TeX-find-display-help info-list))))