unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* hideshow condensed view
@ 2010-02-25 14:24 Andreas Roehler
  2010-02-25 15:21 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Roehler @ 2010-02-25 14:24 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: help-gnu-emacs


Hi Thi,

thanks a lot maintaining hideshow.el.

Use it as default outline-mode now.

Just one thing remains so far: hs displays an empty
line between headers. Would prefer a more condensed
view.

Might it be possible to introduce a function
`hide-all-empty-lines', inclusive a variable which may
be customized?

Thanks again


Andreas

--
https://code.launchpad.net/~a-roehler/python-mode
https://code.launchpad.net/s-x-emacs-werkstatt/

PS: cc at help-gnu-emacs.




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

* Re: hideshow condensed view
  2010-02-25 14:24 hideshow condensed view Andreas Roehler
@ 2010-02-25 15:21 ` Thien-Thi Nguyen
  2010-02-25 16:04   ` Andreas Roehler
  0 siblings, 1 reply; 3+ messages in thread
From: Thien-Thi Nguyen @ 2010-02-25 15:21 UTC (permalink / raw)
  To: Andreas Roehler; +Cc: help-gnu-emacs

() Andreas Roehler <andreas.roehler@online.de>
() Thu, 25 Feb 2010 15:24:24 +0100

   thanks a lot maintaining hideshow.el.

In the last few years, i can't take any credit for its improvement.
See Emacs' ChangeLog for those who actually merit the appreciation...

   Use it as default outline-mode now.

Cool.

   Just one thing remains so far: hs displays an empty
   line between headers. Would prefer a more condensed
   view.

You must have good eyes (still); i use hideshow not
for density but for spaciousness.

   Might it be possible to introduce a function
   `hide-all-empty-lines', inclusive a variable which may
   be customized?

Yeah, it would be possible, but i tend to think of empty lines outside
the (top-level) blocks as also outside the scope of hideshow.  It's like
in the book GEB, there is the tree and there is the stuff outside the
tree.  Get it?

I am already troubled by hideshow straying from its conceptual (both
meanings) simplicity -- a block is between matching parens, no more no
less -- but that's just me...

All this is to say, you probably should write a "squash minor mode",
which puts the invisible property on an overlay for text that matches
the empty line regexp (which of course, could be made customizable), at
which point my advice would be to add a hook to `hs-hide-all' to enable
this mode.

Here's a quick (but tested (lightly)) sketch:

 (defvar empty-lines-rx "^\\s-*\\(\n\\s-*\\)+")
 
 (defvar empty-lines nil
   "List of empty lines (overlays).")
 
 (defvar squash-minor-mode nil)
 
 (defun squash-minor-mode () 
   (interactive)
   (setq squash-minor-mode (not squash-minor-mode))
   (if squash-minor-mode
       (save-excursion
         (goto-char (point-min))
         (while (re-search-forward empty-lines-rx nil t)
           (let ((ov (make-overlay (match-beginning 0) (match-end 0))))
             (overlay-put ov 'display "")
             (push ov empty-lines))))
     (mapc 'delete-overlay empty-lines)
     (setq empty-lines nil))
   (message "empty-lines squashing %s" (if squash-minor-mode 'on 'off)))
 
Have fun!

thi




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

* Re: hideshow condensed view
  2010-02-25 15:21 ` Thien-Thi Nguyen
@ 2010-02-25 16:04   ` Andreas Roehler
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Roehler @ 2010-02-25 16:04 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: help-gnu-emacs

Thien-Thi Nguyen wrote:
> () Andreas Roehler <andreas.roehler@online.de>
> () Thu, 25 Feb 2010 15:24:24 +0100
> 
>    thanks a lot maintaining hideshow.el.
> 
> In the last few years, i can't take any credit for its improvement.
> See Emacs' ChangeLog for those who actually merit the appreciation...
> 
>    Use it as default outline-mode now.
> 
> Cool.
> 
>    Just one thing remains so far: hs displays an empty
>    line between headers. Would prefer a more condensed
>    view.
> 
> You must have good eyes (still); i use hideshow not
> for density but for spaciousness.
> 
>    Might it be possible to introduce a function
>    `hide-all-empty-lines', inclusive a variable which may
>    be customized?
> 
> Yeah, it would be possible, but i tend to think of empty lines outside
> the (top-level) blocks as also outside the scope of hideshow.  It's like
> in the book GEB, there is the tree and there is the stuff outside the
> tree.  Get it?
> 
> I am already troubled by hideshow straying from its conceptual (both
> meanings) simplicity -- a block is between matching parens, no more no
> less -- but that's just me...
> 

If so, me too.


> All this is to say, you probably should write a "squash minor mode",
> which puts the invisible property on an overlay for text that matches
> the empty line regexp (which of course, could be made customizable), at
> which point my advice would be to add a hook to `hs-hide-all' to enable
> this mode.
> 
> Here's a quick (but tested (lightly)) sketch:
> 
>  (defvar empty-lines-rx "^\\s-*\\(\n\\s-*\\)+")
>  
>  (defvar empty-lines nil
>    "List of empty lines (overlays).")
>  
>  (defvar squash-minor-mode nil)
>  
>  (defun squash-minor-mode () 
>    (interactive)
>    (setq squash-minor-mode (not squash-minor-mode))
>    (if squash-minor-mode
>        (save-excursion
>          (goto-char (point-min))
>          (while (re-search-forward empty-lines-rx nil t)
>            (let ((ov (make-overlay (match-beginning 0) (match-end 0))))
>              (overlay-put ov 'display "")
>              (push ov empty-lines))))
>      (mapc 'delete-overlay empty-lines)
>      (setq empty-lines nil))
>    (message "empty-lines squashing %s" (if squash-minor-mode 'on 'off)))

Works, great! Magic!
Think using that as a hook should do it.

Thanks a lot

Andreas


>  
> Have fun!
> 
> thi
> 





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

end of thread, other threads:[~2010-02-25 16:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-25 14:24 hideshow condensed view Andreas Roehler
2010-02-25 15:21 ` Thien-Thi Nguyen
2010-02-25 16:04   ` Andreas Roehler

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).