Yesterday, I heard that version 2.0 of the Thunderbird email client had been released, so I decided to check it out. I would have switched a while back except for one annoying problem — I prefer the two-paned view with a separate window for reading messages, which works great in Thunderbird except that when I delete an open message, instead of the window going away, the next message, which I may have no intention of reading at the moment, gets displayed and marked “read”. Yuck! There’s a preference setting (which you have to go into the “config editor” from the “Advanced / General” panel to edit) that looks like it should control this behavior, but it has no effect. And version 2.0 didn’t fix the problem. :-(

The last time around, I let it go at that and stayed with Apple’s Mail.app. This time I decided to download the source code and see if I could fix the problem in my own custom build. I didn’t know what I was getting into.

First, I got the code, and read the instructions for building Thunderbird. I decided I’d better upgrade to the latest XCode, which I discovered I’d already downloaded but hadn’t installed. Interesting. I uninstalled the old XCode, and since I often find myself low on space in my boot partition (partly because Mozilla keeps saving a gazilion copies of it’s bookmarks file — I’ve looked up information on the problem and how to solve it, but it hasn’t helped), I made the “Developer” directory a symlink to a directory on a bigger partition. That saved a bunch of space where it was most needed. So far so good.

So I got XCode started compiling the code unchanged, just to make sure I could do it, and then went looking for the place in the code that controlled whether that window closed. Interestingly enough, that code is written in JavaScript, as is a lot of Thunderbird — I didn’t know that. After a little Googling, I figured out how to retrieve the value of that preference setting I mentioned earlier, and (in a separate copy of the source file), made the little one-line change needed to bend Thunderbird to my will. Then I waited for the compile to finish. And waited… And was very grateful for preemptive multitasking, which enabled me to work on other things for a few hours, checking on the compile periodically until it finally completed. I’ve gotta get me a newer computer — this 400MHz G4 is really showing its age.

Once the first compile finished, I launched the app, and lo and behold! It worked perfectly! The icon was different from the pre-built Thunderbird I’d downloaded, but otherwise it seemed the same. So I backed up the original of the file I’d modified, copied my changed file into the source tree, and recompiled. And waited. But not nearly so long since I didn’t do a clean compile. But it still took a long time. Once the compile was complete, I tested my changes, and they worked perfectly! Almost ready for the switch, I thought.

Then I selected “Tools / Import” from the menus, selected the “Mail” radio button, clicked “Next”…and discovered that Thunderbird doesn’t know how to import mail from Mail.app. Oh great. A few Googleseconds later (Googleseconds are a lot longer than normal seconds, but we love them anyway), I had import instructions from TwisterMC (be sure to check the comments for info needed if you’re running the latest MacOS X), had my copy of emlxconvert, and started converting mail folders…of which I have about a googol.

Well, the transition took a little more work than expected, but I’m now happily running my own custom version of Thunderbird, secure in the knowledge that if I don’t like the way it works, I can always change it. For anyone who may want the close-window-on-delete behavior, and doesn’t mind compling their own app, here’s the necessary code change: in mozilla/mail/base/content/messageWindow.js, change this (at line 210):

if (gNextMessageViewIndexAfterDelete != nsMsgViewIndex_None)

to this:

if ((!gPrefBranch.getBoolPref(‘mail.close_message_window.on_delete’)) && (gNextMessageViewIndexAfterDelete != nsMsgViewIndex_None))

…and make sure you’ve got that configuration setting set to true.

Anyone involved in Thunderbird care to get that functionality working in a future revision?