[TxMt] language definition regexp question

Peter Michaux petermichaux at gmail.com
Fri Mar 2 08:39:02 UTC 2007


Hi Allan,

Thanks very much for the response. I tried it and fiddled with it a
lot but I couldn't get this working.

On 3/1/07, Allan Odgaard <throw-away-1 at macromates.com> wrote:
> On 1. Mar 2007, at 21:32, Peter Michaux wrote:
>
> > In JavaScript I would like every instance of the word "self" and
> > "parent" to be orange except when they appear as "window.self" or
> > "window.parent". How can I specify these. What I have so far is...
>
> Instead of one rule, make two:
>
>      {   match = '\b(window)\.(this|parent)\b';
>          captures = {
>              1 = { name = 'support.class.js'; };
>              2 = { name = 'variable.language.this-or-parent.js'; };
>          };
>      },


If I try the above rule alone (no other matches in the whole language
file) it doesn't seem to work as a way to capture the "this" and
"parent" words. I can't style them with the following in the
preferences scope selector.

"variable.language.this-or-parent.js".

Did the above work for you?


>      {   name = 'variable.language.js';
>          match = '\b(super|this|parent)\b';
>      }
>
> The first one explicitly matches window.this and window.parent. This
> and parent is still marked up as variable.language, so with no theme
> modifications, it will show the same.
>
> But you can now style all but window.(this|parent) using a scope
> selector of:
>
>      variable.language - variable.language.this-or-parent

WOW! it is possible to subtract scopes? That is very cool!


> Likewise you can style just window.(this|parent) with:
>
>      variable.language.this-or-parent

By the way, I just spent two days trying to learn VIM for a work
situation. What a waste of my time. I think it would take me a year of
plugin programming to get VIM to a state of productivity not quite
matching Textmate. Textmate is a far better solution.

Thanks,
Peter



More information about the textmate mailing list