10

Is it possible to automatically create backlinks to org-mode links? When a link to file B is added to file A, then also a link to file A is added to file B (i.e. the links are symmetrical - going both ways).

A concrete example:

I have two files a.org and b.org.

Inside a.org in heading Links I insert an org-link (with a new function org-link-with-backlink) to the file b.org.

So file a.org looks like this:

* Links
  [[~/org/b.org][b]]

* Heading 1
  lorem ipsum....

I'd like this to happen automatically:

  1. the file b.org is opened (if not open already)

  2. and inside its Links heading a link to a.org is created.

If Links doesn't exist yet, create it by prepending the file and add the link.

If b.org already has a link to a.org in its Links heading then do nothing.

So that b.org looks like this after the operation:

* Links
  [[~/org/a.org][a]]

* Heading X
  foo bar....

If now I inside file c.org add also a link to b.org, then b.org now looks like this:

* Links
  [[~/org/a.org][a]]
  [[~/org/c.org][c]]

* Heading X
  foo bar....

I think some sort of advice around org-link should accomplish this, but unfortunately this is beyond my elisp skills...

Thank you very much!

PS [optional]: I intend to use it in conjunction with org-wiki, to the solution could use the wiki style links as an alternative.

  • 2
    org-occur may be useful for this. See stackoverflow.com/questions/9844154/… – mankoff Jan 18 '17 at 2:06
  • 1
    This post is hard to follow. Could you please clarify the question? – Dan Jan 18 '17 at 2:29
  • Thanks for the feedback. I've expanded the description and added concrete examples. @mankoff thank you - this is definitely related to my question. What I'd like is that the back-linkage happens at the time of link creation. The org-occur trick does it in a "batch mode" when evoked. – user673592 Jan 18 '17 at 8:58
  • 1
    This is a Q&A site and your text here, and duplicate text on SO, don't actually ask a question. See stackoverflow.com/help/how-to-ask and catb.org/~esr/faqs/smart-questions.html – mankoff Jan 18 '17 at 15:31
  • It would help if you could ask an explicit question, and explain what you have tried so far. Right now, this post reads as a "someone please code this for me" post. – Dan Jan 18 '17 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.