Skip to content

Commit

Permalink
Replaces beginning-of-buffer call with (goto-char (point-min)), which…
Browse files Browse the repository at this point in the history
… fixes a byte compilation warning. Makes the call to github asynchronous to avoid blocking the UI.
  • Loading branch information
mcfunley authored and defunkt committed Feb 21, 2010
1 parent 817a13c commit ce61e14
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions gist.el
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ With a prefix argument, makes a private paste."
("file_ext[gistfile1]" . ,(concat "." ext))
("file_name[gistfile1]" . ,name)
("file_contents[gistfile1]" . ,(buffer-substring begin end))))))
(with-current-buffer (url-retrieve-synchronously "http://gist.github.com/gists")
(re-search-backward "^Location: \\(.*\\)$")
(message "Paste created: %s" (match-string 1))
(if gist-view-gist (browse-url (match-string 1)))
(kill-new (match-string 1))
(kill-buffer (current-buffer))))))
(url-retrieve "http://gist.github.com/gists"
'gist-url-retrieved-callback))))

(defun gist-url-retrieved-callback (status)
(let ((location (cadr status)))
(message "Paste created: %s" location)
(when gist-view-gist
(browse-url (location)))
(kill-new location)
(kill-buffer (current-buffer))))

(defun gist-make-query-string (params)
"Returns a query string constructed from PARAMS, which should be
Expand Down Expand Up @@ -209,11 +213,11 @@ If the Gist already exists in a buffer, switches to it"
(url-retrieve-synchronously (format gist-fetch-url id)))
(with-current-buffer gist-buffer
(rename-buffer gist-buffer-name t)
(beginning-of-buffer)
(goto-char (point-min))
(search-forward-regexp "\n\n")
(delete-region (point-min) (point))
(set-buffer-modified-p nil))
(switch-to-buffer-other-window gist-buffer)))))

(provide 'gist)
;;; gist.el ends here.
;;; gist.el ends here.

0 comments on commit ce61e14

Please sign in to comment.