From: Mark Oteiza <mvoteiza@udel.edu>
To: joaotavora@gmail.com (João Távora)
Cc: jwiegley@gmail.com, emacs-devel@gnu.org,
"Simen Heggestøyl" <simenheg@gmail.com>,
dgutov@yandex.ru, "Steve Purcell" <steve@sanityinc.com>,
sdl.web@gmail.com, monnier@iro.umontreal.ca
Subject: Re: Flymake refactored
Date: Thu, 05 Oct 2017 17:22:02 -0400 [thread overview]
Message-ID: <87efqh2sud.fsf@udel.edu> (raw)
In-Reply-To: <87shex276r.fsf@gmail.com> ("João Távora"'s message of "Thu, 05 Oct 2017 11:57:32 +0100")
joaotavora@gmail.com (João Távora) writes:
> Mark Oteiza <mvoteiza@udel.edu> writes:
>> I also seem to have problems using the column number (match-string 2)
>> and so it is left unused.
>
> The problem is that you are calling flymake-diag-region in the wrong
> buffer. It has to be the source buffer, so in your case you need a
> (with-current-buffer source ...) around it.
>
> But that inconvenience has been fixed in the very latest code emacs-26
> branch. In that version, you just pass 'source' (the c/c++ buffer) to
> flymake-diag-region.
Ah, thank you.
> I've built a backend very similar to yours but base on gcc (clang is
> 500MB and no time for that right now). Have a look, below my sig.
Nice. Adding to the pile, a LaTeX checker with chktex below.
> I've also noticed, there's a lot of repetition building up in these
> examples. Later it's probably useful to invent an abstraction that hides
> it away.
At first sight it looks like the much of the sentinel contents could be
abstracted away in something like compilation mode's error regexp alists
;;; flymake-chktex.el --- Flymake backend for chktex(1) -*- lexical-binding: t -*-
;;; Code:
(defgroup flymake-chktex ()
"Flymake backend for chktex"
:link '(url-link "http://www.nongnu.org/chktex/")
:group 'flymake)
(defcustom flymake-chktex-program "chktex"
"Program."
:type 'string
:group 'flymake-chktex)
(defvar-local flymake-chktex--process nil)
(defun flymake-chktex-command (program)
`(,program "--quiet" "--verbosity=0" "--inputfiles"))
(defun flymake-chktex (report-fn &rest _args)
(unless (executable-find flymake-chktex-program)
(error "Cannot find a suitable chktex"))
(when (process-live-p flymake-chktex--process)
(kill-process flymake-chktex--process))
(let ((source (current-buffer)))
(save-restriction
(widen)
(setq flymake-chktex--process
(make-process
:name "flymake-chktex"
:buffer (generate-new-buffer "*flymake-chktex*")
:command (flymake-chktex-command flymake-chktex-program)
:noquery t :connection-type 'pipe
:sentinel
(lambda (process _event)
(unwind-protect
(when (eq process flymake-chktex--process)
(with-current-buffer (process-buffer process)
(goto-char (point-min))
(cl-loop
while (search-forward-regexp
"^stdin:\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\):\\(.*\\)$"
nil t)
for msg = (match-string 4)
for (beg . end) = (flymake-diag-region source
(string-to-number (match-string 1))
(string-to-number (match-string 2)))
collect (flymake-make-diagnostic source beg end :warning msg)
into diags
finally (funcall report-fn diags))))
(kill-buffer (process-buffer process))))))
(process-send-region flymake-chktex--process (point-min) (point-max))
(process-send-eof flymake-chktex--process))))
(defun flymake-chktex-register ()
(add-hook 'flymake-diagnostic-functions 'flymake-chktex nil t))
(add-hook 'plain-tex-mode-hook 'flymake-chktex-register)
(add-hook 'latex-mode-hook 'flymake-chktex-register)
(add-hook 'bibtex-mode-hook 'flymake-chktex-register)
(provide 'flymake-chktex)
;;; flymake-chktex.el ends here
next prev parent reply other threads:[~2017-10-05 21:22 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-28 14:27 Flymake refactored João Távora
2017-09-28 19:52 ` Stefan Monnier
2017-09-29 0:22 ` João Távora
2017-09-29 3:11 ` Stefan Monnier
2017-10-01 16:52 ` João Távora
2017-10-01 20:50 ` Stefan Monnier
2017-10-02 1:01 ` João Távora
2017-10-02 3:12 ` Stefan Monnier
2017-10-03 0:33 ` João Távora
2017-10-03 1:09 ` Stefan Monnier
2017-09-29 12:51 ` Dmitry Gutov
2017-09-29 14:55 ` Ted Zlatanov
2017-09-29 15:03 ` Dmitry Gutov
2017-09-29 16:26 ` Ted Zlatanov
2017-09-29 17:35 ` Dmitry Gutov
2017-09-29 17:56 ` Ted Zlatanov
2017-09-30 15:07 ` Dmitry Gutov
2017-09-30 7:55 ` Marcin Borkowski
2017-09-30 23:43 ` João Távora
2017-10-01 8:53 ` Marcin Borkowski
2017-10-01 11:54 ` Mark Oteiza
2017-10-04 17:37 ` Simen Heggestøyl
2017-10-05 2:08 ` João Távora
2017-10-05 3:52 ` Mark Oteiza
2017-10-05 10:57 ` João Távora
2017-10-05 13:11 ` Stefan Monnier
2017-10-05 14:45 ` João Távora
2017-10-05 23:01 ` João Távora
2017-10-05 21:22 ` Mark Oteiza [this message]
2017-10-05 23:05 ` João Távora
2017-10-06 3:35 ` Stefan Monnier
2017-10-06 7:09 ` Lele Gaifax
2017-10-06 8:14 ` Eli Zaretskii
2017-10-06 8:19 ` Lele Gaifax
2017-10-06 9:48 ` Eli Zaretskii
2017-10-06 9:54 ` Lele Gaifax
2017-10-06 13:04 ` Mark Oteiza
2017-10-06 14:47 ` Lele Gaifax
2017-10-06 15:21 ` Mark Oteiza
2017-10-06 15:26 ` Mark Oteiza
2017-10-06 15:28 ` Lele Gaifax
2017-10-06 16:28 ` João Távora
2017-10-06 19:24 ` Lele Gaifax
2017-10-06 15:13 ` João Távora
2017-10-07 13:28 ` Stefan Monnier
2017-10-07 13:44 ` Eli Zaretskii
2017-10-07 14:40 ` Lele Gaifax
2017-10-07 14:52 ` Eli Zaretskii
2017-10-08 2:06 ` Stefan Monnier
2017-10-08 9:32 ` João Távora
2017-10-08 11:24 ` Lele Gaifax
2017-10-08 14:17 ` Stefan Monnier
2017-10-08 23:33 ` João Távora
2017-10-09 3:01 ` Stefan Monnier
2017-10-09 10:19 ` João Távora
2017-10-09 15:50 ` [SUSPECTED SPAM] " Stefan Monnier
2017-10-09 16:33 ` [PATCH] " Lele Gaifax
2017-10-07 6:31 ` Marcin Borkowski
2017-10-07 13:37 ` Stefan Monnier
2017-10-07 16:48 ` Marcin Borkowski
2017-10-06 12:54 ` John Wiegley
2017-10-06 15:17 ` Mark Oteiza
2017-10-06 16:04 ` João Távora
2017-10-06 21:22 ` Mark Oteiza
2017-10-06 22:03 ` João Távora
2017-10-07 13:31 ` Stefan Monnier
2017-10-07 16:02 ` João Távora
2017-10-07 16:07 ` João Távora
2017-10-07 18:18 ` Mark Oteiza
2017-10-08 9:06 ` João Távora
2017-10-08 12:51 ` Mark Oteiza
2017-10-08 23:21 ` João Távora
2017-10-10 14:27 ` Mark Oteiza
2017-10-10 15:20 ` João Távora
2017-10-10 16:10 ` Mark Oteiza
2017-10-05 11:28 ` Lele Gaifax
2017-10-05 15:12 ` Lele Gaifax
2017-10-10 10:40 ` Lele Gaifax
2017-10-10 12:27 ` João Távora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87efqh2sud.fsf@udel.edu \
--to=mvoteiza@udel.edu \
--cc=dgutov@yandex.ru \
--cc=emacs-devel@gnu.org \
--cc=joaotavora@gmail.com \
--cc=jwiegley@gmail.com \
--cc=monnier@iro.umontreal.ca \
--cc=sdl.web@gmail.com \
--cc=simenheg@gmail.com \
--cc=steve@sanityinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).