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

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

[nongnu] elpa/dslide 1aa45a2223 05/16: Only cleanup overlays in finish,


From: ELPA Syncer
Subject: [nongnu] elpa/dslide 1aa45a2223 05/16: Only cleanup overlays in finish, only for this slide
Date: Mon, 25 Nov 2024 01:00:01 -0500 (EST)

branch: elpa/dslide
commit 1aa45a2223489e2df52d5ee6994e98486a71d128
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>

    Only cleanup overlays in finish, only for this slide
    
    A generational strategy is probably needed, such that we push overlays when
    doing child slides so that we can nuke them more easily and accurately
---
 dslide.el | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/dslide.el b/dslide.el
index 64b40d7f55..277f05decc 100644
--- a/dslide.el
+++ b/dslide.el
@@ -934,6 +934,8 @@ order.")
   (mapc #'dslide-final (oref obj section-actions))
   (when-let ((slide-action (oref obj slide-action)))
     (dslide-final slide-action))
+  ;; Clean up stale overlays
+  (dslide--slide-cleanup-overlays obj)
   ;; Clean up heading marker, which is shared by children
   (set-marker (oref obj begin) nil))
 
@@ -947,6 +949,24 @@ order.")
         (dslide-backward slide-action))
       (dslide--map-find #'dslide-backward (oref obj section-actions))))
 
+(cl-defmethod dslide--slide-cleanup-overlays ((obj dslide-slide))
+  ;; Use this only during final.  TODO We might need a better way to store and
+  ;; purge these overlays.  A generational strategy might be better.
+  (setq dslide-overlays
+        (let ((beg (oref obj begin))
+              (end (save-restriction
+                     (goto-char (oref obj begin))
+                     (org-element-property
+                      :end (org-element-at-point))))
+              filtered)
+          (dolist (o dslide-overlays filtered)
+            (let ((o-beg (overlay-start o))
+                  (o-end (overlay-end o)))
+              ;; conservatively only deletes fully contained overlays
+              (if (and (>= o-beg beg) (<= o-end end) )
+                  (delete-overlay o)
+                (push o filtered)))))))
+
 (cl-defgeneric dslide--map-find (pred sequence)
   "Find first non-nil return value from mapping PRED over SEQUENCE."
   (let (found)
@@ -1760,14 +1780,6 @@ restriction, meaning no progress was made.")
                   (dslide--section-end heading))))
       (unless (and (<= (point-min) begin)
                    (>= (point-max) end))
-        ;; Restriction changes are a good moment to clean up overlays dumped
-        ;; into `dslide-overlays'.  ⚠️ However, this doesn't properly handle
-        ;; the case that the new restriction contains the old restriction,
-        ;; meaning some of the existing overlays may still be necessary.  This
-        ;; should be good for now since there are no known cases where this
-        ;; edge case is reached.
-        (while dslide-overlays
-          (delete-overlay (pop dslide-overlays)))
         (narrow-to-region begin end)
         (dslide-hide-filtered-children obj)
         (when (and dslide-slide-in-effect



reply via email to

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