transclude by default
Is there a way to transclude the contents by default when exporting, without having to press F12 to expand? If there is a #+transclude t tag, it is meant to be transcluded.
How about trying either of the hooks below?
org-export-before-parsing-hook
org-export-before-processing-hook
I think you could either call org-transclusion-add-all-in-buffer or org-transclusion-mode +1, something along these lines?
Adding the following in init (add-hook 'org-export-before-processing-hook 'org-transclusion-add-all-in-buffer) results in the following message when exporting. Any pointer?
Adding transclusion inserts text contents after the link. This function avoids infinite recursion of transclusions.
It retains the
buffer-modified-p' status before transcluding any linked contents. This means transclusion is not considered modification to the buffer for the auto save facilities, such asauto-save-mode' and `auto-save-visited-mode'.The following conditions are checked before calling a function to work on each link:
- Check if the link is preceded by a #+transclusion keyword with value t
- Check if the link at point is NOT within transclusion" (interactive) (cond ((not org-transclusion-mode) (message "Org-transclusion mode is not active.")) ((eq (current-buffer) (window-buffer (selected-window))) (setq org-transclusion-buffer-modified-p (buffer-modified-p)) (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (eq t (org-next-link)) (if (and (bolp) (org-transclusion--ok-to-transclude) (not (org-transclusion--is-within-transclusion))) (progn (org-transclusion-link-open-at-point)))))) (set-buffer-modified-p org-transclusion-buffer-modified-p)))), 1 run-hook-with-args: Wrong number of arguments: ((t) nil "Add all the transclusions in the current buffer. As this function should be used only on the current buffer, no argument is passed.
Hmmm.. This seems to indicate that the function is not called, but the definition of it is.
I don't know why that is the case -- it does not look to be specific to org-transclusion.
You'd need find out the reason why the function is not called, or find an alternative. The former may be related to the fact that org-export copies the Org content into a temp buffer to work on it.
3 ideas.
- Try the other hook
- Try
(add-hook 'org-export-xxxxxx (lambda () (org-transclusion-add-all-in-buffer))instead - Advice
org-export-dispatch(or whatever export command you use) and calladd-all-in-bufferfunction in:before-- transclude just beforeorg-export-dispatch