Open ashgillman opened 11 months ago
I do not know a way; I don’t use attachment links.
But… isn’t it just a link? Then why not use it as a link?
The transcluded link won't work. I guess its because [attachment:
Attachment links can be expanded by org-attach-expand
. Perhaps this could be added to :expand-links
?
On the other hand, the real question might be how to treat properties of the transcluded source. Should the properties of the source or the heading that the transcluded region is in be respected?
This works for me:
(defun org-transclusion-content-filter-expand-links (link)
"Convert LINK to an absolute filename.
LINK is assumed to be an Org element. This function does nothing
to LINK if the link is already absolute.
The current buffer is assumed to be the source buffer for the
transclusion."
(when (or
(string-equal "file" (org-element-property :type link))
(string-equal "attachment" (org-element-property :type link)))
(let ((type (org-element-property :type link))
(path (org-element-property :path link)))
(unless (file-name-absolute-p path)
(setq link (org-element-put-property
link :path
(if (string-equal "attachment" type)
(org-attach-expand path)
(expand-file-name
path
(file-name-directory (buffer-file-name (current-buffer)))))))
(if (string-equal "attachment" type)
(setq link (org-element-put-property
link :type "file")))
link))))
This may be more or less equivalent to @jtoloe function, but I have this snippet in the gist below to support ID and attachment links with anchors that I've been using for a while. It uses org-transclusion-add-functions
instead of :expand-links
. Posting here if it's useful to someone.
https://gist.github.com/lucasvreis/24f378f6f9a95f8c17906cb351bab2e1
Edit: actually, my gist does something completely different (I misunderstood the question): it adds support for attachment links as the transclusion link, instead of expanding their occurrences within the transcluded content into absolute links.
Hi, thanks for a great contribution to the Org Mode ecosystem.
I wonder if there is a known way to transclude images included with Attachment links?
I've tried
:expand-links
without luck.Many thanks, Ash