Compare commits

...

2 Commits

Author SHA1 Message Date
TEC 0fc63bc073
Tell org-lint about all the org-babel langs 2024-04-18 20:42:58 +08:00
TEC 72b72d133a
Replace fundamental-lang src blocks 2024-04-18 20:42:58 +08:00
1 changed files with 64 additions and 3 deletions

View File

@ -330,7 +330,8 @@ few extras.
*** Magit push in daemon
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
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
and the repository exists.
#+end_src
#+end_example
*** 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.
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
#+end_src
@ -9287,12 +9288,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 +9317,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 +9357,52 @@ 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 (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
#+call: confpkg("Org Visuals", after="org")