[Top][All Lists]

[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

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.


(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)))
      (setq ruby--flymake-proc
             :name "ruby-flymake" :noquery t :connection-type 'pipe
             :buffer (generate-new-buffer " *ruby-flymake*")
             :command '("ruby" "-w" "-c")
             (lambda (proc _event)
                   (with-current-buffer (process-buffer proc)
                     (goto-char (point-min))
                      while (search-forward-regexp
                             "^\\(?:.*.rb\\|-\\):\\([0-9]+\\): \\(.*\\)$" nil t)
                      for msg = (match-string 2)
                      for (beg . end) = (flymake-diag-region
                                         (string-to-number (match-string 1)))
                      for type = (if (string-match "^warning" msg) :warning 
                      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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]