Tell org-lint about all the org-babel langs
This commit is contained in:
parent
21e4764873
commit
c063d1f42e
67
config.org
67
config.org
|
@ -330,7 +330,8 @@ few extras.
|
||||||
*** Magit push in daemon
|
*** Magit push in daemon
|
||||||
|
|
||||||
Quite often trying to push to a remote in the Emacs daemon produces as error like this:
|
Quite often trying to push to a remote in the Emacs daemon produces as error like this:
|
||||||
#+begin_src fundamental
|
|
||||||
|
#+begin_example
|
||||||
128 git … push -v origin refs/heads/master\:refs/heads/master
|
128 git … push -v origin refs/heads/master\:refs/heads/master
|
||||||
Pushing to git@github.com:tecosaur/emacs-config.git
|
Pushing to git@github.com:tecosaur/emacs-config.git
|
||||||
|
|
||||||
|
@ -338,7 +339,7 @@ fatal: Could not read from remote repository.
|
||||||
|
|
||||||
Please make sure you have the correct access rights
|
Please make sure you have the correct access rights
|
||||||
and the repository exists.
|
and the repository exists.
|
||||||
#+end_src
|
#+end_example
|
||||||
|
|
||||||
*** Unread emails doesn't work across Emacs instances
|
*** Unread emails doesn't work across Emacs instances
|
||||||
|
|
||||||
|
@ -7719,7 +7720,7 @@ git diff chunk heading to something more useful than just the immediate line
|
||||||
above the hunk --- like the parent heading.
|
above the hunk --- like the parent heading.
|
||||||
|
|
||||||
This can be achieved by first adding a new diff mode to git in =~/.config/git/attributes=
|
This can be achieved by first adding a new diff mode to git in =~/.config/git/attributes=
|
||||||
#+begin_src fundamental
|
#+begin_src gitattributes
|
||||||
,*.org diff=org
|
,*.org diff=org
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
@ -9287,12 +9288,24 @@ regurgitate the code, cross our fingers, and hope it works.
|
||||||
org-link-parameters)
|
org-link-parameters)
|
||||||
"Variables inherited by the org-lint subprocess.")
|
"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 ()
|
(defun flycheck-org-lint-variables-form ()
|
||||||
(require 'org-attach) ; Needed to make variables available
|
(require 'org-attach) ; Needed to make variables available
|
||||||
`(progn
|
`(progn
|
||||||
,@(seq-map (lambda (opt) `(setq-default ,opt ',(symbol-value opt)))
|
,@(seq-map (lambda (opt) `(setq-default ,opt ',(symbol-value opt)))
|
||||||
(seq-filter #'boundp flycheck-org-lint-variables))))
|
(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.
|
(eval ; To preveant eager macro expansion form loading flycheck early.
|
||||||
'(flycheck-define-checker org-lint
|
'(flycheck-define-checker org-lint
|
||||||
"Org buffer checker using `org-lint'."
|
"Org buffer checker using `org-lint'."
|
||||||
|
@ -9304,6 +9317,8 @@ regurgitate the code, cross our fingers, and hope it works.
|
||||||
(flycheck-org-lint-variables-form)))
|
(flycheck-org-lint-variables-form)))
|
||||||
"--eval" (eval (flycheck-sexp-to-string
|
"--eval" (eval (flycheck-sexp-to-string
|
||||||
(flycheck-org-lint-customisations-form)))
|
(flycheck-org-lint-customisations-form)))
|
||||||
|
"--eval" (eval (flycheck-sexp-to-string
|
||||||
|
(flycheck-org-lint-babel-langs-form)))
|
||||||
"--eval" (eval flycheck-org-lint-form)
|
"--eval" (eval flycheck-org-lint-form)
|
||||||
"--" source)
|
"--" source)
|
||||||
:error-patterns
|
:error-patterns
|
||||||
|
@ -9342,6 +9357,52 @@ much.
|
||||||
(org-export-backend-options (org-export-get-backend 'latex)))))
|
(org-export-backend-options (org-export-get-backend 'latex)))))
|
||||||
#+end_src
|
#+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 (functionp symb)
|
||||||
|
(let ((name (symbol-name symb)))
|
||||||
|
(let ((fn (symbol-function symb)))
|
||||||
|
(when (symbolp fn)
|
||||||
|
(setq symb (symbol-function symb)
|
||||||
|
fn (symbol-function symb)))
|
||||||
|
(when (and (string-suffix-p "-mode" name)
|
||||||
|
(autoloadp fn))
|
||||||
|
(ignore-errors (autoload-do-load fn))))
|
||||||
|
(cond
|
||||||
|
((string-prefix-p "org-babel-execute:" name)
|
||||||
|
(push (replace-regexp-in-string "^org-babel-execute:" "" name)
|
||||||
|
langs))
|
||||||
|
((and (string-suffix-p "-mode" name)
|
||||||
|
(provided-mode-derived-p
|
||||||
|
symb 'prog-mode 'text-mode 'conf-mode))
|
||||||
|
(push (replace-regexp-in-string "-mode$" "" name)
|
||||||
|
langs))))))
|
||||||
|
obarray)
|
||||||
|
(dolist (mode-mapping org-src-lang-modes)
|
||||||
|
(push (car mode-mapping) langs))
|
||||||
|
(mapcar #'intern
|
||||||
|
(sort (delete-dups langs) #'string<)))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
This increases the tangle time by about 10--20%, but I think it's worth it to be
|
||||||
|
extra thorough. If this really becomes a pain, we can always think about doing
|
||||||
|
some sort of cache file based on the load-path/packages installed.
|
||||||
|
|
||||||
*** Visuals
|
*** Visuals
|
||||||
|
|
||||||
#+call: confpkg("Org Visuals", after="org")
|
#+call: confpkg("Org Visuals", after="org")
|
||||||
|
|
Loading…
Reference in New Issue