Created
February 4, 2014 21:07
-
-
Save anonymous/8812412 to your computer and use it in GitHub Desktop.
Created with Christopher Biscardi's region-to-gist
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
;;; 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