Created
August 4, 2019 19:39
-
-
Save znewman01/3e4a9c8109e7dad2403a0f28dc587632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'json) | |
(require 'org-attach) | |
(defun zjn--format-iacr-org (region) | |
(let* ((id (if (string-empty-p region) | |
(read-string "IACR ePrint ID (ex. 2019/001)? ") | |
region)) | |
(json-string (zjn--fetch-iacr-info id)) | |
(json-object-type 'hash-table) | |
(json-array-type 'list) | |
(json-key-type 'string) | |
(article (json-read-from-string json-string))) | |
(save-excursion | |
(org-back-to-heading t) | |
(end-of-line) | |
; Use insert rather than the format string so we don't clobber the article | |
; attachment | |
(insert (gethash "title" article) | |
"\nhttps://eprint.iacr.org/" | |
(gethash "id" article) | |
"\nAuthor(s): " | |
(mapconcat 'identity (gethash "authors" article) ", ") | |
"\n#+BEGIN_SRC bibtex\n" | |
(gethash "bibtex" article) | |
"#+END_SRC")) | |
(let ((org-attach-directory "~/notes/data")) | |
(org-attach-attach (gethash "pdf_link" article) nil 'url))) | |
"") ; needs to return string to satisfy org-capture | |
(setq org-capture-templates nil) | |
(push '("i" "IACR" entry (file+headline "~/notes/research.org" "Paper queue") | |
"* %(zjn--format-iacr-org \"%i\")\n") | |
org-capture-templates) |
Author
znewman01
commented
Aug 4, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment