Devigner blog about development and design

Textmate and Gist for Emacs

First of all, Happy Thanksgiving to everyone. I hope you’re enjoying food, family and football, I know I am. I’m also enjoying my new emacs minor-mode developed by Chris Wanstrath, aka defunkt.

Textmate.el for Emacs

Since switching from Textmate to Emacs, the only thing I have missed is ⌘T or Go to File. I used it all the time in Textmate and although there were some minor-modes for Emacs that got me closer, it still wasn’t ⌘T.

Chris has developed Textmate.el, a minor-mode that brings some of the similar key bindings to Emacs for those of us who relied on Textmate bindings.

From the readme:

⌘T – Go to File ⇧⌘T – Go to Symbol ⌘L – Go to Line ⌘/ – Comment Line (or Selection/Region) ⌘] – Shift Right (currently indents region) ⌘[ – Shift Left (not yet implemented) ⌥⌘] – Align Assignments ⌥⌘[ – Indent Line ⌘RET – Insert Newline at Line’s End ⌥⌘T – Reset File Cache (for Go to File)

A “project” in textmate-mode is determined by the presence of a .git directory. If no .git directory is found in your current directory, textmate-mode will traverse upwards until one (or none) is found. The directory housing the .git directory is presumed to be the project’s root.

In other words, calling Go to File from ~/Projects/fieldrunners/app/views/towers/show.html.erb will use ~/Projects/fieldrunners/ as the root if ~/Projects/fieldrunners/.git exists.

In your emacs config:

(add-to-list ’load-path “~/.emacs.d/vendor/textmate.el”)
(require ’textmate)

Chris’s example above is typical of Rails projects but I can attest to the fact that this works nicely for Python/Django projects.

Thanks Chris!

Gist.el for Emacs

While you’re visiting Chris at Github I recommend you also grab a copy of Gist.el. Gists are like pasties for those who aren’t familiar with the term. What Gist.el does well is paste the buffer or region to your account on github and return the url in your kill-ring, public or private. Gist.el will also allow you to yank a gist into a buffer.