update packages
This commit is contained in:
@@ -26,10 +26,7 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'bibtex)
|
||||
(require 'dash)
|
||||
(require 'f)
|
||||
(require 'org)
|
||||
(require 's)
|
||||
(require 'org-ref-utils)
|
||||
(require 'parsebib)
|
||||
|
||||
@@ -42,6 +39,7 @@
|
||||
|
||||
(declare-function parsebib-find-bibtex-dialect "parsebib")
|
||||
(declare-function org-ref-clean-bibtex-entry "org-ref-core")
|
||||
(declare-function org-ref-normalize-bibtex-completion-bibliography "org-ref-utils")
|
||||
;; this is a C function
|
||||
(declare-function libxml-parse-xml-region "xml")
|
||||
|
||||
@@ -85,7 +83,7 @@
|
||||
(with-current-buffer
|
||||
(url-retrieve-synchronously (format "https://ui.adsabs.harvard.edu/abs/%s/exportcitation" arxiv-bibliographic-code))
|
||||
(when (re-search-forward
|
||||
"<textarea.*>\\(.*\\(?:\n.*\\)*?\\(?:\n\\s-*\n\\|\\'\\)\\)</textarea>"
|
||||
"<textarea.*>\\(.*\\(?:\n.*\\)*?\\)\\(?:\n\\s-*\n\\)</textarea>"
|
||||
nil t)
|
||||
(xml-substitute-special (match-string 1)))))
|
||||
|
||||
@@ -121,13 +119,13 @@ Returns a formatted BibTeX entry."
|
||||
(match-beginning 0))
|
||||
(point-max)))
|
||||
(entry (assq 'entry parse-tree))
|
||||
(authors (--map (nth 2 (nth 2 it))
|
||||
(--filter (and (listp it) (eq (car it) 'author)) entry)))
|
||||
(authors (mapcar (lambda (it) (nth 2 (nth 2 it)))
|
||||
(seq-filter (lambda (it) (and (listp it) (eq (car it) 'author))) entry)))
|
||||
(year (format-time-string "%Y" (date-to-time (nth 2 (assq 'published entry)))))
|
||||
(title (nth 2 (assq 'title entry)))
|
||||
(names (arxiv-bibtexify-authors authors))
|
||||
(category (cdar (nth 1 (assq 'primary_category entry))))
|
||||
(abstract (s-trim (nth 2 (assq 'summary entry))))
|
||||
(abstract (string-trim (nth 2 (assq 'summary entry))))
|
||||
(url (nth 2 (assq 'id entry)))
|
||||
(temp-bibtex (format arxiv-entry-format-string "" title names year arxiv-number category abstract url))
|
||||
(key (with-temp-buffer
|
||||
@@ -145,9 +143,12 @@ Returns a formatted BibTeX entry."
|
||||
|
||||
(defun arxiv-bibtexify-authors (authors)
|
||||
"Return names in 'SURNAME, FIRST NAME' format from AUTHORS list."
|
||||
(s-join " and "
|
||||
(--map (concat (-last-item it) ", " (s-join " " (-remove-last 'stringp it)))
|
||||
(--map (s-split " +" it) authors))))
|
||||
(string-join
|
||||
(mapcar (lambda (it)
|
||||
(concat (car (last it)) ", "
|
||||
(string-join (butlast it) " ")))
|
||||
(mapcar (lambda (it) (split-string it " +")) authors))
|
||||
" and "))
|
||||
|
||||
|
||||
(defun arxiv-maybe-arxiv-id-from-current-kill ()
|
||||
@@ -166,22 +167,22 @@ Returns a formatted BibTeX entry."
|
||||
(;; check if current-kill looks like an arxiv ID
|
||||
;; if so, return it
|
||||
;; Ex: 1304.4404v2
|
||||
(s-match (concat "^" arxiv-id-regexp) the-current-kill)
|
||||
(org-ref--string-match (concat "^" arxiv-id-regexp) the-current-kill)
|
||||
the-current-kill)
|
||||
(;; check if current-kill looks like an arxiv cite
|
||||
;; if so, remove the prefix and return
|
||||
;; Ex: arXiv:1304.4404v2 --> 1304.4404v2
|
||||
(s-match (concat arxiv-cite-prefix-regexp arxiv-id-regexp "$") the-current-kill)
|
||||
(org-ref--string-match (concat arxiv-cite-prefix-regexp arxiv-id-regexp "$") the-current-kill)
|
||||
(replace-regexp-in-string arxiv-cite-prefix-regexp "" the-current-kill))
|
||||
(;; check if current-kill looks like an arxiv url
|
||||
;; if so, remove the url prefix and return
|
||||
;; Ex: https://arxiv.org/abs/1304.4404 --> 1304.4404
|
||||
(s-match (concat arxiv-url-prefix-regexp arxiv-id-regexp "$") the-current-kill)
|
||||
(org-ref--string-match (concat arxiv-url-prefix-regexp arxiv-id-regexp "$") the-current-kill)
|
||||
(replace-regexp-in-string arxiv-url-prefix-regexp "" the-current-kill))
|
||||
(;; check if current-kill looks like an arxiv PDF url
|
||||
;; if so, remove the url prefix, the .pdf suffix, and return
|
||||
;; Ex: https://arxiv.org/pdf/1304.4404.pdf --> 1304.4404
|
||||
(s-match (concat arxiv-url-prefix-regexp arxiv-id-regexp "\\.pdf$") the-current-kill)
|
||||
(org-ref--string-match (concat arxiv-url-prefix-regexp arxiv-id-regexp "\\.pdf$") the-current-kill)
|
||||
(replace-regexp-in-string arxiv-url-prefix-regexp "" (substring the-current-kill 0 (- (length the-current-kill) 4))))
|
||||
;; otherwise, return nil
|
||||
(t
|
||||
@@ -199,10 +200,8 @@ Returns a formatted BibTeX entry."
|
||||
;; now get the bibfile to add it to
|
||||
(completing-read
|
||||
"Bibfile: "
|
||||
(append (f-entries "." (lambda (f) (f-ext? f "bib")))
|
||||
(if (stringp bibtex-completion-bibliography)
|
||||
(list bibtex-completion-bibliography)
|
||||
bibtex-completion-bibliography)))))
|
||||
(append (org-ref--directory-files "." (lambda (f) (org-ref--file-ext-p f "bib")))
|
||||
(org-ref-normalize-bibtex-completion-bibliography)))))
|
||||
(save-window-excursion
|
||||
(find-file bibfile)
|
||||
(goto-char (point-max))
|
||||
@@ -245,8 +244,8 @@ key."
|
||||
;; now get the bibfile to add it to
|
||||
(completing-read
|
||||
"Bibfile: "
|
||||
(append (f-entries "." (lambda (f) (f-ext? f "bib")))
|
||||
bibtex-completion-bibliography))
|
||||
(append (org-ref--directory-files "." (lambda (f) (org-ref--file-ext-p f "bib")))
|
||||
(org-ref-normalize-bibtex-completion-bibliography)))
|
||||
(cond
|
||||
((stringp bibtex-completion-library-path)
|
||||
bibtex-completion-library-path)
|
||||
|
||||
Reference in New Issue
Block a user