On Aug 22, 2012, at 12:27 AM, Gerd Knops <gerti-textm...@bitart.com> wrote:

> […] A far better approach would be one based on scopes alone:
> 
> - assign indents to certain scopes
> - count all existing scopes at the beginning if a line
> - subtract all scopes no longer existing at the end of that line
> 
> The result is the indent for that line. Period. Done. Really!

This would require that everything that increase indent also add a scope, am I 
right?

I don’t see how to do that e.g. for single-line if/for statements:

    for(size_t i = 0; i < count; ++i)
        fprintf(stderr, "%zu\n", i);

Similarly for braceless languages matching “blocks” is pretty difficult. For 
whitespace-indented languages we can, to some degree, use the begin/while 
construct to match the leading whitespace, but there are also languages which 
uses keywords to begin/end a block, but where the keyword can also appear in 
other places, e.g. in ruby we may have ‘if’ after a line, which doesn’t start a 
new block, but if doesn’t need to be first on the line, to actually start a 
block.

Maybe some sort of hybrid is called for?

_______________________________________________
textmate-dev mailing list
textmate-dev@lists.macromates.com
http://lists.macromates.com/listinfo/textmate-dev

Reply via email to