[TxMt] Re: Code folding question...

Martin Kühl martin.kuehl at gmail.com
Fri Aug 21 18:48:24 UTC 2009


On 21.08.2009, at 20:30, Eric O'Connell wrote:

> I'm not sure there's a way to do it exactly the way you want, because
> the folding stop/start markers don't "know" about each other-- there's
> no way you could reference the captured name of your section from the
> start in the folding stop marker. So I kinda hacked it, and I got this
> to work:
>
> /* { Section_Start test */
>
> div#supercool {
> font-size: 400%;
> }
>
> div#not-so-cool {
> display:none;
> }
>
> /* Section_End test } */
>
> Note the braces at the end and beginning of the braces... This works
> by adding to the start/stop markers:
>
> 	foldingStartMarker = '/\*\*(?!\*)|\{\s*($|/\*(?!.*?\*/.*\S))|\/\*.*?\
> {';
> 	foldingStopMarker = '(?<!\*)\*\*/|^\s*\}|\}.*?\*\/';
>
> I added everything from the final pipe "|" onward.. and these sections
> will nest.

You could dispose of the braces by adding '/\*\s*Section_Start\b' and  
'/\*\s*Section_End\b' to the start and stop markers respectively. It  
would still nest but ignore the labels, and I don’t think using the  
labels is possible (nor do I think overlapping sections [like: a> b>  
<a <b] are sensible, but would have to be supported for OP’s proposal  
to work).

Note that the rules already support folding comments like these:

/** test */
...
/* test **/

Same caveats apply.

HTH,
Martin

> On Aug 21, 2009, at 11:06 AM, Keith Solomon wrote:
>
>> I'm trying to set up a code folding rule that will let me fold
>> sections
>> of CSS files I work on.  I usually define sections in my code like
>> this:
>>
>> /* Section_Start <section name> */
>> ...
>> /* Section_End <section name */
>>
>> I've got the Pragmatic book, and I've looked at the included bundles,
>> but I can't figure out a working solution...anybody got some
>> pointers on
>> how to accomplish this?
>>
>> Keith
>>
>> -- 
>> Keith Solomon - ksolomon at gmail.com
>> My Blog - http://reciprocity.be/
>> My Flickr - http://www.flickr.com/photos/zarath0s/
>>
>>
>> _______________________________________________
>> textmate mailing list
>> textmate at lists.macromates.com
>> http://lists.macromates.com/listinfo/textmate
>
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate




More information about the textmate mailing list