From mboxrd@z Thu Jan 1 00:00:00 1970 From: Filip Buric Subject: [Orgmode] WISH: link expansion in Freemind export Date: Mon, 6 Jun 2011 23:42:00 +0300 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=00504502d44ba1d68904a5112294 Return-path: Received: from eggs.gnu.org ([140.186.70.92]:42870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTgch-0003hn-4U for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 16:42:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTgcd-0002sQ-Po for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 16:42:06 -0400 Received: from mail-ey0-f169.google.com ([209.85.215.169]:52382) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTgcd-0002sF-5m for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 16:42:03 -0400 Received: by eyd9 with SMTP id 9so1712208eyd.0 for ; Mon, 06 Jun 2011 13:42:01 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --00504502d44ba1d68904a5112294 Content-Type: text/plain; charset=UTF-8 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: ...

DATA

... where 'DATA' is the actual contents of file.org, instead of

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 --00504502d44ba1d68904a5112294 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 t= odo-list
* stuff
* more stuff
=C2=A0[[./file.org][testlink]]

would produce:

...
<p>DAT= A</p>
...

where 'DATA' is the actual contents of file.org, instead of <p><a href=3D...></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 c= ontents instead of the html link:

=C2=A0(defun org-freemind-convert-= links-from-org (org-str)
=C2=A0=C2=A0 "Convert org links in ORG-STR= to freemind links and return the result."
=C2=A0=C2=A0 (let ((fm-str (replace-regexp-in-string
=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 (rx (not (any "[\""))
=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A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0=C2=A0=C2=A0=C2=A0 (inser= t-file-contents(substring fm-str
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (+ (st= ring-match "\\[\\[" fm-str) 2)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (string-match "\\]\\[" fm-s= tr)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (buffer-string))))

(It= 's been a long time since I've written (*)lisp code so this might n= ot 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 w= hy the above code is not in patch notation.)
A proper solution would pro= bably be to add more options to org-exp.el and additional code in org-freem= ind.el.

I suppose other export formats, such as ASCII, or just normal editing, = might use this option as well.


Best regards,
Filip
--00504502d44ba1d68904a5112294--