]> git.donarmstrong.com Git - org-ref.git/blob - doi-utils.org
fix conflicting letter in hydra
[org-ref.git] / doi-utils.org
1 #+TITLE: DOI utilities for making bibtex entries and downloading pdfs
2
3 This package provides functionality to download PDFs and bibtex entries from a DOI, as well as to update a bibtex entry from a DOI. It depends slightly on org-ref, to determine where to save pdf files too, and where to insert bibtex entries in the default bibliography.
4
5 The principle commands you will use from here are:
6
7 - doi-utils-get-bibtex-entry-pdf with the cursor in a bibtex entry.
8 - doi-utils-insert-bibtex-entry-from-doi to insert a bibtex entry at your cursor, clean it and try to get a pdf.
9 - doi-utils-add-bibtex-entry-from-doi to add an entry to your default bibliography (cleaned with pdf if possible).
10 - doi-utils-add-bibtex-entry-from-region to add an entry from a highlighed doi to your default bibliography.
11 - doi-utils-update-bibtex-entry-from-doi with cursor in an entry to update its fields.
12
13 * Header
14 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
15 ;;; doi-utils.el --- get bibtex entries and pdfs from a DOI
16
17 ;; Copyright(C) 2014 John Kitchin
18
19 ;; Author: John Kitchin <jkitchin@andrew.cmu.edu>
20 ;; This file is not currently part of GNU Emacs.
21
22 ;; This program is free software; you can redistribute it and/or
23 ;; modify it under the terms of the GNU General Public License as
24 ;; published by the Free Software Foundation; either version 2, or (at
25 ;; your option) any later version.
26
27 ;; This program is distributed in the hope that it will be useful, but
28 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
29 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
30 ;; General Public License for more details.
31
32 ;; You should have received a copy of the GNU General Public License
33 ;; along with this program ; see the file COPYING.  If not, write to
34 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
35 ;; Boston, MA 02111-1307, USA.
36
37 ;;; Commentary:
38 ;;
39 ;; Lisp code to generate and update bibtex entries from a DOI, and to
40 ;; download pdfs from publisher websites from a DOI.
41 ;;
42 ;; Package-Requires: ((org-ref))
43
44 (require 'json)
45 #+END_SRC
46
47 * Getting pdf files from a DOI
48 The idea here is simple. When you visit http://dx.doi.org/doi, you get redirected to the journal site. Once you have the url for the article, you can usually compute the url to the pdf, or find it in the page. Then you simply download it.
49
50 There are some subtleties in doing this that are described here. To get the redirect, we have to use url-retrieve, and a callback function. The callback does not return anything, so we communicate through global variables. url-retrieve is asynchronous, so we have to make sure to wait for it to finish.
51
52 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
53 (defvar *doi-utils-waiting* t
54   "stores waiting state for url retrieval.")
55
56 (defvar *doi-utils-redirect* nil
57   "stores redirect url from a callback function")
58
59 (defun doi-utils-redirect-callback (&optional status)
60   "callback for url-retrieve to set the redirect"
61   (when (plist-get status :error)
62     (signal (car (plist-get status :error)) (cdr(plist-get status :error))))
63   (when (plist-get status :redirect) ;  is nil if there none
64     (message "redirects = %s" (plist-get status :redirect))
65     (message "*doi-utils-redirect* set to %s"
66              (setq *doi-utils-redirect* (plist-get status :redirect))))
67   ;; we have done our job, so we are not waiting any more.
68   (setq *doi-utils-waiting* nil))
69 #+END_SRC
70
71 To actually get the redirect we use url-retrieve like this.
72
73 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
74 (defun doi-utils-get-redirect (doi)
75   "get redirect url from dx.doi.org/doi"
76   ;; we are going to wait until the url-retrieve is done
77   (setq *doi-utils-waiting* t)
78   ;; start with no redirect. it will be set in the callback.
79   (setq *doi-utils-redirect* nil)
80   (url-retrieve
81    (format "http://dx.doi.org/%s" doi)
82    'doi-utils-redirect-callback)
83   ; I suspect we need to wait here for the asynchronous process to
84   ; finish. we loop and sleep until the callback says it is done via
85   ; `*doi-utils-waiting*'. this works as far as i can tell. Before I
86   ; had to run this a few times to get it to work, which i suspect
87   ; just gave the first one enough time to finish.
88   (while *doi-utils-waiting* (sleep-for 0.1)))
89 #+END_SRC
90
91 Once we have a redirect for a particular doi, we need to compute the url to the pdf. We do this with a series of functions. Each function takes a single argument, the redirect url. If it knows how to compute the pdf url it does, and returns it. We store the functions in a variable:
92
93 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
94 (defvar doi-utils-pdf-url-functions nil
95   "list of functions that return a url to a pdf from a redirect url. Each function takes one argument, the redirect url. The function must return a pdf-url, or nil.")
96 #+END_SRC
97
98 ** APS journals
99 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
100 (defun aps-pdf-url (*doi-utils-redirect*)
101   (when (string-match "^http://journals.aps.org" *doi-utils-redirect*)
102     (replace-regexp-in-string "/abstract/" "/pdf/" *doi-utils-redirect*)))
103 #+END_SRC
104
105 ** Science
106 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
107 (defun science-pdf-url (*doi-utils-redirect*)
108   (when (string-match "^http://www.sciencemag.org" *doi-utils-redirect*)
109     (concat *doi-utils-redirect* ".full.pdf")))
110 #+END_SRC
111
112 ** Nature
113 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
114 (defun nature-pdf-url (*doi-utils-redirect*)
115   (when (string-match "^http://www.nature.com" *doi-utils-redirect*)
116     (let ((result *doi-utils-redirect*))
117       (setq result (replace-regexp-in-string "/full/" "/pdf/" result))
118       (replace-regexp-in-string "\.html$" "\.pdf" result))))
119 #+END_SRC
120
121 ** Wiley
122 http://onlinelibrary.wiley.com/doi/10.1002/anie.201402680/abstract
123 http://onlinelibrary.wiley.com/doi/10.1002/anie.201402680/pdf
124
125 It appears that it is not enough to use the pdf url above. That takes you to an html page. The actual link to teh pdf is embedded in that page. This is how ScienceDirect does things too.
126
127 This is where the link is hidden:
128
129 <iframe id="pdfDocument" src="http://onlinelibrary.wiley.com/store/10.1002/anie.201402680/asset/6397_ftp.pdf?v=1&amp;t=hwut2142&amp;s=d4bb3cd4ad20eb733836717f42346ffb34017831" width="100%" height="675px"></iframe>
130
131
132
133 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
134 (defun doi-utils-get-wiley-pdf-url (redirect-url)
135   "wileyscience direct hides the pdf url in html. we get it out here"
136   (setq *doi-utils-waiting* t)
137   (url-retrieve redirect-url
138                 (lambda (status)
139                   (beginning-of-buffer)
140                   (re-search-forward "<iframe id=\"pdfDocument\" src=\"\\([^\"]*\\)\"" nil)
141                   (setq *doi-utils-pdf-url* (match-string 1)
142                         ,*doi-utils-waiting* nil)))
143   (while *doi-utils-waiting* (sleep-for 0.1))
144   ,*doi-utils-pdf-url*)
145
146 (defun wiley-pdf-url (*doi-utils-redirect*)
147   (when (string-match "^http://onlinelibrary.wiley.com" *doi-utils-redirect*)
148    (doi-utils-get-wiley-pdf-url (replace-regexp-in-string "/abstract" "/pdf" *doi-utils-redirect*))
149    ,*doi-utils-pdf-url*))
150 #+END_SRC
151
152 ** Springer
153 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
154 (defun springer-pdf-url (*doi-utils-redirect*)
155   (when (string-match "^http://link.springer.com" *doi-utils-redirect*)
156     (replace-regexp-in-string "/article/" "/content/pdf/" (concat *doi-utils-redirect* ".pdf"))))
157 #+END_SRC
158
159 ** ACS
160 here is a typical url http://pubs.acs.org/doi/abs/10.1021/nl500037x
161 the pdf is found at http://pubs.acs.org/doi/pdf/10.1021/nl500037x
162
163 we just change /abs/ to /pdf/.
164
165 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
166 (defun acs-pdf-url (*doi-utils-redirect*)
167   (when (string-match "^http://pubs.acs.org" *doi-utils-redirect*)
168     (replace-regexp-in-string "/abs/" "/pdf/" *doi-utils-redirect*)))
169 #+END_SRC
170
171 #+BEGIN_SRC emacs-lisp :tangle no
172 (acs-pdf-url  "http://pubs.acs.org/doi/abs/10.1021/nl500037x")
173 #+END_SRC
174
175 #+RESULTS:
176 : http://pubs.acs.org/doi/pdf/10.1021/nl500037x
177
178 ** IOP
179 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
180 (defun iop-pdf-url (*doi-utils-redirect*)
181   (when (string-match "^http://iopscience.iop.org" *doi-utils-redirect*)
182     (let ((tail (replace-regexp-in-string "^http://iopscience.iop.org" "" *doi-utils-redirect*)))
183       (concat "http://iopscience.iop.org" tail "/pdf" (replace-regexp-in-string "/" "_" tail) ".pdf"))))
184 #+END_SRC
185
186 ** JSTOR
187 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
188 (defun jstor-pdf-url (*doi-utils-redirect*)
189   (when (string-match "^http://www.jstor.org" *doi-utils-redirect*)
190     (concat (replace-regexp-in-string "/stable/" "/stable/pdfplus/" *doi-utils-redirect*) ".pdf")))
191 #+END_SRC
192
193 ** AIP
194 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
195 (defun aip-pdf-url (*doi-utils-redirect*)
196   (when (string-match "^http://scitation.aip.org" *doi-utils-redirect*)
197     ;; get stuff after content
198     (let (p1 p2 s p3)
199       (setq p2 (replace-regexp-in-string "^http://scitation.aip.org/" "" *doi-utils-redirect*))
200       (setq s (split-string p2 "/"))
201       (setq p1 (mapconcat 'identity (-remove-at-indices '(0 6) s) "/"))
202       (setq p3 (concat "/" (nth 0 s) (nth 1 s) "/" (nth 2 s) "/" (nth 3 s)))
203       (format "http://scitation.aip.org/deliver/fulltext/%s.pdf?itemId=/%s&mimeType=pdf&containerItemId=%s"
204               p1 p2 p3))))
205 #+END_SRC
206
207 ** Taylor and Francis
208 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
209 (defun tandfonline-pdf-url (*doi-utils-redirect*)
210   (when (string-match "^http://www.tandfonline.com" *doi-utils-redirect*)
211     (replace-regexp-in-string "/abs/\\|/full/" "/pdf/" *doi-utils-redirect*)))
212 #+END_SRC
213 ** ECS
214 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
215 (defun ecs-pdf-url (*doi-utils-redirect*)
216   (when (string-match "^http://jes.ecsdl.org" *doi-utils-redirect*)
217     (replace-regexp-in-string "\.abstract$" ".full.pdf" *doi-utils-redirect*)))
218 #+END_SRC
219
220 http://ecst.ecsdl.org/content/25/2/2769
221 http://ecst.ecsdl.org/content/25/2/2769.full.pdf
222
223 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
224 (defun ecst-pdf-url (*doi-utils-redirect*)
225   (when (string-match "^http://ecst.ecsdl.org" *doi-utils-redirect*)
226     (concat *doi-utils-redirect* ".full.pdf")))
227 #+END_SRC
228
229
230 ** RSC
231 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
232 (defun rsc-pdf-url (*doi-utils-redirect*)
233   (when (string-match "^http://pubs.rsc.org" *doi-utils-redirect*)
234     (let ((url (downcase *doi-utils-redirect*)))
235       (setq url (replace-regexp-in-string "articlelanding" "articlepdf" url))
236       url)))
237 #+END_SRC
238
239 ** Elsevier/ScienceDirect
240 You cannot compute these pdf links; they are embedded in the redirected pages.
241
242 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
243 (defvar *doi-utils-pdf-url* nil
244   "stores url to pdf download from a callback function")
245
246 (defun doi-utils-get-science-direct-pdf-url (redirect-url)
247   "science direct hides the pdf url in html. we get it out here"
248   (setq *doi-utils-waiting* t)
249   (url-retrieve redirect-url
250                 (lambda (status)
251                   (beginning-of-buffer)
252                   (re-search-forward "pdfurl=\"\\([^\"]*\\)\"" nil t)
253                   (setq *doi-utils-pdf-url* (match-string 1)
254                         ,*doi-utils-waiting* nil)))
255   (while *doi-utils-waiting* (sleep-for 0.1))
256   ,*doi-utils-pdf-url*)
257
258
259 (defun science-direct-pdf-url (*doi-utils-redirect*)
260   (when (string-match "^http://www.sciencedirect.com" *doi-utils-redirect*)
261     (doi-utils-get-science-direct-pdf-url *doi-utils-redirect*)
262     ,*doi-utils-pdf-url*))
263
264 ;; sometimes I get
265 ;; http://linkinghub.elsevier.com/retrieve/pii/S0927025609004558
266 ;; which actually redirect to
267 ;; http://www.sciencedirect.com/science/article/pii/S0927025609004558
268 (defun linkinghub-elsevier-pdf-url (*doi-utils-redirect*)
269   (when (string-match "^http://linkinghub.elsevier.com/retrieve" *doi-utils-redirect*)
270     (let ((second-redirect (replace-regexp-in-string
271                             "http://linkinghub.elsevier.com/retrieve"
272                             "http://www.sciencedirect.com/science/article"
273                             ,*doi-utils-redirect*)))
274       (message "getting pdf url from %s" second-redirect)
275       ;(doi-utils-get-science-direct-pdf-url second-redirect)
276       ,*doi-utils-pdf-url*)))
277 #+END_SRC
278
279 ** PNAS
280 http://www.pnas.org/content/early/2014/05/08/1319030111
281 http://www.pnas.org/content/early/2014/05/08/1319030111.full.pdf
282
283 with supporting info
284 http://www.pnas.org/content/early/2014/05/08/1319030111.full.pdf+html?with-ds=yes
285 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
286 (defun pnas-pdf-url (*doi-utils-redirect*)
287   (when (string-match "^http://www.pnas.org" *doi-utils-redirect*)
288     (concat *doi-utils-redirect* ".full.pdf?with-ds=yes")))
289 #+END_SRC
290
291 ** Add all functions
292 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
293 (setq doi-utils-pdf-url-functions
294       (list
295        'aps-pdf-url
296        'science-pdf-url
297        'nature-pdf-url
298        'wiley-pdf-url
299        'springer-pdf-url
300        'acs-pdf-url
301        'iop-pdf-url
302        'jstor-pdf-url
303        'aip-pdf-url
304        'science-direct-pdf-url
305        'linkinghub-elsevier-pdf-url
306        'tandfonline-pdf-url
307        'ecs-pdf-url
308        'ecst-pdf-url
309        'rsc-pdf-url
310        'pnas-pdf-url))
311 #+END_SRC
312
313 ** Get the pdf url for a doi
314 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
315 (defun doi-utils-get-pdf-url (doi)
316   "returns a url to a pdf for the doi if one can be
317 calculated. Loops through the functions in `doi-utils-pdf-url-functions'
318 until one is found"
319   (doi-utils-get-redirect doi)
320
321   (unless *doi-utils-redirect*
322     (error "No redirect found for %s" doi))
323   (message "applying functions")
324   (catch 'pdf-url
325     (dolist (func doi-utils-pdf-url-functions)
326      (message "calling %s" func)
327       (let ((this-pdf-url (funcall func *doi-utils-redirect*)))
328 (message "t: %s" this-pdf-url)
329         (when this-pdf-url
330           (message "found pdf url: %s" this-pdf-url)
331           (throw 'pdf-url this-pdf-url))))))
332 #+END_SRC
333
334 #+RESULTS:
335 : doi-utils-get-pdf-url
336
337
338 #+BEGIN_SRC emacs-lisp :tangle no
339 (doi-utils-get-pdf-url "10.1126/science.1158722")
340 #+END_SRC
341
342 #+RESULTS:
343 : http://www.sciencemag.org/content/321/5890/792.full.pdf
344
345 #+BEGIN_SRC emacs-lisp :tangle no
346 (doi-utils-get-pdf-url  "10.1021/nl500037x")
347 #+END_SRC
348
349 #+RESULTS:
350 : http://pubs.acs.org/doi/pdf/10.1021/nl500037x
351
352
353 #+BEGIN_SRC emacs-lisp :tangle no
354 (doi-utils-get-pdf-url  "10.1002/anie.201402680")
355 #+END_SRC
356
357 #+RESULTS:
358 : http://onlinelibrary.wiley.com/doi/10.1002/anie.201402680/pdf
359
360 ** Finally, download the pdf
361 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
362 (defun doi-utils-get-bibtex-entry-pdf ()
363   "download pdf for entry at point if the pdf does not already
364 exist locally. The entry must have a doi. The pdf will be saved
365 to `org-ref-pdf-directory', by the name %s.pdf where %s is the
366 bibtex label. Files will not be overwritten. The pdf will be
367 checked to make sure it is a pdf, and not some html failure
368 page. you must have permission to access the pdf. We open the pdf
369 at the end."
370   (interactive)
371   (save-excursion
372     (bibtex-beginning-of-entry)
373     (let (;; get doi, removing http://dx.doi.org/ if it is there.
374           (doi (replace-regexp-in-string
375                 "http://dx.doi.org/" ""
376                 (bibtex-autokey-get-field "doi")))
377           (key)
378           (pdf-url)
379           (pdf-file)
380           (content))
381       ;; get the key and build pdf filename.
382       (re-search-forward bibtex-entry-maybe-empty-head)
383       (setq key (match-string bibtex-key-in-head))
384       (setq pdf-file (concat org-ref-pdf-directory key ".pdf"))
385
386       ;; now get file if needed.
387       (when (and doi (not (file-exists-p pdf-file)))
388         (setq pdf-url (doi-utils-get-pdf-url doi))
389         (if pdf-url
390             (progn
391               (url-copy-file pdf-url pdf-file)
392               ;; now check if we got a pdf
393               (with-temp-buffer
394                 (insert-file-contents pdf-file)
395                 ;; PDFS start with %PDF-1.x as the first few characters.
396                 (if (not (string= (buffer-substring 1 6) "%PDF-"))
397                     (progn
398                       (message "%s" (buffer-string))
399                       (delete-file pdf-file))
400                   (message "%s saved" pdf-file)))
401
402               (when (file-exists-p pdf-file)
403                 (org-open-file pdf-file)))
404           (message "No pdf-url found for %s at %s" doi *doi-utils-redirect* ))
405           pdf-file))))
406 #+END_SRC
407
408 * Getting bibtex entries from a DOI
409
410 I [[http://homepages.see.leeds.ac.uk/~eeaol/notes/2013/02/doi-metadata/][found]] you can download metadata about a DOI from http://dx.doi.org. You just have to construct the right http request to get it. Here is a function that gets the metadata as a plist in emacs.
411
412 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
413 (defun doi-utils-get-json-metadata (doi)
414   "Try to get json metadata for DOI. Open the DOI in a browser if we do not get it."
415   (let ((url-request-method "GET")
416         (url-mime-accept-string "application/citeproc+json")
417         (json-object-type 'plist)
418         (json-data))
419     (with-current-buffer
420         (url-retrieve-synchronously
421          (concat "http://dx.doi.org/" doi))
422       (setq json-data (buffer-substring url-http-end-of-headers (point-max)))
423       (if (string-match "Resource not found" json-data)
424           (progn
425             (browse-url (concat "http://dx.doi.org/" doi))
426             (error "Resource not found. Opening website."))
427         (json-read-from-string json-data)))))
428 #+END_SRC
429
430 #+RESULTS:
431 : doi-utils-get-json-metadata
432
433 For example:
434 #+BEGIN_SRC emacs-lisp :tangle no
435 (doi-utils-get-json-metadata "10.1103/PhysRevLett.99.016105")
436 #+END_SRC
437
438 #+RESULTS:
439 | :member | http://id.crossref.org/member/16 | :volume | 99 | :indexed | (:timestamp 1423435577602 :date-parts [[2015 2 8]]) | :publisher | American Physical Society (APS) | :source | CrossRef | :URL | http://dx.doi.org/10.1103/PhysRevLett.99.016105 | :ISSN | [0031-9007 1079-7114] | :DOI | 10.1103/physrevlett.99.016105 | :type | journal-article | :title | Scaling Properties of Adsorption Energies for Hydrogen-Containing Molecules on Transition-Metal Surfaces | :issue | 1 | :deposited | (:timestamp 1313712000000 :date-parts [[2011 8 19]]) | :reference-count | 26 | :container-title | Phys. Rev. Lett. | :author | [(:given F. :family Abild-Pedersen) (:given J. :family Greeley) (:given F. :family Studt) (:given J. :family Rossmeisl) (:given T. :family Munter) (:given P. :family Moses) (:given E. :family Skúlason) (:given T. :family Bligaard) (:given J. :family Nørskov)] | :prefix | http://id.crossref.org/prefix/10.1103 | :score | 1.0 | :issued | (:date-parts [[2007 7]]) | :subject | [Physics and Astronomy(all)] | :subtitle | [] |
440
441 or for a book:
442 #+BEGIN_SRC emacs-lisp :tangle no
443 (doi-utils-get-json-metadata "10.1007/978-1-4612-4968-9")
444 #+END_SRC
445
446 #+RESULTS:
447 | :member | nil | :indexed | (:timestamp 1423773021494 :date-parts [[2015 2 12]]) | :publisher | Springer New York | :source | CrossRef | :URL | http://dx.doi.org/10.1007/978-1-4612-4968-9 | :ISBN | [http://id.crossref.org/isbn/978-0-387-96347-1 http://id.crossref.org/isbn/978-1-4612-4968-9] | :ISSN | [0172-6056] | :DOI | 10.1007/978-1-4612-4968-9 | :type | book | :title | Constructive Combinatorics | :deposited | (:timestamp 1378684800000 :date-parts [[2013 9 9]]) | :reference-count | 0 | :container-title | Undergraduate Texts in Mathematics | :author | [(:given Dennis :family Stanton) (:given Dennis :family White)] | :prefix | none | :score | 1.0 | :issued | (:date-parts [[1986]]) | :subtitle | [] |
448
449 We can use that data to construct a bibtex entry. We do that by defining a template, and filling it in. I wrote this template expansion code which makes it easy to substitute values like %{} in emacs lisp.
450
451 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
452 (defun doi-utils-expand-template (s)
453   "expand a template containing %{} with the eval of its contents"
454   (replace-regexp-in-string "%{\\([^}]+\\)}"
455                             (lambda (arg)
456                               (let ((sexp (substring arg 2 -1)))
457                                 (format "%s" (eval (read sexp))))) s))
458 #+END_SRC
459
460 Now we define a function that fills in that template from the metadata.
461
462 As different bibtex types share common keys, it is advantageous to separate data extraction from json, and the formatting of the bibtex entry.
463
464 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
465 (setq doi-utils-json-metadata-extract
466       '((type       (plist-get results :type))
467         (author     (mapconcat (lambda (x) (concat (plist-get x :given) " " (plist-get x :family)))
468                      (plist-get results :author) " and "))
469         (title      (plist-get results :title))
470         (subtitle   (plist-get results :subtitle))
471         (journal    (plist-get results :container-title))
472         (series     (plist-get results :container-title))
473         (publisher  (plist-get results :publisher))
474         (volume     (plist-get results :volume))
475         (issue      (plist-get results :issue))
476         (number     (plist-get results :issue))
477         (year       (elt (elt (plist-get (plist-get results :issued) :date-parts) 0) 0))
478         (month      (elt (elt (plist-get (plist-get results :issued) :date-parts) 0) 1))
479         (pages      (plist-get results :page))
480         (doi        (plist-get results :DOI))
481         (url        (plist-get results :URL))
482         (booktitle  (plist-get results :container-title))))
483 #+END_SRC
484
485 Next, we need to define the different bibtex types. Each type has a bibtex type (for output) and the type as provided in the doi record. Finally, we have to declare the fields we want to output.
486
487 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el :results none
488 (setq doi-utils-bibtex-type-generators nil)
489
490 (defun doi-utils-concat-prepare (lst &optional acc)
491   "Given a list `lst' of strings and other expressions, which are
492 intented to passed to `concat', concat any subsequent strings,
493 minimising the number of arguments being passed to `concat'
494 without changing the results."
495   (cond ((null lst) (nreverse acc))
496         ((and (stringp (car lst))
497               (stringp (car acc)))
498          (doi-utils-concat-prepare (cdr lst) (cons (concat (car acc) (car lst))
499                                          (cdr acc))))
500         (t (doi-utils-concat-prepare (cdr lst) (cons (car lst) acc)))))
501
502 (defmacro doi-utils-def-bibtex-type (name matching-types &rest fields)
503   "Define a BibTeX type identified by (symbol) `name' with
504 `fields' (given as symbols), matching to retrieval expressions in
505 `doi-utils-json-metadata-extract'. This type will only be used
506 when the `:type' parameter in the JSON metadata is contained in
507 `matching-types' - a list of strings."
508   `(push (lambda (type results)
509            (when (or ,@(mapcar (lambda (match-type) `(string= type ,match-type)) matching-types))
510              (let ,(mapcar (lambda (field)
511                              (let ((field-expr (assoc field doi-utils-json-metadata-extract)))
512                                (if field-expr
513                                    ;; need to convert to string first
514                                    `(,(car field-expr) (format "%s" ,(cadr field-expr)))
515                                    (error "unknown bibtex field type %s" field))))
516                            fields)
517                (concat
518                 ,@(doi-utils-concat-prepare
519                    (-flatten
520                     (list (concat "@" (symbol-name name) "{,\n")
521                           ;; there seems to be some bug with mapcan,
522                           ;; so we fall back to flatten
523                           (mapcar (lambda (field)
524                                     `("  " ,(symbol-name field) " = {" ,field "},\n"))
525                                   fields)
526                           "}\n")))))))
527          doi-utils-bibtex-type-generators))
528
529 (doi-utils-def-bibtex-type article ("journal-article" "article-journal")
530                            author title journal year volume number pages doi url)
531
532 (doi-utils-def-bibtex-type inproceedings ("proceedings-article")
533                            author title booktitle year month pages doi url)
534
535 (doi-utils-def-bibtex-type book ("book")
536                            author title series publisher year pages doi url)
537
538 (doi-utils-def-bibtex-type inbook ("book-chapter")
539                            author title booktitle series publisher year pages doi url)
540
541 #+END_SRC
542
543 With the code generating the bibtex entry in place, we can glue it to the json retrieval code.
544 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
545 (defun doi-utils-doi-to-bibtex-string (doi)
546   "return a bibtex entry as a string for the doi. Not all types are supported yet."
547   (let* ((results (doi-utils-get-json-metadata doi))
548          (type (plist-get results :type)))
549     ;(format "%s" results) ; json-data
550     (or (some (lambda (g) (funcall g type results)) doi-utils-bibtex-type-generators)
551         (message "%s not supported yet\n%S." type results))))
552 #+END_SRC
553
554 #+RESULTS:
555 : doi-utils-doi-to-bibtex-string
556
557 To see that in action:
558 #+BEGIN_SRC emacs-lisp :tangle no
559 (doi-utils-doi-to-bibtex-string "10.1103/PhysRevLett.99.016105")
560 #+END_SRC
561
562 #+RESULTS:
563 #+begin_example
564 @article{,
565   author = {F. Abild-Pedersen and J. Greeley and F. Studt and J. Rossmeisl and T. Munter and P. Moses and E. Skúlason and T. Bligaard and J. Nørskov},
566   title = {Scaling Properties of Adsorption Energies for Hydrogen-Containing Molecules on Transition-Metal Surfaces},
567   journal = {Phys. Rev. Lett.},
568   year = {2007},
569   volume = {99},
570   number = {1},
571   pages = {nil},
572   doi = {10.1103/physrevlett.99.016105},
573   url = {http://dx.doi.org/10.1103/PhysRevLett.99.016105},
574 }
575 #+end_example
576
577 and for a book:
578
579 #+BEGIN_SRC emacs-lisp :tangle no
580 (doi-utils-doi-to-bibtex-string "10.1007/978-1-4612-4968-9")
581 #+END_SRC
582
583 #+RESULTS:
584 #+begin_example
585 @book{,
586   author = {Dennis Stanton and Dennis White},
587   title = {Constructive Combinatorics},
588   series = {Undergraduate Texts in Mathematics},
589   publisher = {Springer New York},
590   year = {1986},
591   pages = {nil},
592   doi = {10.1007/978-1-4612-4968-9},
593   url = {http://dx.doi.org/10.1007/978-1-4612-4968-9},
594 }
595 #+end_example
596
597 That is just the string for the entry. To be useful, we need a function that inserts the string into a buffer. This function will insert the string at the cursor, clean the entry, try to get the pdf, and create a notes entry for you.
598
599 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
600 (defun doi-utils-insert-bibtex-entry-from-doi (doi)
601   "insert bibtex entry from a doi. Also cleans entry using
602 org-ref, and tries to download the corresponding pdf."
603   (interactive "sDOI :")
604   (insert (doi-utils-doi-to-bibtex-string doi))
605   (backward-char)
606   ;; set date added for the record
607   (bibtex-set-field "DATE_ADDED" (current-time-string))
608   (if (bibtex-key-in-head nil)
609        (org-ref-clean-bibtex-entry t)
610      (org-ref-clean-bibtex-entry))
611    ;; try to get pdf
612    (doi-utils-get-bibtex-entry-pdf)
613    (save-selected-window
614      (org-ref-open-bibtex-notes)))
615
616 #+END_SRC
617
618 It may be you are in some other place when you want to add a bibtex entry. This next function will open the first entry in org-ref-default-bibliography go to the end, and add the entry. You can sort it later.
619
620 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
621 (defun doi-utils-add-bibtex-entry-from-doi (doi bibfile)
622   "Add entry to end of a file in in the current directory ending
623 with .bib or in `org-ref-default-bibliography'. If you have an
624 active region that starts like a DOI, that will be the initial
625 prompt. If no region is selected and the first entry of the
626 kill-ring starts like a DOI, then that is the intial
627 prompt. Otherwise, you have to type or pste in a DOI."
628   (interactive
629    (list (read-input "DOI: "
630                      ;; now set initial input
631                      (cond
632                       ;; If region is active and it starts like a doi we want it.
633                       ((and  (region-active-p)
634                              (s-match "^10" (buffer-substring
635                                               (region-beginning)
636                                               (region-end))))
637                        (buffer-substring (region-beginning) (region-end)))
638                       ;; if the first entry in the kill-ring looks
639                       ;; like a DOI, let's use it.
640                       ((if (s-match "^10" (car kill-ring))
641                            (car kill-ring)))
642                       ;; otherwise, we have no initial input. You
643                       ;; will have to type it in.
644                       (t
645                        nil)))
646          ;;  now get the bibfile to add it to
647          (ido-completing-read
648           "Bibfile: "
649           (append (f-entries "." (lambda (f) (f-ext? f "bib")))
650                   org-ref-default-bibliography))))
651   ;; Wrap in save-window-excursion to restore your window arrangement after this
652   ;; is done.
653   (save-window-excursion
654     (find-file bibfile)
655     ;; Check if the doi already exists
656     (goto-char (point-min))
657     (if (search-forward doi nil t)
658         (message "%s is already in this file" doi)
659       (end-of-buffer)
660       (insert "\n\n")
661       (doi-utils-insert-bibtex-entry-from-doi doi)
662       (save-buffer))))
663 #+END_SRC
664
665
666 * Updating bibtex entries
667 I wrote this code because it is pretty common for me to copy bibtex entries from ASAP articles that are incomplete, e.g. no page numbers because it is not in print yet. I wanted a convenient way to update an entry from its DOI. Basically, we get the metadata, and update the fields in the entry.
668
669 There is not bibtex set field function, so I wrote this one.
670
671 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
672 (defun bibtex-set-field (field value &optional nodelim)
673   "set field to value in bibtex file. create field if it does not exist"
674   (interactive "sfield: \nsvalue: ")
675   (bibtex-beginning-of-entry)
676   (let ((found))
677     (if (setq found (bibtex-search-forward-field field t))
678         ;; we found a field
679         (progn
680           (goto-char (car (cdr found)))
681           (when value
682             (bibtex-kill-field)
683             (bibtex-make-field field nil nil nodelim)
684             (backward-char)
685             (insert value)))
686       ;; make a new field
687       (message "new field being made")
688       (bibtex-beginning-of-entry)
689       (forward-line) (beginning-of-line)
690       (bibtex-next-field nil)
691       (forward-char)
692       (bibtex-make-field field nil nil nodelim)
693       (backward-char)
694       (insert value))))
695 #+END_SRC
696
697 The updating function for a whole entry looks like this. We get all the keys from the json plist metadata, and update the fields if they exist.
698
699 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
700 (defun plist-get-keys (plist)
701    "return keys in a plist"
702   (loop
703    for key in results by #'cddr collect key))
704
705 (defun doi-utils-update-bibtex-entry-from-doi (doi)
706   "update fields in a bibtex entry from the doi. Every field will be updated, so previous changes will be lost."
707   (interactive (list
708                 (or (replace-regexp-in-string "http://dx.doi.org/" "" (bibtex-autokey-get-field "doi"))
709                     (read-string "DOI: "))))
710   (let* ((results (doi-utils-get-json-metadata doi))
711          (type (plist-get results :type))
712          (author (mapconcat
713                   (lambda (x) (concat (plist-get x :given)
714                                     " " (plist-get x :family)))
715                   (plist-get results :author) " and "))
716          (title (plist-get results :title))
717          (journal (plist-get results :container-title))
718          (year (format "%s"
719                        (elt
720                         (elt
721                          (plist-get
722                           (plist-get results :issued) :date-parts) 0) 0)))
723         (volume (plist-get results :volume))
724         (number (or (plist-get results :issue) ""))
725         (pages (or (plist-get results :page) ""))
726         (url (or (plist-get results :URL) ""))
727         (doi (plist-get results :DOI)))
728
729     ;; map the json fields to bibtex fields. The code each field is mapped to is evaluated.
730     (setq mapping '((:author . (bibtex-set-field "author" author))
731                     (:title . (bibtex-set-field "title" title))
732                     (:container-title . (bibtex-set-field "journal" journal))
733                     (:issued . (bibtex-set-field "year" year))
734                     (:volume . (bibtex-set-field "volume" volume))
735                     (:issue . (bibtex-set-field "number" number))
736                     (:page . (bibtex-set-field "pages" pages))
737                     (:DOI . (bibtex-set-field "doi" doi))
738                     (:URL . (bibtex-set-field "url" url))))
739
740     ;; now we have code to run for each entry. we map over them and evaluate the code
741     (mapcar
742      (lambda (key)
743        (eval (cdr (assoc key mapping))))
744      (plist-get-keys results)))
745
746   ; reclean entry, but keep key if it exists.
747   (if (bibtex-key-in-head)
748       (org-ref-clean-bibtex-entry t)
749     (org-ref-clean-bibtex-entry)))
750 #+END_SRC
751
752 A downside to updating an entry is it overwrites what you have already fixed. So, we next develop a function to update the field at point.
753
754 #+BEGIN_SRC emacs-lisp
755 (defun doi-utils-update-field ()
756   (interactive)
757   (let* ((doi (bibtex-autokey-get-field "doi"))
758          (results (doi-utils-get-json-metadata doi))
759          (field (car (bibtex-find-text-internal nil nil ","))))
760     (cond
761      ((string= field "volume")
762       (bibtex-set-field field (plist-get results :volume)))
763      ((string= field "number")
764       (bibtex-set-field field (plist-get results :issue)))
765      ((string= field "pages")
766       (bibtex-set-field field (plist-get results :page)))
767      ((string= field "year")
768       (bibtex-set-field field (plist-get results :year)))
769      (t
770       (message "%s not supported yet." field)))))
771 #+END_SRC
772
773
774 * DOI functions for WOS
775 I came across this API http://wokinfo.com/media/pdf/OpenURL-guide.pdf to make links to the things I am interested in here. Based on that document, here are three links based on a doi:10.1021/jp047349j that take you to different Web Of Science (WOS) pages.
776
777
778 1. go to article in WOS: http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:doi/10.1021/jp047349j
779 2. citing articles: http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F10.1021/jp047349j&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.citing=yes
780 3. related articles: http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F10.1021/jp047349j&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.related=yes
781
782 These are pretty easy to construct, so we can write functions that will create them and open the url in our browser. There are some other options that could be considered, but since we usually have a doi, it seems like the best way to go for creating the links. Here are the functions.
783
784 #+BEGIN_SRC emacs-lisp  :tangle doi-utils.el
785 (defun doi-utils-wos (doi)
786   "Open Web of Science entry for DOI"
787   (interactive "sDOI: ")
788   (browse-url
789    (format
790     "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:doi/%s" doi)))
791
792 (defun doi-utils-wos-citing (doi)
793   "Open Web of Science citing articles entry. May be empty if none are found"
794   (interactive "sDOI: ")
795   (browse-url
796    (concat
797     "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F"
798     doi
799     "&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.citing=yes")))
800
801 (defun doi-utils-wos-related (doi)
802   "Open Web of Science related articles page."
803   (interactive "sDOI: ")
804   (browse-url
805    (concat "http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info%3Adoi%2F"
806            doi
807            "&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&svc.related=yes")))
808
809 #+END_SRC
810
811 * A new doi link for org-mode
812 The idea is to add a menu to the doi link, so rather than just clicking to open the article, you can do other things.
813 1. open doi
814 2. open in wos
815 3. open citing articles
816 4. open related articles
817 5. open bibtex entry
818 6. get bibtex entry
819
820 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el :results silent
821 (defun doi-utils-open (doi)
822  (interactive "sDOI: ")
823  (browse-url (concat "http://dx.doi.org/" doi)))
824
825
826 (defun doi-utils-open-bibtex (doi)
827   "Search through `reftex-default-bibliography' for DOI."
828   (interactive "sDOI: ")
829   (catch 'file
830     (dolist (f reftex-default-bibliography)
831       (find-file f)
832       (when (search-forward doi (point-max) t)
833         (bibtex-beginning-of-entry)
834         (throw 'file t)))))
835
836
837 (defun doi-utils-crossref (doi)
838   "Search DOI in CrossRef."
839   (interactive "sDOI: ")
840   (browse-url
841    (format
842     "http://search.crossref.org/?q=%s" doi)))
843
844
845 (defun doi-utils-google-scholar (doi)
846   "Google scholar the word at point or selection."
847   (interactive "sDOI: ")
848   (browse-url
849    (format
850     "http://scholar.google.com/scholar?q=%s" doi)))
851
852
853 (defun doi-utils-pubmed (doi)
854   "Pubmed the word at point or selection."
855   (interactive "sDOI: ")
856   (browse-url
857    (format
858     "http://www.ncbi.nlm.nih.gov/pubmed/?term=%s"
859     (url-hexify-string doi))))
860
861
862 (defvar doi-link-menu-funcs '()
863  "Functions to run in doi menu. Each entry is a list of (key menu-name function).
864 The function must take one argument, the doi.")
865
866 (setq doi-link-menu-funcs
867       '(("o" "pen" doi-utils-open)
868         ("w" "os" doi-utils-wos)
869         ("c" "iting articles" doi-utils-wos-citing)
870         ("r" "elated articles" doi-utils-wos-related)
871         ("s" "Google Scholar" doi-utils-google-scholar)
872         ("f" "CrossRef" doi-utils-crossref)
873         ("p" "ubmed" doi-utils-pubmed)
874         ("b" "open in bibtex" doi-utils-open-bibtex)
875         ("g" "et bibtex entry" doi-utils-add-bibtex-entry-from-doi)))
876
877
878 (defun doi-link-menu (link-string)
879    "Generate the link menu message, get choice and execute it.
880 Options are stored in `doi-link-menu-funcs'."
881    (interactive)
882    (message
883    (concat
884     (mapconcat
885      (lambda (tup)
886        (concat "[" (elt tup 0) "]"
887                (elt tup 1) " "))
888      doi-link-menu-funcs "") ": "))
889    (let* ((input (read-char-exclusive))
890           (choice (assoc
891                    (char-to-string input) doi-link-menu-funcs)))
892      (when choice
893        (funcall
894         (elt
895          choice
896          2)
897         link-string))))
898
899 (org-add-link-type
900  "doi"
901  'doi-link-menu)
902 #+END_SRC
903
904 doi:10.1021/jp047349j
905
906
907 * Getting a doi for a bibtex entry missing one
908 Some bibtex entries do not have a DOI, maybe because they were entered by hand, or copied from a source that did not have it available. Here we develop some functions to help you find the DOI using Crossref.
909
910 Here is our example bibtex entry.
911 #+BEGIN_SRC bibtex
912 @article{deml-2014-oxide,
913   author =       {Ann M. Deml and Vladan Stevanovi{\'c} and
914                   Christopher L. Muhich and Charles B. Musgrave and
915                   Ryan O'Hayre},
916   title =        {Oxide Enthalpy of Formation and Band Gap Energy As
917                   Accurate Descriptors of Oxygen Vacancy Formation
918                   Energetics},
919   journal =      {Energy Environ. Sci.},
920   volume =       7,
921   number =       6,
922   pages =        1996,
923   year =         2014,
924   doi =          {10.1039/c3ee43874k,
925   url =          {http://dx.doi.org/10.1039/c3ee43874k}},
926
927 }
928
929
930 #+END_SRC
931
932 The idea is to query Crossref in a way that is likely to give us a hit relevant to the entry.
933
934 According to http://search.crossref.org/help/api we can send a query with a free form citation that may give us something back. We do this to get a list of candidates, and run a helm command to get the doi.
935
936
937 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
938 (defun doi-utils-crossref-citation-query ()
939   "Query Crossref with the title of the bibtex entry at point to
940 get a list of possible matches. This opens a helm buffer to
941 select an entry. The default action inserts a doi and url field
942 in the bibtex entry at point. The second action opens the doi
943 url. If there is already a doi field, the function raises an
944 error."
945   (interactive)
946   (bibtex-beginning-of-entry)
947   (let* ((entry (bibtex-parse-entry))
948          (json-string)
949          (json-data)
950          (doi))
951     (unless (string= ""(reftex-get-bib-field "doi" entry))
952       (error "Entry already has a doi field"))
953
954     (with-current-buffer
955         (url-retrieve-synchronously
956          (concat
957           "http://search.crossref.org/dois?q="
958           (url-hexify-string (org-ref-bib-citation))))
959       (setq json-string (buffer-substring url-http-end-of-headers (point-max)))
960       (setq json-data (json-read-from-string json-string)))
961
962     (let* ((name (format "Crossref hits for %s" (org-ref-bib-citation)))
963            (helm-candidates (mapcar (lambda (x)
964                                       (cons
965                                        (concat
966                                         (cdr (assoc 'fullCitation x))
967                                         " "
968                                         (cdr (assoc 'doi x)))
969                                        (cdr (assoc 'doi x))))
970                                       json-data))
971            (source `((name . ,name)
972                      (candidates . ,helm-candidates)
973                      ;; just return the candidate
974                      (action . (("Insert doi and url field" . (lambda (doi)
975                                                                 (bibtex-make-field "doi")
976                                                                 (backward-char)
977                                                                 ;; crossref returns doi url, but I prefer only a doi for the doi field
978                                                                 (insert (replace-regexp-in-string "^http://dx.doi.org/" "" doi))
979                                                                 (when (string= ""(reftex-get-bib-field "url" entry))
980                                                                   (bibtex-make-field "url")
981                                                                   (backward-char)
982                                                                   (insert doi))))
983                                 ("Open url" . (lambda (doi)
984                                                 (browse-url doi))))))))
985       (helm :sources '(source)))))
986 #+END_SRC
987
988 #+RESULTS:
989 : doi-utils-crossref-citation-query
990
991
992
993 * Debugging a DOI
994 I wrote this function to help debug a DOI. This function generates an org-buffer with the doi, gets the json metadata, shows the bibtex entry, and the pdf link for it.
995
996 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
997 (defun doi-utils-debug (doi)
998   "Generate an org-buffer showing data about DOI."
999   (interactive "sDOI: ")
1000   (switch-to-buffer "*debug-doi*")
1001   (erase-buffer)
1002   (org-mode)
1003   (insert (concat "doi:" doi) "\n\n")
1004   (insert "* JSON
1005 " (format "%s" (doi-utils-get-json-metadata doi)) "
1006
1007 * Bibtex
1008
1009 " (doi-utils-doi-to-bibtex-string doi) "
1010
1011 * PDF
1012 " (doi-utils-get-pdf-url doi)))
1013 #+END_SRC
1014
1015 #+RESULTS:
1016 : doi-utils-debug
1017
1018 * Adding a bibtex entry from a crossref query
1019 The idea here is to perform a query on Crossref, get a helm buffer of candidates, and select the entry(ies) you want to add to your bibtex file. You can select a region, e.g. a free form citation, or set of words, or you can type the query in by hand.
1020
1021 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
1022 (defun doi-utils-add-entry-from-crossref-query (query bibtex-file)
1023   (interactive (list
1024                 (read-input
1025                  "Query: "
1026                  ;; now set initial input
1027                  (cond
1028                   ;; If region is active assume we want it
1029                   ((region-active-p)
1030                    (replace-regexp-in-string
1031                     "\n" " "
1032                     (buffer-substring (region-beginning) (region-end))))
1033                   ;; type or paste it in
1034                   (t
1035                    nil)))
1036                 (ido-completing-read
1037                  "Bibfile: "
1038                  (append (f-entries "." (lambda (f) (f-ext? f "bib")))
1039                          org-ref-default-bibliography))))
1040   (let* ((json-string)
1041          (json-data)
1042          (doi))
1043
1044     (with-current-buffer
1045         (url-retrieve-synchronously
1046          (concat
1047           "http://search.crossref.org/dois?q="
1048           (url-hexify-string query)))
1049       (setq json-string (buffer-substring url-http-end-of-headers (point-max)))
1050       (setq json-data (json-read-from-string json-string)))
1051
1052     (let* ((name (format "Crossref hits for %s"
1053                          ;; remove carriage returns. they cause problems in helm.
1054                          (replace-regexp-in-string "\n" " " query)))
1055            (helm-candidates (mapcar (lambda (x)
1056                                       (cons
1057                                        (concat
1058                                         (cdr (assoc 'fullCitation x))
1059                                         " "
1060                                         (cdr (assoc 'doi x)))
1061                                        (cdr (assoc 'doi x))))
1062                                       json-data))
1063            (source `((name . ,name)
1064                      (candidates . ,helm-candidates)
1065                      ;; just return the candidate
1066                      (action . (("Insert bibtex entry" . (lambda (doi)
1067                                                            (doi-utils-add-bibtex-entry-from-doi
1068                                                             (replace-regexp-in-string "^http://dx.doi.org/" "" doi) ,bibtex-file)))
1069                                 ("Open url" . (lambda (doi)
1070                                                 (browse-url doi))))))))
1071       (helm :sources '(source)))))
1072 #+END_SRC
1073
1074 ** json
1075
1076 #+name: json
1077 #+BEGIN_EXAMPLE
1078 [
1079   {
1080     "doi": "http://dx.doi.org/10.1039/c3ee43874k",
1081     "score": 4.7002907,
1082     "normalizedScore": 100,
1083     "title": "Oxide enthalpy of formation and band gap energy as accurate descriptors of oxygen vacancy formation energetics",
1084     "fullCitation": "Ann M. Deml, Vladan Stevanović, Christopher L. Muhich, Charles B. Musgrave, Ryan O'Hayre, 2014, 'Oxide enthalpy of formation and band gap energy as accurate descriptors of oxygen vacancy formation energetics', <i>Energy &amp; Environmental Science</i>, vol. 7, no. 6, p. 1996",
1085     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1039%2Fc3ee43874k&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Oxide+enthalpy+of+formation+and+band+gap+energy+as+accurate+descriptors+of+oxygen+vacancy+formation+energetics&amp;rft.jtitle=Energy+%26+Environmental+Science&amp;rft.date=2014&amp;rft.volume=7&amp;rft.issue=6&amp;rft.spage=1996&amp;rft.aufirst=Ann+M.&amp;rft.aulast=Deml&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Ann+M.+Deml&amp;rft.au=+Vladan+Stevanovi%C4%87&amp;rft.au=+Christopher+L.+Muhich&amp;rft.au=+Charles+B.+Musgrave&amp;rft.au=+Ryan+O%27Hayre",
1086     "year": "2014"
1087   },
1088   {
1089     "doi": "http://dx.doi.org/10.1103/physrevb.86.085123",
1090     "score": 1.129964,
1091     "normalizedScore": 24,
1092     "title": "Composition-dependent oxygen vacancy formation in multicomponent wide-band-gap oxides",
1093     "fullCitation": "Altynbek Murat, Julia E. Medvedeva, 2012, 'Composition-dependent oxygen vacancy formation in multicomponent wide-band-gap oxides', <i>Physical Review B</i>, vol. 86, no. 8",
1094     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1103%2Fphysrevb.86.085123&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Composition-dependent+oxygen+vacancy+formation+in+multicomponent+wide-band-gap+oxides&amp;rft.jtitle=Physical+Review+B&amp;rft.date=2012&amp;rft.volume=86&amp;rft.issue=8&amp;rft.aufirst=Altynbek&amp;rft.aulast=Murat&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Altynbek+Murat&amp;rft.au=+Julia+E.+Medvedeva",
1095     "year": "2012"
1096   },
1097   {
1098     "doi": "http://dx.doi.org/10.1021/cm5033755",
1099     "score": 0.94063884,
1100     "normalizedScore": 20,
1101     "title": " Tunable Oxygen Vacancy Formation Energetics in the Complex Perovskite Oxide Sr  x  La  1– x  Mn  y  Al  1– y  O 3 ",
1102     "fullCitation": "Ann M. Deml, Vladan Stevanović, Aaron M. Holder, Michael Sanders, Ryan O’Hayre, Charles B. Musgrave, 2014, ' Tunable Oxygen Vacancy Formation Energetics in the Complex Perovskite Oxide Sr  x  La  1– x  Mn  y  Al  1– y  O 3 ', <i>Chemistry of Materials</i>, vol. 26, no. 22, pp. 6595-6602",
1103     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1021%2Fcm5033755&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=+Tunable+Oxygen+Vacancy+Formation+Energetics+in+the+Complex+Perovskite+Oxide+Sr++x++La++1%E2%80%93+x++Mn++y++Al++1%E2%80%93+y++O+3+&amp;rft.jtitle=Chemistry+of+Materials&amp;rft.date=2014&amp;rft.volume=26&amp;rft.issue=22&amp;rft.spage=6595&amp;rft.epage=6602&amp;rft.aufirst=Ann+M.&amp;rft.aulast=Deml&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Ann+M.+Deml&amp;rft.au=+Vladan+Stevanovi%C4%87&amp;rft.au=+Aaron+M.+Holder&amp;rft.au=+Michael+Sanders&amp;rft.au=+Ryan+O%E2%80%99Hayre&amp;rft.au=+Charles+B.+Musgrave",
1104     "year": "2014"
1105   },
1106   {
1107     "doi": "http://dx.doi.org/10.1103/physrevb.37.5905",
1108     "score": 0.8346345,
1109     "normalizedScore": 17,
1110     "title": "Oxygen-vacancy-formation enthalpy in YBa_{2}(Cu_{0.985}Fe_{0.015})_{3}O_{7-δ} oxide superconductor",
1111     "fullCitation": "Chuck Blue, Khaled Elgaid, Ivan Zitkovsky, P. Boolchand, Darl McDaniel, W. Joiner, Jean Oostens, Warren Huff, 1988, 'Oxygen-vacancy-formation enthalpy in YBa_{2}(Cu_{0.985}Fe_{0.015})_{3}O_{7-δ} oxide superconductor', <i>Physical Review B</i>, vol. 37, no. 10, pp. 5905-5908",
1112     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1103%2Fphysrevb.37.5905&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Oxygen-vacancy-formation+enthalpy+in+YBa_%7B2%7D%28Cu_%7B0.985%7DFe_%7B0.015%7D%29_%7B3%7DO_%7B7-%CE%B4%7D+oxide+superconductor&amp;rft.jtitle=Physical+Review+B&amp;rft.date=1988&amp;rft.volume=37&amp;rft.issue=10&amp;rft.spage=5905&amp;rft.epage=5908&amp;rft.aufirst=Chuck&amp;rft.aulast=Blue&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Chuck+Blue&amp;rft.au=+Khaled+Elgaid&amp;rft.au=+Ivan+Zitkovsky&amp;rft.au=+P.+Boolchand&amp;rft.au=+Darl+McDaniel&amp;rft.au=+W.+Joiner&amp;rft.au=+Jean+Oostens&amp;rft.au=+Warren+Huff",
1113     "year": "1988"
1114   },
1115   {
1116     "doi": "http://dx.doi.org/10.1063/1.1732384",
1117     "score": 0.7613335,
1118     "normalizedScore": 16,
1119     "title": "Enthalpy of Formation of Oxygen Vacancies in Barium Oxide",
1120     "fullCitation": "H. Holloway, 1962, 'Enthalpy of Formation of Oxygen Vacancies in Barium Oxide', <i>The Journal of Chemical Physics</i>, vol. 36, no. 11, p. 2820",
1121     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1063%2F1.1732384&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Enthalpy+of+Formation+of+Oxygen+Vacancies+in+Barium+Oxide&amp;rft.jtitle=The+Journal+of+Chemical+Physics&amp;rft.date=1962&amp;rft.volume=36&amp;rft.issue=11&amp;rft.spage=2820&amp;rft.aufirst=H.&amp;rft.aulast=Holloway&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=H.+Holloway",
1122     "year": "1962"
1123   },
1124   {
1125     "doi": "http://dx.doi.org/10.1002/crat.2170221219",
1126     "score": 0.73206276,
1127     "normalizedScore": 15,
1128     "title": "Vacancy formation enthalpy in AgZn alloys",
1129     "fullCitation": "St. Chabik, 1987, 'Vacancy formation enthalpy in AgZn alloys', <i>Crystal Research and Technology</i>, vol. 22, no. 12, pp. 1523-1527",
1130     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1002%2Fcrat.2170221219&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Vacancy+formation+enthalpy+in+AgZn+alloys&amp;rft.jtitle=Crystal+Research+and+Technology&amp;rft.date=1987&amp;rft.volume=22&amp;rft.issue=12&amp;rft.spage=1523&amp;rft.epage=1527&amp;rft.aufirst=St.&amp;rft.aulast=Chabik&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=St.+Chabik",
1131     "year": "1987"
1132   },
1133   {
1134     "doi": "http://dx.doi.org/10.1007/s10562-013-0985-7",
1135     "score": 0.692246,
1136     "normalizedScore": 14,
1137     "title": "Methane Oxidation by Lanthanum Oxide Doped with Cu, Zn, Mg, Fe, Nb, Ti, Zr, or Ta: The Connection Between the Activation Energy and the Energy of Oxygen-Vacancy Formation",
1138     "fullCitation": "Alan R. Derk, Bo Li, Sudhanshu Sharma, George M. Moore, Eric W. McFarland, Horia Metiu, 2013, 'Methane Oxidation by Lanthanum Oxide Doped with Cu, Zn, Mg, Fe, Nb, Ti, Zr, or Ta: The Connection Between the Activation Energy and the Energy of Oxygen-Vacancy Formation', <i>Catalysis Letters</i>, vol. 143, no. 5, pp. 406-410",
1139     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1007%2Fs10562-013-0985-7&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Methane+Oxidation+by+Lanthanum+Oxide+Doped+with+Cu%2C+Zn%2C+Mg%2C+Fe%2C+Nb%2C+Ti%2C+Zr%2C+or+Ta%3A+The+Connection+Between+the+Activation+Energy+and+the+Energy+of+Oxygen-Vacancy+Formation&amp;rft.jtitle=Catalysis+Letters&amp;rft.date=2013&amp;rft.volume=143&amp;rft.issue=5&amp;rft.spage=406&amp;rft.epage=410&amp;rft.aufirst=Alan+R.&amp;rft.aulast=Derk&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Alan+R.+Derk&amp;rft.au=+Bo+Li&amp;rft.au=+Sudhanshu+Sharma&amp;rft.au=+George+M.+Moore&amp;rft.au=+Eric+W.+McFarland&amp;rft.au=+Horia+Metiu",
1140     "year": "2013"
1141   },
1142   {
1143     "doi": "http://dx.doi.org/10.1039/c3cp55214d",
1144     "score": 0.6675249,
1145     "normalizedScore": 14,
1146     "title": "Oxygen vacancy formation and annihilation in lanthanum cerium oxide as a metal reactive oxide on 4H-silicon carbide",
1147     "fullCitation": "Way Foong Lim, Kuan Yew Cheong, 2014, 'Oxygen vacancy formation and annihilation in lanthanum cerium oxide as a metal reactive oxide on 4H-silicon carbide', <i>Physical Chemistry Chemical Physics</i>, vol. 16, no. 15, p. 7015",
1148     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1039%2Fc3cp55214d&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Oxygen+vacancy+formation+and+annihilation+in+lanthanum+cerium+oxide+as+a+metal+reactive+oxide+on+4H-silicon+carbide&amp;rft.jtitle=Physical+Chemistry+Chemical+Physics&amp;rft.date=2014&amp;rft.volume=16&amp;rft.issue=15&amp;rft.spage=7015&amp;rft.aufirst=Way+Foong&amp;rft.aulast=Lim&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Way+Foong+Lim&amp;rft.au=+Kuan+Yew+Cheong",
1149     "year": "2014"
1150   },
1151   {
1152     "doi": "http://dx.doi.org/10.1021/cm052543j",
1153     "score": 0.6519111,
1154     "normalizedScore": 13,
1155     "title": "Energetics of Bulk and Nano-Akaganeite, Î²-FeOOH:  Enthalpy of Formation, Surface Enthalpy, and Enthalpy of Water Adsorption",
1156     "fullCitation": "Lena Mazeina, Suraj Deore, Alexandra Navrotsky, 2006, 'Energetics of Bulk and Nano-Akaganeite, Î²-FeOOH:  Enthalpy of Formation, Surface Enthalpy, and Enthalpy of Water Adsorption', <i>Chemistry of Materials</i>, vol. 18, no. 7, pp. 1830-1838",
1157     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1021%2Fcm052543j&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Energetics+of+Bulk+and+Nano-Akaganeite%2C+%CE%B2-FeOOH%3A%C2%A0+Enthalpy+of+Formation%2C+Surface+Enthalpy%2C+and+Enthalpy+of+Water+Adsorption&amp;rft.jtitle=Chemistry+of+Materials&amp;rft.date=2006&amp;rft.volume=18&amp;rft.issue=7&amp;rft.spage=1830&amp;rft.epage=1838&amp;rft.aufirst=Lena&amp;rft.aulast=Mazeina&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Lena+Mazeina&amp;rft.au=+Suraj+Deore&amp;rft.au=+Alexandra+Navrotsky",
1158     "year": "2006"
1159   },
1160   {
1161     "doi": "http://dx.doi.org/10.1063/1.1677897",
1162     "score": 0.6344446,
1163     "normalizedScore": 13,
1164     "title": "Thermochemical and Theoretical Investigations of the Sodium-Oxygen System. I. The Standard Enthalpy of Formation of Sodium Oxide (Na2O)",
1165     "fullCitation": "P. A. G. O'Hare, 1972, 'Thermochemical and Theoretical Investigations of the Sodium-Oxygen System. I. The Standard Enthalpy of Formation of Sodium Oxide (Na2O)', <i>The Journal of Chemical Physics</i>, vol. 56, no. 9, p. 4513",
1166     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1063%2F1.1677897&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Thermochemical+and+Theoretical+Investigations+of+the+Sodium-Oxygen+System.+I.+The+Standard+Enthalpy+of+Formation+of+Sodium+Oxide+%28Na2O%29&amp;rft.jtitle=The+Journal+of+Chemical+Physics&amp;rft.date=1972&amp;rft.volume=56&amp;rft.issue=9&amp;rft.spage=4513&amp;rft.aufirst=P.+A.+G.&amp;rft.aulast=O%27Hare&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=P.+A.+G.+O%27Hare",
1167     "year": "1972"
1168   },
1169   {
1170     "doi": "http://dx.doi.org/10.1063/1.1679492",
1171     "score": 0.6344446,
1172     "normalizedScore": 13,
1173     "title": "Erratum: Thermochemical and theoretical investigations of the sodium-oxygen system. I. The standard enthalpy of formation of sodium oxide (Na2O)",
1174     "fullCitation": "P. A. G. O'Hare, 1973, 'Erratum: Thermochemical and theoretical investigations of the sodium-oxygen system. I. The standard enthalpy of formation of sodium oxide (Na2O)', <i>The Journal of Chemical Physics</i>, vol. 58, no. 5, p. 2196",
1175     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1063%2F1.1679492&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Erratum%3A+Thermochemical+and+theoretical+investigations+of+the+sodium-oxygen+system.+I.+The+standard+enthalpy+of+formation+of+sodium+oxide+%28Na2O%29&amp;rft.jtitle=The+Journal+of+Chemical+Physics&amp;rft.date=1973&amp;rft.volume=58&amp;rft.issue=5&amp;rft.spage=2196&amp;rft.aufirst=P.+A.+G.&amp;rft.aulast=O%27Hare&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=P.+A.+G.+O%27Hare",
1176     "year": "1973"
1177   },
1178   {
1179     "doi": "http://dx.doi.org/10.1002/pssb.19680250249",
1180     "score": 0.62748235,
1181     "normalizedScore": 13,
1182     "title": "On enthalpy calculation of vacancy formation in inorganic substances",
1183     "fullCitation": "B. N. Oshcherin, 1968, 'On enthalpy calculation of vacancy formation in inorganic substances', <i>Physica Status Solidi (b)</i>, vol. 25, no. 2, pp. K123-K125",
1184     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1002%2Fpssb.19680250249&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=On+enthalpy+calculation+of+vacancy+formation+in+inorganic+substances&amp;rft.jtitle=Physica+Status+Solidi+%28b%29&amp;rft.date=1968&amp;rft.volume=25&amp;rft.issue=2&amp;rft.spage=K123&amp;rft.epage=K125&amp;rft.aufirst=B.+N.&amp;rft.aulast=Oshcherin&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=B.+N.+Oshcherin",
1185     "year": "1968"
1186   },
1187   {
1188     "doi": "http://dx.doi.org/10.1002/pssb.2221040224",
1189     "score": 0.62748235,
1190     "normalizedScore": 13,
1191     "title": "Vacancy Formation Enthalpy in Cadmium by Positron Lifetime Measurements",
1192     "fullCitation": "P. Mascher, L. Breitenhuber, W. Puff, 1981, 'Vacancy Formation Enthalpy in Cadmium by Positron Lifetime Measurements', <i>physica status solidi (b)</i>, vol. 104, no. 2, pp. 601-605",
1193     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1002%2Fpssb.2221040224&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Vacancy+Formation+Enthalpy+in+Cadmium+by+Positron+Lifetime+Measurements&amp;rft.jtitle=physica+status+solidi+%28b%29&amp;rft.date=1981&amp;rft.volume=104&amp;rft.issue=2&amp;rft.spage=601&amp;rft.epage=605&amp;rft.aufirst=P.&amp;rft.aulast=Mascher&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=P.+Mascher&amp;rft.au=+L.+Breitenhuber&amp;rft.au=+W.+Puff",
1194     "year": "1981"
1195   },
1196   {
1197     "doi": "http://dx.doi.org/10.1016/0375-9601(79)90707-2",
1198     "score": 0.62748235,
1199     "normalizedScore": 13,
1200     "title": "Vacancy formation enthalpy in Î³ cerium from positron annihilation",
1201     "fullCitation": "M. Boidron, R. Paulin, 1979, 'Vacancy formation enthalpy in Î³ cerium from positron annihilation', <i>Physics Letters A</i>, vol. 73, no. 3, pp. 200-202",
1202     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1016%2F0375-9601%2879%2990707-2&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Vacancy+formation+enthalpy+in+%CE%B3+cerium+from+positron+annihilation&amp;rft.jtitle=Physics+Letters+A&amp;rft.date=1979&amp;rft.volume=73&amp;rft.issue=3&amp;rft.spage=200&amp;rft.epage=202&amp;rft.aufirst=M.&amp;rft.aulast=Boidron&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=M.+Boidron&amp;rft.au=+R.+Paulin",
1203     "year": "1979"
1204   },
1205   {
1206     "doi": "http://dx.doi.org/10.1016/0036-9748(83)90449-0",
1207     "score": 0.62748235,
1208     "normalizedScore": 13,
1209     "title": "Estimation of the vacancy formation enthalpy of metals",
1210     "fullCitation": "Alcides R. Patete, Joachim P. Neumann, 1983, 'Estimation of the vacancy formation enthalpy of metals', <i>Scripta Metallurgica</i>, vol. 17, no. 8, pp. 1047-1048",
1211     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1016%2F0036-9748%2883%2990449-0&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Estimation+of+the+vacancy+formation+enthalpy+of+metals&amp;rft.jtitle=Scripta+Metallurgica&amp;rft.date=1983&amp;rft.volume=17&amp;rft.issue=8&amp;rft.spage=1047&amp;rft.epage=1048&amp;rft.aufirst=Alcides+R.&amp;rft.aulast=Patete&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Alcides+R.+Patete&amp;rft.au=+Joachim+P.+Neumann",
1212     "year": "1983"
1213   },
1214   {
1215     "doi": "http://dx.doi.org/10.1039/c3ja50034a",
1216     "score": 0.62469214,
1217     "normalizedScore": 13,
1218     "title": "Formation of an oxygen vacancy-dinitrogen complex in nitrogen-doped hafnium oxide",
1219     "fullCitation": "Mino Yang, Jee-Hwan Bae, Cheol-Woong Yang, Anass Benayad, Hionsuck Baik, 2013, 'Formation of an oxygen vacancy-dinitrogen complex in nitrogen-doped hafnium oxide', <i>Journal of Analytical Atomic Spectrometry</i>, vol. 28, no. 4, p. 482",
1220     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1039%2Fc3ja50034a&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Formation+of+an+oxygen+vacancy-dinitrogen+complex+in+nitrogen-doped+hafnium+oxide&amp;rft.jtitle=Journal+of+Analytical+Atomic+Spectrometry&amp;rft.date=2013&amp;rft.volume=28&amp;rft.issue=4&amp;rft.spage=482&amp;rft.aufirst=Mino&amp;rft.aulast=Yang&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Mino+Yang&amp;rft.au=+Jee-Hwan+Bae&amp;rft.au=+Cheol-Woong+Yang&amp;rft.au=+Anass+Benayad&amp;rft.au=+Hionsuck+Baik",
1221     "year": "2013"
1222   },
1223   {
1224     "doi": "http://dx.doi.org/10.1016/0021-9517(81)90023-3",
1225     "score": 0.62469214,
1226     "normalizedScore": 13,
1227     "title": "SCF-SW-X$alpha; calculations of the removal of oxygen from oxide surfaces by vacancy formation and crystallographic shear mechanisms",
1228     "fullCitation": "E BROCAWIK, 1981, 'SCF-SW-X$alpha; calculations of the removal of oxygen from oxide surfaces by vacancy formation and crystallographic shear mechanisms', <i>Journal of Catalysis</i>, vol. 72, no. 2, pp. 379-382",
1229     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1016%2F0021-9517%2881%2990023-3&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=SCF-SW-X%24alpha%3B+calculations+of+the+removal+of+oxygen+from+oxide+surfaces+by+vacancy+formation+and+crystallographic+shear+mechanisms&amp;rft.jtitle=Journal+of+Catalysis&amp;rft.date=1981&amp;rft.volume=72&amp;rft.issue=2&amp;rft.spage=379&amp;rft.epage=382&amp;rft.aufirst=E&amp;rft.aulast=BROCAWIK&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=E+BROCAWIK",
1230     "year": "1981"
1231   },
1232   {
1233     "doi": "http://dx.doi.org/10.1063/1.2335842",
1234     "score": 0.62469214,
1235     "normalizedScore": 13,
1236     "title": "Bulk and surface oxygen vacancy formation and diffusion in single crystals, ultrathin films, and metal grown oxide structures",
1237     "fullCitation": "J. Carrasco, N. Lopez, F. Illas, H.-J. Freund, 2006, 'Bulk and surface oxygen vacancy formation and diffusion in single crystals, ultrathin films, and metal grown oxide structures', <i>The Journal of Chemical Physics</i>, vol. 125, no. 7, p. 074711",
1238     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1063%2F1.2335842&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Bulk+and+surface+oxygen+vacancy+formation+and+diffusion+in+single+crystals%2C+ultrathin+films%2C+and+metal+grown+oxide+structures&amp;rft.jtitle=The+Journal+of+Chemical+Physics&amp;rft.date=2006&amp;rft.volume=125&amp;rft.issue=7&amp;rft.spage=074711&amp;rft.aufirst=J.&amp;rft.aulast=Carrasco&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=J.+Carrasco&amp;rft.au=+N.+Lopez&amp;rft.au=+F.+Illas&amp;rft.au=+H.-J.+Freund",
1239     "year": "2006"
1240   },
1241   {
1242     "doi": "http://dx.doi.org/10.1016/j.ijhydene.2011.12.079",
1243     "score": 0.6176822,
1244     "normalizedScore": 13,
1245     "title": "Oxygen vacancy formation on the Ni/Ce0.75Zr0.25O2(111) surface. A DFT+U study",
1246     "fullCitation": "Delfina García Pintos, Alfredo Juan, Beatriz Irigoyen, 2012, 'Oxygen vacancy formation on the Ni/Ce0.75Zr0.25O2(111) surface. A DFT+U study', <i>International Journal of Hydrogen Energy</i>, vol. 37, no. 19, pp. 14937-14944",
1247     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1016%2Fj.ijhydene.2011.12.079&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Oxygen+vacancy+formation+on+the+Ni%2FCe0.75Zr0.25O2%28111%29+surface.+A+DFT%2BU+study&amp;rft.jtitle=International+Journal+of+Hydrogen+Energy&amp;rft.date=2012&amp;rft.volume=37&amp;rft.issue=19&amp;rft.spage=14937&amp;rft.epage=14944&amp;rft.aufirst=Delfina&amp;rft.aulast=Garc%C3%ADa+Pintos&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Delfina+Garc%C3%ADa+Pintos&amp;rft.au=+Alfredo+Juan&amp;rft.au=+Beatriz+Irigoyen",
1248     "year": "2012"
1249   },
1250   {
1251     "doi": "http://dx.doi.org/10.1103/physrevb.90.144105",
1252     "score": 0.6172708,
1253     "normalizedScore": 13,
1254     "title": "Vacancy formation enthalpy of filled <span class=\"aps-inline-formula\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mi>d</mi></math></span>-band noble metals by hybrid functionals",
1255     "fullCitation": "Weiwei Xing, Peitao Liu, Xiyue Cheng, Haiyang Niu, Hui Ma, Dianzhong Li, Yiyi Li, Xing-Qiu Chen, 2014, 'Vacancy formation enthalpy of filled &lt;span class=&quot;aps-inline-formula&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;mi&gt;d&lt;/mi&gt;&lt;/math&gt;&lt;/span&gt;-band noble metals by hybrid functionals', <i>Physical Review B</i>, vol. 90, no. 14",
1256     "coins": "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1103%2Fphysrevb.90.144105&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Vacancy+formation+enthalpy+of+filled+%3Cspan+class%3D%22aps-inline-formula%22%3E%3Cmath+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1998%2FMath%2FMathML%22%3E%3Cmi%3Ed%3C%2Fmi%3E%3C%2Fmath%3E%3C%2Fspan%3E-band+noble+metals+by+hybrid+functionals&amp;rft.jtitle=Physical+Review+B&amp;rft.date=2014&amp;rft.volume=90&amp;rft.issue=14&amp;rft.aufirst=Weiwei&amp;rft.aulast=Xing&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Weiwei+Xing&amp;rft.au=+Peitao+Liu&amp;rft.au=+Xiyue+Cheng&amp;rft.au=+Haiyang+Niu&amp;rft.au=+Hui+Ma&amp;rft.au=+Dianzhong+Li&amp;rft.au=+Yiyi+Li&amp;rft.au=+Xing-Qiu+Chen",
1257     "year": "2014"
1258   }
1259 ]
1260 #+END_EXAMPLE
1261
1262
1263 #+BEGIN_SRC emacs-lisp :var data=json  :results value raw :tangle no
1264 (let ((json-object-type 'plist)
1265       (json (json-read-from-string data)))
1266 (aref json 0))
1267 #+END_SRC
1268
1269 #+RESULTS:
1270 ((year . 2014) (coins . ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1039%2Fc3ee43874k&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Oxide+enthalpy+of+formation+and+band+gap+energy+as+accurate+descriptors+of+oxygen+vacancy+formation+energetics&amp;rft.jtitle=Energy+%26+Environmental+Science&amp;rft.date=2014&amp;rft.volume=7&amp;rft.issue=6&amp;rft.spage=1996&amp;rft.aufirst=Ann+M.&amp;rft.aulast=Deml&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Ann+M.+Deml&amp;rft.au=+Vladan+Stevanovi%C4%87&amp;rft.au=+Christopher+L.+Muhich&amp;rft.au=+Charles+B.+Musgrave&amp;rft.au=+Ryan+O%27Hayre) (fullCitation . Ann M. Deml, Vladan Stevanovi\304\207, Christopher L. Muhich, Charles B. Musgrave, Ryan O'Hayre, 2014, 'Oxide enthalpy of formation and band gap energy as accurate descriptors of oxygen vacancy formation energetics', <i>Energy &amp; Environmental Science</i>, vol. 7, no. 6, p. 1996) (title . Oxide enthalpy of formation and band gap energy as accurate descriptors of oxygen vacancy formation energetics) (normalizedScore . 100) (score . 4.7002907) (doi . http://dx.doi.org/10.1039/c3ee43874k))
1271
1272
1273
1274 Here is a list of helm candidates
1275 #+BEGIN_SRC emacs-lisp :var data=json :results code :tangle no
1276 (let (;(json-object-type 'plist)
1277       (json (json-read-from-string data)))
1278   (mapcar (lambda (x) (cons (assoc 'fullCitation x) x)) json))
1279 #+END_SRC
1280
1281 #+RESULTS:
1282 #+BEGIN_SRC emacs-lisp :tangle no
1283
1284 (((fullCitation . "Ann M. Deml, Vladan Stevanovi\304\207, Christopher L. Muhich, Charles B. Musgrave, Ryan O'Hayre, 2014, 'Oxide enthalpy of formation and band gap energy as accurate descriptors of oxygen vacancy formation energetics', <i>Energy &amp; Environmental Science</i>, vol. 7, no. 6, p. 1996")
1285   (year . "2014")
1286   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1039%2Fc3ee43874k&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Oxide+enthalpy+of+formation+and+band+gap+energy+as+accurate+descriptors+of+oxygen+vacancy+formation+energetics&amp;rft.jtitle=Energy+%26+Environmental+Science&amp;rft.date=2014&amp;rft.volume=7&amp;rft.issue=6&amp;rft.spage=1996&amp;rft.aufirst=Ann+M.&amp;rft.aulast=Deml&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Ann+M.+Deml&amp;rft.au=+Vladan+Stevanovi%C4%87&amp;rft.au=+Christopher+L.+Muhich&amp;rft.au=+Charles+B.+Musgrave&amp;rft.au=+Ryan+O%27Hayre")
1287   (fullCitation . "Ann M. Deml, Vladan Stevanovi\304\207, Christopher L. Muhich, Charles B. Musgrave, Ryan O'Hayre, 2014, 'Oxide enthalpy of formation and band gap energy as accurate descriptors of oxygen vacancy formation energetics', <i>Energy &amp; Environmental Science</i>, vol. 7, no. 6, p. 1996")
1288   (title . "Oxide enthalpy of formation and band gap energy as accurate descriptors of oxygen vacancy formation energetics")
1289   (normalizedScore . 100)
1290   (score . 4.7002907)
1291   (doi . "http://dx.doi.org/10.1039/c3ee43874k"))
1292  ((fullCitation . "Altynbek Murat, Julia E. Medvedeva, 2012, 'Composition-dependent oxygen vacancy formation in multicomponent wide-band-gap oxides', <i>Physical Review B</i>, vol. 86, no. 8")
1293   (year . "2012")
1294   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1103%2Fphysrevb.86.085123&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Composition-dependent+oxygen+vacancy+formation+in+multicomponent+wide-band-gap+oxides&amp;rft.jtitle=Physical+Review+B&amp;rft.date=2012&amp;rft.volume=86&amp;rft.issue=8&amp;rft.aufirst=Altynbek&amp;rft.aulast=Murat&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Altynbek+Murat&amp;rft.au=+Julia+E.+Medvedeva")
1295   (fullCitation . "Altynbek Murat, Julia E. Medvedeva, 2012, 'Composition-dependent oxygen vacancy formation in multicomponent wide-band-gap oxides', <i>Physical Review B</i>, vol. 86, no. 8")
1296   (title . "Composition-dependent oxygen vacancy formation in multicomponent wide-band-gap oxides")
1297   (normalizedScore . 24)
1298   (score . 1.129964)
1299   (doi . "http://dx.doi.org/10.1103/physrevb.86.085123"))
1300  ((fullCitation . "Ann M. Deml, Vladan Stevanovi\304\207, Aaron M. Holder, Michael Sanders, Ryan O\342\200\231Hayre, Charles B. Musgrave, 2014, ' Tunable Oxygen Vacancy Formation Energetics in the Complex Perovskite Oxide Sr  x  La  1\342\200\223 x  Mn  y  Al  1\342\200\223 y  O 3 ', <i>Chemistry of Materials</i>, vol. 26, no. 22, pp. 6595-6602")
1301   (year . "2014")
1302   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1021%2Fcm5033755&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=+Tunable+Oxygen+Vacancy+Formation+Energetics+in+the+Complex+Perovskite+Oxide+Sr++x++La++1%E2%80%93+x++Mn++y++Al++1%E2%80%93+y++O+3+&amp;rft.jtitle=Chemistry+of+Materials&amp;rft.date=2014&amp;rft.volume=26&amp;rft.issue=22&amp;rft.spage=6595&amp;rft.epage=6602&amp;rft.aufirst=Ann+M.&amp;rft.aulast=Deml&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Ann+M.+Deml&amp;rft.au=+Vladan+Stevanovi%C4%87&amp;rft.au=+Aaron+M.+Holder&amp;rft.au=+Michael+Sanders&amp;rft.au=+Ryan+O%E2%80%99Hayre&amp;rft.au=+Charles+B.+Musgrave")
1303   (fullCitation . "Ann M. Deml, Vladan Stevanovi\304\207, Aaron M. Holder, Michael Sanders, Ryan O\342\200\231Hayre, Charles B. Musgrave, 2014, ' Tunable Oxygen Vacancy Formation Energetics in the Complex Perovskite Oxide Sr  x  La  1\342\200\223 x  Mn  y  Al  1\342\200\223 y  O 3 ', <i>Chemistry of Materials</i>, vol. 26, no. 22, pp. 6595-6602")
1304   (title . " Tunable Oxygen Vacancy Formation Energetics in the Complex Perovskite Oxide Sr  x  La  1\342\200\223 x  Mn  y  Al  1\342\200\223 y  O 3 ")
1305   (normalizedScore . 20)
1306   (score . 0.94063884)
1307   (doi . "http://dx.doi.org/10.1021/cm5033755"))
1308  ((fullCitation . "Chuck Blue, Khaled Elgaid, Ivan Zitkovsky, P. Boolchand, Darl McDaniel, W. Joiner, Jean Oostens, Warren Huff, 1988, 'Oxygen-vacancy-formation enthalpy in YBa_{2}(Cu_{0.985}Fe_{0.015})_{3}O_{7-\316\264} oxide superconductor', <i>Physical Review B</i>, vol. 37, no. 10, pp. 5905-5908")
1309   (year . "1988")
1310   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1103%2Fphysrevb.37.5905&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Oxygen-vacancy-formation+enthalpy+in+YBa_%7B2%7D%28Cu_%7B0.985%7DFe_%7B0.015%7D%29_%7B3%7DO_%7B7-%CE%B4%7D+oxide+superconductor&amp;rft.jtitle=Physical+Review+B&amp;rft.date=1988&amp;rft.volume=37&amp;rft.issue=10&amp;rft.spage=5905&amp;rft.epage=5908&amp;rft.aufirst=Chuck&amp;rft.aulast=Blue&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Chuck+Blue&amp;rft.au=+Khaled+Elgaid&amp;rft.au=+Ivan+Zitkovsky&amp;rft.au=+P.+Boolchand&amp;rft.au=+Darl+McDaniel&amp;rft.au=+W.+Joiner&amp;rft.au=+Jean+Oostens&amp;rft.au=+Warren+Huff")
1311   (fullCitation . "Chuck Blue, Khaled Elgaid, Ivan Zitkovsky, P. Boolchand, Darl McDaniel, W. Joiner, Jean Oostens, Warren Huff, 1988, 'Oxygen-vacancy-formation enthalpy in YBa_{2}(Cu_{0.985}Fe_{0.015})_{3}O_{7-\316\264} oxide superconductor', <i>Physical Review B</i>, vol. 37, no. 10, pp. 5905-5908")
1312   (title . "Oxygen-vacancy-formation enthalpy in YBa_{2}(Cu_{0.985}Fe_{0.015})_{3}O_{7-\316\264} oxide superconductor")
1313   (normalizedScore . 17)
1314   (score . 0.8346345)
1315   (doi . "http://dx.doi.org/10.1103/physrevb.37.5905"))
1316  ((fullCitation . "H. Holloway, 1962, 'Enthalpy of Formation of Oxygen Vacancies in Barium Oxide', <i>The Journal of Chemical Physics</i>, vol. 36, no. 11, p. 2820")
1317   (year . "1962")
1318   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1063%2F1.1732384&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Enthalpy+of+Formation+of+Oxygen+Vacancies+in+Barium+Oxide&amp;rft.jtitle=The+Journal+of+Chemical+Physics&amp;rft.date=1962&amp;rft.volume=36&amp;rft.issue=11&amp;rft.spage=2820&amp;rft.aufirst=H.&amp;rft.aulast=Holloway&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=H.+Holloway")
1319   (fullCitation . "H. Holloway, 1962, 'Enthalpy of Formation of Oxygen Vacancies in Barium Oxide', <i>The Journal of Chemical Physics</i>, vol. 36, no. 11, p. 2820")
1320   (title . "Enthalpy of Formation of Oxygen Vacancies in Barium Oxide")
1321   (normalizedScore . 16)
1322   (score . 0.7613335)
1323   (doi . "http://dx.doi.org/10.1063/1.1732384"))
1324  ((fullCitation . "St. Chabik, 1987, 'Vacancy formation enthalpy in AgZn alloys', <i>Crystal Research and Technology</i>, vol. 22, no. 12, pp. 1523-1527")
1325   (year . "1987")
1326   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1002%2Fcrat.2170221219&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Vacancy+formation+enthalpy+in+AgZn+alloys&amp;rft.jtitle=Crystal+Research+and+Technology&amp;rft.date=1987&amp;rft.volume=22&amp;rft.issue=12&amp;rft.spage=1523&amp;rft.epage=1527&amp;rft.aufirst=St.&amp;rft.aulast=Chabik&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=St.+Chabik")
1327   (fullCitation . "St. Chabik, 1987, 'Vacancy formation enthalpy in AgZn alloys', <i>Crystal Research and Technology</i>, vol. 22, no. 12, pp. 1523-1527")
1328   (title . "Vacancy formation enthalpy in AgZn alloys")
1329   (normalizedScore . 15)
1330   (score . 0.73206276)
1331   (doi . "http://dx.doi.org/10.1002/crat.2170221219"))
1332  ((fullCitation . "Alan R. Derk, Bo Li, Sudhanshu Sharma, George M. Moore, Eric W. McFarland, Horia Metiu, 2013, 'Methane Oxidation by Lanthanum Oxide Doped with Cu, Zn, Mg, Fe, Nb, Ti, Zr, or Ta: The Connection Between the Activation Energy and the Energy of Oxygen-Vacancy Formation', <i>Catalysis Letters</i>, vol. 143, no. 5, pp. 406-410")
1333   (year . "2013")
1334   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1007%2Fs10562-013-0985-7&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Methane+Oxidation+by+Lanthanum+Oxide+Doped+with+Cu%2C+Zn%2C+Mg%2C+Fe%2C+Nb%2C+Ti%2C+Zr%2C+or+Ta%3A+The+Connection+Between+the+Activation+Energy+and+the+Energy+of+Oxygen-Vacancy+Formation&amp;rft.jtitle=Catalysis+Letters&amp;rft.date=2013&amp;rft.volume=143&amp;rft.issue=5&amp;rft.spage=406&amp;rft.epage=410&amp;rft.aufirst=Alan+R.&amp;rft.aulast=Derk&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Alan+R.+Derk&amp;rft.au=+Bo+Li&amp;rft.au=+Sudhanshu+Sharma&amp;rft.au=+George+M.+Moore&amp;rft.au=+Eric+W.+McFarland&amp;rft.au=+Horia+Metiu")
1335   (fullCitation . "Alan R. Derk, Bo Li, Sudhanshu Sharma, George M. Moore, Eric W. McFarland, Horia Metiu, 2013, 'Methane Oxidation by Lanthanum Oxide Doped with Cu, Zn, Mg, Fe, Nb, Ti, Zr, or Ta: The Connection Between the Activation Energy and the Energy of Oxygen-Vacancy Formation', <i>Catalysis Letters</i>, vol. 143, no. 5, pp. 406-410")
1336   (title . "Methane Oxidation by Lanthanum Oxide Doped with Cu, Zn, Mg, Fe, Nb, Ti, Zr, or Ta: The Connection Between the Activation Energy and the Energy of Oxygen-Vacancy Formation")
1337   (normalizedScore . 14)
1338   (score . 0.692246)
1339   (doi . "http://dx.doi.org/10.1007/s10562-013-0985-7"))
1340  ((fullCitation . "Way Foong Lim, Kuan Yew Cheong, 2014, 'Oxygen vacancy formation and annihilation in lanthanum cerium oxide as a metal reactive oxide on 4H-silicon carbide', <i>Physical Chemistry Chemical Physics</i>, vol. 16, no. 15, p. 7015")
1341   (year . "2014")
1342   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1039%2Fc3cp55214d&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Oxygen+vacancy+formation+and+annihilation+in+lanthanum+cerium+oxide+as+a+metal+reactive+oxide+on+4H-silicon+carbide&amp;rft.jtitle=Physical+Chemistry+Chemical+Physics&amp;rft.date=2014&amp;rft.volume=16&amp;rft.issue=15&amp;rft.spage=7015&amp;rft.aufirst=Way+Foong&amp;rft.aulast=Lim&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Way+Foong+Lim&amp;rft.au=+Kuan+Yew+Cheong")
1343   (fullCitation . "Way Foong Lim, Kuan Yew Cheong, 2014, 'Oxygen vacancy formation and annihilation in lanthanum cerium oxide as a metal reactive oxide on 4H-silicon carbide', <i>Physical Chemistry Chemical Physics</i>, vol. 16, no. 15, p. 7015")
1344   (title . "Oxygen vacancy formation and annihilation in lanthanum cerium oxide as a metal reactive oxide on 4H-silicon carbide")
1345   (normalizedScore . 14)
1346   (score . 0.6675249)
1347   (doi . "http://dx.doi.org/10.1039/c3cp55214d"))
1348  ((fullCitation . "Lena Mazeina, Suraj Deore, Alexandra Navrotsky, 2006, 'Energetics of Bulk and Nano-Akaganeite, \316\262-FeOOH:\302\240 Enthalpy of Formation, Surface Enthalpy, and Enthalpy of Water Adsorption', <i>Chemistry of Materials</i>, vol. 18, no. 7, pp. 1830-1838")
1349   (year . "2006")
1350   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1021%2Fcm052543j&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Energetics+of+Bulk+and+Nano-Akaganeite%2C+%CE%B2-FeOOH%3A%C2%A0+Enthalpy+of+Formation%2C+Surface+Enthalpy%2C+and+Enthalpy+of+Water+Adsorption&amp;rft.jtitle=Chemistry+of+Materials&amp;rft.date=2006&amp;rft.volume=18&amp;rft.issue=7&amp;rft.spage=1830&amp;rft.epage=1838&amp;rft.aufirst=Lena&amp;rft.aulast=Mazeina&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=Lena+Mazeina&amp;rft.au=+Suraj+Deore&amp;rft.au=+Alexandra+Navrotsky")
1351   (fullCitation . "Lena Mazeina, Suraj Deore, Alexandra Navrotsky, 2006, 'Energetics of Bulk and Nano-Akaganeite, \316\262-FeOOH:\302\240 Enthalpy of Formation, Surface Enthalpy, and Enthalpy of Water Adsorption', <i>Chemistry of Materials</i>, vol. 18, no. 7, pp. 1830-1838")
1352   (title . "Energetics of Bulk and Nano-Akaganeite, \316\262-FeOOH:\302\240 Enthalpy of Formation, Surface Enthalpy, and Enthalpy of Water Adsorption")
1353   (normalizedScore . 13)
1354   (score . 0.6519111)
1355   (doi . "http://dx.doi.org/10.1021/cm052543j"))
1356  ((fullCitation . "P. A. G. O'Hare, 1972, 'Thermochemical and Theoretical Investigations of the Sodium-Oxygen System. I. The Standard Enthalpy of Formation of Sodium Oxide (Na2O)', <i>The Journal of Chemical Physics</i>, vol. 56, no. 9, p. 4513")
1357   (year . "1972")
1358   (coins . "ctx_ver=Z39.88-2004&amp;rft_id=info%3Adoi%2Fhttp%3A%2F%2Fdx.doi.org%2F10.1063%2F1.1677897&amp;rfr_id=info%3Asid%2Fcrossref.org%3Asearch&amp;rft.atitle=Thermochemical+and+Theoretical+Investigations+of+the+Sodium-Oxygen+System.+I.+The+Standard+Enthalpy+of+Formation+of+Sodium+Oxide+%28Na2O%29&amp;rft.jtitle=The+Journal+of+Chemical+Physics&amp;rft.date=1972&amp;rft.volume=56&amp;rft.issue=9&amp;rft.spage=4513&amp;rft.aufirst=P.+A.+G.&amp;rft.aulast=O%27Hare&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.au=P.+A.+G.+O%27Hare")
1359   (fullCitation . "P. A. G. O'Hare, 1972, 'Thermochemical and Theoretical Investigations of the Sodium-Oxygen System. I. The Standard Enthalpy of Formation of Sodium Oxide (Na2O)', <i>The Journal of Chemical Physics</i>, vol. 56, no. 9, p. 4513")
1360   (title . "Thermochemical and Theoretical Investigations of the Sodium-Oxygen System. I. The Standard Enthalpy of Formation of Sodium Oxide (Na2O)")
1361   (normalizedScore . 13)
1362   (score . 0.6344446)
1363   (doi . "http://dx.doi.org/10.1063/1.1677897"))
1364  ...)
1365 #+END_SRC
1366
1367
1368 * ISBN utility
1369 These are not really doi utilities, but for now I am putting them here.
1370
1371 I found this on the web. It can be handy, but the bibtex entry has a lot of stuff in it.
1372
1373 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
1374 (defun isbn-to-bibtex-lead (isbn)
1375  "Search lead.to for ISBN bibtex entry. You have to copy the entry if it is on the page to your bibtex file."
1376  (interactive "sISBN: ")
1377 (browse-url
1378 (format "http://lead.to/amazon/en/?key=%s+&si=all&op=bt&bn=&so=sa&ht=us" isbn)))
1379 #+END_SRC
1380
1381 Here we get isbn metadata and build a bibtex entry.
1382 http://xisbn.worldcat.org/xisbnadmin/doc/api.htm#getmetadata
1383
1384
1385 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
1386 (defun isbn-to-bibtex (isbn bibfile)
1387   "Get bibtex entry for ISBN and insert it into BIBFILE unless an
1388 entry with the generated key already exists in the file."
1389   (interactive
1390    (list
1391     (read-input
1392      "ISBN: "
1393      ;; now set initial input
1394      (cond
1395       ;; If region is active and it starts with a number, we use it
1396       ((and  (region-active-p)
1397              (s-match "^[0-9]" (buffer-substring (region-beginning) (region-end))))
1398        (buffer-substring (region-beginning) (region-end)))
1399       ;; if first entry in kill ring starts with a number assume it is an isbn
1400       ;; and use it as the guess
1401       ((if (s-match "^[0-9]" (car kill-ring))
1402            (car kill-ring)))
1403       ;; type or paste it in
1404       (t
1405        nil)))
1406     (ido-completing-read
1407      "Bibfile: "
1408      (append (f-entries "." (lambda (f) (f-ext? f "bib")))
1409              org-ref-default-bibliography))))
1410
1411   (let* ((results (with-current-buffer
1412                       (url-retrieve-synchronously
1413                        (format
1414                         "http://xisbn.worldcat.org/webservices/xid/isbn/%s?method=getMetadata&format=json&fl=*"
1415                         isbn))
1416                     (json-read-from-string
1417                      (buffer-substring url-http-end-of-headers (point-max)))))
1418          (status (cdr (nth 1 results)))
1419          (metadata (aref (cdar results) 0))
1420          (new-entry)
1421          (new-key))
1422
1423     ;; check if we got something
1424     (unless (string= "ok" status)
1425       (error "Status is %s" status))
1426
1427     ;; construct an alphabetically sorted bibtex entry. I assume ISBN numbers go
1428     ;; with book entries.
1429     (setq new-entry
1430           (concat "\n@book{,\n"
1431                   (mapconcat
1432                    'identity
1433                    (loop for field in (-sort 'string-lessp (mapcar 'car metadata))
1434                          collect
1435                          (format "  %s={%s}," field (cdr (assoc field metadata))))
1436                    "\n")
1437                   "\n}\n"))
1438
1439     ;; build entry in temp buffer to get the key so we can check for duplicates
1440     (setq new-entry (with-temp-buffer
1441                       (insert new-entry)
1442                       (org-ref-clean-bibtex-entry)
1443                       (setq new-key (bibtex-key-in-head))
1444                       (buffer-string)))
1445     (find-file bibfile)
1446     (goto-char (point-min))
1447     (when (search-forward new-key nil t)
1448       (beep)
1449       (setq new-key (read-input
1450                      (format  "%s already exists. Enter new key (C-g to cancel): " new-key)
1451                      new-key)))
1452     (goto-char (point-max))
1453     (insert new-entry)
1454     ;; set key. It is simplest to just replace it, even if it is the same.
1455     (bibtex-beginning-of-entry)
1456     (re-search-forward bibtex-entry-maybe-empty-head)
1457     (if (match-beginning bibtex-key-in-head)
1458         (delete-region (match-beginning bibtex-key-in-head)
1459                        (match-end bibtex-key-in-head)))
1460     (insert new-key)
1461     (bibtex-fill-entry)
1462     (save-buffer)))
1463 #+END_SRC
1464
1465
1466
1467 * end of file
1468 #+BEGIN_SRC emacs-lisp :tangle doi-utils.el
1469 (provide 'doi-utils)
1470 #+END_SRC
1471 * load
1472 #+BEGIN_SRC emacs-lisp :tangle no
1473 (org-babel-load-file "doi-utils.org")
1474 #+END_SRC
1475
1476 #+RESULTS:
1477 : Loaded doi-utils.el