mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-13 13:13:35 -05:00
fix(org,cli): tangle: load ob-* libs for noweb-usable blocks
For performance reasons, Doom CLI runs in a minimal environment wherein no `ob-<language>` libraries are initially loaded; but tangling a document with noweb-enabled blocks can trigger an org-babel evaluation of any noweb-addressable block; and any such evaluation will fail tangling with an error unless the correct `ob-<language>` library has been loaded. So. This changes the tangle CLI function to note any noweb-addressable labels (i.e. any `#+NAME:` or `:noweb-ref` associated with a block) when iterating through the source document's blocks; for each block where one is found, it conditionally attempts to `require` the corresponding `ob-<src-lang>` library.
This commit is contained in:
@@ -52,7 +52,16 @@ EXAMPLES:
|
||||
(let* ((tags (org-get-tags-at))
|
||||
(info (org-babel-get-src-block-info 'no-eval))
|
||||
(src-lang (nth 0 info))
|
||||
(src-tfile (cdr (assq :tangle (nth 2 info)))))
|
||||
(src-tfile (cdr (assq :tangle (nth 2 info))))
|
||||
(src-noweb-ref (or (nth 4 info)
|
||||
(cdr (assq :noweb-ref (nth 2 info))))))
|
||||
;; a block which can be referenced via noweb may need to be
|
||||
;; evaluated even if it will not be tangled per se
|
||||
(when-let* ((src-noweb-ref)
|
||||
(ob-library-name (concat "ob-" src-lang))
|
||||
((locate-library ob-library-name)))
|
||||
(require (intern ob-library-name)))
|
||||
|
||||
(cond ((member "notangle" tags))
|
||||
|
||||
((let* ((tags (seq-group-by (fn! (equal (car %) "--or")) tags))
|
||||
|
Reference in New Issue
Block a user