summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-10-17 23:22:19 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-01-10 15:55:46 +0100
commitbbf1c26aafb7f313aa3c7842e689a7bf18e5f7f2 (patch)
tree6e0d0e5aa24d0de5b25982b29209a38287fee87a
parent728920a8edf7e24ae1656b2a6bfaeb7c58b15012 (diff)
downloadorg-mode-bbf1c26aafb7f313aa3c7842e689a7bf18e5f7f2.tar.gz
Remove `org-hide-block-overlays' variable
* lisp/org.el (org-hide-block-overlays): Remove variable. (org-show-block-all): Use `remove-overlays' to remove block-related overlays instead of relying on a global state. (org-hide-block-toggle): Do not update removed variable. Tiny refactoring.
-rw-r--r--lisp/org.el17
1 files changed, 2 insertions, 15 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 00a127e..669893b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7223,9 +7223,6 @@ DATA should have been made by `org-outline-overlay-data'."
;;; Folding of blocks
-(defvar-local org-hide-block-overlays nil
- "Overlays hiding blocks.")
-
(defun org-block-map (function &optional start end)
"Call FUNCTION at the head of all source blocks in the current buffer.
Optional arguments START and END can be used to limit the range."
@@ -7252,8 +7249,7 @@ Optional arguments START and END can be used to limit the range."
(defun org-show-block-all ()
"Unfold all blocks in the current buffer."
(interactive)
- (mapc #'delete-overlay org-hide-block-overlays)
- (setq org-hide-block-overlays nil))
+ (remove-overlays nil nil 'invisible 'org-hide-block))
(defun org-hide-block-toggle-maybe ()
"Toggle visibility of block at point.
@@ -7294,14 +7290,7 @@ a block. Return a non-nil value when toggling is successful."
(let ((ov (make-overlay start end)))
(overlay-put ov 'invisible 'org-hide-block)
;; Make the block accessible to `isearch'.
- (overlay-put
- ov 'isearch-open-invisible
- (lambda (ov)
- (when (memq ov org-hide-block-overlays)
- (setq org-hide-block-overlays (delq ov org-hide-block-overlays)))
- (when (eq (overlay-get ov 'invisible) 'org-hide-block)
- (delete-overlay ov))))
- (push ov org-hide-block-overlays)
+ (overlay-put ov 'isearch-open-invisible #'delete-overlay)
;; When the block is hidden away, make sure point is left in
;; a visible part of the buffer.
(when (> (line-beginning-position) start)
@@ -7311,8 +7300,6 @@ a block. Return a non-nil value when toggling is successful."
t))
((or (not force) (eq force 'off))
(dolist (ov overlays t)
- (when (memq ov org-hide-block-overlays)
- (setq org-hide-block-overlays (delq ov org-hide-block-overlays)))
(when (eq (overlay-get ov 'invisible) 'org-hide-block)
(delete-overlay ov))))))))