[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Three Flymake backends Was Re: Two issues with the new Flymake
From: |
João Távora |
Subject: |
Re: Three Flymake backends Was Re: Two issues with the new Flymake |
Date: |
Sun, 05 Nov 2017 21:05:50 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) |
Dmitry Gutov <address@hidden> writes:
> On 11/5/17 3:22 PM, João Távora wrote:
>
>> I think the doors are still open for the "sooner" case :-) I don't have
>> rubucop, but defining new backends of the
>> "feed-to-stdin-then-parse-with-regexp" type is really easy (and of
>> really verbose, but we're trying to fix that)
>
> OK, I'll keep that in mind. :)
FWIW I installed it and quickly hacked up this. It's the same
boilerplate again, with the tiny exception that rubocop needs the file
to be also saved for some reason (pure stdin doesn't work for some
reason).
(defvar-local rubocop--flymake-proc nil)
(defun rubocop-flymake (report-fn &rest _args)
"Rubocop backend"
(unless (executable-find "rubocop")
(error "Cannot find a suitable checker"))
(when (process-live-p rubocop--flymake-proc)
(kill-process rubocop--flymake-proc))
(let ((source (current-buffer)))
(when buffer-file-name
(save-restriction
(widen)
(setq
rubocop--flymake-proc
(make-process
:name "rubocop-flymake" :noquery t :connection-type 'pipe
:buffer (generate-new-buffer " *rubocop-flymake*")
:command `("rubocop" "--stdin" ,buffer-file-name "--format" "emacs")
:sentinel
(lambda (proc _event)
(when (eq 'exit (process-status proc))
(unwind-protect
(if (with-current-buffer source (eq proc
rubocop--flymake-proc))
(with-current-buffer (process-buffer proc)
(goto-char (point-min))
(cl-loop
while (search-forward-regexp
"^\\(?:.*.rb\\|-\\):\\([0-9]+\\):\\([0-9]+\\):
\\(.*\\)$"
nil t)
for msg = (match-string 3)
for (beg . end) = (flymake-diag-region
source
(string-to-number (match-string 1))
(string-to-number (match-string 2)))
for type = (if (string-match "^E: " msg)
:error
:note)
collect (flymake-make-diagnostic source
beg
end
type
msg)
into diags
finally (funcall report-fn diags)))
(flymake-log :debug "Canceling obsolete check %s"
proc))
(kill-buffer (process-buffer proc)))))))
(process-send-region rubocop--flymake-proc (point-min) (point-max))
(process-send-eof rubocop--flymake-proc)))))
> The defalias way should be all right with remove-hook, though.
Yes, and exposing the function that returns the lambda is also OK.
> I'm in the "don't create new macros unless it's _really_ beneficial"
> camp, though it might be in the minority here.
I'm with you on that camp. However macros that create functions or
defmethod, if done in the standard fashion, almost always escape that
razor.
- Re: Two issues with the new Flymake, (continued)
Three Flymake backends Was Re: Two issues with the new Flymake, João Távora, 2017/11/03
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, Stefan Monnier, 2017/11/04
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, Dmitry Gutov, 2017/11/05
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, João Távora, 2017/11/05
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, Dmitry Gutov, 2017/11/05
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, João Távora, 2017/11/05
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, Dmitry Gutov, 2017/11/05
- Re: Three Flymake backends Was Re: Two issues with the new Flymake,
João Távora <=
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, Dmitry Gutov, 2017/11/05
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, João Távora, 2017/11/06
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, Dmitry Gutov, 2017/11/06
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, João Távora, 2017/11/06
- Re: Three Flymake backends Was Re: Two issues with the new Flymake, Dmitry Gutov, 2017/11/12