help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: hideshow condensed view


From: Andreas Roehler
Subject: Re: hideshow condensed view
Date: Thu, 25 Feb 2010 17:04:57 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20081227)

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
> 





reply via email to

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