Skip to content

Instantly share code, notes, and snippets.

@tobias
Created November 5, 2010 20:27
Show Gist options
  • Save tobias/664738 to your computer and use it in GitHub Desktop.
Save tobias/664738 to your computer and use it in GitHub Desktop.
;;;###autoload
(defun gist-list ()
"Displays a list of all of the current user's gists in a new buffer."
(interactive)
(message "Retrieving list of your gists...")
(github-with-auth-info login token
(gist-request
(format "https://gist.github.com/api/v1/xml/gists/%s" login)
'gist-lists-retrieved-callback)))
(defun gist-lists-retrieved-callback (status)
"Called when the list of gists has been retrieved. Parses the result
and displays the list."
(goto-char (point-min))
(search-forward "<?xml")
(let ((gists (gist-xml-cleanup
(xml-parse-region (match-beginning 0) (point-max)))))
(kill-buffer (current-buffer))
(with-current-buffer (get-buffer-create "*gists*")
(goto-char (point-min))
(save-excursion
(kill-region (point-min) (point-max))
(gist-insert-list-header)
(mapc 'gist-insert-gist-link (xml-node-children (car gists)))
;; remove the extra newline at the end
(delete-backward-char 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment