<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">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">elextr@gmail.com</a>> wrote:<br>

> ...<br>
<div class="im">> 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>Ok, just thought docstrings might be useful for you to show.</div><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>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> </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><br class="">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> <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>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">

How does this sound?<br>
<br>
And thanks for the pointers, too!<br>
<br>
Best,<br>
Peter<br>
<div class=""><div class="h5">_______________________________________________<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>
</div></div></blockquote></div><div><br class="">Again if you are making it public via G-P it needs "a reasonable level of quality"</div><div><br></div></div></div>