fix(org): check :async on already loaded languages

Running a regular/`:sync` source block would prevent successive
invocations of blocks of that same language with `:async` from loading
`ob-async`.
This commit is contained in:
Samuel Tschiedel 2025-10-21 21:20:49 -03:00
parent 62b505d7c0
commit 2a78b9bb83
No known key found for this signature in database
GPG key ID: AAAF89E3D2C70F09

View file

@ -298,11 +298,11 @@ Also adds support for a `:sync' parameter to override `:async'."
"Load babel libraries lazily when babel blocks are executed." "Load babel libraries lazily when babel blocks are executed."
(defun +org--babel-lazy-load (lang &optional async) (defun +org--babel-lazy-load (lang &optional async)
(cl-check-type lang (or symbol null)) (cl-check-type lang (or symbol null))
(unless (cdr (assq lang org-babel-load-languages))
(when async
;; ob-async has its own agenda for lazy loading packages (in the child ;; ob-async has its own agenda for lazy loading packages (in the child
;; process), so we only need to make sure it's loaded. ;; process), so we only need to make sure it's loaded.
(when async
(require 'ob-async nil t)) (require 'ob-async nil t))
(unless (cdr (assq lang org-babel-load-languages))
(prog1 (or (run-hook-with-args-until-success '+org-babel-load-functions lang) (prog1 (or (run-hook-with-args-until-success '+org-babel-load-functions lang)
(require (intern (format "ob-%s" lang)) nil t) (require (intern (format "ob-%s" lang)) nil t)
(require lang nil t)) (require lang nil t))