> I'm trying to analyze and subclass a sparsely documented CPAN-modul and
> I have problems to understand the flow over 3 or more levels of nested ifs
> over several pages.
>
> I remeber that there was a possibility to fold levels of indentation away,
> such that only lines with an indentation smaller than a given level x are
> visible ... but I can't find it :-(
>
> Workarounds I found are:
>
> 1. using M-x occur with regex="if|else|elsif" opening a new window with the
> grepped lines for navigating the source. (works)
>
> 2. entering outline-minor-mode and redefining outline-regex and
> outline-level to fold if blocks away (didn't try that)
>
> Any suggestions?
I have to say that folding isn't a subject I've looked into much (though
it has occured to me it might be useful to fold pod away when you just
want to see code).
There's a folding.el, but I think that does something more specific
(and I don't see the point of it at all, as is typical with Jari Alto
code, I'm afraid).
There's a "hideshow.el" mode that's include with gnu emacs, but I don't
see perl on the list of languages it works with:
http://www.emacswiki.org/emacs/HideShow
There is some sort of "universal code folding" feature that's supposed
to work solely on identation level, though.
By the way, are you familiar with "narrow-to-defun" aka "C-x n d"?
Despite the name "defun" it also works with perl sub definitions.
I find it useful for reading hairy perl code. Then when you do a search
on a variable name, you know you're still inside the same sub. (When
you're through, do a "C-x n w" to widen your view of the code again.)
> PS: emacs regexes are always a BIG PAIN to read, is there any method to
> transform them to perl-syntax and back for better readability?
Good question: none that I know of. I have wondered if it might make
sense to implement a variant of emacs regexps that you convert into
elisp before you use them. My guess is that it's the kind of thing that
wouldn't get used all that much: once you know you need it, you'll have
gotten used to living without.