emacs-citar / citar

Emacs package to quickly find and act on bibliographic references, and edit org, markdown, and latex academic documents.
GNU General Public License v3.0
502 stars 54 forks source link

importing bib from doi and cross-ref, including pdf #758

Open trembel opened 1 year ago

trembel commented 1 year ago

As I'm using emacs for my bibliography management, so far I have to rely on org-ref for some features. org-ref has a very nice import functionality for bib entries (https://github.com/jkitchin/org-ref/blob/master/doi-utils.el). Using doi-utils-add-entry-from-crossref-query and doi-utils-add-bibtex-entry-from-doi one can easily search for papers on a lot of platforms. It automatically fills the bib informations into a configured bibtex file, and does download the pdf if possible.

I think porting this to citar wouldn't be a too big thing, as especially doi-utils.el is pretty standalone. If I find time, I will dig into this.

bdarcus commented 1 year ago

I'm generally of the view that org-ref is like five packages in one. That's a perfect example of a piece of functionality that should be an independent package. While it could be easily installed as the single file with straight or elpaca, it has no independent melpa recipe.

Beyond that, a couple of things:

First, I'm a little unclear on the UI, and how much really needs to be tied to org-ref or to citar.

Can you clarify that, maybe with a screenshot or two to demonstrate?

Also, see:

https://github.com/emacs-citar/citar/wiki/Embark#embark-become

image

See the search string that yields no results there? If I choose an option, it pipes that string to the relevant function, and it opens.

How does that biblio-based solution compare?

Finally, see this new package (and his comparison list):

https://github.com/rougier/persid

I haven't tried it, but seemed promising. Notably, it offers no query capability.

bdarcus commented 1 year ago

@trembel just bumping this, as I realize this issue is waiting on your input ;-)

pprevos commented 1 month ago

The biblio package has functionality to extract BibTeX entries from databases. I wrote a function for EWS that integrates it with Citar. This is a more generalised version:

(defun ews--bibtex-combined-biblio-lookup ()
  "Combines `biblio-lookup' and `biblio-doi-insert-bibtex'."
  (require 'biblio)
  (let* ((dbs (biblio--named-backends))
         (db-list (append dbs '(("DOI" . biblio-doi-backend))))
         (db-selected (biblio-completing-read-alist
                       "Backend:"
                       db-list)))
    (if (eq db-selected 'biblio-doi-backend)
        (let ((doi (read-string "DOI: ")))
          (biblio-doi-insert-bibtex doi))
      (biblio-lookup db-selected))))

(defun ews-bibtex-biblio-lookup ()
  "Insert Biblio search results into curent buffer or select BibTeX file."
  (interactive)
  (if-let ((current-mode major-mode)
       citar-bibliography
       (bibfiles (length citar-bibliography))
       (bibfile (cond ((eq bibfiles 1) (car ews-bibtex-files))
              ((equal major-mode 'bibtex-mode)
               (buffer-file-name))
              (t (completing-read
                  "Select BibTeX file:" citar-bibliography)))))
      (progn (find-file bibfile)
         (goto-char (point-max))
         (ews--bibtex-combined-biblio-lookup)
         (save-buffer))
    (message "No BibTeX file(s) defined.")))