mxs.sbrk.org ยป blog | home | projects

How to paste code from emacs

First, you need to install http-post-simple, which provides some functions to perform http requests:

$ cd /usr/local/share/emacs/site-lisp/
$ sudo wget http://www.emacswiki.org/emacs/download/http-post-simple.el

Then, add the following chunk of code to your .emacs file:

;; c0depast3r
(require 'http-post-simple)
(defun c0depast3r-paste ()
  "paste a chunk of code to pastebin.sbrk.org"
  (interactive)
  (http-post-simple "http://pastebin.sbrk.org/add"
                    (list (list 'author (getenv "USER"))
                          (list 'code
                           (buffer-substring
                             (region-beginning) (region-end))))))

It takes the selected region from the current buffer and post it to pastebin.sbrk.org. To use it, just select a region (ctrl + space to define the starting point of the region, then ctrl + space to end the selection), and run the c0depast3r-paste function (meta-x c0depast3r-paste). You should be able to see you code in the latest entries.


Generated on Sun Apr 15 13:15:47 UTC 2012 by gromit.sh