jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.36k stars 242 forks source link

adding pdf without dnd #390

Closed DrWaleedAYousef closed 7 years ago

DrWaleedAYousef commented 7 years ago

I use emacs as the dired manager (using dired +) so no dnd. How can I add a pdf to the bib file?

jkitchin commented 7 years ago

I am not sure what you mean. Do you mean add some field like file = "some-path"? Is so, you could just type that in, or make a function that allows you to browse to a path and then insert it. e.g. with read-file-name.

DrWaleedAYousef commented 7 years ago

I am just looking for the most convenient way, like Mendely, to add a pdf to the library without doing many steps. In Mendely, there is a folder that Mendely listens to and extract the info. of each pdf in this folder, add them to the library, rename the pdf, copy it to the library pdf folder, then add the file field to the entry. Do you have a similar function doing all of that? (similar to the dnd option that does not work in emacs)

jkitchin commented 7 years ago

You might checkout org-ref-pdf-dir-to-bibtex. It sort of does that. It is generally tricky though, since it relies on finding a doi inside the text of the pdf. There is no function to watch a directory. You could add a timer to do that, or setup a hook function perhaps.

DrWaleedAYousef commented 7 years ago

I tried org-ref-pdf-dir-to-bibtex; it sort of doing the job with some glitches, which I will report to you soon. However, for the time being a few observations are:

1- it does not produce a ready-to-use bib file; e.g., this is an output. As you see, the @article is not at the start of the line and the "file" field is not added inside the bib info: %[[file:/home/wyousef/texmf/bibtex/bib/base/tmp/a.pdf]@article{johnson2006bayesian, author = {Timothy D. Johnson and Valen E. Johnson}, title = {A Bayesian Hierarchical Approach To Multirater Correlated Roc Analysis}, journal = {Statistics in Medicine}, volume = 25, number = 11, pages = {1858-1871}, year = 2006, doi = {10.1002/sim.2314}, url = {https://doi.org/10.1002/sim.2314}, DATE_ADDED = {Thu Mar 2 17:38:12 2017}, }

2- It seems that it does not append to a current bib file. For example, if I specify a current bib file it creates a new buffer for it with the same path and name!! Of course when I save it overwrites.

I really love your org-ref and I wish to use it much more than mendely and bibref. However, I will appreciate too much if you help me for more convenient use.

Thanks so much

jkitchin commented 7 years ago

Thanks for reporting the issue with that function. I pushed some fixes for 1. I can't reproduce 2, but maybe the new commits address it. The %file line is intended to be a comment, not a field. In general I find this way of making bibtex files on the unreliable side because there may not be a findable doi in the pdf, or there may be many dois in the pdf, and then you have to pick which one you want. This function more or less shows what is needed to get a feature like this, but is mostly intended for a one time indexing of pdfs, not for a regular use to get bibtex entries in. for that, adding by doi is much more reliable.

I don't use mendeley or bibref, so i have no way to test if it works for them or not.

DrWaleedAYousef commented 7 years ago

Thanks so much for your efforts; Ok I am convinced that it is more robust to use doi-insert-bibtex to add the record, and I should do that from within the bib file.

Then, there is only one function to add a pdf to this new record, i.e., org-ref-bibtex-assoc-pdf-with-entry, which RENAMES the selected file to Record_KEY.pdf and puts it in the pdf directory. Here I have some comments:

  1. "Renaming" is too dangerous; this deletes the selected file from its location to the new pdf directory, which may not be desired.

  2. If there is a pdf file attached, there is no way, e.g., "⌘", to know that unless I go to the directory and see. Even, while in the bib buffer and the cursor is inside the record, opening helm-bibtex does not highlight this record. It populates the whole bib file and highlight the first record.

  3. What if I want to add more than one file using the "file" field. I have to do this manually through something like: File = {:/path/to/article.pdf:PDF;:/path/to/supplementary_materials.txt:txt}

Thanks so much

John Kitchin notifications@github.com writes:

Thanks for reporting the issue with that function. I pushed some fixes for 1. I can't reproduce 2, but maybe the new commits address it. The %file line is intended to be a comment, not a field. In general I find this way of making bibtex files on the unreliable side because there may not be a findable doi in the pdf, or there may be many dois in the pdf, and then you have to pick which one you want. This function more or less shows what is needed to get a feature like this, but is mostly intended for a one time indexing of pdfs, not for a regular use to get bibtex entries in. for that, adding by doi is much more reliable.

I don't use mendeley or bibref, so i have no way to test if it works for them or not.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.*

jkitchin commented 7 years ago
  1. Check out the doc string. You can choose to rename or copy. Some people think not renaming is too tedious since then they then have to manually delete it ;) Choose your cake and eat it too.

  2. pull requests are welcome. There is no reason helm-bibtex should do that I think, it is not aware of where the cursor is. I only ever search via helm-bibtex or the ivy equivalent. This is not easy to automate, since there it is not so easy to guarantee a pdf retrieval is successful.

  3. I can see some need for this, but I don't have a good solution for it. pull requests are welcome.