diff --git a/elisp/extras.el b/elisp/extras.el index 42859a4..de4ce18 100644 --- a/elisp/extras.el +++ b/elisp/extras.el @@ -168,7 +168,25 @@ ;;TRAMP (load "~/.emacs.d/elisp/tramp-setup.el") - (load "~/.emacs.d/elisp/outline-keymap.el") (load "~/.emacs.d/elisp/bibtex-setup.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))