Function: tex-chktex
tex-chktex is a byte-compiled function defined in tex-mode.el.gz.
Signature
(tex-chktex REPORT-FN &rest ARGS)
Documentation
Flymake backend for linting TeX buffers with ChkTeX.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/tex-mode.el.gz
(defun tex-chktex (report-fn &rest _args)
"Flymake backend for linting TeX buffers with ChkTeX."
(unless (executable-find tex-chktex-program)
(error "Cannot find a suitable TeX checker"))
(when (process-live-p tex-chktex--process)
(kill-process tex-chktex--process))
(let ((source (current-buffer))
(re "^stdin:\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\):\\(.*\\)$"))
(save-restriction
(widen)
(setq tex-chktex--process
(make-process
:name "tex-chktex"
:buffer (generate-new-buffer "*tex-chktex*")
:command (tex-chktex-command)
:noquery t :connection-type 'pipe
:sentinel
(lambda (process _event)
(when (eq (process-status process) 'exit)
(unwind-protect
(when (eq process
(with-current-buffer source tex-chktex--process))
(with-current-buffer (process-buffer process)
(goto-char (point-min))
(cl-loop
while (search-forward-regexp re nil t)
for msg = (match-string 4)
for line = (string-to-number (match-string 1))
for col = (string-to-number (match-string 2))
for (beg . end) = (flymake-diag-region source line col)
collect (flymake-make-diagnostic source beg end :warning msg)
into diags
finally (funcall report-fn diags))))
(kill-buffer (process-buffer process)))))))
(process-send-region tex-chktex--process (point-min) (point-max))
(process-send-eof tex-chktex--process))))