Skip to content

Instantly share code, notes, and snippets.

@znewman01
Created August 4, 2019 19:39
Show Gist options
  • Save znewman01/3e4a9c8109e7dad2403a0f28dc587632 to your computer and use it in GitHub Desktop.
Save znewman01/3e4a9c8109e7dad2403a0f28dc587632 to your computer and use it in GitHub Desktop.
(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)
@znewman01
Copy link
Author

org-iacr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment