Created
November 5, 2010 12:57
-
-
Save pjstadig/664097 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
(defun gist-region (begin end &optional private &optional callback) | |
"Post the current region as a new paste at gist.github.com | |
Copies the URL into the kill ring. | |
With a prefix argument, makes a private paste." | |
(interactive "r\nP") | |
(let* ((file (or (buffer-file-name) (buffer-name))) | |
(name (file-name-nondirectory file)) | |
(ext (or (cdr (assoc major-mode gist-supported-modes-alist)) | |
(file-name-extension file) | |
"txt"))) | |
(gist-request | |
"https://gist.github.com/gists" | |
(or callback 'gist-created-callback) | |
`(,@(if private '(("action_button" . "private"))) | |
("file_ext[gistfile1]" . ,(concat "." ext)) | |
("file_name[gistfile1]" . ,name) | |
("file_contents[gistfile1]" . ,(buffer-substring begin end)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment