unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* outline-minor-mode with text before first heading
@ 2004-10-21  1:31 Peter Heslin
  2004-10-21  8:04 ` Peter Heslin
  2004-10-22 10:47 ` Richard Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Heslin @ 2004-10-21  1:31 UTC (permalink / raw)


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
hide-body.

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

;; 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?

Peter

725,728c725,729
< (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))
730c731
< (defun hide-region-body (start end)
---
> (defun hide-region-body (start end &optional no-prelim)
739a741,742
>         (when no-prelim
>           (outline-next-preface))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: outline-minor-mode with text before first heading
  2004-10-21  1:31 outline-minor-mode with text before first heading Peter Heslin
@ 2004-10-21  8:04 ` Peter Heslin
  2004-10-22 10:47 ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Heslin @ 2004-10-21  8:04 UTC (permalink / raw)


On 2004-10-21, Peter Heslin <usenet@heslin.eclipse.co.uk> wrote:

> I'll append the patch.

Actually, this is a better patch, since it does the right thing if you
happen to use a prefix arg when there is no text before the first
heading.

725,728c725,729
< (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))
730,731c731,733
< (defun hide-region-body (start end)
<   "Hide all body lines in the region, but not headings."
---
> (defun hide-region-body (start end &optional no-prelim)
>   "Hide all body lines in the region, but not headings.  If
> NO-PRELIM is t, do not hide text before the first heading"
739a742,744
>         (when (and no-prelim
>                    (not (outline-on-heading-p)))
>           (outline-next-preface))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: outline-minor-mode with text before first heading
  2004-10-21  1:31 outline-minor-mode with text before first heading Peter Heslin
  2004-10-21  8:04 ` Peter Heslin
@ 2004-10-22 10:47 ` Richard Stallman
  2004-10-22 19:32   ` Stefan
  2004-10-22 20:53   ` Peter Heslin
  1 sibling, 2 replies; 5+ messages in thread
From: Richard Stallman @ 2004-10-22 10:47 UTC (permalink / raw)
  Cc: emacs-devel

Maybe hide-body should always leave text before the first heading
unchanged.  Maybe that text should never be hidden.  Does anyone
think it is a useful feature to hide text before the first heading?

By the way, please use diff -c to make patches.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: outline-minor-mode with text before first heading
  2004-10-22 10:47 ` Richard Stallman
@ 2004-10-22 19:32   ` Stefan
  2004-10-22 20:53   ` Peter Heslin
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan @ 2004-10-22 19:32 UTC (permalink / raw)
  Cc: Peter Heslin, emacs-devel

> Maybe hide-body should always leave text before the first heading
> unchanged.

Actually I thought that hide-body never touches the text before the heading
(whether it's the first or not).


        Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: outline-minor-mode with text before first heading
  2004-10-22 10:47 ` Richard Stallman
  2004-10-22 19:32   ` Stefan
@ 2004-10-22 20:53   ` Peter Heslin
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Heslin @ 2004-10-22 20:53 UTC (permalink / raw)
  Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]

On Fri, Oct 22, 2004 at 06:47:10AM -0400, Richard Stallman wrote:
> Maybe hide-body should always leave text before the first heading
> unchanged.  Maybe that text should never be hidden.  Does anyone
> think it is a useful feature to hide text before the first heading?

Since both you and Stefan seem inclined to think that hiding text
before the first heading is the wrong thing to do (and I agree),
here's a simpler patch that fixes the bug rather than making the new
behavior optional.
 
> By the way, please use diff -c to make patches.

OK.



[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 1133 bytes --]

*** /usr/local/share/emacs/21.3.50/lisp/outline.el	2004-09-13 12:28:12.000000000 +0100
--- outline.el	2004-10-22 21:24:18.000000000 +0100
***************
*** 723,729 ****
  			 (progn (outline-next-preface) (point)) nil)))
  
  (defun hide-body ()
!   "Hide all of buffer except headings."
    (interactive)
    (hide-region-body (point-min) (point-max)))
  
--- 723,729 ----
  			 (progn (outline-next-preface) (point)) nil)))
  
  (defun hide-body ()
!   "Hide all body lines in buffer, leaving all headings visible."
    (interactive)
    (hide-region-body (point-min) (point-max)))
  
***************
*** 738,744 ****
  	(narrow-to-region start end)
  	(goto-char (point-min))
  	(if (outline-on-heading-p)
! 	    (outline-end-of-heading))
  	(while (not (eobp))
  	  (outline-flag-region (point)
  			       (progn (outline-next-preface) (point)) t)
--- 738,745 ----
  	(narrow-to-region start end)
  	(goto-char (point-min))
  	(if (outline-on-heading-p)
! 	    (outline-end-of-heading)
! 	  (outline-next-preface))
  	(while (not (eobp))
  	  (outline-flag-region (point)
  			       (progn (outline-next-preface) (point)) t)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-10-22 20:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-21  1:31 outline-minor-mode with text before first heading Peter Heslin
2004-10-21  8:04 ` Peter Heslin
2004-10-22 10:47 ` Richard Stallman
2004-10-22 19:32   ` Stefan
2004-10-22 20:53   ` Peter Heslin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).