Page 1 of 1

python.coder folding

Posted: Sun Apr 04, 2021 7:09 am
by ogreg
I've used Akelpad for a long time for text files only, recently began using it for Javascript and PHP files, with code folding - it's working great.

Trying folding in the Python coder, it seems that I either have an outdated version (10-09-2016), or maybe some/most code folding is not implemented?

I've tried to screen the group for answers to this, but no obvious hits.

Re: python.coder folding

Posted: Mon Apr 05, 2021 2:52 pm
by DV
Looks like code folding for `if`, `for`, `with` etc. is not supported because of indentation-based syntax in Python.
If we look at the "CodeFold" section of AkelPad's .coder files, it mentions "fold start" and "fold end", and nothing about indentations. Most likely, the Coder plugin currently does not support indentation-based folding.

Posted: Fri Apr 09, 2021 10:49 am
by ogreg
Thank you - I also think it's a bit uphill to code the folding from scratch.
I might be content (for now) with folding of just 'class' and 'def'.
The code below aims to improve python.coder by correcting the error where non-indented code is 'folding-swallowed' by a preceding def or class.
The folding marker for level 1 is now terminated correctly at a blank line.
In my quick test level 1 class/def seem to fold correctly - there are still problems with folding of inner class/def.
Old code in folds: section:

Code: Select all

;173=1+4+8+32+128
;173	0	0	0	"class"   "class"  " 	"       0	0
;173	0	0	0	"def"     "def"    " 	"       0	0
;173	0	0	0	"def"     "class"  " 	"       0	0
Replace by:

Code: Select all

;3145901=1+4+8+32+128+1048576+2097152
3145901	0	0	0	"^[ \t]*(class|def)"   "^\s*\n\S.*"  " 	"       0	0
I'm sure there are better ways to do it, but I'm not into plugin coding.