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

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

Re: Arbitrary folding in emacs


From: Nicolas Richard
Subject: Re: Arbitrary folding in emacs
Date: Sun, 30 Mar 2014 12:19:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> But obviously, it'll be a bit crude (e.g. no commands to unhide, tho you
> might be able to use reveal-mode for that).

Here's a "toggling" version :
(defun my-toggle-hide-region (beg end)
  "Hide region. Unless it contains already hidden text, then show it."
  (interactive "r")
  (let ((has-invisible-p
         (catch 'invisible
           (dolist (ov (overlays-in beg end))
             (when (eq 'outline (overlay-get ov 'invisible))
               (throw 'invisible t))))))
    (outline-flag-region beg end (not has-invisible-p))))

-- 
Nico.



reply via email to

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