[TxMt] Re: Indentation (TM2 R bundle)

Jon Clayden jon.clayden at gmail.com
Thu Jan 12 12:43:19 UTC 2012


Thanks for the info, Michael - it helps a lot. I've managed to get the
old behaviour back by adding this to the patterns in the R grammar:

{  begin = '\{';
   beginCaptures = { 0 = { name = 'punctuation.section.block.begin.r'; }; };
   end = '\}';
   endCaptures = { 0 = { name = 'punctuation.section.block.end.r'; }; };
   name = 'meta.block.r';
   patterns = ( { include = 'source.r'; } );
},

Jon


On 11 January 2012 17:56, Michael Sheets <mummer at whitefalls.org> wrote:
> On Jan 9, 2012, at 9:31 AM, Jon Clayden wrote:
>
>> The R bundle for Avian/TM2 seems to have lost the (neat) ability to
>> add and move to an indented new line after typing an open brace
>> followed by Enter. That is, going from
>
> I've answered this question a few times elsewhere so I figured a detailed explaination is in order:
>
> In TM1 the behavior of the return key when it was between {} was hardcoded and only worked for those specific characters. It also had the major downside that you couldn't override it's behavior when the characters weren't special.
>
> So in 2.0 there is now a snippet¹ with a very specific scope:
>
> source & ((L:punctuation.section.*.begin & R:punctuation.section.*.end) | (L:punctuation.definition.*.begin & R:punctuation.definition.*.end)) - string
>
> In short this means it works only in source files, when the caret is between two specific punctuation scopes, with the special exclusion of strings. This means that is can work with any set of characters, even cases where the begin/end are multiple characters. And this works without a special 'this is empty' scope that had to be used to get this behavior in 1.x.
>
> The downside is that the characters must be matched and given a proper scope for this to work. As you've seen it works in the C languages because they match all block cases and give the proper scopes to the punctuation. In some languages it can be impossible to full match blocks, and in others the grammar just doesn't do so currently.
>
> So the fix is to either start scoping blocks, or if that's not possible the grammar can specially match empty cases so the scopes at least exist there. If you have any questions on how to do this you can see me on IRC for help (username: Infininight).
>
> ¹ The snippet is "Return Inside Empty Item" inside the Source bundle.
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate


More information about the textmate mailing list