[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Support flymake with org-lint
From: |
Nicolas Goaziou |
Subject: |
Re: [O] Support flymake with org-lint |
Date: |
Mon, 11 Jun 2018 23:09:18 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Hello,
Alex Branham <address@hidden> writes:
> Here's a patch that adds support for flymake in Emacs 26 and greater.
Thank you.
Some comments follow.
> It uses org-lint.el as the backend. It can be pretty slow if you have
> a large buffer open, so I don't think I'd recommend enabling it by
> default. It's nice to be able to use e.g. flymake-goto-next-error to
> navigate around the buffer though.
According to `flymake-diagnostic-functions', backend functions can use
asynchronous processes. This would be more usable if large buffers were
checked asynchronously.
> Subject: [PATCH] Add support for flymake
>
> * lisp/org-flymake.el (org-flymake-org-lint-backend): New function
> * lisp/org-flymake.el (org-flymake-setup): New function
It should be
* lisp/org-flymake.el: New file.
However, it could go in "org-lint.el" directly, if useful enough,
instead of a new library. This is also more logical since it uses
internal functions and variables from there.
> +(defun org-flymake-org-lint-backend (report-fn &rest _args)
> + "A Flymake backend for `org-lint'.
> +Calls REPORT-FN directly."
> + (let* ((report (org-lint--generate-reports
> + (current-buffer) org-lint--checkers))
> + (report (mapcar
> + (lambda (c) (seq-into (nth 0 (cdr c)) 'list))
> + report)))
> + (funcall report-fn
> + (cl-loop
> + for (line _trust description _checkers) in report
> + for (beg . end) = (flymake-diag-region (current-buffer)
> (string-to-number line))
> + collect
> + (flymake-make-diagnostic (current-buffer) beg end :note
> description)))
> + report))
The following may be more idiomatic. At least it uses neither cl-lib nor
seq:
(funcall report-fn
;; Convert Lint reports into Flymake diagnostic objects.
(mapcar
(lambda (report)
(pcase-let*
((`(,_ [,line ,_ ,description ,_]) report)
(`(,beg . ,end) (flymake-diag-region (current-buffer)
(string-to-number
line))))
(flymake-make-diagnostic (current-buffer) beg end :note
description)))
(org-lint--generate-reports (current-buffer) org-lint--checkers)))
Anyway, I would suggest to focus on asynchronous report generation.
WDYT?
Regards,
--
Nicolas Goaziou