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