On 03/04/21 2:56 pm, Nicolas Goaziou wrote:
> Hello,
> 
> Ramesh Nedunchezian <rameshnedunchez...@outlook.com> writes:
> 
>> I was expecting that the linter report will be in
>> `compilation-minor-mode`.
> 
> Well, it isn't, obviously.
> 
>> With things as it is now, is there a way I can quickly move between
>> next or previous errors, when I am in _either_ of the source buffer or
>> the linter report?
> 
> You move back to the linter report and proceed from there. I cannot
> think of any other way.

Some one has integrated flycheck with `org-lint'.  I am copying their
code verbatim here
https://github.com/flycheck/flycheck/issues/1757#issuecomment-759546940.
Full credit goes to https://github.com/czikus.

The author of the snippet is massaging (org-lint)'s output--note that
this is a elisp list--in to something that one wold expect from a
compiler i.e., a set of error messages in stdout. Flycheck is invoking
emacs on command line.

This suggests that making (org-lint) throwout errors on stdout would
be of immediate use to flycheck-like apps.

That said, it would be useful to add file name (optionally) to the
tabulated list output.  (What if one wants to run `org-lint' on all
files that they want to publish?)

(defconst flycheck-org-lint-form
    (flycheck-prepare-emacs-lisp-form
      (require 'org)
      (require 'org-attach)
      (let ((source (car command-line-args-left))
            (process-default-directory default-directory))
        (with-temp-buffer
          (insert-file-contents source 'visit)
          (setq buffer-file-name source)
          (setq default-directory process-default-directory)
          (delay-mode-hooks (org-mode))
          (setq delayed-mode-hooks nil)
          (dolist (err (org-lint))
            (let ((inf (cl-second err)))
              (princ (elt inf 0))
              (princ ": ")
              (princ (elt inf 2))
              (terpri)))))))
  (defconst flycheck-org-lint-variables
    '(org-directory
      org-id-locations
      org-id-locations-file
      org-attach-id-dir
      org-attach-use-inheritance
      org-attach-id-to-path-function-list)
    "Variables inherited by the org-lint subprocess.")
  (defun flycheck-org-lint-variables-form ()
    (require 'org-attach)  ; Needed to make variables available
    `(progn
       ,@(seq-map (lambda (opt) `(setq-default ,opt ',(symbol-value opt)))
                  (seq-filter #'boundp flycheck-org-lint-variables))))
  (flycheck-define-checker org-lint
    "Org buffer checker using `org-lint'."
    :command ("emacs" (eval flycheck-emacs-args)
              "--eval" (eval (concat "(add-to-list 'load-path \""
                                     (file-name-directory (locate-library 
"org"))
                                     "\")"))
              "--eval" (eval (flycheck-sexp-to-string
                              (flycheck-org-lint-variables-form)))
              "--eval" (eval flycheck-org-lint-form)
              "--" source)
    :error-patterns
    ((error line-start line ": " (message) line-end))
    :modes (org-mode))

Reply via email to