Skip to content

Instantly share code, notes, and snippets.

@tobias
Created September 23, 2010 04:18
Show Gist options
  • Save tobias/593091 to your computer and use it in GitHub Desktop.
Save tobias/593091 to your computer and use it in GitHub Desktop.
(defun yank-to-gist ()
"yank from the top of the kill ring, create a gist from it, and insert the gist url at the point"
(interactive)
(save-excursion
(let ((buffer (current-buffer)))
(set-buffer (get-buffer-create "*yank-to-gist*"))
(yank)
(gist-region
(point-min)
(point-max)
t
(lexical-let ((buf buffer))
(function (lambda (status)
(let ((location (cadr status)))
(set-buffer buf)
(message "Paste created: %s" location)
(insert location)
(kill-new location))))))
(kill-buffer))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment