branch: externals/auctex commit 57147c70646594270973364a0130650d419c9b34 Author: Mosè Giordano <m...@gnu.org> Commit: Mosè Giordano <m...@gnu.org>
Another fix for vertical bad box warnings * tex-buf.el (TeX-parse-error): Use different regexps for horizontal and vertical bad boxes, they cannot be handled together. (TeX-warning): Do not move point when a vertical bad box has been found. * tests/tex/compilation-log.txt: Add a test where the parser used to fail to find the file for warnings after a vertical bad box warning. * tests/tex/error-parsing.el: Update result accordingly. --- tests/tex/compilation-log.txt | 14 ++++++++++++++ tests/tex/error-parsing.el | 12 +++++++++++- tex-buf.el | 40 ++++++++++++++++++++++++++++++---------- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/tests/tex/compilation-log.txt b/tests/tex/compilation-log.txt index 3598af4..f3d2b00 100644 --- a/tests/tex/compilation-log.txt +++ b/tests/tex/compilation-log.txt @@ -47,6 +47,20 @@ Overfull \hbox (0.93071pt too wide) detected at line 31 []\T1/jkpl/m/n/10.95 144 ) +(./file name/with spaces.tex +chapter 5. +<use image/an_image.pdf> [82] [83 <./image/an_image.pdf>] [84] [85] [86] (./image/another.tex +<image/another.pdf, id=1357, 208.78pt x 146.5475pt> <use image/another.pdf>) +<image/another2.pdf, id=1358, 542.025pt x 481.8pt> <use image/another2.pdf> +Underfull \vbox (badness 3942) has occurred while \output is active [87 <./image/another.pdf> <./image/another2.pdf>] [88] (./image/beta.tex +<image/beta.pdf, id=1410, 289.08pt x 201.75375pt> +<use image/beta.pdf>) [89] [90 <./image/beta.pdf>] +Overfull \hbox (13.59138pt too wide) in paragraph at lines 367--368 +[]\T1/pplj/m/n/10.95 Un qua-dri-vet-to-re co-va-rian-te $\OMS/zplm/m/n/10.95 f\OML/zplm/m/it/10.95 A[]\OMS/zplm/m/n/10.95 g$ \T1/pplj/m/n/10.95 e un in-sie-me di quat-tro quan-ti-ta $\OT1/zplm/m/n/10.95 (\OML/zplm/m/it/10.95 A[]; A[]; A[]; A[]\OT1/zplm/m/n/10.95 )$ +[91] [92] + +[93]) + LaTeX Warning: There were undefined references. ) diff --git a/tests/tex/error-parsing.el b/tests/tex/error-parsing.el index 170c8bf..2d0f282 100644 --- a/tests/tex/error-parsing.el +++ b/tests/tex/error-parsing.el @@ -100,7 +100,17 @@ ABD: EveryShipout initializing macros" ;; 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) + ;; The line of this warning ends with a new file opened. This test + ;; makes sure point stays exactly at the end of the warning so that + ;; the next the next warning in the list has the right file + ;; (otherwise it would be nil). + (bad-box "./file name/with spaces.tex" nil "Underfull \\vbox (badness 3942) has occurred while \\output is active [87 <./image/another.pdf> <./image/another2.pdf>]" + 0 "\nUnderfull \\vbox (badness 3942) has occurred while \\output is active [87 <./image/another.pdf> <./image/another2.pdf>]" + nil nil t 2142 nil) + (bad-box "./file name/with spaces.tex" 367 "Overfull \\hbox (13.59138pt too wide) in paragraph at lines 367--368" + 0 "\n[]\\T1/pplj/m/n/10.95 Un qua-dri-vet-to-re co-va-rian-te $\\OMS/zplm/m/n/10.95 f\\OML/zplm/m/it/10.95 A[]\\OMS/zplm/m/n/10.95 g$ \\T1/pplj/m/n/10.95 e un in-sie-me di quat-tro quan-ti-ta $\\OT1/zplm/m/n/10.95 (\\OML/zplm/m/it/10.95 A[]; A[]; A[]; A[]\\OT1/zplm/m/n/10.95 )$" "$" + 368 t 2600 nil) (warning "./test.tex" nil "LaTeX Warning: There were undefined references." - 0 "LaTeX Warning: There were undefined references.\n" nil nil nil 1785 nil))))) + 0 "LaTeX Warning: There were undefined references.\n" nil nil nil 2667 nil))))) ;;; error-parsing.el ends here diff --git a/tex-buf.el b/tex-buf.el index 15e9a69..9a3662b 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -2328,9 +2328,12 @@ Return non-nil if an error or warning is found." " !\\(?:offset(\\([---0-9]+\\))\\|" ;; Hook to change file name "name(\\([^)]+\\))\\)\\|" - ;; LaTeX bad box - "^\\(\\(?:Overfull\\|Underfull\\|Tight\\|Loose\\)\ - \\\\[hv]box.*\\)\\|" + ;; Start of LaTeX bad box + "^\\(\\(?:Overfull\\|Underfull\\|Tight\\|Loose\\) " + ;; Horizontal bad box + "\\(?:\\\\hbox.* at lines? [0-9]+\\(?:--[0-9]+\\)?$\\|" + ;; Vertical bad box. See also `TeX-warning'. + "\\\\vbox ([ a-z0-9]+) has occurred while \\\\output is active \\[[^]]+\\]\\)\\)\\|" ;; LaTeX warning "^\\(" LaTeX-warnings-regexp ".*\\)")) (error-found nil)) @@ -2586,8 +2589,25 @@ warning." line)) ;; Find the context - (context-start (progn (if bad-box (end-of-line) - (beginning-of-line)) + (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) @@ -2603,11 +2623,11 @@ warning." (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. + ;; 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