After loading a python file into textmate, I noticed that the folding is very inconsistent throughout the file:
http://www.flickr.com/photos/84201647@N00/53572833/
Notice in the screen shot that one method is folded after the comment (!) and others are folded at some arbitrary point inside the method (!!). I tried searching the mailing list archive for this, and most of the references are from last year. Am I missing something, or has this problem not been fixed in the past year?
Allan Odgaard wrote:
On 18/10/2005, at 3.37, Chris Fonnesbeck wrote:
After loading a python file into textmate, I noticed that the folding is very inconsistent [...] has this problem not been fixed in the past year?
It hasn't been fixed, and it's unlikely to be until 1.3.
Bit of context: creating foldings for python programs is hideously difficult if you don't include extra whitespace to aid the parser.
For example:
class someClass: def someMethod(self, foo, bar): foo = bar + 1
return foo
The function folding close marker should come after return foo, but there's no way to know that it should be there if you don't include 4 spaces on that line.
So the workaround for this is to include whitespace in your code. It's not ideal, but doing it any other way is far from trivial.
Jeroen.
On 10/18/05, Jeroen van der Ham jeroen@je-ju.net wrote:
Allan Odgaard wrote:
On 18/10/2005, at 3.37, Chris Fonnesbeck wrote:
After loading a python file into textmate, I noticed that the folding is very inconsistent [...] has this problem not been fixed in the past year?
It hasn't been fixed, and it's unlikely to be until 1.3.
Bit of context: creating foldings for python programs is hideously difficult if you don't include extra whitespace to aid the parser.
For example:
class someClass: def someMethod(self, foo, bar): foo = bar + 1
return foo
The function folding close marker should come after return foo, but there's no way to know that it should be there if you don't include 4 spaces on that line.
So the workaround for this is to include whitespace in your code. It's not ideal, but doing it any other way is far from trivial.
Jeroen.
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.
C.
On 10/18/05, Chris Fonnesbeck fonnesbeck@gmail.com wrote:
On 10/18/05, Jeroen van der Ham jeroen@je-ju.net wrote:
Allan Odgaard wrote:
On 18/10/2005, at 3.37, Chris Fonnesbeck wrote:
After loading a python file into textmate, I noticed that the folding is very inconsistent [...] has this problem not been fixed in the past year?
It hasn't been fixed, and it's unlikely to be until 1.3.
Bit of context: creating foldings for python programs is hideously difficult if you don't include extra whitespace to aid the parser.
For example:
class someClass: def someMethod(self, foo, bar): foo = bar + 1
return foo
The function folding close marker should come after return foo, but there's no way to know that it should be there if you don't include 4 spaces on that line.
So the workaround for this is to include whitespace in your code. It's not ideal, but doing it any other way is far from trivial.
Jeroen.
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.
Just saw the gutter option for folding ... never mind. Thanks.
On 18/10/2005, at 15.33, 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.
Just saw the gutter option for folding ... never mind. Thanks.
<lecture>
Ok... If possible, please don't quote 6 pages of past letters when replying with a one-liner.. it gets a bit annoying to have to scroll all the time to see what the letter is about.
As for past context, threading will usually take care of preserving that. So when not commenting directly on something, not including it is best.
</lecture>
-- Sune.
On 10/19/05, Sune Foldager cryo@cyanite.org wrote:
On 18/10/2005, at 15.33, 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.
Just saw the gutter option for folding ... never mind. Thanks.
<lecture>
Ok... If possible, please don't quote 6 pages of past letters when replying with a one-liner.. it gets a bit annoying to have to scroll all the time to see what the letter is about.
As for past context, threading will usually take care of preserving that. So when not commenting directly on something, not including it is best.
</lecture>
-- Sune.
unsubscribe lecture
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.
2005/10/18, Allan Odgaard throw-away-1@macromates.com:
On 18/10/2005, at 3.37, Chris Fonnesbeck wrote:
After loading a python file into textmate, I noticed that the folding is very inconsistent [...] has this problem not been fixed in the past year?
It hasn't been fixed, and it's unlikely to be until 1.3.
I am not sure if this is only Python related, but I've noticed another problem with folding in Python files: when cursor is on the line beneath the folded block, pressing [backspace] removes the whole block (the little gray icon, and all code in it). I've accidentally did it few times already, when re-formatting code for TextMate folding.
-- Ksenia
On 23/10/2005, at 3.31, Ksenia Marasanova wrote:
I am not sure if this is only Python related, but I've noticed another problem with folding in Python files: when cursor is on the line beneath the folded block, pressing [backspace] removes the whole block (the little gray icon, and all code in it).
This is correct behavior, for now at least (and not related to any specific language). I think it was mentioned that it might switch to unfold and delete inside the fold instead, but I'm not sure.
-- Sune.