M-x all-things-emacs

Fixing Pastie for Emacs

January 7th, 2008 by Rob Christie · 10 Comments

Pastie Icon Recently, I have been doing more remote pair programming at my day job, and I was copying some code snippets into pastie. Pastie is a site that allows you to share code snippets with nice syntax highlighting. One thing led to another, and next I was searching for emacs integration with pastie. I found it here, but unfortunately the lisp package no longer seemed to work. It turned out that the package just needed to support a minor change to the pastie API. I have fixed it, and added support for sniffing more of the emacs modes associated with Ruby on Rails and java. Here is the updated version of pastie.el. (Note: After publishing I added it to the emacs wiki based on a user’s suggestion: pastie.el). The package has the following functions:

pastie-buffer – Posts the current buffer as a new paste at pastie.caboo.se.
pastie-region – Posts the selected region as a new paste at pastie.caboo.se.
pastie-get – Fetches the contents of a paste from pastie.caboo.se into a new buffer.

Tags: misc · rails · ruby

10 responses so far ↓

  • 1 Suno // Jan 7, 2008 at 9:01 am

    Great Job! Very useful! Pyhton mode is still missing though :-]

  • 2 Suno // Jan 7, 2008 at 9:06 am

    me again … I thought it might be a great idea if you create a “pastie” page at emacswiki.org so pastie might thrive since others might add code etc.

    Tia, Suno :-)

  • 3 Tiago // Jan 7, 2008 at 2:39 pm

    Here it is with python mode enabled: http://pastie.caboo.se/paste/136134

  • 4 Rob Christie // Jan 7, 2008 at 4:40 pm

    @Sunu,

    Good idea. It is now on the wiki at pastie.el.

  • 5 Dan McKinley // Jan 7, 2008 at 5:15 pm

    Here’s a version with python mode and a function that lets you browse to the last paste.

    http://pastie.caboo.se/paste/136194

  • 6 Ryan McGeary // Jan 7, 2008 at 6:01 pm

    Dan, Good call. I wonder if it makes sense to pastie-browse automatically at the end of pastie-region?

  • 7 Johan Andersson // Jan 11, 2008 at 8:00 am

    Hi and great work! Nice to see you post again!

  • 8 Jacob Tjoernholm // Feb 7, 2008 at 2:43 pm

    Great, thanks!

    I wonder how many copies of pastie.el is now on pastie – it’s a pretty obvious choice for trying itself out ;-)

  • 9 Phil // Apr 5, 2008 at 11:46 pm

    I’ve just coded up a similar package (though much, much less code) called SCPaste that leverages Emacs’ font-lock so it knows how to syntax highlight everything that Emacs supports.

    http://p.hagelb.org

  • 10 Ryan McGeary // Apr 6, 2008 at 3:53 am

    Phil, Clever and simple.

Leave a Comment