Add function to get bibtex from doi.
This commit is contained in:
@@ -168,7 +168,25 @@
|
|||||||
|
|
||||||
;;TRAMP
|
;;TRAMP
|
||||||
(load "~/.emacs.d/elisp/tramp-setup.el")
|
(load "~/.emacs.d/elisp/tramp-setup.el")
|
||||||
|
|
||||||
(load "~/.emacs.d/elisp/outline-keymap.el")
|
(load "~/.emacs.d/elisp/outline-keymap.el")
|
||||||
(load "~/.emacs.d/elisp/bibtex-setup.el")
|
(load "~/.emacs.d/elisp/bibtex-setup.el")
|
||||||
(load "~/.emacs.d/elisp/keypad.el")
|
(load "~/.emacs.d/elisp/keypad.el")
|
||||||
|
|
||||||
|
;; from https://www.anghyflawn.net/blog/2014/emacs-give-a-doi-get-a-bibtex-entry/
|
||||||
|
(defun get-bibtex-from-doi (doi)
|
||||||
|
"Get a BibTeX entry from the DOI"
|
||||||
|
(interactive "MDOI: ")
|
||||||
|
(let ((url-mime-accept-string "text/bibliography;style=bibtex"))
|
||||||
|
(with-current-buffer
|
||||||
|
(url-retrieve-synchronously
|
||||||
|
(format "http://dx.doi.org/%s"
|
||||||
|
(replace-regexp-in-string "http://dx.doi.org/" "" doi)))
|
||||||
|
(switch-to-buffer (current-buffer))
|
||||||
|
(goto-char (point-max))
|
||||||
|
(setq bibtex-entry
|
||||||
|
(buffer-substring
|
||||||
|
(string-match "@" (buffer-string))
|
||||||
|
(point)))
|
||||||
|
(kill-buffer (current-buffer))))
|
||||||
|
(insert (decode-coding-string bibtex-entry 'utf-8))
|
||||||
|
(bibtex-fill-entry))
|
||||||
|
|||||||
Reference in New Issue
Block a user