summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2019-09-21 12:00:12 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2019-09-21 12:04:00 +0200
commit2c7224f8942e6338ea9dce727a7b573bf4f3f5a6 (patch)
tree5f93f6c4299c5afa942491ca0abbb49ae920f818
parent8147d939ae5c2d933c9a87f6281a8dfd7c850836 (diff)
downloademacs-2c7224f8942e6338ea9dce727a7b573bf4f3f5a6.tar.gz
Allow reveal.el to toggle `display' properties
* lisp/reveal.el (reveal-open-new-overlays): Allow also toggling `displa' overlay properties (bug#28785).
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/reveal.el34
2 files changed, 30 insertions, 9 deletions
diff --git a/etc/NEWS b/etc/NEWS
index e8d3dffd3bd..02fe93a782d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2130,6 +2130,11 @@ valid event type.
* Lisp Changes in Emacs 27.1
+** 'reveal-mode' can now also be used for more than to toggle between
+invisible and visible: It can also toggle 'display' properties in
+overlays. This is only done on 'display' properties that have the
+'reveal-toggle-invisible' property set.
+
+++
** 'process-contact' now takes an optional NO-BLOCK parameter to allow
not waiting for a process to be set up.
diff --git a/lisp/reveal.el b/lisp/reveal.el
index 67740c8149b..5483073474e 100644
--- a/lisp/reveal.el
+++ b/lisp/reveal.el
@@ -26,6 +26,11 @@
;; is always visible. When point enters a region of hidden text,
;; `reveal-mode' temporarily makes it visible.
;;
+;; Overlays can also use the `display' property. For them to be
+;; revealed, the `reveal-toggle-invisible' property also has to be
+;; present, and should be a function to toggle between having a
+;; display property and not.
+;;
;; This is normally used in conjunction with `outline-minor-mode',
;; `hs-minor-mode', `hide-ifdef-mode', ...
;;
@@ -103,21 +108,32 @@ Each element has the form (WINDOW . OVERLAY).")
(overlays-at (point))))
(setq old-ols (delq ol old-ols))
(when (overlay-start ol) ;Check it's still live.
- (let ((inv (overlay-get ol 'invisible)) open)
- (when (and inv
- ;; There's an `invisible' property. Make sure it's
- ;; actually invisible, and ellipsized.
- (and (consp buffer-invisibility-spec)
- (cdr (assq inv buffer-invisibility-spec)))
+ ;; We either have an invisible overlay, or a display
+ ;; overlay. Always reveal invisible text, but only reveal
+ ;; display properties if `reveal-toggle-invisible' is
+ ;; present.
+ (let ((inv (overlay-get ol 'invisible))
+ (disp (and (overlay-get ol 'display)
+ (overlay-get ol 'reveal-toggle-invisible)))
+ open)
+ (when (and (or (and inv
+ ;; There's an `invisible' property.
+ ;; Make sure it's actually invisible,
+ ;; and ellipsized.
+ (and (consp buffer-invisibility-spec)
+ (cdr (assq inv buffer-invisibility-spec))))
+ disp)
(or (setq open
(or (overlay-get ol 'reveal-toggle-invisible)
(and (symbolp inv)
(get inv 'reveal-toggle-invisible))
- (overlay-get ol 'isearch-open-invisible-temporary)))
+ (overlay-get
+ ol 'isearch-open-invisible-temporary)))
(overlay-get ol 'isearch-open-invisible)
(and (consp buffer-invisibility-spec)
- (cdr (assq inv buffer-invisibility-spec))))
- (overlay-put ol 'reveal-invisible inv))
+ (cdr (assq inv buffer-invisibility-spec)))))
+ (when inv
+ (overlay-put ol 'reveal-invisible inv))
(push (cons (selected-window) ol) reveal-open-spots)
(if (null open)
(overlay-put ol 'invisible nil)