Add function to retrieve formatted citation from DOI

Uses the API of the DOI service directly. Before, I had to add them to
the bibtex file or use an external service like
citation.crosscite.org. Now I can just copy-paste the DOI and get the
formatted citation in the kill-ring directly.
This commit is contained in:
Dimitri Lozeve 2021-06-24 17:58:51 +02:00
parent f94f05e266
commit 4f826a6c9b

16
init.el
View file

@ -689,9 +689,9 @@
(require 'org-ref-isbn) (require 'org-ref-isbn)
(require 'org-ref-arxiv) (require 'org-ref-arxiv)
(setq bibtex-autokey-year-length 4)) (setq bibtex-autokey-year-length 4)
(defun dl/formatted-citation-at-point () (defun dl/formatted-citation-at-point ()
"Kill the formatted citation for the reference at point using Pandoc." "Kill the formatted citation for the reference at point using Pandoc."
(interactive) (interactive)
(let* ((bibfile (expand-file-name (car (org-ref-find-bibliography)))) (let* ((bibfile (expand-file-name (car (org-ref-find-bibliography))))
@ -704,6 +704,18 @@
bibfile bibfile
cslfile))))) cslfile)))))
(defun dl/formatted-citation-from-doi (doi)
"Kill the formatted citation for the given DOI."
(interactive
(list (read-string
"DOI: "
;; now set initial input
(doi-utils-maybe-doi-from-region-or-current-kill))))
(let ((url-mime-accept-string "text/x-bibliography; style=chicago-author-date"))
(with-temp-buffer
(url-insert-file-contents (format "https://doi.org/%s" doi))
(kill-new (buffer-string))))))
(use-package org-roam (use-package org-roam
:straight t :straight t
:hook (after-init . org-roam-mode) :hook (after-init . org-roam-mode)