3

I'm going through a LaTeX document fixing a bunch of broken references. I use AUCTeX. I ran TeX-toggle-debug-warnings to make TeX-next-error jump to warnings about references.

However, my document also has other warnings that I don't care about right now. So I compile, I press C-x `, and each time I get these two warnings before the interesting ones.

How can I tell AUCTeX to ignore specific warnings? (This question isn't about the \markboth/\markright warnings in particular, I expect to enter a regexp somewhere.) Either on a document by document basis, or in my init file.

  • Do you know you can see the list of all errors and warnings with M-x TeX-error-overview RET, instead of going through a series of C-x ` ? – giordano Feb 11 '16 at 19:08
  • @giordano I didn't, thank you. But actually I can't, because that command is not available on my machine (Ubuntu 14.04, AUCTeX 11.87). In any case, I want something really straightforward to go to the first “interesting” warning — I basically have a cycle of C-c C-c RET C-x ` fix repeat. – Gilles 'SO- stop being evil' Feb 11 '16 at 19:20
  • Full parsing of the whole output log is what has been implemented in AUCTeX 11.88 (making it possible to create TeX-error-overview). Why can't you install AUCTeX via ELPA? – giordano Feb 11 '16 at 19:33
  • Anyway, a possible way to do what you want is to redefine `TeX-parse-error' to ignore unwanted warnings. But note this and many other functions related to error and warning reporting have been rewritten since AUCTeX 11.87, then answering a question specific to a code four-year-old is somewhat a waste of time. – giordano Feb 14 '16 at 14:34
  • @giordano I'd accept an answer that requires 11.88. But answering a question about the version of a package that's in current distributions (Debian stable, Ubuntu LTS) isn't a waste of time. – Gilles 'SO- stop being evil' Feb 14 '16 at 18:44
2

This feature is now present in development version of AUCTeX and will be available in the next ELPA release (presumably 11.89.2) and in the next official stable version (presumably 11.90). There are two options controlling the behavior: TeX-ignore-warnings and TeX-suppress-ignored-warnings. With the former you set the regexp matching warnings to be ignored, with the second you actually tell AUCTeX to hide the warnings. For your case you'd have to add the following code to your init file

(setq TeX-ignore-warnings
      "LaTeX Warning: Command \\\\mark\\(both\\|right\\)  has changed."
      TeX-suppress-ignored-warnings t)

You can show or hide these warnings with C-C C-t C-x (TeX-toggle-suppress-ignored-warnings).

In the error overview you can open with M-x TeX-error-overview RET, it's possible to toggle visibility of such ignored warnings with x. BTW, you can also toggle visibility of all bad boxes and generic warnings with b and w, respectively.


In previous versions of AUCTeX, the best way to accomplish what you ask is be to hack into TeX-parse-error and skip warnings to be ignored there. But this function was fairly large and is changed fairly often, then a redefinition would overwrite these changes, so I advise against redefining TeX-parse-error.

Instead, if you have AUCTeX 11.88 or later you can hack into TeX-parse-all-errors: after parsing the whole compilation log remove the unwanted warnings. Add the following code to your init file

(setq mg-ignored-warnings
      "LaTeX Warning: Command \\\\mark\\(both\\|right\\)  has changed.")
(defun mg-remove-ignored-warnings (&rest args)
  "Remove unwanted warnings from `TeX-error-list'."
  (let ((list TeX-error-list)
    entry new-list)
    (while (setq entry (pop list))
      (unless (and mg-ignored-warnings
           (string-match mg-ignored-warnings (nth 3 entry)))
    (push entry new-list)))
    (setq TeX-error-list (reverse new-list))))
(advice-add #'TeX-parse-all-errors :after #'mg-remove-ignored-warnings)

You only have to set mg-ignored-warnings to a regexp matching warnings you want to skip and you're done.

Please note also that since version 11.88 it's available a nice formatted list of all errors and warnings reported in the compilation log, M-x TeX-error-overview RET, that makes navigating through such messages much easier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.