I said I was going on holiday, and I am, but the following piece of prose has now matured enough to be almost ready for posting, so without further ado I’m posting it.
TextMate is a relatively new text editor for the Mac platform. The swaggering slogans of this new arrival – “the missing editor”, “code and markup brought to the 21st century” – position it as a rival for both BareBones’s BBEdit and the motley crowd of keyboard-oriented text editors that have been the reliable weapons of the Unix user for decades – vim, vi, pico, emacs, ed, and the rest.
There’s a nice bit of rivalry going on between TextMate and BBEdit – BBEdit’s boss made a glancing reference to ‘overnight text editors’, once, which quickly appeared on the back of TextMate t-shirts… See this wry comment at the TextMate blog.
There’s no doubting TextMate’s many virtues – just use it for an hour and you’ll spot some of them. But is it any good as an editor for newLISP? I think I can answer ‘yes’, because, unlike many of its competitors, TextMate can be taught new languages. There’s now a newLISP definition (called a ‘bundle’) for TextMate, based on the work of my distinguished co-blogger michael, and others, and further developed with the help of the TextMate community and TextMate’s author, who patiently shone some light in some of the darker corners. You can find it on the newLISP web site.
The advantage of the TextMate approach is that you’re not restricted to features that were developed for and by users of other programming languages. For example, BBEdit provides a pop-up menu showing all the functions in your document, but only if you use the mainstream languages. You can add similar functionality for your own chosen language, but only by writing a plug-in (and you’ll have to write it in some kind of C anyway, most probably).
However, if you can describe the syntax of your language with regular expressions, you can teach TextMate what function definitions look like, and which keywords belong to which categories. The approach seems a little odd at first, but it works, for the most part. TextMate’s ‘knowledge’ is evident when you’re editing newLISP code with a newLISP bundle active: the colour scheme illuminates the syntax and structure. Also, the effects of actions and commands depend on the context in which you’re working. It’s possible (and fun) to assign distinctive colour schemes to different language elements. Those destructive newLISP keywords such as replace can be made to look very menacing with garish yellow backgrounds! And how about showing those deprecated or obsolescent keywords in a sad-looking grey?
TextMate is highly configurable and sensitive to context. For example, I’m used to using the Command B key combination to select everything between enclosing parentheses. I can tell TextMate that Command B should do this when I’m writing newLISP, but that the same key stroke should do angle-bracket magic in an HTML document, and double-asterisk business when I’m writing in MarkDown. Similarly, when I press Control H, I’ll get a MarkDown syntax summary, an HTML reference page, or an extract from the newLISP manual, depending on where my cursor is at the time.
The basic task of parenthesis balancing (essential for us newLISPers) is handled quite well in TextMate but not perfectly. Moving the caret forward over a closing parenthesis briefly highlights the matching opening parenthesis – something that BBEdit can’t do. However, the other three cases (moving back over a closing parenthesis, and moving forward and backward over an opening parenthesis) don’t do anything visual – perhaps there are good reasons.
Unfortunately, TextMate’s balancing code isn’t smart enough to ignore parentheses in strings and comments. I spent 10 minutes trying to pin down a coding problem before I realised that TextMate hadn’t been telling me the truth. TextMate can’t balance this correctly:
(println "(" )
but BBEdit can, and I was used to it being able to do so. This is a bit of my newLISP formatting script, so I consider it fairly essential! I haven’t found out how to teach TextMate about this yet.
There are plenty of entertaining discussions about BBEdit and TextMate, and I think it would be hard to compare these two editors objectively without writing an enormously long – essentially pointless, for everyone has different needs – review. For example, BBEdit is AppleScript-friendly, and that’s always been a strong point in its favour for us long-time Mac users. BBEdit is well-documented, well-supported, and packed with features, and I’m comfortable with it. But TextMate also has good documentation, and the community is as helpful, and more productive. Perhaps TextMate is more flexible and customizable, and better for newLISP, too. TextMate develops quicker and costs less, but BBEdit… well, let’s stop there.
If you’re thinking of using newLISP on MacOS X, it’s worth checking out TextMate with the newLISP text bundle. Let me know how you get on, and please help to improve it!
