tmalsburg/helm-bibtex

helm-bibtex support for adding files to file field

Jdogzz opened this issue · 2 comments

I saw in the documentation the support for using the file field which has worked perfectly for me to open up any of the many files I may have associated with a bibtex entry:

https://github.com/tmalsburg/helm-bibtex#pdf-files

However, I would like to ask if it would be possible to add files to that field using helm-bibtex. In that same section of documentation there are two supported means of working with PDFs:

  1. Use a key-labelled PDF
  2. Use the file field

The first means is given a function:

  1. M-x helm-bibtex,
  2. go to entry,
  3. C-z,
  4. then use f10 "Add PDF to library",
  5. select from the options of adding PDF from buffer, file, or URL

to import a PDF and relabel by key. I would like to have a function which helps with the second means, using the file field and not moving any files around, just using them where they're already located on disk. Ideally, the workflow would be something like:

  1. M-x helm-bibtex,
  2. go to entry,
  3. C-z,
  4. then use f11 "Add files to bibtex entry",
  5. select from the options of adding files from buffer, file, clipboard, or URL.

There's a couple of ways I envision adding files in from this last step:

  1. file: I navigate to the location on disk, use C-Space to select a few different files in a directory, and all the files I select get added back to back in the file field of the bibtex entry.
  2. clipboard: It's likely that I already have a directory open with a bunch of files that I've gathered. In my file manager on Xfce if I select all the files, hit Ctrl-C, go to a buffer in emacs, and hit Ctrl-V, then I get output that looks like this:
/mydata/references/refdata/202203121139/fig1.png
/mydata/references/refdata/202203121139/fig2.png
/mydata/references/refdata/202203121139/fig3.png
/mydata/references/refdata/202203121139/PhysRevFluids.7.034101.pdf
/mydata/references/refdata/202203121139/TBT_SM.pdf

which is only a hop, skip, and a jump away from exactly what needs to go into the file field, namely stripping newlines and replacing them with semicolons, so the file field looks like this:

  file =         {/mydata/references/refdata/202203121139/PhysRevFluids.7.034101.pdf;/mydata/references/refdata/202203121139/TBT_SM.pdf;/mydata/references/refdata/202203121139/fig1.png;/mydata/references/refdata/202203121139/fig2.png;/mydata/references/refdata/202203121139/fig3.png},

and that format works, as I mentioned at the outset, perfectly for my needs and as expected from the documentation. So simply grabbing from clipboard with this assumed would work as an option.

Hi, I understand why that may be useful for some users. However, helm/ivy-bibtex were not designed to be BibTeX editors and I think they'd be terrible for that purpose. The main intended use case is really navigating bibliographies that were built using other packages inside Emacs or outside (in my case, the .bib is written by hand in Emacs). So I won't include this feature in default helm/ivy-bibtex.

Having said that, I'd be happy to create a contrib directory where we can collect such extensions. Let me know if you'd like to go that route and we can discuss details. One benefit: You can design this feature in whichever way works best for yourself. Note though, that I won't be able to contribute any code to this. Too busy with other stuff and I'm hardly able to manage basic housekeeping in this project.

That makes sense you want to keep helm-bibtex focused not on BibTeX editing. I actually think ebib has the functionality I'm desiring in this vein, if a little bit manual until this feature is added if I'm understanding the purpose correctly: joostkremers/ebib#235

I'll go ahead and close this since I can get by with this extra bit of homework. Thank you very much for the reply.