[Please don't use auc-tex at sunsite.dk. The mailing list for general
discussion of AUCTeX moved in March to auctex at gnu.org.]
* Akim Demaille (2005-11-04) writes:
> I would love to have AUC-TeX provide a means to capture warnings just
> as it provides support for bad box warnings. For instance:
>
> LaTeX Warning: Reference `grm.pda.nsupm' on page 123 undefined on input line
> 50
> 8.
>
> LaTeX Warning: \oval, \circle, or \line size unavailable on input line 170.
>
> Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
> (hyperref) removing `math shift' on input line 1453.
AUCTeX should be able to jump to the first two warnings if you enable
`TeX-debug-bad-boxes' e.g. with `C-c C-w'. The hyperref warning will
not be recognized. Also, warnings without line numbers won't be
recognized. And what I found rather a pity is that AUCTeX does not
inform the user if warnings or bad boxes where found.
The attached patch (against CVS) will remedy some of these problems
and do some more:
* Display of warnings or bad boxes can be enabled and disabled
independently of each other. This can come handy if you have a
document with many overfull or underfull boxes and want to debug
warnings other than those.
* After running LaTeX the user will be informed if warnings or bad
boxes were found if the respective options `TeX-debug-bad-boxes'
or `TeX-debug-warnings' are enabled.
* Warnings without line numbers and warnings issued by packages will
be found as well. You can check that e.g. by defining two
identical labels. (Display of the .aux file might not be too
informative, though.)
The patch is not perfect yet because e.g. it is not able to determine
the line number in multi-line warnings like the one by hyperref shown
above. This will probably be a bit harder to do.
If somebody wants to start a bikeshed discussion we could argue about
a key binding for toggling this feature. (Toggling is not part of the
patch yet.) I'd like to see `C-c C-t C-w' for toggling warnings and
`C-c C-t C-b' for toggling bad boxes. Ideally `C-c C-w' would be
thrown out of the window (sooner or later).
What I'd really like to see is an error/warning overview buffer as
suggested before. Something like that would probably be easier to do
if compile.el offered it ready to be used by other libraries.
--
Ralf
Index: tex-buf.el
===================================================================
RCS file: /cvsroot/auctex/auctex/tex-buf.el,v
retrieving revision 1.239
diff -u -r1.239 tex-buf.el
--- tex-buf.el 13 Oct 2005 11:02:27 -0000 1.239
+++ tex-buf.el 5 Nov 2005 12:49:29 -0000
@@ -888,6 +888,20 @@
(setq TeX-command-next TeX-command-Show)
nil))
+(defun TeX-LaTeX-sentinel-has-warnings ()
+ "Return non-nil, if the output buffer contains warnings.
+Warnings can be indicated by LaTeX or packages."
+ (save-excursion
+ (goto-char (point-min))
+ (re-search-forward
+ "^\\(LaTeX [A-Za-z]*\\|Package [A-Za-z]+ \\)Warning:" nil t)))
+
+(defun TeX-LaTeX-sentinel-has-bad-boxes ()
+ "Return non-nil, if LaTeX output indicates overfull or underfull boxes."
+ (save-excursion
+ (goto-char (point-min))
+ (re-search-forward "^\\(Ov\\|Und\\)erfull \\\\" nil t)))
+
;; should go into latex.el? --pg
(defun TeX-LaTeX-sentinel (process name)
"Cleanup TeX output buffer after running LaTeX."
@@ -925,8 +939,18 @@
(setq TeX-command-next TeX-command-Show))
((re-search-forward
"^\\(\\*\\* \\)?J?I?p?\\(La\\|Sli\\)TeX\\(2e\\)? \\(Version\\|ver\\.\\|<[0-9/]*>\\)" nil t)
- (message (concat name ": successfully formatted "
- (TeX-current-pages)))
+ (let* ((warnings (and TeX-debug-warnings
+ (TeX-LaTeX-sentinel-has-warnings)))
+ (bad-boxes (and TeX-debug-bad-boxes
+ (TeX-LaTeX-sentinel-has-bad-boxes)))
+ (add-info (when (or warnings bad-boxes)
+ (concat " (with "
+ (when warnings "warnings")
+ (when (and warnings bad-boxes) " and ")
+ (when bad-boxes "bad boxes")
+ ")"))))
+ (message (concat name ": successfully formatted "
+ (TeX-current-pages) add-info)))
(setq TeX-command-next TeX-command-Show))
(t
(message (concat name ": problems after "
@@ -1344,16 +1368,20 @@
"Goto next error. Pop to OLD buffer if no more errors are found."
(while
(progn
- (re-search-forward (concat "\\("
- "^! \\|"
- "(\\|"
- ")\\|"
- "\\'\\|"
- "!offset([---0-9]*)\\|"
- "!name([^)]*)\\|"
- "^.*erfull \\\\.*[0-9]*--[0-9]*\\|"
- "^LaTeX Warning: .*[0-9]+\\.$"
- "\\)"))
+ (re-search-forward
+ (concat "\\("
+ "^! \\|"
+ "(\\|"
+ ")\\|"
+ "\\'\\|"
+ "!offset([---0-9]*)\\|"
+ "!name([^)]*)\\|"
+ (when TeX-debug-bad-boxes
+ "^.*erfull \\\\.*[0-9]*--[0-9]*")
+ (when (and TeX-debug-bad-boxes TeX-debug-warnings) "\\|")
+ (when TeX-debug-warnings
+ "^\\(LaTeX [A-Za-z]*\\|Package [A-Za-z]+ \\)Warning:.*")
+ "\\)"))
(let ((string (TeX-match-buffer 1)))
(cond (;; TeX error
@@ -1362,13 +1390,18 @@
nil)
;; LaTeX warning
- ((string-match (concat "\\("
- "^.*erfull \\\\.*[0-9]*--[0-9]*\\|"
- "^LaTeX Warning: .*[0-9]+\\.$"
- "\\)")
-
- string)
- (TeX-warning string))
+ ((string-match
+ (concat
+ "\\("
+ "^.*erfull \\\\.*[0-9]*--[0-9]*\\|"
+ ;; XXX: Add full support for multi-line warnings like
+ ;; Package hyperref Warning: Token not allowed in a PDFDocEncoded string,
+ ;; (hyperref) removing `math shift' on input line 1453.
+ "^\\(LaTeX [A-Za-z]*\\|Package [A-Za-z]+ \\)Warning:.*"
+ "\\)")
+ string)
+ (TeX-warning string)
+ nil)
;; New file -- Push on stack
((string= string "(")
@@ -1459,8 +1492,7 @@
(message (concat "! " error))))))
(defun TeX-warning (string)
- "Display a warning for STRING.
-Return nil if we gave a report."
+ "Display a warning for STRING."
(let* ((error (concat "** " string))
@@ -1474,8 +1506,7 @@
"`\\(\\w+\\)'"))
;; Get error-line (warning)
- (line (progn
- (re-search-backward line-string)
+ (line (when (re-search-backward line-string nil t)
(string-to-int (TeX-match-buffer 1))))
(line-end (if bad-box (string-to-int (TeX-match-buffer 2))
line))
@@ -1497,9 +1528,7 @@
(error-point (point))
;; Now find the error word.
- (string (progn
- (re-search-backward word-string
- context-start t)
+ (string (when (re-search-backward word-string context-start t)
(TeX-match-buffer 1)))
;; We might use these in another file.
@@ -1511,29 +1540,27 @@
(setq TeX-error-point (point))
;; Go back to TeX-buffer
- (if TeX-debug-bad-boxes
- (let ((runbuf (current-buffer))
- (master (with-current-buffer
- TeX-command-buffer
- (expand-file-name (TeX-master-file)))))
- (run-hooks 'TeX-translate-location-hook)
- (find-file-other-window file)
- (setq TeX-master master)
- ;; Find line and string
- (goto-line (+ offset line))
- (beginning-of-line 0)
- (let ((start (point)))
- (goto-line (+ offset line-end))
- (end-of-line)
- (search-backward string start t)
- (search-forward string nil t))
- ;; Display help
- (if TeX-display-help
- (TeX-help-error error (if bad-box context (concat "\n" context))
- runbuf)
- (message (concat "! " error)))
- nil)
- t)))
+ (let ((runbuf (current-buffer))
+ (master (with-current-buffer
+ TeX-command-buffer
+ (expand-file-name (TeX-master-file)))))
+ (run-hooks 'TeX-translate-location-hook)
+ (find-file-other-window file)
+ (setq TeX-master master)
+ ;; Find line and string
+ (when line
+ (goto-line (+ offset line))
+ (beginning-of-line 0)
+ (let ((start (point)))
+ (goto-line (+ offset line-end))
+ (end-of-line)
+ (search-backward string start t)
+ (search-forward string nil t)))
+ ;; Display help
+ (if TeX-display-help
+ (TeX-help-error error (if bad-box context (concat "\n" context))
+ runbuf)
+ (message (concat "! " error))))))
;;; - Help
Index: tex.el
===================================================================
RCS file: /cvsroot/auctex/auctex/tex.el,v
retrieving revision 5.542
diff -u -r5.542 tex.el
--- tex.el 5 Nov 2005 09:27:37 -0000 5.542
+++ tex.el 5 Nov 2005 12:49:30 -0000
@@ -787,7 +787,12 @@
:type 'boolean)
(defcustom TeX-debug-bad-boxes nil
- "*Non-nil means also find overfull/underfull boxes warnings with \\[TeX-next-error]."
+ "Non-nil means also find overfull/underfull box warnings with \\[TeX-next-error]."
+ :group 'TeX-output
+ :type 'boolean)
+
+(defcustom TeX-debug-warnings nil
+ "Non-nil means also find LaTeX or package warnings with \\[TeX-next-error]."
:group 'TeX-output
:type 'boolean)
_______________________________________________
auctex mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex