E-Scribe News : a programmer’s blog

About Me

PBX I'm Paul Bissex, and e-scribe.com is my consulting business. I build web applications using open source software, especially Django. In the '90s I did graphic design for newspapers and magazines. Then I wrote technology commentary and reviews for Wired, Salon.com, Chicago Tribune, and lots of little places you've never heard of. Feel free to email me.

Book

I'm co-author of "Python Web Development with Django", an excellent guide to my favorite web framework. Published by Addison-Wesley, it is available from Amazon and your favorite technical bookstore as well.

Colophon

Built using Django, served by Apache and mod_wsgi. The database is SQLite. The operating system is FreeBSD, on a VPS hosted at Johncompanies.com. Comment-spam protection by Akismet. Vintage topo imagery from the Maptech archive. The markup engine is Markdown.

Pile o'Tags

Stuff I Use

Akismet, bitbucket, del.icio.us, Django, Emacs, FreeBSD, Git, jQuery, LaunchBar, Markdown, Mercurial, OS X, Postfix, Python, Review Board, S3, SQLite, TextMate, Ubuntu Linux

Spam Report

At least 96057 pieces of comment spam killed since January 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?

Post a comment

Thanks for reading! Please note: Your comment will not appear until approved, which may take a few hours or more. Spammers will be torpedoed.


(Will not be shared)

(Optional)