Closed swflint closed 5 months ago
This looks like a sensible solution. I'm just a bit worried about the function bibtex-key-in-head
: looking at its source, I notice it requires a search to happen just before it to make it work. I assume it works here because of the call to biblio-format-bibtex
in ebib-biblio-import-doi
, but does it also work if the user has biblio-bibtex-use-autokey
set to nil
?
And what about ebib-biblio-selection-import
? It uses ebib-biblio-selection-import-callback
, but there's no preceding call to bibtex.el
that might preform the required search.
I haven't tested it yet, but it seems to me that we'd need the following just before the call to bibtex-key-in-head
:
(looking-at bibtex-any-entry-maybe-empty-head)
Could you please check? Thanks!
I think you are correct. It does need to perform the search, which it now does (though I'm not sure if it's bibtex-any-entry-maybe-empty-head
, I think it may need to be bibtex-entry-head
, I'll need to confirm).
Additionally, it appears it works if biblio-bibtex-use-autokey
is nil, as a key is still generated (may be by crossref, not sure), just not using the bibtex-autokey
framework.
I think you are correct. It does need to perform the search, which it now does
Great, thanks!
(though I'm not sure if it's
bibtex-any-entry-maybe-empty-head
, I think it may need to bebibtex-entry-head
, I'll need to confirm).
I just checked, I think bibtex-any-entry-maybe-empty-head
is the better choice, because it is set when you do (require 'bibtex)
. bibtex-entry-head
is only set when Emacs visits a .bib
file, which Ebib doesn't do, so we cannot rely on it being set to anything. (In fact, if I understand correctly, we cannot be entirely sure it has a value even if Emacs is visiting a .bib
file, because the value may be set buffer-locally, in which case the global value may still be nil
.)
So I'm going to merge this in its current state. Thanks again for the PR!
This is an alternative to the (seemingly more complex) #241.
Instead, it re-uses the callback function defined for selection import for DOI-forwarded data. It uses the standard
bibtex
library to get the key of the first entry, and after importing, sets the current key & updates ebib buffers.