emacs-diffs
[Top][All Lists]
Advanced

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

master b6594d7 2/3: Allow reveal mode to not automatically re-hide revea


From: Lars Ingebrigtsen
Subject: master b6594d7 2/3: Allow reveal mode to not automatically re-hide revealed text
Date: Sat, 19 Sep 2020 12:23:38 -0400 (EDT)

branch: master
commit b6594d76068937958a7fab08a09115d84df7e81d
Author: Lennart Borgman <lennart.borgman@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Allow reveal mode to not automatically re-hide revealed text
    
    * lisp/reveal.el (reveal-hide-revealed): New command (bug#7101).
    (reveal-auto-hide): New defcustom.
    (reveal-post-command): Use it.
---
 etc/NEWS       |  6 ++++++
 lisp/reveal.el | 22 ++++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 26aa030..6d27f76 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1015,6 +1015,12 @@ window after starting).  This variable defaults to nil.
 
 ** Miscellaneous
 
+---
+*** New user option 'reveal-auto-hide'.
+If non-nil (the default), revealed text is automatically hidden when
+point leaves the text.  If nil, the text is not hidden again.  Instead
+`M-x reveal-hide-revealed' can be used to hide all the revealed text.
+
 +++
 *** New user options to control the look of line/column numbers in the mode 
line.
 'mode-line-position-line-format' is the line number format (when
diff --git a/lisp/reveal.el b/lisp/reveal.el
index 92b80071..f9e3864 100644
--- a/lisp/reveal.el
+++ b/lisp/reveal.el
@@ -60,6 +60,13 @@
   :type 'boolean
   :group 'reveal)
 
+(defcustom reveal-auto-hide t
+  "Automatically hide revealed text when leaving it.
+If nil, the `reveal-hide-revealed' command can be useful to hide
+revealed text manually."
+  :type 'boolean
+  :version "28.1")
+
 (defvar reveal-open-spots nil
   "List of spots in the buffer which are open.
 Each element has the form (WINDOW . OVERLAY).")
@@ -97,7 +104,8 @@ Each element has the form (WINDOW . OVERLAY).")
                         (cdr x))))
                     reveal-open-spots))))
         (setq old-ols (reveal-open-new-overlays old-ols))
-        (reveal-close-old-overlays old-ols)))))
+        (when reveal-auto-hide
+          (reveal-close-old-overlays old-ols))))))
 
 (defun reveal-open-new-overlays (old-ols)
   (let ((repeat t))
@@ -196,6 +204,14 @@ Each element has the form (WINDOW . OVERLAY).")
                 (delq (rassoc ol reveal-open-spots)
                       reveal-open-spots)))))))
 
+(defun reveal-hide-revealed ()
+  "Hide all revealed text.
+If there is revealed text under point, this command does not hide
+that text."
+  (interactive)
+  (let ((reveal-auto-hide t))
+    (reveal-post-command)))
+
 (defvar reveal-mode-map
   (let ((map (make-sparse-keymap)))
     ;; Override the default move-beginning-of-line and move-end-of-line
@@ -209,7 +225,9 @@ Each element has the form (WINDOW . OVERLAY).")
   "Toggle uncloaking of invisible text near point (Reveal mode).
 
 Reveal mode is a buffer-local minor mode.  When enabled, it
-reveals invisible text around point."
+reveals invisible text around point.
+
+Also see the `reveal-auto-hide' variable."
   :group 'reveal
   :lighter (global-reveal-mode nil " Reveal")
   :keymap reveal-mode-map



reply via email to

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