update packages
This commit is contained in:
@@ -23,9 +23,11 @@
|
||||
;; Provides functions to download bibtex entries from isbn numbers.
|
||||
|
||||
;;; Code:
|
||||
(require 'f)
|
||||
(require 'org-ref-utils)
|
||||
(require 'org)
|
||||
|
||||
(declare-function org-ref-possible-bibfiles "org-ref-core" ())
|
||||
(declare-function org-ref-clean-bibtex-entry "org-ref-bibtex" ())
|
||||
|
||||
(defvar url-http-end-of-headers)
|
||||
|
||||
@@ -154,12 +156,12 @@ in the file. Data comes from www.ebook.de."
|
||||
(cond
|
||||
;; If region is active and it starts with a number, we use it
|
||||
((and (region-active-p)
|
||||
(s-match "^[0-9]" (buffer-substring (region-beginning) (region-end))))
|
||||
(org-ref--string-match "^[0-9]" (buffer-substring (region-beginning) (region-end))))
|
||||
(buffer-substring (region-beginning) (region-end)))
|
||||
;; if first entry in kill ring starts with a number assume it is an isbn
|
||||
;; and use it as the guess
|
||||
((stringp (car kill-ring))
|
||||
(when (s-match "^[0-9]" (car kill-ring))
|
||||
(when (org-ref--string-match "^[0-9]" (car kill-ring))
|
||||
(car kill-ring)))
|
||||
;; type or paste it in
|
||||
(t
|
||||
@@ -188,7 +190,7 @@ in the file. Data comes from www.ebook.de."
|
||||
(org-ref-isbn-clean-bibtex-entry)
|
||||
(org-ref-clean-bibtex-entry)
|
||||
(bibtex-fill-entry)
|
||||
(s-trim (buffer-string))))
|
||||
(string-trim (buffer-string))))
|
||||
(save-buffer))))
|
||||
|
||||
|
||||
@@ -205,12 +207,12 @@ API: https://openlibrary.org/developers/api
|
||||
(cond
|
||||
;; If region is active and it starts with a number, we use it
|
||||
((and (region-active-p)
|
||||
(s-match "^[0-9]" (buffer-substring (region-beginning) (region-end))))
|
||||
(org-ref--string-match "^[0-9]" (buffer-substring (region-beginning) (region-end))))
|
||||
(buffer-substring (region-beginning) (region-end)))
|
||||
;; if first entry in kill ring starts with a number assume it is an isbn
|
||||
;; and use it as the guess
|
||||
((stringp (car kill-ring))
|
||||
(when (s-match "^[0-9]" (car kill-ring))
|
||||
(when (org-ref--string-match "^[0-9]" (car kill-ring))
|
||||
(car kill-ring)))
|
||||
;; type or paste it in
|
||||
(t
|
||||
@@ -221,19 +223,20 @@ API: https://openlibrary.org/developers/api
|
||||
(json (with-current-buffer (url-retrieve-synchronously url)
|
||||
(json-read-from-string (string-trim (buffer-substring url-http-end-of-headers (point-max))))))
|
||||
(title (cdr (assoc 'title json)))
|
||||
(publisher (s-join ", " (cdr (assoc 'publishers json))))
|
||||
(publisher (string-join (cdr (assoc 'publishers json)) ", "))
|
||||
(year (cdr (assoc 'publish_date json)))
|
||||
;; this is a list of urls
|
||||
(author-urls (cdr (assoc 'authors json)))
|
||||
(authors (s-join " and "
|
||||
(authors (string-join
|
||||
(cl-loop for aurl across author-urls
|
||||
collect
|
||||
(with-current-buffer (url-retrieve-synchronously
|
||||
(format "https://openlibrary.org%s.json"
|
||||
(cdr (assoc 'key aurl))))
|
||||
(cdr (assoc 'key aurl))))
|
||||
(cdr (assoc 'personal_name
|
||||
(json-read-from-string
|
||||
(string-trim (buffer-substring url-http-end-of-headers (point-max))))))))))
|
||||
(string-trim (buffer-substring url-http-end-of-headers (point-max))))))))
|
||||
" and "))
|
||||
(burl (format "https://openlibrary.org%s" (cdr (assoc 'key json))))
|
||||
(bibtex (format "@Book{,
|
||||
author = {%s},
|
||||
|
||||
Reference in New Issue
Block a user