[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

outline-minor-mode with text before first heading

From: Peter Heslin
Subject: outline-minor-mode with text before first heading
Date: Thu, 21 Oct 2004 01:31:51 +0000 (UTC)
User-agent: slrn/ (Linux)

As far as I can see, the only way to reveal the text before the first
heading that is hidden by M-x hide-body is to do M-x show-all.  In
some sense this behavior is logical and consistent, since that text is
part of the "body", but not part of any "entry", so it is ignored by
hide-entry or show-entry, but is affected by hide-body and show-all.
But it is inconvenient.

For example, on a CVS build from about a month ago, I do emacs -q, and
then M-x outline-minor-mode.  I type some text in the scratch buffer
beginning with "(foo" in the first column, and then I do M-x

The "(foo" form is hidden as it should be, but so too is the comment

;; This buffer is for notes you don't want to save  

If I move point up there, and type M-x show-entry, I get the error
"before first heading", which is, in fact, true, since comment
headings are supposed to begin with at least three semicolons.  If I
add another semicolon to the start of the comment, then everything is
fine.  If I remove the semicolon, and try M-x hide-entry, then Emacs
properly refuses to hide anything, giving the same "before first
entry" error.

This may be rigorously logical behavior, but it gets in the way if you
mainly use hide-body to get an overview of a file, and then show-entry
and hide-entry to look at the bits you are interested in.  With the
current behavior, there is some text that you can't get to look at
without doing show-all, which undoes all of your other careful folding
and unfolding.  This is not a hypothetical problem, but one I come up
against most times I use outline-minor-mode.

It would be great if there were some way to work around the problem,
such as an argument passed to hide-body that tells it not to hide text
before the first heading.  I have made a small modification to
outline.el that adds an extra argument to the definition of hide-body,
passes it to hide-region-body, and if that arg is t, adds a call to
outline-next-preface right after (goto-char (point-min)).  I'll append
the patch.

It solves my problem, and it shouldn't affect any current behavior.
Are there any objections to such a change?


< (defun hide-body ()
<   "Hide all of buffer except headings."
<   (interactive)
<   (hide-region-body (point-min) (point-max)))
> (defun hide-body (&optional no-prelim)
>   "Hide all of buffer except headings. If NO-PRELIM is t, do not
> hide text before the first heading"
>   (interactive "P")
>   (hide-region-body (point-min) (point-max) no-prelim))
< (defun hide-region-body (start end)
> (defun hide-region-body (start end &optional no-prelim)
>         (when no-prelim
>           (outline-next-preface))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]