Skip to content

Instantly share code, notes, and snippets.

@julianrubisch
Last active February 19, 2021 13:51
Show Gist options
  • Save julianrubisch/003b2a2841c6559ccf63540bd6074e60 to your computer and use it in GitHub Desktop.
Save julianrubisch/003b2a2841c6559ccf63540bd6074e60 to your computer and use it in GitHub Desktop.
(defun jr/gist-carbon-region ()
"Create a gist, upload to carbon and put the gist URL in the kill ring.
This function makes it easy to tweet a marked region: Invoke it and
the region will be uploaded to Github, the gist ID appended to carbon,
and the default browser opened. As a convenience, the created gist URL
is also placed in the kill ring.
gist mode (https://github.com/defunkt/gist.el) is required."
(interactive)
(setq gist-view-gist nil)
(gist-mode t)
(gist-region (region-beginning) (region-end))
(let
((gist-url (substring-no-properties (current-kill 0))))
(string-match "gist\\.github\\.com\\/\\(.+\\)$" gist-url)
(browse-url (concat "https://carbon.now.sh/" (match-string 1 gist-url)))
)
(gist-mode nil))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment