From 2d13dbe10a2bfdb536d158b1e42f3e1a7ab1c712 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 10 Dec 2018 13:45:31 -0500 Subject: [PATCH] lang/org: fix ob-async support ob-async uses org-babel-load-languages to load babel packages in a child process, but packages entered into the org-babel-load-languages variable by Doom's lazy loader were misnamed. This caused load errors in the child process. The language-to-package resolution is now performed before it is entered into org-babel-load-languages. Additionally, ob-async will now be lazy loaded if it is available (and fail silently otherwise). --- modules/lang/org/+babel.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/lang/org/+babel.el b/modules/lang/org/+babel.el index 42edd5c53..4336af32c 100644 --- a/modules/lang/org/+babel.el +++ b/modules/lang/org/+babel.el @@ -31,14 +31,12 @@ the first function to return non-nil.") "Load babel libraries as needed when babel blocks are executed." (when (funcall orig-fn info) (let* ((lang (nth 0 info)) - (lang (if (symbolp lang) lang (intern lang)))) + (lang (if (symbolp lang) lang (intern lang))) + (lang (or (cdr (assq lang +org-babel-mode-alist)) + lang))) (when (and (not (cdr (assq lang org-babel-load-languages))) (or (run-hook-with-args-until-success '+org-babel-load-functions lang) - (require - (intern (format "ob-%s" - (or (cdr (assq lang +org-babel-mode-alist)) - lang))) - nil t))) + (require (intern (format "ob-%s" lang)) nil t))) (add-to-list 'org-babel-load-languages (cons lang t))) t))) (advice-add #'org-babel-confirm-evaluate :around #'+org*babel-lazy-load-library) @@ -52,7 +50,14 @@ the first function to return non-nil.") (cl-loop with fn = (if others #'not #'identity) for p in params if (funcall fn (eq (car p) key)) - collect p))) + collect p)) + + ;; org-async has its own agenda for lazy loading packages (in the child + ;; process), so we only need to make sure it's loaded. + (defun +org|load-async (&rest _) + "Load `ob-async', if it is available." + (require 'ob-async nil t)) + (add-hook '+org-babel-load-functions #'+org|load-async)) ;;