(use-package org-transclusion
:ensure t
)
(require 'org-transclusion-http)
(add-to-list 'org-transclusion-extensions 'org-transclusion-http)
(add-to-list 'org-transclusion-extensions 'org-transclusion-html)
;(add-to-list 'org-transclusion-extensions 'dmg-org-transclusion-function)
;(add-to-list 'org-transclusion-extensions #'dmg-org-transclusion-function)
testing it: the following text is transcluded
(defun dmg-hello-world ()
(interactive)
(insert
"* Hello world\n\n-this is working\n"))
(org-link-set-parameters "dmg" :follow #'dmg-follow-link)
(defun dmg-run-thunk (thunk)
"empty the buffer, then run the THUNK.
the THUNK should insert the text into the
current buffer"
(interactive)
(let ((pos (point)))
(erase-buffer)
(unless (derived-mode-p 'org-mode)
(org-mode))
(funcall thunk)
))
(defun dmg-org-transclusion-function-add (link plist)
(and (string= "dmg" (org-element-property :type link))
(append '(:tc-type "org-html-file")
(dmg-org-transclusion-function-run link plist))))
(add-hook 'org-transclusion-add-functions 'dmg-org-transclusion-function-add)
(defun dmg-org-transclusion-function-run (link _plist)
"Return payload list without :tc-type.
:src-content value be return value of calling function FN at LINK."
(let* ((fn (org-element-property :path link))
(org-buf
(get-buffer-create
(format "*org-transclusion-fn %s*" fn)))
(src-content
(with-current-buffer org-buf
(dmg-run-thunk (intern fn))
(buffer-string))))
(with-current-buffer org-buf
(org-with-wide-buffer
(list :src-buf (current-buffer)
:src-beg (point-min)
:src-end (point-max)
:src-content src-content)))))