-
-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support org lint #2031
base: master
Are you sure you want to change the base?
Support org lint #2031
Conversation
Rick Astley seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Sorry for the delay. All checkers that are defined should also appear in the list flycheck-checkers. I think this is what this test is complaining about. |
Hey cpitclaudel, no prob. Sorry for the noobish pull, I'll check on this and see. |
@RlckAstley Any updates here? |
@bbatsov I have been using a modified variant of the code for a while (see (require 'flycheck)
(add-to-list 'flycheck-checkers 'org-lint)
(defconst flycheck-org-lint-form
(flycheck-prepare-emacs-lisp-form
(require 'org)
(require 'org-attach)
(advice-add 'org-macro-initialize-templates :around
(lambda (fun &optional default)
"Ensure `org-lint' knows about global macros."
(require 'ox)
(if (and ;; (not noninteractive)
;; (eql this-command 'org-lint)
(not default))
(funcall fun org-export-global-macros)
(funcall fun default))))
(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-export-global-macros
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 ()
"Make `org-lint' availables available."
(flycheck-sexp-to-string
`(progn
(require 'org-attach)
,@(seq-map (lambda (opt) `(setq-default ,opt ',(symbol-value opt)))
(seq-filter #'boundp flycheck-org-lint-variables)))))
;;;; options
(flycheck-def-option-var flycheck-org-lint-load-path 'inherit org-lint
"Load path to use in the Org Lint syntax checker.
When set to `inherit', use the `load-path' of the current Emacs
session during syntax checking.
When set to a list of strings, add each directory in this list to
the `load-path' before invoking the byte compiler. Relative
paths in this list are expanded against the `default-directory'
of the buffer to check.
When nil, do not explicitly set the `load-path' during syntax
checking. The syntax check only uses the built-in `load-path' of
Emacs in this case.
Note that changing this variable can lead to wrong results of the
syntax check, e.g. if an unexpected version of a required library
is used."
:type '(choice (const :tag "Inherit current `load-path'" inherit)
(repeat :tag "Load path" directory))
:risky t
:package-version '(flycheck . "35.0"))
;;;; org-lint checker
(flycheck-define-checker org-lint
"Org buffer checker using `org-lint'.
See URL `https://orgmode.org/'."
:command ("emacs" (eval
(let ((args (pcase flycheck-org-lint-load-path
(`inherit `("--batch"
"-u" ,(getenv "USER")))
(p flycheck-emacs-args))))
args))
(eval
(let ((path (pcase flycheck-org-lint-load-path
(`inherit load-path)
(p (seq-map #'expand-file-name p)))))
(flycheck-prepend-with-option "--directory" path)))
(option "--eval" flycheck-emacs-lisp-package-user-dir nil
flycheck-option-emacs-lisp-package-user-dir)
(option "--eval" flycheck-emacs-lisp-initialize-packages nil
flycheck-option-emacs-lisp-package-initialize)
"--eval" (eval (flycheck-org-lint-variables-form))
"--eval" (eval flycheck-org-lint-form)
;; seems `org-lint' works fine with source (cf. source-inplace)
"--" source)
:error-patterns
((error line-start line ": " (message) line-end))
:modes (org-mode)
:next-checkers (proselint))
;;; End:
(provide 'flycheck-org-lint)
;;; flycheck-org-lint.el ends here |
Adding a pull request to support org-lint. The code was originally written several years ago by @czikus and proposed by @zoechi, see #1757
CI/CD and make specs fails with
(seq-difference flycheck-checkers checkers) to be 'equal' to 'nil', but instead it was '(org-lint)' which does not match because: (different-types (org-lint) nil)
. See: https://github.com/RlckAstley/flycheck/actions/runs/6067151846I'm having a hard time understanding why this is happening. From what I can tell, my style and definition matches spec. I've spent a few hours trying to figure this out, but need to move on. Will try to get on gitter, but seems a bit dead. Also, I'm on liberachat #emacs under RickAstley. Apologies for a premature pull, but I need some help and am a noob.
Also, make check has some odd errors on emacs 25.3 and I'm getting whitespace errors for python related checkers on 28.3 -- not stuff I've touched.