Hello,
I thought it would be nice to be able to replace a local link with the contents of the target file
when exporting to Freemind and I couldn't figure out how to do this with the existing options
(just started using org-mode). I wanted to be able to make linked notes and then visualise
them as a mind map. For instance, exporting something like:
* TODO todo-list
* stuff
* more stuff
[[./file.org][testlink]]
would produce:
...
<p>DATA</p>
...
where 'DATA' is the actual contents of file.org, instead of <p><a href=...></a></p>
I already modified my copy of org-freemind.el to try this out.
I just modified org-free-mind-convert-links-from-org to insert the target contents instead of the html link:
(defun org-freemind-convert-links-from-org (org-str)
"Convert org links in ORG-STR to freemind links and return the result."
(let ((fm-str (replace-regexp-in-string
(rx (not (any "[\""))
(submatch
"http"
(opt ?\s)
"://"
(1+
(any "-%.?@a-zA-Z0-9()_/:~=&#"))))
"[[\\1][\\1]]"
org-str)))
(with-temp-buffer
(insert-file-contents(substring fm-str
(+ (string-match "\\[\\[" fm-str) 2)
(string-match "\\]\\[" fm-str)))
(buffer-string))))
(It's been a long time since I've written (*)lisp code so this might not be the best way to do this.)
Ideally this expansion would be recursive (and replace links in target files). I only handled one level since this is my usual use case (main note - satellite notes)
and making it recursive would also imply doing more restructuring through org-freemind.el, which is out of my way right now.
I just dived in to get the functionality through this hack. (This is also why the above code is not in patch notation.)
A proper solution would probably be to add more options to org-exp.el and additional code in org-freemind.el.
I suppose other export formats, such as ASCII, or just normal editing, might use this option as well.
Best regards,
Filip