Fold mode is an unfinished, experimental folding minor mode for Emacs, written to use overlays rather than selective display.
The prototype code is actually a fully usable folded-file viewer - known problems are only apparent when editing a folded buffer.
Sadly, I don't have the time right now for Elisp programming or tracking down Emacs bugs, so I've decided to put the unfinished code on this site, for people who do have both some interest in the subject and some time to deal with the problems.
Some features of the current code are:
previous-lineis supported natively by Emacs.
Outline mode in Emacs 20 uses overlays.
I'm not aware of any folding mode for Emacs using overlays, but then, I haven't looked very hard.
The de-facto standard folding mode for Emacs,
- which to this day uses selective display to hide folds - in its 1993
version already contained the following comment by Jamie
I can see a lot of use for the newer features of Emacs 19:
Using invisible text-properties (I hope they are intended to make text invisible; it isn't implemented like that yet), it will be possible to hide folded text without affecting the text of the buffer. At the moment, Folding mode uses selective display to hide text, which involves substituting carriage-returns for line-feeds in the buffer. This isn't such a good way. It may also be possible to display different folds in different windows in Emacs 19.
Using even more text-properties, it may be possible to track pointer movements in and out of folds, and have Folding mode automatically enter or exit folds as necessary to maintain a sensible display. Because the text itself is not modified (if overlays are used to hide text), this is quite safe. It would make it unnecessary to provide functions like `fold-forward-char', `fold-goto-line' or `fold-next-error', and things like I-search would automatically move in and out of folds as necessary.
Yet more text-properties/overlays might make it possible to avoid using narrowing. This might allow some major modes to indent text properly, e.g., C++ mode.