org-roam / org-roam-bibtex

Org Roam integration with bibliography management software
GNU General Public License v3.0
568 stars 47 forks source link

abbreviate file path #175

Closed emacsbliss closed 3 years ago

emacsbliss commented 3 years ago

currently org-roam-bibtex will insert the absolute file path as is from bib file.

for eg, it's something like this with my current orb template:

:NOTER_DOCUMENT: /Users/emacsbliss/Zotero/storage/SV96UAIW/how-javascript-works-the-mechanics-of-web-push-notifications-290176c5c55d.html

However the issue is when I switch to different computer (for eg, company one) where I don't have control with username, then org-noter will break because user name is different even though Zotero is installed on same location (ie. ~/Zotero) on both machine.

I think it would make sense to insert abbreviate file path so it will work on different machines with different username as long as Zotero is under same location relative to user home directory.

With this PR, it will insert this:

:NOTER_DOCUMENT: ~/Zotero/storage/SV96UAIW/how-javascript-works-the-mechanics-of-web-push-notifications-290176c5c55d.html
myshevchuk commented 3 years ago

Hi, that's not really the case. The situation is somewhat more complex. ORB uses bibtex-completion-find-pdf to retrieve the filename or filenames. In the simplest instance, it inserts whatever is in the file field. If the value of the field is an abbreviated path, it inserts the abbreviated path.

I don't mind ORB providing a way to enforce file path abbreviations, that's actually a good idea. But I stand to the principle that any enforcements should be controlled by the user. Please modify the code to provide a user option, e.g. orb-abbreviate-file-path or orb-abbreviate-file-name, and abbreviate the paths only if the value of this option is true.

emacsbliss commented 3 years ago

thanks for the comment. I think it makes sense and I have made another push to include the change. thanks!

myshevchuk commented 3 years ago

Done. I also slightly refactored the function and updated the docstrings. The result should be the same.