branch: externals/auctex commit 2e543efcc625e2e8645c934e01d3baf76b104bee Author: Mosè Giordano <m...@gnu.org> Commit: Mosè Giordano <m...@gnu.org>
Fix parsing of vertical bad boxes context * tex-buf.el (TeX-warning): Use as context for vertical bad boxes the warning itself and don't move point. * tests/tex/compilation-log.txt: Add a test for vertical bad boxes, and horizontal bad boxes ending with "at line NN". The two warnings are in two consecutive lines, make sure the second one is correctly reported. * tests/tex/error-parsing.el: Update result of the test accordingly. --- tests/tex/compilation-log.txt | 6 +++++ tests/tex/error-parsing.el | 12 +++++++++- tex-buf.el | 46 +++++++++++++++++++++++++---------------- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/tests/tex/compilation-log.txt b/tests/tex/compilation-log.txt index 2e8e00f..3598af4 100644 --- a/tests/tex/compilation-log.txt +++ b/tests/tex/compilation-log.txt @@ -41,6 +41,12 @@ LaTeX Font Warning: Font shape `OML/cmm/b/it' in size <5.5> not available [1{/opt/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./test.aux) +(./test.lof +Underfull \vbox (badness 1048) has occurred while \output is active [7] +Overfull \hbox (0.93071pt too wide) detected at line 31 + []\T1/jkpl/m/n/10.95 144 +) + LaTeX Warning: There were undefined references. ) diff --git a/tests/tex/error-parsing.el b/tests/tex/error-parsing.el index 979059b..170c8bf 100644 --- a/tests/tex/error-parsing.el +++ b/tests/tex/error-parsing.el @@ -90,7 +90,17 @@ ABD: EveryShipout initializing macros" (warning "./test.tex" 70 "LaTeX Font Warning: Font shape `OML/cmm/b/it' in size <5.5> not available" 0 "LaTeX Font Warning: Font shape `OML/cmm/b/it' in size <5.5> not available (Font) size <5> substituted on input line 70.\n" nil 70 nil 1485 nil) + (bad-box "./test.lof" nil "Underfull \\vbox (badness 1048) has occurred while \\output is active [7]" + 0 "\nUnderfull \\vbox (badness 1048) has occurred while \\output is active [7]" + nil nil t 1651 nil) + ;; It is possible there are two different bad box warnings in two + ;; consecutive lines (for example it happens if the first one is a + ;; vertical bad box which doesn't provide additional information), + ;; this test makes sure the second warning is not mistaken as + ;; context of the first one. + (bad-box "./test.lof" 31 "Overfull \\hbox (0.93071pt too wide) detected at line 31" + 0 "\n []\\T1/jkpl/m/n/10.95 144" "144" 31 t 1733 nil) (warning "./test.tex" nil "LaTeX Warning: There were undefined references." - 0 "LaTeX Warning: There were undefined references.\n" nil nil nil 1616 nil))))) + 0 "LaTeX Warning: There were undefined references.\n" nil nil nil 1785 nil))))) ;;; error-parsing.el ends here diff --git a/tex-buf.el b/tex-buf.el index 052f414..15e9a69 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -2590,24 +2590,34 @@ warning." (beginning-of-line)) (point))) - (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) - (forward-line 1) - (end-of-line)) - (buffer-substring context-start (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. + (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))