[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
TeX-command and flymake
TeX-command and flymake
Sat, 02 Sep 2023 10:28:59 +0200
mu4e 1.10.6; emacs 29.1
I wanted to get errors and warnings produced during compilation of LaTeX
documents using flymake which is the interface I am used to getting such
information from. With TeX-parse-all-errors non-nil, it is
straightforward to implement a flymake backend,
(defun latex-refs--make-flymake-diagonostic (item)
"Turn an error or warning ITEM from `TeX-error-list' to a flymake diagnostic."
(when (and (not (nth 10 item)) (search-forward (nth 6 item) nil t))
(match-beginning 0) (match-end 0)
(if (eq (nth 0 item) 'error) :error :warning)
(nth 3 item))))
(defun latex-refs-flymake-diagnostic-fun (report-fun &rest _args)
"A flymake diagnostic function based on `TeX-error-list'.
See `flymake-diagnostic-functions' for REPORT-FUN."
(when-let ((buf (TeX-active-buffer)))
(dolist (item (buffer-local-value 'TeX-error-list buf))
(push (latex-refs--make-flymake-diagonostic item)
The prefix `latex-refs` is nonsensical but I couldn't think of a better
name and just threw the functions in a package I had.
The function `latex-refs-flymake-diagnostic-fun` can then be added to
`flymake-diagonostic-functions`. There is also a canonical time to run
it which is when the compilation finishes. However it seems there is no
hook that I can use to issue a `flymake-start` command at such time.
`TeX-after-compilation-finished-functions` are only run if the
compilation finished successfully. So instead I had to advise the
sentinel. Is there a more canonical way to run something when
compilation is unsuccessful?
I also ended up writing another flymake backend which parse the BibTeX
log files and feeds the errors to flymake. I am not sure how robust the
parsing is and I need it to extend it to parse warnings too but the
current state can be found at
Now my questions are:
1) Is there a simpler way of getting LaTeX and BibTeX errors and
warnings through flymake?
2) Flymake integrates with `project.el` so to get warnings for both tex
and bib files together I also had to write a little project backend. Is
there another possibly simpler way?
3) It took some configuration but I quite like the resulting setup. Are
there parts of it that other people think are useful and that I can
contribute to auctex proper?
- TeX-command and flymake,