emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/consult 7c47909b0e 2/3: Improve consult--invisible-open


From: ELPA Syncer
Subject: [elpa] externals/consult 7c47909b0e 2/3: Improve consult--invisible-open-temporarily
Date: Mon, 16 Jan 2023 08:57:33 -0500 (EST)

branch: externals/consult
commit 7c47909b0ee5c53e42cf0e10110cfd57dadefb3b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Improve consult--invisible-open-temporarily
---
 consult.el | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/consult.el b/consult.el
index 0029a99724..3949ccbdde 100644
--- a/consult.el
+++ b/consult.el
@@ -1363,9 +1363,22 @@ See `isearch-open-necessary-overlays' and 
`isearch-open-overlay-temporary'."
       ;; restore them.  A better show API would return all the applied
       ;; modifications such that we can restore the ones which got modified.
       (progn
-        (with-memoization consult--org-fold-regions
-          (delq nil (org-fold-core-get-regions
-                     :with-markers t :from (point-min) :to (point-max))))
+        (unless consult--org-fold-regions
+          (setq consult--org-fold-regions
+                (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"))
+                  (buffer (current-buffer)))
+              (fset hook (lambda ()
+                           (remove-hook 'minibuffer-exit-hook hook)
+                           (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)
@@ -1425,11 +1438,6 @@ The function can be used as the `:state' argument of 
`consult--read'."
         overlays invisible)
     (set-marker-insertion-type saved-max t) ;; Grow when text is inserted
     (lambda (action cand)
-      (when (eq action 'return)
-        (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))
       (when (eq action 'preview)
         (mapc #'funcall invisible)
         (mapc #'delete-overlay overlays)



reply via email to

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