[TxMt] Defining functions in bundle

Allan Odgaard throw-away-1 at macromates.com
Thu Aug 3 12:48:10 UTC 2006


On 3/8/2006, at 11:05, cormullion at mac.com wrote:

> I've got the idea of matching the names, but now I'm trying to work  
> out how to match the shape of possible function definitions.  
> Assuming temporarily that names are just [a-z]*, I'm trying to match:
>
> (define (func)
> (define (fun arg1)
> (define (func arg1 arg2)
> (define (func arg1 arg2 arg3)
>
> I can find these patterns with:
>
> (\(define)(\s+)\((\w+\s*)+(\))
>
> but I can't successfully capture a variable number of arguments for  
> use with 'capture'?

No, that is not possible, as regexp captures will only capture the  
last repeat.

In this case you would change the rule to using begin/end, like:

    {  name = 'meta.function.newlisp';
       begin = '\((define)\s+\(';
       beginCaptures = { 1 = { name =  
'keyword.control.define.newlisp'; }; };
       end = '\)';
       patterns = (
          {  name = 'variable.parameter.newlisp';
             match = '[a-z]+';
          }
       );
    }




More information about the textmate mailing list