branch: externals/auctex
commit 2c21439771b038682814b239dfba0b8d799d487c
Author: Mosè Giordano <[email protected]>
Commit: Mosè Giordano <[email protected]>
Improve parsing of certain warnings
* tex-buf.el (TeX-warning): Get full context and line numbers for
warnings matching `LaTeX-warnings-regexp'.
* tests/tex/compilation-log.txt: Add example warnings for this case.
* tests/tex/error-parsing.el: Update result of test accordingly.
---
tests/tex/compilation-log.txt | 36 +++++++++++++++++++++++++++++++++---
tests/tex/error-parsing.el | 40 ++++++++++++++++++++++++++++++++++++----
tex-buf.el | 24 +++++++++++++++++++++++-
3 files changed, 92 insertions(+), 8 deletions(-)
diff --git a/tests/tex/compilation-log.txt b/tests/tex/compilation-log.txt
index 98b3422..f97b300 100644
--- a/tests/tex/compilation-log.txt
+++ b/tests/tex/compilation-log.txt
@@ -1,13 +1,43 @@
-(./test.tex
+(./test.tex (./nice-class.cls
+Document Class: nice-class 1970/01/01 v42 A good class
+
+Package nice-class Warning: ******************************************
+(nice-class) * THIS IS JUST A WARNING WITH A PESKY
+(nice-class) * UNMATCHED CLOSED PARENTHESIS :-)
+(nice-class) ****************************************** on
input line 32.
+
+)
+
(/opt/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
-Package foo Warning: This is a warning!
+./test.tex:2: Class nice-class Error: ***********************************
+(nice-class) * This is a very bad error!
+(nice-class) ************************************.
+
+See the suftesi class documentation for explanation.
+Type H <return> for immediate help.
+ ...
+
+l.2 \begin{document}
+
+(/other/packages/loaded.sty)
+ABD: EveryShipout initializing macros
+
+Package foo Warning: This is a warning! on input line 3.
[1{/opt/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./test.aux)
(./secondary-file.tex [8] [9] [10]
Underfull \hbox (badness 6608) in paragraph at lines 131--132
[]|\T1/jkpl/m/n/10.95 (+20) Something bla
-[11] [12]))
+[11] [12])
+
+LaTeX Warning: Reference `wrong' on page 1 undefined on input line 4.
+
+[1{/opt/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./test.aux)
+
+LaTeX Warning: There were undefined references.
+
+)
diff --git a/tests/tex/error-parsing.el b/tests/tex/error-parsing.el
index ce09750..b826fc3 100644
--- a/tests/tex/error-parsing.el
+++ b/tests/tex/error-parsing.el
@@ -49,13 +49,45 @@ command line and from another directory."
(insert-file-contents TeX-test-compilation-log)
(TeX-parse-all-errors)
TeX-error-list)
- '((warning "./test.tex" nil "Package foo Warning: This is a warning!"
- 0 "Package foo Warning: This is a warning!\n"
- nil nil nil 170)
+ '((warning
+ "./nice-class.cls" 32
+ "Package nice-class Warning:
******************************************"
+ 0
+ "Package nice-class Warning:
******************************************
+(nice-class) * THIS IS JUST A WARNING WITH A PESKY
+(nice-class) * UNMATCHED CLOSED PARENTHESIS :-)
+(nice-class) ****************************************** on
input line 32.\n"
+ nil 32 nil 376)
+ (error
+ "./test.tex" 2
+ "Class nice-class Error: ***********************************" 0
+ "\n(nice-class) * This is a very bad error!
+(nice-class) ************************************.
+
+See the suftesi class documentation for explanation.
+Type H <return> for immediate help.
+ ...
+
+l.2 \\begin{document}
+
+(/other/packages/loaded.sty)
+ABD: EveryShipout initializing macros"
+ "\\begin{document}\n\n(/other/packages/loaded.sty)" nil nil 971)
+ (warning "./test.tex" 3
+ "Package foo Warning: This is a warning! on input line 3." 0
+ "Package foo Warning: This is a warning! on input line 3.\n"
+ nil 3 nil 1030)
(bad-box
"./secondary-file.tex" 131
"Underfull \\hbox (badness 6608) in paragraph at lines 131--132"
0 "\n[]|\\T1/jkpl/m/n/10.95 (+20) Something bla" "bla"
- 132 10 391)))))
+ 132 10 1251)
+ (warning "./test.tex" 4
+ "LaTeX Warning: Reference `wrong' on page 1 undefined on input
line 4."
+ 0
+ "LaTeX Warning: Reference `wrong' on page 1 undefined on input
line 4.\n"
+ "wrong" 4 nil 1334)
+ (warning "./test.tex" 4 "LaTeX Warning: There were undefined
references."
+ 0 "LaTeX Warning: There were undefined references.\n" nil 4 nil
1465)))))
;;; error-parsing.el ends here
diff --git a/tex-buf.el b/tex-buf.el
index 0d924c7..3ba1f87 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -2510,7 +2510,18 @@ warning."
(beginning-of-line))
(point)))
- (context (progn
+ (context (if (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.
+ (progn
+ (beginning-of-line)
+ (while (null (eolp))
+ (forward-line 1))
+ (buffer-substring context-start (progn (end-of-line)
+ (point))))
(forward-line 1)
(end-of-line)
(while (equal (current-column) 79)
@@ -2530,6 +2541,17 @@ warning."
(offset (or (car TeX-error-offset) 0))
(file (car TeX-error-file)))
+ ;; 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 (string-to-number (match-string 1 context)))))
+
;; This is where we start next time.
(goto-char error-point)
(setq TeX-error-point (point))