Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A question about org-super-links-backlink-prefix customization #80

Open
vincent-picaud opened this issue Dec 21, 2022 · 3 comments
Open

Comments

@vincent-picaud
Copy link

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 ! :)

@vincent-picaud vincent-picaud changed the title A question about org-super-links-backlink-prefixcustomizationn A question about org-super-links-backlink-prefix customization Dec 21, 2022
@toshism
Copy link
Owner

toshism commented Dec 22, 2022

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.

@toshism
Copy link
Owner

toshism commented Dec 23, 2022

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.

@vincent-picaud
Copy link
Author

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants