Tell org-lint about all the org-babel langs

This commit is contained in:
TEC 2024-04-18 20:05:22 +08:00
parent 21e4764873
commit 8b9174a1df
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 43 additions and 0 deletions

View File

@ -9287,12 +9287,24 @@ regurgitate the code, cross our fingers, and hope it works.
org-link-parameters)
"Variables inherited by the org-lint subprocess.")
(defconst flycheck-org-lint-babel-langs
'<<org-babel-list-langs()>>
"Languages that org-babel should know of.")
(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))))
(defun flycheck-org-lint-babel-langs-form ()
`(progn
,@(mapcar
(lambda (lang)
`(defun ,(intern (format "org-babel-execute:%s" lang)) (_body _params)
"Stub for org-lint."))
flycheck-org-lint-babel-langs)))
(eval ; To preveant eager macro expansion form loading flycheck early.
'(flycheck-define-checker org-lint
"Org buffer checker using `org-lint'."
@ -9304,6 +9316,8 @@ regurgitate the code, cross our fingers, and hope it works.
(flycheck-org-lint-variables-form)))
"--eval" (eval (flycheck-sexp-to-string
(flycheck-org-lint-customisations-form)))
"--eval" (eval (flycheck-sexp-to-string
(flycheck-org-lint-babel-langs-form)))
"--eval" (eval flycheck-org-lint-form)
"--" source)
:error-patterns
@ -9342,6 +9356,35 @@ much.
(org-export-backend-options (org-export-get-backend 'latex)))))
#+end_src
A larger annoyance is that org-lint doesn't actually know what languages
org-babel should recognise, with Doom's lazy loading system. Since the list of
languages should really only change when packages are added/removed, we might as
well statically determine a list of all org-babel languages at configuration
generation time.
#+name: org-babel-list-langs
#+begin_src emacs-lisp :noweb-ref none
(let (langs)
(dolist (dir load-path)
(dolist (file (directory-files dir t "\\.elc?$"))
(let ((basename (file-name-base file)))
(when (string-prefix-p "ob-" basename)
(ignore-errors
(require (intern basename) file t))))))
(mapatoms
(lambda (symb)
(when (and (functionp symb)
(string-prefix-p
"org-babel-execute:"
(symbol-name symb)))
(push (intern (replace-regexp-in-string
"org-babel-execute:" ""
(symbol-name symb)))
langs)))
obarray)
langs)
#+end_src
*** Visuals
#+call: confpkg("Org Visuals", after="org")