What are *exactly* the folding rules? I understand folding keeps into account both the rules given in the language definition and the text indentation, but which one takes precedence? above all, is there a way to completely overrule the indentation thing and let folding use only the rules declared in the language?
Thanks, Piero
On 10. Jun 2007, at 13:36, Piero D'Ancona wrote:
What are *exactly* the folding rules?
From the manual:
[...] the folding system is based on both having clear indent markers and having the fold start/stop markers use the same indent level. This means that folding based purely on indent or where the start/stop markers do not align, is currently not supported.
I understand folding keeps into account both the rules given in the language definition and the text indentation, but which one takes precedence?
Both are required, none take precedence.
above all, is there a way to completely overrule the indentation thing and let folding use only the rules declared in the language?
No.
Allan Odgaard <throw-away-1@...> writes:
I understand folding keeps into account both the rules given in the language definition and the text indentation, but which one takes precedence?
Both are required, none take precedence.
I did RTFM. But I am confised, nevertheless (sorry, just a mathematician, JAM). Try this: create a tex file containing only
\begin{equation} \begin{split} \end{split} \end{equation}
(no indentation) and you will notice that folding is indeed activated on both groups. Moreover, using the menu shortcuts shows that the outer group is folding level 1 and the inner group is folding level 2. So, Indentation is not strictly required after all. Then try this:
\begin{equation} \begin{split} \end{split} \end{equation}
(outer group indented). The result is the same, outer group level 1, inner group level 2. What is going on?
But I can happily dispense from understanding the details. The reason I am asking is the following: it would be great to use TextMate as a cataloging tool for my removable media; if I drag and drop a CDrom on an open TextMate window I get a list of the contents, nicely indented. Think about it: a project with the catalog, in plain .txt files, of all my CDs and DVDs, plust the searching power of TextMate. What is missing is a way to fold-unfold the list. But the way this list is indented clashes with TextMate folding rules, so I am not able to define appropriate folding rules to manage the catalog.
OK sorry for the waste of time Thanks, Piero
On 10. Jun 2007, at 17:38, Piero D'Ancona wrote:
I understand folding keeps into account both the rules given in the language definition and the text indentation, but which one takes precedence?
Both are required, none take precedence.
I did RTFM. But I am confised, nevertheless (sorry, just a mathematician, JAM). Try this: create a tex file containing only
\begin{equation} \begin{split} \end{split} \end{equation}
(no indentation) and you will notice that folding is indeed activated on both groups [...]
The indent for the fold start and fold stop marker needs to be the same.
In your example the indent is zero for both the start and the stop marker (both in nesting level 1 and 2), thus it works.
In your next example you change the indent of the outer group to 1, but it is also changed for the stop marker, thus the indent is still the same for the start and the stop marker.
Allan Odgaard <throw-away-1@...> writes:
The indent for the fold start and fold stop marker needs to be the same.
So, at least now I understand the mechanism; it was not clear for me after reading the manual (sorry). Let me write it down explicitly for reference (correct me if I'm wrong):
Folding is determined by the patterns listed in the language definition. But a startfold and an endfold markers will be coupled only if they have the same indentation, otherwise they will be ignored (well, at least one of them). Thus if I write in a tex file
\begin{equation} \begin{split} \end{split} \end{equation}
line 1 is coupled with line 3 and line 2 is coupled with line 4. Moreover, the couple l2-l4 is nesting level 1, while the couple l1-l3 is nesting level 2
I am more and more convinced that an option to ignore indentation could be useful... at least for languages like LaTeX, where indentation is just a matter of taste. One might add more precise start/stop markers in the language definition to ensure proper coupling
Piero
On Jun 10, 2007, at 10:23 AM, Piero D'Ancona wrote:
I am more and more convinced that an option to ignore indentation could be useful... at least for languages like LaTeX, where indentation is just a matter of taste. One might add more precise start/stop markers in the language definition to ensure proper coupling
Piero
I second this. Such an option would work well for LaTeX users since the begin and end pairs are logically nested and indentation adds nothing but visual pleasure if right, but headaches for folding if wrong. When I first learned to use TextMate this was a constant problem, but I can now keep things clean and tidy using all the lovely macros you all set up. So I appeal for this option for the hordes of Latex users I expect to see coming over to TextMate once 2.0 is released ;-)
Jenny
On Jun 10, 2007, at 5:05 AM, Allan Odgaard wrote:
[...] the folding system is based on both having clear indent markers and having the fold start/stop markers use the same indent level. This means that folding based purely on indent or where the start/stop markers do not align, is currently not supported.
Is there any chance of allowing misalignment of folding markers in 2.0? I have found that the indentation of folding markers can be inadvertently changed during standard text editing and must be corrected by hand. Logically, the begin and end tags are still well defined, even though they might have mismatching indents.
Jenny
On 10. Jun 2007, at 17:56, Jenny Harrison wrote:
Is there any chance of allowing misalignment of folding markers in 2.0? I have found that the indentation of folding markers can be inadvertently changed during standard text editing and must be corrected by hand. Logically, the begin and end tags are still well defined, even though they might have mismatching indents.
They are not always logically defined when indent is ignored (and certainly not with the current regexp system, i.e. where no logical pairing of begin/end markers is defined).
But it is a common request to get more flexibility in the system, so I am considering it, though I have yet to see a good proposal for how to improve it ;)
Allan Odgaard <throw-away-1@...> writes:
But it is a common request to get more flexibility in the system, so I am considering it, though I have yet to see a good proposal for how to improve it ;)
What about adding a preference to choose if use indentation or rely exclusively on the rules in the language definition? this should not be difficult
Piero
On Jun 10, 2007, at 11:13 AM, Allan Odgaard wrote:
On 10. Jun 2007, at 17:56, Jenny Harrison wrote:
Is there any chance of allowing misalignment of folding markers in 2.0? I have found that the indentation of folding markers can be inadvertently changed during standard text editing and must be corrected by hand. Logically, the begin and end tags are still well defined, even though they might have mismatching indents.
They are not always logically defined when indent is ignored (and certainly not with the current regexp system, i.e. where no logical pairing of begin/end markers is defined).
But it is a common request to get more flexibility in the system, so I am considering it, though I have yet to see a good proposal for how to improve it ;)
Some ideas:
* Gobble up trailing empty lines * Allow some fold markers to consolidate with the previous line
so that this:
- (void)method1 { // code }
- (void)method2 { // code }
neatly folds into:
=>- (void)method1 =>- (void)method2
* Purely indentation based folding. I have a bunch of files optimized for this from my jEdit days, and code in some languages with no obvious fold markers can be written to support this. I guess python folks would like this too.
* Make some assembler programmers happy: Indentation based folding, but with a pattern that if it applies makes a line being ignored for fold markers. Example:
func1: code code .local1: code jmp .label1
func2: code code
Here labels prefixed with a '.' are local labels. Ideally the above should fold to:
=>func1: =>func2:
Gerd
On Jun 10, 2007, at 7:05 AM, Allan Odgaard wrote:
On 10. Jun 2007, at 13:36, Piero D'Ancona wrote:
What are *exactly* the folding rules?
From the manual:
[...] the folding system is based on both having clear indent markers and having the fold start/stop markers use the same indent level. This means that folding based purely on indent or where the start/stop markers do not align, is currently not supported.
That doesn't seem to explain this folding properly (which works fine):
- (void)somethingOrOther { // Code here ... }