Skip to content
Browse files

Added callback function

Fixed some odd missing local definition errors
  • Loading branch information...
1 parent 131b73e commit 957c4e0186777012bf364cb2175c38a1a49e1eb5 Dan Leslie committed with defunkt Feb 26, 2010
Showing with 12 additions and 13 deletions.
  1. +12 −13 gist.el
View
25 gist.el
@@ -81,7 +81,7 @@ posted.")
(xml-mode . "xml")))
;;;###autoload
-(defun gist-region (begin end &optional private)
+(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.
@@ -92,19 +92,18 @@ With a prefix argument, makes a private paste."
(name (file-name-nondirectory file))
(ext (or (cdr (assoc major-mode gist-supported-modes-alist))
(file-name-extension file)
- "txt"))
- (url-max-redirections 0)
- (url-request-method "POST")
- (url-request-data
- (gist-make-query-string
- `(,@(if private '(("action_button" . "private")))
- ("login" . ,login)
- ("token" . ,token)
- ("file_ext[gistfile1]" . ,(concat "." ext))
- ("file_name[gistfile1]" . ,name)
- ("file_contents[gistfile1]" . ,(buffer-substring begin end))))))
+ "txt")))
+ (setq url-max-redirections 0)
+ (setq url-request-method "POST")
+ (setq url-request-data (gist-make-query-string
+ `(,@(if private '(("action_button" . "private")))
+ ("login" . ,login)
+ ("token" . ,token)
+ ("file_ext[gistfile1]" . ,(concat "." ext))
+ ("file_name[gistfile1]" . ,name)
+ ("file_contents[gistfile1]" . ,(buffer-substring begin end)))))
(url-retrieve "http://gist.github.com/gists"
- 'gist-url-retrieved-callback))))
+ (or callback 'gist-url-retrieved-callback)))))
(defun gist-url-retrieved-callback (status)
(let ((location (cadr status)))

0 comments on commit 957c4e0

Please sign in to comment.
Something went wrong with that request. Please try again.