Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
(defun sacha/copy-code-as-org-block-and-gist (beg end)
(interactive "r")
(let ((filename (file-name-base))
(mode (symbol-name major-mode))
(if (use-region-p) (buffer-substring beg end) (buffer-string)))
(gist (if (use-region-p) (gist-region beg end) (gist-buffer))))
(format "\n[[%s][Gist: %s]]\n#+begin_src %s\n%s\n#+end_src\n"
(oref (oref gist :data) :html-url) filename
(replace-regexp-in-string "-mode$" "" mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment