[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: |
Dmitry Gutov |
Subject: |
Re: Three Flymake backends Was Re: Two issues with the new Flymake |
Date: |
Mon, 6 Nov 2017 01:56:22 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Thunderbird/56.0 |
On 11/5/17 11:05 PM, João Távora wrote:
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).
Thanks. Is there a place in the code where you are saving the file? I
don't see it.
The backend seems to work fine for me in this regard, but that might be
dependent on the version, see
https://github.com/bbatsov/rubocop/issues/2576.
That aside, it seems like it didn't pick up the project configuration
file. Here's what worked for me:
(defvar-local rubocop--flymake-proc nil)
(defvar rubocop-config-file ".rubocop.yml")
(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))
(command (list "rubocop" "--stdin" buffer-file-name "--format"
"emacs"))
config-dir)
(when buffer-file-name
(setq config-dir (locate-dominating-file buffer-file-name
rubocop-config-file))
(when config-dir
(setq command (append command (list "--config"
(expand-file-name rubocop-config-file
config-dir)))))
(save-restriction
(widen)
(setq
rubocop--flymake-proc
(make-process
:name "rubocop-flymake" :noquery t :connection-type 'pipe
:buffer (generate-new-buffer " *rubocop-flymake*")
:command command
: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)))))
- 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, 2017/11/05
- Re: Three Flymake backends Was Re: Two issues with the new Flymake,
Dmitry Gutov <=
- 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