<div dir="ltr"><div><div>I appreciate the help, Lex. What I meant for the scanning was that it would happen twice, once to determine that, e.g. fold level 5 is actually fold level 2 and fold level 9 is actually fold level 3, and then again to do the actual folding. I think your outline of folding-as-you-go would probably work, too, and may, in fact, be better.<br>

<br></div>It would only scan when the user initiates the (un)fold all at level X action. Geany scans the whole file for the (un)fold all action already, and given that that doesn't take too long, I'm guessing that this wouldn't either. But I haven't tried it out yet.<br>

<br></div>Peter<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jan 25, 2014 at 3:13 PM, Lex Trotman <span dir="ltr"><<a href="mailto:elextr@gmail.com" target="_blank">elextr@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On 26 January 2014 02:53, Peter O'Malley <span dir="ltr"><<a href="mailto:ooomalley@gmail.com" target="_blank">ooomalley@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On Fri, Jan 24, 2014 at 2:29 PM, Lex Trotman <<a href="mailto:elextr@gmail.com" target="_blank">elextr@gmail.com</a>> wrote:<br>



> ...<br>
<div>> 4) The folder would have to always count increases/decreases from the start<br>
> of the file to actually get a level that counts correctly or save state on<br>
> the file.  At the moment it starts from near the start of the visible range<br>
> most of the time to make it faster, and saves no state so it only knows the<br>
> actual indentation, not the level number.  You will have to keep count<br>
> yourself as you go through the file clearing/setting the fold points.<br>
><br>
> Cheers<br>
> Lex<br>
><br>
<br>
</div>Let's say that I'm only interested in python code that's (close to)<br>
PEP 8 and ignore stuff like triple-quoted strings for the moment.<br></blockquote><div><br></div></div><div>Ok, just thought docstrings might be useful for you to show.</div><div class="im"><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">



"Keeping count myself" throughout the entire file is basically the<br>
only idea I had come up with. I was thinking of something fairly<br>
simple like this:<br>
* User requested to fold level 2<br>
* Check document for HEADERFLAG's at fold level 1; found some; increment counter<br>
* Check level 2... none exist, level 3... none exist... (etc) found<br>
some at level 5<br>
* Counter now at 2, so fold all level 5<br>
<br>
Obviously this wouldn't scale too well for large files. But in my<br>
(limited) experience python files don't grow very large... </blockquote><div><br></div></div><div>wrong :)</div><div><br></div><div>If its put in Geany-Plugins you *will* get bug reports if its slow with big files.  Remember you are maintaining it :)</div>


<div><br></div><div>If I read your above right, you are scanning the file multiple times.  And what is triggering this?  How often will it run and annoy your users?  But if its only triggered manually I would have said its ok.</div>


<div><br></div><div>But in any case, naively I would have said only one scan is needed using the levels from the current lexer (warning, not much thought gone into this :) </div><div><br></div><div>level = 0</div><div>fold_level = 0</div>


<div>for all lines:</div><div>    line_level = get_fold_level_of_line()<br></div><div>    if fold_level < line_level): ++level</div><div>    elif fold_level > line_level: --level</div><div>    fold_level = line_level</div>


<div>    if line has header_flag:</div><div>        if level < level_to_expand_to: unfold</div><div>        else fold</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


and I<br>
personally don't like large source files anyway ;-).</blockquote></div><div><div><br>Again if you are making it public via G-P it needs "a reasonable level of quality" since its not just your files any more :)</div>


</div><div class="im"><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> (And I suppose<br>


this functionality could be turned on/off with a setting, too.)<br>
<br></blockquote><div><br></div></div><div>Well, its a plugin, so it can be disabled. Thats fine.</div><div><br></div><div>Cheers</div><div>Lex</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div class="im">

How does this sound?<br>
<br>
And thanks for the pointers, too!<br>
<br>
Best,<br>
Peter<br>
</div><div class="im"><div><div>_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.geany.org" target="_blank">Devel@lists.geany.org</a><br>
<a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
</div></div></div></blockquote></div><div><br>Again if you are making it public via G-P it needs "a reasonable level of quality"</div><div><br></div></div></div>
<br>_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
<a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
<br></blockquote></div><br></div>