python.coder folding

Discuss and announce AkelPad plugins
Post Reply
  • Author
  • Message
Offline
Posts: 2
Joined: Sun Apr 04, 2021 6:42 am

python.coder folding

Post 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.

DV
Offline
Posts: 1250
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Re: python.coder folding

Post 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.

Offline
Posts: 2
Joined: Sun Apr 04, 2021 6:42 am

Post 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.
Post Reply