New Snipplr TextMate Bundle (Beta)

Published in: Brainstorming, Development, News, PluginsPosted by Tyler on 05/09/07

Today I want to share with everyone a beta version of a new TextMate bundle I’m working on for Snipplr. It’s a major improvement over the old bundle.

Previously, it would pop-up a box for you to type in some keywords. Then it would search Snipplr and show you a list of matching snippets you could insert into your document. That worked pretty well, but you had to be online for it to communicate with Snipplr. You’d lose access to your snippets if you weren’t connected to the net.

This new version syncs your snippets and favorites directly into TextMate’s bundle menu – giving you offline access to all your code stored in Snipplr. If you don’t mind me saying so, this rocks. Here’s a screen shot:


Keep in mind that this bundle is still in development. Everything is working fine for me, but your mileage may vary. You can download the new bundle here. Note: You must be logged in to Snipplr for the download to work. Also, make sure you uninstall the old bundle from TextMate before installing this one.

For the nerds in the audience…

This bundle was a lot of fun to write because it forced me to dig into TextMate’s bundle format. I’ve written some advanced bundles before (at least I consider them to be . . . at work we use a bundle that lets us stage and deploy our clients’ websites on remote servers via TextMate) but nothing like this.

When you download the bundle from Snipplr, PHP generates a custom bundle on the fly based on the snippets in your account. It creates all the .tmSnippet and .tmCommand files as well as the OS X property listings. It’s by no means brain surgery, but it definitely took some tinkering to make it come out right.

The bundle also includes a command to refresh itself. It does this by downloading a new bundle in the background and rsync’ing it with the pristine copy stored in TextMate. I consider this a cheap hack – I’m hoping TextMate 2.0 provides an official API for bundles to self-update. (Ideally, each bundle .plist would contain a URL and version number that TextMate could use to search for updates and, if available, update the bundle à la Firefox extensions. You there, Allan? :)) It tells TextMate to update its bundle listing using a quick AppleScript command (osascript -e 'tell app "TextMate" to reload bundles').

There’s probably a better way to do all this – I need to search the TextMate mailing list.

Next up, I’m going to try and register the update command with launchd so the bundle can stay in sync automatically – preferably when TextMate isn’t active.

I’d appreciate any feedback from the Snipplr community on this bundle. Bugs and feature requests are always welcome.

Also, if anyone is interested in beta testing the new version of Snipplr we’re working on, let me know.


RSS Icon Subscribe to comments
Posted By: Roshambo on May 17th, 2007

Very nice work; thank you for sharing. I really appreciate the extra nerd note, too. Keep up the fantastic work, sir.

Posted By: Remy Sharp on July 24th, 2007

I’ve started using the new bundle for textmate, but whenever I submit a new JavaScript snippet it’s submitted as “Other”.

I’ve tried tweaking the submitted scope, but since it doesn’t seem to follow the API snipplr has, I’m not sure if you’re doing something on the server side for the textmate bundle.

Here’s the tweak I made to the post command:

scope=`perl -e’split(/\./, $ARGV[0]); print $_[1] eq “js” ? “javascript” : $_[1];’ $TM_SCOPE | tr ” ” “+”`

So the submitted url included “/scope/javascript/…”.

This still doesn’t do anything to set the scope correctly (i.e. before it was “/scrope/source.js/…”

Any ideas?

Posted By: Abraham Estrada on January 28th, 2008

Do you plan to release an e – Text Editor Bundle?

Posted By: Ken Ray on July 15th, 2008

Not sure why, but when I add a snippet to TextMate, I get two lines for “LCC Scroll Enhancer loaded” before the snippet that gets inserted. For example, when I insert the JavaScript “showhide” function, I get this:

2008-07-15 23:19:15.494 CocoaDialog[639:10b] LCC Scroll Enhancer loaded
2008-07-15 23:19:18.945 CocoaDialog[656:10b] LCC Scroll Enhancer loaded
function showhide(e) {
el = document.getElementById(e); = == “block” ? “none” : “block”;

Any idea why this is happening?

Leave a Reply

You may use Markdown to format your comment.
HTML renders as source code.