[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult a9a619cb55 2/2: consult--invisible-open-tempora
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult a9a619cb55 2/2: consult--invisible-open-temporarily: Try to make exit-hook more robust |
Date: |
Fri, 10 Feb 2023 04:57:26 -0500 (EST) |
branch: externals/consult
commit a9a619cb5519047accf0e42932db28ef1f95594b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
consult--invisible-open-temporarily: Try to make exit-hook more robust
---
consult.el | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/consult.el b/consult.el
index aeaed623b8..0b9cea3c5b 100644
--- a/consult.el
+++ b/consult.el
@@ -1365,20 +1365,23 @@ See `isearch-open-necessary-overlays' and
`isearch-open-overlay-temporary'."
(delq nil (org-fold-core-get-regions
:with-markers t :from (point-min) :to (point-max))))
(when consult--org-fold-regions
- (let ((hook (make-symbol
"consult--invisible-open-temporarily-cleanup-hook")))
- (fset hook (apply-partially
- #'run-at-time 0 nil
- (lambda (buffer)
- (when (buffer-live-p buffer)
- (with-current-buffer buffer
- (pcase-dolist (`(,beg ,end ,_)
consult--org-fold-regions)
- (when (markerp beg) (set-marker beg nil))
- (when (markerp end) (set-marker end nil)))
- (kill-local-variable
'consult--org-fold-regions))))
- (current-buffer)))
- (when-let (win (active-minibuffer-window))
- (with-current-buffer (window-buffer win)
- (add-hook 'minibuffer-exit-hook hook nil 'local))))))
+ (let ((hook (make-symbol
"consult--invisible-open-temporarily-cleanup-hook"))
+ (buffer (current-buffer))
+ (depth (recursion-depth)))
+ (fset hook
+ (lambda ()
+ (when (= (recursion-depth) depth)
+ (remove-hook 'minibuffer-exit-hook hook)
+ (run-at-time
+ 0 nil
+ (lambda ()
+ (when (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (pcase-dolist (`(,beg ,end ,_)
consult--org-fold-regions)
+ (when (markerp beg) (set-marker beg nil))
+ (when (markerp end) (set-marker end nil)))
+ (kill-local-variable
'consult--org-fold-regions))))))))
+ (add-hook 'minibuffer-exit-hook hook))))
(org-fold-show-set-visibility 'canonical)
(list (lambda ()
(pcase-dolist (`(,beg ,end ,spec) consult--org-fold-regions)