org-super-links
org-super-links copied to clipboard
A question about org-super-links-backlink-prefix customization
I have two files
- file_A.org
file_A.org
* Introduction
- file_B.org
file_B.org
* Introduction
what I would like when I create links is
- file_A.org
* Introduction
:PROPERTIES:
:ID: 045bb041-3130-4ef8-bf50-f9ad0b284180
:END:
A link: [[id:a54fca82-c47a-4529-aa51-bb14403801a0][Introduction]]
- file_B.org
* Introduction
:PROPERTIES:
:ID: a54fca82-c47a-4529-aa51-bb14403801a0
:END:
:BACKLINKS:
*<<-* file_A::[[id:045bb041-3130-4ef8-bf50-f9ad0b284180][Introduction]]
:END:
I have modified org-super-links-backlink-prefix as follows:
(setq org-super-links-backlink-prefix
#'(lambda () (concat "*<<-* " (file-name-nondirectory (file-name-sans-extension (buffer-file-name))) "::"))))
but with that what I get is
- file_B.org
* Introduction
:PROPERTIES:
:ID: a54fca82-c47a-4529-aa51-bb14403801a0
:END:
:BACKLINKS:
*<<-* file_B::[[id:045bb041-3130-4ef8-bf50-f9ad0b284180][Introduction]]
:END:
You see that "file_B" is used instead of "file_A". The reason is that (buffer-file-name) is evaluated in file_B.org when the back link drawer is created. What I would like is the function that returns me the buffer-file-name of file_A.org instead. Maybe this function is already avalaible in org-super-links.el. Do you have an idea to help me ?
Thank you for this package ! :)
Hey, interesting, you are right on the reason why it functions that way. I'll try to take a look at the code soon and see if there is a good way to handle that use case. It's been a bit since I've looked closely at it.
So unfortunately it looks like there is not really a straightforward way to do what you want. You could duplicate the org-super-links--insert-link and org-super-links-insert-backlink functions. Change org-super-links--insert-link to pass in the marker to the source as an extra param in the call to org-super-links-insert-backlink and then jump to the marker there to get the buffer name. You could do something similar by modifying org-super-links-links-action. Both feel pretty gross though.
If I think of something better I'll let you know.
Thank you for spending time to think about my problem.
I understand, and this is a valuable feedback.
Do you want me to close this question or to keep it active ?