(archive 'newLISPer)

August 18, 2006

TextMate – the missing 21st century editor…?

Filed under: newLISP — newlisper @ 19:31

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!


1 Comment »

  1. >I bet you have been so busy with getting this bundle working that you haven’t had a chance to explore snippets yet. If not, I’m beginning to believe the real bursts of productivity within TextMate come from snippets. The ${1:default} placeholders can be nested! (This makes filling in whole placeholders, or just parts of them, possible.) With this, you can make complete web pages in a few keystrokes. And it’s fun, too! :-)In case all this is Greek to you:$1, $2, $n Sequence of placeholders.$0 Default placeholder (not too sure what this is used for).${1:default text} The default text is highlighted, so you can just type.Also, if you use the same number later in the snippet, whatever you put in the first one is duplicated in the others:snippet: first: ${1:first} last: ${2:last name}…$1 $2$0===result (square brackets indicate highlight): first: [first] last: last name…first last nameEntering first name and tabbing brings us here: first: Don last: [last name]…Don last namelast name, TAB, and we are here (@ $0): first: Don last: Lucio…Don Lucio_Add nested placeholders to that, and you have a powerful way to enter structured text!Gotta go,m i c h a e l

    Comment by m i c h a e l — August 19, 2006 @ 16:50 | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: