[TxMt] inconsistent python folding
    Allan Odgaard 
    throw-away-1 at macromates.com
       
    Tue Oct 18 13:38:34 UTC 2005
    
    
  
On 18/10/2005, at 15.31, Chris Fonnesbeck wrote:
> Is there any way to turn off folding until this is fixed? Right now my
> code looks like a dog's breakfast, with folding in arbitrary places.
View -> Language -> Edit Languages…
In the Python bundle, you'll find the Python language grammar which has:
     foldingStartMarker = '^\s*(def|class)\s+([.a-zA-Z0-9_ b]+)\s*(\ 
((.*)\))?\s*:|\{\s*$|\(\s*$|\[\s*$';
     foldingStopMarker = '^\s*$|^\s*\}|^\s*\]|^\s*\)';
You can remove the patterns, or maybe set them to something you want  
to fold on (e.g. {{{ and }}}).
Notice however that if you edit the Python language, it places your  
customized version in ~/Library/Application Support/TextMate/Bundles,  
and this one overshadows the default version. So if the default is  
updated, yoy won't see these changes (as long as you have a local  
version).
To avoid this, you can create a new language that includes the  
default one, and set the folding markers for your new language, e.g.  
(after creating a new language, paste this in the text box):
{   scopeName = 'source.python.custom';
     firstLineMatch = '^#!/.*\bpython\b';
     fileTypes = ( 'py', 'rpy', 'cpy' );
     foldingStartMarker = '\{\{\{';
     foldingStopMarker = '\}\}\}';
     patterns = (
         { include = 'source.python'; }
     );
}
You may need to manually select your new language to be used for  
Python files, but after that, it'll stick.
    
    
More information about the textmate
mailing list