Open MagicRB opened 3 years ago
Can you explain what that means, please? I don’t use org-babel-load-file.
And if it doesn’t work, probably it is not designed to work.
Sure, I conjured up a little demo that is somewhat hacky.
(defun magic_rb/org-transclusion-babel-load (&optional narrowed)
"Call `org-babel-load-file` on all transcludes in the current file."
(interactive "P")
(save-restriction
(let ((marker (move-marker (make-marker) (point)))
(load-link (lambda ()
(let* ((keyword-plist (org-transclusion-keyword-string-to-plist))
(link (org-transclusion-wrap-path-to-link
(plist-get keyword-plist :link)))
(link-raw (org-element-property :raw-link link))
(link-type (org-element-property :type link)))
(when (string-equal link-type "id")
(org-babel-load-file (org-id-find-id-file link-raw)))))))
(unless narrowed (widen))
(goto-char (point-min))
;; Handle inactive transclusions
(let ((regexp "^[ \t]*#\\+TRANSCLUDE:"))
(while (re-search-forward regexp nil t)
;; Don't transclude if within a transclusion to avoid infinite
;; recursion
(unless (or (org-transclusion-within-transclusion-p)
(plist-get (org-transclusion-keyword-string-to-plist)
:disable-auto))
(funcall load-link))))
;; Handle active transclusions
(while (setq match (text-property-search-forward 'org-transclusion-type))
(goto-char (prop-match-beginning match))
(org-transclusion-remove)
(funcall load-link)
(org-transclusion-add))
(goto-char marker)
(move-marker marker nil) ; point nowhere for GC
t)))
So basically, in my .emacs
I only load org-mode, straight, and now org-transclusion, I then load this huge literate .org
file which contains my whole config with org-babel-load-file
, which basically evaluates all elisp code blocks in the file. The hack I devised works, but it's completely disconnected from the initial org-babel-load-file
call so load order might and will become an issue for me, but it does solve my immediate problem, though a better solution would be appreciated. I think that if we added some kind of "return all org transclusion links in file" then we could simplify my code and maybe talk to the babel people, but I'm way over my head already.
EDIT: so the end goal is to be able to link my org roam network with my init process so that I could load random snippets of elisp i happen to collect.
After some more research I learned that org babel doesn't even handle the basic #+INCLUDE:
directives, so this is more of a org-babel
problem. Therefore this issue transforms into a warning to others and a reminder of what unfortunately won't work for now...
Hi, I'm looking to split up my monolithic emacs configuration into multiple org roam files/nodes. I thought that org-babel-load-file would automatically handle org-transclusion but apparently not. Do I need to do something to make it work or is it simply just not supported?