E-Scribe : a programmer’s blog

About Me

PBX I'm Paul Bissex. I build web applications using open source software, especially Django. Started my career doing graphic design for newspapers and magazines in the '90s. Then wrote tech commentary and reviews for Wired, Salon, Chicago Tribune, and others you never heard of. Then I built operations software at a photography school. Then I helped big media serve 40 million pages a day. Then I worked on a translation services API doing millions of dollars of business. Now I'm building the core platform of a global startup accelerator. Feel free to email me.

Book

I co-wrote "Python Web Development with Django". It was the first book to cover the long-awaited Django 1.0. Published by Addison-Wesley and still in print!

Colophon

Built using Django, served with gunicorn and nginx. The database is SQLite. Hosted on a FreeBSD VPS at Johncompanies.com. Comment-spam protection by Akismet.

Elsewhere

Pile o'Tags

Stuff I Use

Bitbucket, Debian Linux, Django, Emacs, FreeBSD, Git, jQuery, LaunchBar, macOS, Markdown, Mercurial, Python, S3, SQLite, Sublime Text, xmonad

Spam Report

At least 236559 pieces of comment spam killed since 2008, mostly via Akismet.

Bicycle Repair Man bundle for TextMate

Look! For a long time I've wanted to try working with Bicycle Repair Man, the Python refactoring tool. Unfortunately, the fact that it had neither documentation nor integration with my favorite editor kept pushing it to the back burner.

About a month ago I was excited to come across a post from a guy named David Coffin who had created a BRM integration script for TextMate. I hooked it up per his instructions, and with a little fiddling I got it working. The first thing I tried was the Extract Method or Function command. I had code something like this (structurally, I mean):

def funfacts(string):
    l = len(string)
    a = string.count('a')
    u = string.upper()
    print "Length: %s  Number of a's: %s  Uppercase: %s" % (l, a, u)

I selected the three assignment lines, ran the "Extract Method or Function" command, and typed a name for the new function (funfacts_helper) into the dialog. I hit return and my code changed to this:

def funfacts(string):
    l, a, u = funfacts_helper(string)
    print "Length: %s  Number of a's: %s  Uppercase: %s" % (l, a, u)

def funfacts_helper(string):
    l = len(string)
    a = string.count('a')
    u = string.upper()
    return l, a, u

Cool. Now, people who have been using fancy refactoring IDEs for a long time may just laugh in their sleeves that I was impressed by this, but I was. This is great timing for me since I expect my copy of the Refactoring book to arrive any day.

David's biketextmate.py script supports five BRM commands: Rename, Find Definition, Extract Method or Function, Inline Local Variable, and Extract Local Variable.

I decided this thing needed to become a proper distributable TextMate bundle. (I actually have commit privileges in the bundle repository, not that you'd know it from my activity in the past year.) I made some minor changes to the biketextmate.py script, mostly to improve handling of file paths with spaces. Boy, did it take me a stupidly long time to figure out where those errors were coming from.

Anyway, please try it out and provide feedback. You'll need to install Bicycle Repair Man (try easy_install bicyclerepair), then fetch a tarball of the bundle -- or get the latest via Subversion:

svn co svn://open.e-scribe.com/python/misc/biketextmate
Update: I imported this into my new public Subversion repository and updated the previous command appropriately.

I don't have contact info for David, but I'm posting a comment on his blog pointing here. So David, if you're reading this, feel free to take my work and run with it, assuming you find it useful.

Saturday, April 14th, 2007
+ + + +
2 comments

Comment from Craig , 2 years later

I couldn't get to the repository anymore but I downloaded the tarball. It has a slight conflict with the latest version of Bicycle Repair Man. You have to change all the brm.findDefintion() calls to brm.findDefinitionByCoordinates().

Comment from scott , 4 years later

Have you still been using Bicycle Repair Man? Worth installing?

Comments are closed for this post. But I welcome questions/comments via email or Twitter.