From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Support flymake with org-lint Date: Mon, 11 Jun 2018 23:09:18 +0200 Message-ID: <87muw1xc75.fsf@nicolasgoaziou.fr> References: <87k1r9te7f.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSU45-0007Pj-K9 for emacs-orgmode@gnu.org; Mon, 11 Jun 2018 17:09:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSU42-0001jI-Ba for emacs-orgmode@gnu.org; Mon, 11 Jun 2018 17:09:25 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:42609) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSU42-0001iM-4Z for emacs-orgmode@gnu.org; Mon, 11 Jun 2018 17:09:22 -0400 In-Reply-To: <87k1r9te7f.fsf@gmail.com> (Alex Branham's message of "Fri, 08 Jun 2018 11:50:28 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Alex Branham Cc: Org Mode List Hello, Alex Branham 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