tmalsburg / helm-bibtex

Search and manage bibliographies in Emacs
GNU General Public License v2.0
464 stars 74 forks source link

[Feature request/Question] A reverse bibtex-completion-find-pdf function? #381

Open c1-g opened 3 years ago

c1-g commented 3 years ago

Is there any function that takes a filepath, then return an entry key for it as a string? We could generalize this further by say, bibtex-completion-find-key-with-field (string &optional field), this function takes STRING then match it against all fields of every bibtex entry in bibtex-completion-bibliography then return a list of keys with STRING in their fields, or to be even more specific, match STRING against FIELD of every bibtex entry, return a list of keys that matches. I can work on a pull request as this feature will make my note-taking even more convenient and open a lot of possibilities for writing some extensions in the future but, I have no clue how to do this since the relavant bibtex-completion functions seem to take a key as their argument.

tmalsburg commented 3 years ago

Is there any function that takes a filepath, then return an entry key for it as a string?

Well, you can add the file field to bibtex-completion-additional-search-fields and then search for file paths using the usual UI.

We could generalize this further by say, bibtex-completion-find-key-with-field (string &optional field), this function takes STRING then match it against all fields of every bibtex entry in bibtex-completion-bibliography then return a list of keys with STRING in their fields, or to be even more specific, match STRING against FIELD of every bibtex entry, return a list of keys that matches.

That’s the usecase for which I designed helm/ivy-bibtex :) What’s wrong with the current approach?

I can work on a pull request as this feature will make my note-taking even more convenient and open a lot of possibilities for writing some extensions in the future but

Interesting. Could you please describe your use case in more detail? How exactly would the function that you’re proposing make note-taking more efficient? Perhaps there already are facilities to solve your specific problem.

I have no clue how to do this since the relavant bibtex-completion functions seem to take a key as their argument.

You can access a list of all entries via bibtex-completion-candidates. It’s then relatively easy to filter them and to extract the keys.

tmalsburg commented 3 years ago

I will have a closer look at your PR when I have a better understanding of what you're trying to achieve.