emacs-devel
[Top][All Lists]
Advanced

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

Re: hiding lines


From: Alan Mackenzie
Subject: Re: hiding lines
Date: Thu, 2 Apr 2009 19:30:50 +0000
User-agent: Mutt/1.5.9i

Hi, Werner,

On Thu, Apr 02, 2009 at 08:52:01AM +0200, Werner LEMBERG wrote:

> Folks,


> I would like to hide lines in a buffer which satisfy a regexp --
> either the lines get completely hidden (or perhaps indicated with
> `...' as in the outline mode), or a search-and-replace function
> doesn't match them.

> Does Emacs have such a thing?  A lookup in the docs doesn't show
> anything relevant.  This would be a very convenient function for
> editing lists.

The following makes the current region invisible and intangible.  It
doesn't, as yet, make it visible and tangible again very well.  It's not
quite what you're asking for, but you can likely use it as the engine
end of what you want.

    (defun make-region-invisible (beg end &optional arg)
      "Make the current region invisible and intangible.
    With a prefix arg, make it visible again.  With an arg of 0,
    make all such regions visible."
      (interactive "r\nP")
      (let (ov ovs)
        (cond
         ((eq arg 0)
          (setq ovs (overlays-in (point-min) (point-max)))
          (mapc (lambda (o)
                  (when (overlay-get o 'acm-invisible)
                    (delete-overlay o)))
                ovs))
         ((equal arg '(4))
          (setq ovs (overlays-at (point)))
          (mapc (lambda (o)
                  (when (overlay-get o 'acm-invisible)
                    (delete-overlay o)))
                ovs))
         (t
          (setq ov (make-overlay beg end))
          (overlay-put ov 'acm-invisible t)
          (overlay-put ov 'invisible t)
          (overlay-put ov 'intangible t)))))
    (global-set-key "\C-cz" 'make-region-invisible)


>     Werner

-- 
Alan Mackenzie (Nuremberg, Germany).




reply via email to

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