Folding: level based
I am using Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-03-28, modified by Debian with elpy and evil-mode.
I have problems to get into the folding features. What makes it much harder for me is that I do not know which one of the involved components (eamcs, elpy, evil, emacs inbuild foldeing-mode, ...?) is responsible or how they interfere to each other.
Let me explain what I need. And maybe you can point me into the right direction if elpy is not involved here.
See this example code:
def modul_function()
for x in range(100):
print(x)
def _sub_function():
print('sub')
_sub_function()
class Foo:
class Bar:
def __init__(self):
print('init sub-class Bar')
def __init__(self):
print('in class Foo')
def method(self):
with something():
# comment
print('inside with')
For example: I want to keep the 1st level unfolded but the 2nd and each deeper folded.
Like this:

Other case: This depends on the possition of the current cursor. I want to unfold the current level under the cursor (not all in the file!) but not the deeper ones.
Other case: I want to unfold the current level and all deeper ones under the cursor (not all in the file!).
The with and for blocks are also should be foldable and treated like a "level", which is still a problem (#1929). I would assume that every python indention is foldable.
What I am still able to do is the simple toogleing of the current (under the cursor) folding via the vim-like commands from evil-mode.
I also heard about M-1 C-x $ or M-2 C-x $ etc. But this work only for the 1st level in my setup not for the 2nd, 3rd etc.
Maybe related to #1933