emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Alex Branham <alex.branham@gmail.com>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: Support flymake with org-lint
Date: Mon, 11 Jun 2018 23:09:18 +0200	[thread overview]
Message-ID: <87muw1xc75.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <87k1r9te7f.fsf@gmail.com> (Alex Branham's message of "Fri, 08 Jun 2018 11:50:28 -0500")

Hello,

Alex Branham <alex.branham@gmail.com> 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

      reply	other threads:[~2018-06-11 21:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 16:50 Support flymake with org-lint Alex Branham
2018-06-11 21:09 ` Nicolas Goaziou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87muw1xc75.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=alex.branham@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).