From: Lennart Borgman Date: Sat, 19 Sep 2020 15:43:42 +0000 (+0200) Subject: Allow reveal mode to not automatically re-hide revealed text X-Git-Tag: emacs-28.0.90~6004 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b6594d76068937958a7fab08a09115d84df7e81d;p=emacs.git 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. --- diff --git a/etc/NEWS b/etc/NEWS index 26aa030391d..6d27f769e08 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 92b80071f71..f9e38646349 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