Skip to content

Instantly share code, notes, and snippets.

Created February 4, 2014 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8812412 to your computer and use it in GitHub Desktop.
Save anonymous/8812412 to your computer and use it in GitHub Desktop.
Created with Christopher Biscardi's region-to-gist
;;; Region to Gist
(defun region-to-gist ()
"Sends region to Gist"
(interactive)
(if (region-active-p)
(gist-req (buffer-substring-no-properties (region-beginning) (region-end))))
nil)
(defun gist-test (buf)
(message "%S" `(:content ,buf)))
(defun gist-req (buf)
(request
"https://api.github.com/gists"
:type "POST"
:data (json-encode `(:description "Created with Christopher Biscardi's region-to-gist"
:public t
:files (:example.el (:content ,buf))))
;; :data "key=value&key2=value2" ; this is equivalent
:parser 'json-read
:success (function*
(lambda (&key data &allow-other-keys)
(message "I sent: %S" (assoc-default 'html_url data)))))
nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment