TextMate tip

I had an interesting little run-in with TextMate today. I’ve just been turned on (finally) to the lovely TODO bundle. However, it was producing very spurious results and taking a long time to do so.

Tracking it down wasn’t too hard, as it turned out. Just a few print statements in the TODO bundle did the trick. But the answer surprised me.

It turns out that when you have a project open in TextMate, it keeps a TM_PROJECT_DIRECTORY environment variable pointed at the directory you’ve got open in there. With just one folder open in that project, it’s got the same value as the folder. The TODO bundle searches everything in $TM_PROJECT_DIRECTORY. Nice and simple.

But, when you have two directories open in the project then $TM_PROJECT_DIRECTORY gets set to the highest common directory. In my case I had /Users/dom/work/project1 and /Users/dom/work/project2 open in the same TextMate project, so $TM_PROJECT_DIRECTORY was being set to /Users/dom/work. Now there’s a lot of stuff in there. No wonder it was taking a long time.

So, be warned. Stick to single folders in a project if you want to use the TODO bundle.

Comments 1

  1. Soryu wrote:

    Just a note: Same things for symlinks to files outside the project folder. (Think of including your apache access log in the project and running TODO.)

    Posted 25 Mar 2007 at 12:48