[TxMt] Re: Extending comment definition?

Christopher Creutzig christopher at creutzig.de
Tue May 26 06:10:33 UTC 2009


William Uther wrote:

>    I frequently comment out snippets of code by sticking `if (false)  
> { ... }` around the code.  The other variation I use is to convert an  
> existing condition into a comment: `if (false && previous condition)  
> { ... }`.  You don't want to over-use this idiom, but it is useful in  
> its place.
> 
>    At the moment TextMate treats this just like normal code (which is  
> exactly what you'd expect).  I was wondering if there was a way to  
> make TextMate see these patterns as comments.  It isn't easy as you  

 I'm not an expert on TM grammars, but it seems to me that
preprocessor-rule-disabled is probably a good start, using the handy
predefined block pattern to get the right scope.

 (BTW: The C language definition includes a couple of things I can't
remember seeing before: iterate? riterate? Can someone explain these?
And I thought new was a C++ keyword, not C?)

> really want to pick the right brace to close the comment.  There could  
> be further blocks of code nested inside the 'comment block'.

 Also, don't forget about the else block at the end and about the 'if
(true || whatever)' things. And while I believe VC 2005 doesn't accept
them, the C standard also allows 'if (false and whatever)'. :-)


Christopher



More information about the textmate mailing list