[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Flymake refactored
From: |
João Távora |
Subject: |
Re: Flymake refactored |
Date: |
Thu, 05 Oct 2017 03:08:24 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) |
Simen Heggestøyl <address@hidden> writes:
> (I haven't really used Flymake or flymake-easy, so please excuse me if
> the following question doesn't make any sense.)
>
> Would it make sense to merge flymake-easy into Flymake while you're at
> it, if it makes Flymake easier to use out of the box (as the package
> name suggests)?
You question makes sense, but I don't favor doing that for two reasons:
* It would detract from the new API I'm trying to promote;
* It keeps Emacs tied to the legacy backend;
Of course if flymake-easy decides to hook onto the new API and still
provide its declarative interface, I have nothing against that.
But I hope the new API is simple enough to render even that
superfluous.
For example, here's a decent Ruby checker under 40 lines that does the
same as MELPA's flymake-ruby.el (which is based on flymake-easy), but
using the new API and without creating any temporary files.
João
(defvar-local ruby--flymake-proc nil)
(defun ruby-flymake (report-fn &rest _args)
(unless (executable-find
(car ruby-flymake-command)) (error "Cannot find a suitable ruby"))
;; Kill any obsolete processes, then create a new
(when (process-live-p ruby--flymake-proc) (kill-process ruby--flymake-proc))
(let ((source (current-buffer)))
(save-restriction
(widen)
(setq ruby--flymake-proc
(make-process
:name "ruby-flymake" :noquery t :connection-type 'pipe
:buffer (generate-new-buffer " *ruby-flymake*")
:command '("ruby" "-w" "-c")
:sentinel
(lambda (proc _event)
(unwind-protect
(with-current-buffer (process-buffer proc)
(goto-char (point-min))
(cl-loop
while (search-forward-regexp
"^\\(?:.*.rb\\|-\\):\\([0-9]+\\): \\(.*\\)$" nil t)
for msg = (match-string 2)
for (beg . end) = (flymake-diag-region
source
(string-to-number (match-string 1)))
for type = (if (string-match "^warning" msg) :warning
:error)
collect (flymake-make-diagnostic source beg end type msg)
into diags
finally (funcall report-fn diags)))
(kill-buffer (process-buffer proc))))))
(process-send-region ruby--flymake-proc (point-min) (point-max))
(process-send-eof ruby--flymake-proc))))
>
> -- Simen
- Re: Flymake refactored, Marcin Borkowski, 2017/10/01
- Re: Flymake refactored, João Távora, 2017/10/01
- Re: Flymake refactored, Simen Heggestøyl, 2017/10/04
- Re: Flymake refactored,
João Távora <=
- Re: Flymake refactored, Mark Oteiza, 2017/10/04
- Re: Flymake refactored, João Távora, 2017/10/05
- Re: Flymake refactored, Stefan Monnier, 2017/10/05
- Re: Flymake refactored, João Távora, 2017/10/05
- Re: Flymake refactored, João Távora, 2017/10/05
- Re: Flymake refactored, Mark Oteiza, 2017/10/05
- Re: Flymake refactored, João Távora, 2017/10/05
- Re: Flymake refactored, Stefan Monnier, 2017/10/05
- Re: Flymake refactored, Lele Gaifax, 2017/10/06
- Re: Flymake refactored, Eli Zaretskii, 2017/10/06