Re: TeX-command and flymake
Hi Rahguzar, > Rahguzar writes: > Now my questions are: > 1) Is there a simpler way of getting LaTeX and BibTeX errors and > warnings through flymake? For LaTeX run, I suppose you can set (override) `TeX-sentinel-default-function' locally. That value is set to `TeX-sentinel-function' in `TeX-run-TeX' and called in `TeX-command-sentinel' eventually. This approach would be somewhat awkward because it have to work as a replacement of `TeX-LaTeX-sentinel'. It seems that `TeX-LaTeX-sentinel' doesn't offer hook to delegate its role only partially. For BibTeX, there are none as far as I can see in the current AUCTeX since `TeX-BibTeX-sentinel' is hard-coded in `TeX-run-BibTeX'. You have to add a new entry for BibTeX in `TeX-command-list'. A proposal for implementation of new flexible interface would be appreciated. :-) Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine
TeX-command and flymake
Hi all, 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." (goto-char (point-min)) (when (and (not (nth 10 item)) (search-forward (nth 6 item) nil t)) (flymake-make-diagnostic (current-buffer) (match-beginning 0) (match-end 0) (if (eq (nth 0 item) 'error) :error :warning) (nth 3 item ;;;###autoload (defun latex-refs-flymake-diagnostic-fun (report-fun _args) "A flymake diagnostic function based on `TeX-error-list'. See `flymake-diagnostic-functions' for REPORT-FUN." (when-let ((buf (TeX-active-buffer))) (funcall report-fun (save-excursion (let ((diagnostics)) (dolist (item (buffer-local-value 'TeX-error-list buf)) (push (latex-refs--make-flymake-diagonostic item) diagnostics)) (nreverse diagnostics)) 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 https://codeberg.org/rahguzar/latex-refs/src/commit/14c669f5d1c64760d089dd3418adcdbb31ee34c7/latex-refs.el#L174-L272 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? Thanks, Rahguzar