cpitclaudel / biblio.el

Browse and import bibliographic references from CrossRef, DBLP, HAL, arXiv, Dissemin, and doi.org from Emacs
GNU General Public License v3.0
185 stars 15 forks source link

Target buffer selection #52

Open aikrahguzar opened 2 years ago

aikrahguzar commented 2 years ago

Makes the default choice target buffer sensitive to the major-mode of the buffer from which the search was started.

Also changes the behavior of biblio--selection-change-buffer. Now it only offers buffers with major mode derived from frombibtex-mode. This uses directory-name-p with requires emacs 25.1 but can be avoided.

dankessler commented 2 years ago

This looks really useful! :)

As I discussed in #54, I think it'd be nice to support the use case where the user (or a calling library) can just specify precisely what buffer should be used.

I think you could accomplish this by

  1. rename biblio-target-buffer-default to something like biblio-get-default-target-buffer
  2. declare a new customizable variable biblio-target-buffer-default
  3. adjust the logic in biblio-get-default-target-buffer to respect the value of biblio-target-buffer-default, if set, and if not, to proceed with the lookup logic that it already has.
dankessler commented 2 years ago

Assuming we can get this integrated, I think this would set the stage for a nice enhancement in helm-bibtex and likely many other tools, where a nigh top-level let form can be extended to bind biblio-target-buffer-default to something sensible, e.g., for helm-bibtex we could add (biblio-target-buffer-default bibtex-completion-bibliography) to the list of bindings inside the let* form.

aikrahguzar commented 2 years ago

Came across a few typos in docstrings

Thanks I fixed these.

aikrahguzar commented 2 years ago

This looks really useful! :)

As I discussed in #54, I think it'd be nice to support the use case where the user (or a calling library) can just specify precisely what buffer should be used.

This seems like a good idea to me so I implemented it but directly. biblio-lookup takes three optional arguments the last of which is the target buffer. biblio-target-buffer-functions machinery is used only if no target buffer is passed. That seemed like a better way to doing this than through a variable.