On 26 January 2014 02:53, Peter O'Malley <ooomalley@gmail.com> wrote:
On Fri, Jan 24, 2014 at 2:29 PM, Lex Trotman <elextr@gmail.com> wrote:
> ...
> 4) The folder would have to always count increases/decreases from the start
> of the file to actually get a level that counts correctly or save state on
> the file.  At the moment it starts from near the start of the visible range
> most of the time to make it faster, and saves no state so it only knows the
> actual indentation, not the level number.  You will have to keep count
> yourself as you go through the file clearing/setting the fold points.
>
> Cheers
> Lex
>

Let's say that I'm only interested in python code that's (close to)
PEP 8 and ignore stuff like triple-quoted strings for the moment.

Ok, just thought docstrings might be useful for you to show.

 
"Keeping count myself" throughout the entire file is basically the
only idea I had come up with. I was thinking of something fairly
simple like this:
* User requested to fold level 2
* Check document for HEADERFLAG's at fold level 1; found some; increment counter
* Check level 2... none exist, level 3... none exist... (etc) found
some at level 5
* Counter now at 2, so fold all level 5

Obviously this wouldn't scale too well for large files. But in my
(limited) experience python files don't grow very large...

wrong :)

If its put in Geany-Plugins you *will* get bug reports if its slow with big files.  Remember you are maintaining it :)

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.

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 :) 

level = 0
fold_level = 0
for all lines:
    line_level = get_fold_level_of_line()
    if fold_level < line_level): ++level
    elif fold_level > line_level: --level
    fold_level = line_level
    if line has header_flag:
        if level < level_to_expand_to: unfold
        else fold
 
and I
personally don't like large source files anyway ;-).

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 :)
 
(And I suppose
this functionality could be turned on/off with a setting, too.)


Well, its a plugin, so it can be disabled. Thats fine.

Cheers
Lex
 
How does this sound?

And thanks for the pointers, too!

Best,
Peter
_______________________________________________
Devel mailing list
Devel@lists.geany.org
https://lists.geany.org/cgi-bin/mailman/listinfo/devel

Again if you are making it public via G-P it needs "a reasonable level of quality"