Is there a way to emulate Vim's folding of .vimrc
from Emacs?
In other words, I believe most folding and hiding packages in Emacs rely on open and closing expressions. I am not sure of the internals of these, as I have not tried to learn this much Lisp as of yet.
In Vim, folding seems to be calculated line-by-line, so the writing a function can be based on manipulating the previous fold level, as well as an absolute value.
So in a .vimrc
file, we can have both
" level 1 {{{
some code
" level 2 {{{
some code
" end of section }}}
" end of section }}}
" level 1 {{{
some code
" end of section }}}
(with pairs {{{
and }}}
) or
" level 1 {{{1
some code
" level 2 {{{2
some code
" level 1 {{{1
(with {{{n
) as well as mixes of these; some recommend to use the absolute values for sectioning, and the relative folding for functions.
So open and closing expressions seem to correspond with declaring relative fold levels. Is there an existing way to declare absolute fold levels in Emacs? Or can anyone point me in the right direction so I can know where to head when I tackle this on a hobby day?
(Line by line function of buffer? Overlays? What is the underlying function for folding?)
.vimrc
. Without digging through the code (of snippet and possibly package), I imagined there might be an easier way.outline-mode
is indeed the way to go, with variablesoutline-level
and/oroutline-regexp
. Even it may possibly be working if I can read through the existing snippet and use it carefully, but this is deferred til I have time. I hope to write up a solution and/or my understanding when I get to this.