I'm using the Outline minor mode. (Or the major mode or Org mode, but in these modes the scenario in this question is rare.) I want to show all of the headings that have no parent, plus the text before the very first heading.
In simple cases, this just means showing level 1 headings. But when a file starts with a larger-level heading, I want to show this larger-level heading, and all headings at the same level until the first heading at a smaller level, and so on. If the file starts with a non-heading line, I want to show all the text up to the first heading. For example consider the following LaTeX file meant to be included in a larger document:
%% This file contains stuff.
%% It starts with a comment.
\section*{Introduction}
There's stuff here, then more stuff.
\chapter{One}
Hello.
\chapter{Two}
More.
I want a command that shows this and hides the rest:
%% This file contains stuff.
%% It starts with a comment.
\section*{Introduction}…
\chapter{One}…
\chapter{Two}…
This is different from hide-sublevels
which shows headings up to a given level.
The idea is to show only the minimum set of headings such that the whole document is somewhere under one of the visible headings, except for the first entry before the first heading, which remains visible. All entries (except for that top entry) and all headings that have a parent should be hidden.
(I'll use this to replace hide-sublevels
in outline-focus
, so as to show parentless headings, plus all the headings on the path to the point, à la hide-other
.)
Does this exist in Outline or Org, or do I need to roll my own?