[TxMt] Simple bundle help

Tom Armitage tom.armitage at gmail.com
Thu Aug 10 10:13:22 UTC 2006

Cool. That sounds like enough to work with :)

The biggest thing to get your head around is "scope". The easiest way
to explain that is that it's a bit like how CSS rules apply to html.
Pres ctrl+shift+p at any point in your document, and the current scope
will pop up. Often, there are several.

You've got two options: either make TextMate know that when it's
inside a taglib, that's a new scope, or, alternatively, just extend

I'd suggest looking at the RHTML/Rails/Ruby/HTML grammars. What
happens there is that RHTML has a tiny rule to say "if you're inside
these kinds of brackets, you're in my templating langauge, and that's
just Ruby/Rails" so it imports all the Ruby and Rails syntax _when
it's in that scope_. And then it imports HTML's grammar on top of that

I don't think your grammar will be hard. If you look in the langaugse
(Command-Opt-Ctrl-L) editor, you'll see you can either match lines to
a regex, or to a begin/end pair. You'll be able to simply modify some
HTML grammar to make it match <foo: thing> and </foo: thing> as a
highlighting pair.

One thing: stick to using default scopes wherever possible - this will
mean that your syntax highlighting is dependent on a user's colour
settings and not special stuff you've invented.

That might sounds complex; I hope not. I dove into writing a bundle
and found it not too hard once you get your head around it. The
examples built into the system are excellent, and I strongly suggest
checking them out.

At some point, I might write a straightforward guide to building
bundles for people trying to do simple things.

Let me know how you get on,


On 10/08/06, Adam van den Hoven <adsmart at gmail.com> wrote:
> Tom,
> I do understand regular expressions. I'm far from an regex ninja but
> certainly above average.
> A tag library is a way to simplify jsp code (depending on your point
> of view). Basically you hide a chunk of code behind a tag so that you
> can do something like:
> <foo:section>
>     <foo:helloworld />
> </foo:section>
> <foo:section>
>     <foo:welcome date="yyyy-mm-dd" name="LLL, FFF" />
>     <p>Have you built your hover car yet?</p>
> </foo:section>
> and you might expect to have at the browser:
> <div class="section section0" >
>     <p>Hello world!</p>
>     <p>Lovely day, isn't it?</p>
> </div>
> <div class="sections section1">
>     <div class="welcome">
>         <p>Welcome Smith, John.</p>
>         <p>You last visited us on 2006-08-12.</p>
>     </div>
>     <p>Have you built your hover car yet?</p>
> </div>
> This sort of notation can, frequently, be easier to read if you need
> to allow non-technical users to edit complex code driven content. It
> can be a lot of work to build taglibs (few people do) but we have a
> big dev team on our side.
> My biggest worries were with the syntax highlighting, but I guess
> mostly its going to highlight correctly already. Maybe I'll start by
> duplicaing some of the very useful things HTML does (like div+tab talk
> about a time saver) before I ask for more help.
> A
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate

More information about the textmate mailing list