Skip to content

Instantly share code, notes, and snippets.

/example.el
Created Feb 4, 2014

Embed
What would you like to do?
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
You can’t perform that action at this time.