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
bibtex-completion-find-pdf-in-field not working with zotero and better-bibtex export format #124
Comments
Hm, that format should actually work -- at least that was my memory. I'm currently traveling and will look into it after my return. |
Just tested this and it's working on my machine. So either this has been fixed or it has something to do with org-ref after all (I don't use org-ref) or it's a Windows-specific issue or I misunderstood the problem. Could you please test again? |
Hi, I am running Emacs 25.1 on OS X with ivy-bibtex. I am trying to open pdf with ivy-bibtex. The file field in Zotero+BBT is relative path. However, ivy-bibtex seems can not find the file. Here is my configuration part for ivy-bibtex: (use-package ivy-bibtex :ensure t)
(setq bibtex-completion-notes-path "~/Dropbox/OrgMode/Papers.org"
bibtex-completion-bibliography '("~/Dropbox/Zotero/Zotero.bib")
bibtex-completion-library-path '("~/Dropbox/Zotero/"))
(setq bibtex-completion-pdf-field "file")
(--map (concat it fpath)
(-flatten bibtex-completion-library-path))
(setq ivy-bibtex-open-pdf-function
(lambda (fpath)
(call-process "open" nil 0 nil "-a" "/Applications/Skim.app" fpath))) Is there any way to tell the open-pdf-function the absolute path? Thanks. |
You say that your paths are relative, but relative to what? Ivy-bibtex tries to combine |
All file fields in bib file are relative to a certain folder, which I set the same as the bibtex-completion-library-path ( "~/Dropbox/Zotero/" in this case). Here is a quick example in my .bib file
The absolute path of the pdf file is "~/Dropbox/Zotero/Bell_2008_Journal_of_Accounting_Research.pdf". As you suggest that Ivy-bibtex tries to combine bibtex-completion-library-path with the path in the file field, I think ivy-bibtex should be able to find the file. But it does not work somehow. Thanks for your time. |
Was the value in the file field generated by Zotero? I was under the impression that Zotero like most other bibliography managers uses this format (OP's example above): file = {2011_Optogenetics.pdf:/Deisseroth/2011_Optogenetics.pdf:application/pdf} |
I am finding a similar issue while opening the PDF. In my case, the PDF filename contains spaces. When I try to open the PDF I get following error in the
Also, I am using this solution to open the PDF file. |
@wadkar your problem seems to be related to org-ref. Different project. As far as helm-bibtex is concerned, spaces in file names should be ok. |
@tmalsburg thanks. I will take it over to Check BBT's option in the |
@tmalsburg I used an add-on for Zotero (zotfile) to link all my files to a central dropbox folder. In Zotero, each item only has a link to the pdf file. However, BBT can successfully identify the relative path of the pdf, which is something as below
@wadkar I will try it. It sounds the right path to this issue. |
@wadkar I get the same error when my bibtex library isn't properly defined for org-ref, does it happen when opening the org-ref link or only when trying to access the pdf from the helm buffer? For me, it happens when I try to open (C-c C-o) the org-ref link as a helm buffer. @tmalsburg This issue is still present for me even with updated emacs (25.1.1), org-ref (20161117.630) and helm-bibtex (20161119.412) on OS X 10.10.5. I am also using zotfile to relocate my pdfs to a designated location, BBT is able to find these pdfs just fine as well. I cannot really see the issue being caused by org-ref, but I don't really know enough about debugging emacs to look much deeper at the moment. Do you have a reference for how to trace these function calls? I basically used C-h k and C-h f to see what functions were being called and traced them down to The only way I have been able to correct this is by adding the adapted
If I remove this from It seems that @shenshifo is encountering the same issues on OS X, so perhaps this is an OS X specific issue with @tmalsburg, what OS are you using? I noticed you referenced Windows, but I am not using Windows so I do not know if this is a Windows issue as well. @shenshifo I noticed that you are using the As a side note, BBT is generating the leading / as you have shown so you probably don't need the trailing / in your
and my
I think is this most important when using the concat hack as it isn't intelligent, like f-join, about dealing with superflous /s. This could be generating |
@abradd Thanks a lot. It works after I add the function from your gist. Great! |
To be clear, helm-bibtex / ivy-bibtex currently don't support plain relative paths in the file field. So @shenshifo's problem is not a due to a bug or the OS. We currently have support for absolute paths and for specifications following this format:
I can add support for plain relative paths if this a standard format that enough people are using. It will slow down parsing of the library for everyone who's using the file field to link PDFs. To avoid this slowdown we'd have to revamp the code for finding PDFs completely. This is actually overdue but I don't have the time to work on it. |
Bare relative paths should now work. Please confirm. Details here 9a48c31. |
I had the same problem as @abradd and @shenshifo on helm-bibtex-20170808.1124 . The problem was that f-join ignores prefixes if one of the arguments starts with /. So (f-join "/path/to/library" "/mypath/to/myfile.pdf") becomes "/mypath/to/myfile.pdf". The concat workaround in @abradd 's gist worked for me. |
Oh, I assumed that this was fixed. If not, please consider making a PR. |
This broke on me again recently due to a change in BetterBibtex. This thread is quite old now but maybe some of the following will be useful to someone.
This does work for singular bare relative paths, but doesn't work if there is a second path:
as it takes the html file instead of the pdf and would not have worked with the previous examples in this thread because it uses As an aside, it turns out the The reason this workflow broke for me was because BetterBibtex relative paths stopped working, they have since been restored and took on the format:
Again the relative path failed because of the leading /. I tested adapting the the code in
which both isn't support and still doesn't work without changes to the code. The changes required to get it to work are minor:
The check for But I wanted to discuss the topology of the the file entry in the bibtex file. At one point the field generated by BetterBibtex was: file = {2011_Optogenetics.pdf:/Deisseroth/2011_Optogenetics.pdf:application/pdf} which would have worked if not for the preceding /. Rather than re-inventing the wheel it may make more sense to see if BetterBibtex can return to the previous format above for relative paths (with the removal of the preceding /) to produce: file = {2011_Optogenetics.pdf:Deisseroth/2011_Optogenetics.pdf:application/pdf} which should work with the code as is. Or perhaps there is a more common format for the file field that would be preferable? |
BBT will actually return
rather than
depending on how you set the JabRef format in the preferences. If it's off, you get only file paths; if either 3 or 4, you get the 3-part format. But then you get it for all |
I wasn't aware of that setting. Thanks for letting me know. The file field now looks like:
and works with helm-bibtex without any changes.
Good point. The html content above also takes on the 3 part style as you mentioned. From my brief testing of the code it seems that even a full path used in the 3 part format works. As such, I'll close this issue. |
Wrt the problem as initially reported here, the "relative" paths starting with I'm also going to add an option to always export full absolute paths because relative paths don't use the BBT cache. |
Thanks for the update, @retorquere. |
This seems to be a bit brittle?
Any idea how to debug this? And: thanks a bundle for this excellent tool! |
I am running Emacs 24.5 on OS X with helm-bibtex (v. 20160823.900) and org-ref (v .20160816.1723) with the helm-bibtex backend. I switched my workflow from Mendeley to Zotero + better-bibtex (BBT) and it broke the open pdf functionality of org-ref. I believe I have tracked down the source of the issue in bibtex-completion-find-pdf-in-field which I am pretty confident is unaltered by org-ref. It doesn't seem to handle the export format of BBT. An example format for BBT export is:
file = {2011_Optogenetics.pdf:/Deisseroth/2011_Optogenetics.pdf:application/pdf}
BBT uses full paths or relative paths for the location of the pdf depending upon the location of your bibtex file (in my case they are in the same directory so the path is relative). I set bibtex-completion-library-path to accommodate this.
It seems that the
command should capture this case, but it doesn't work for some reason. I was only able to open the pdf through org-ref by adding an additional function to bibtex-completion-find-pdf-field:
The text was updated successfully, but these errors were encountered: