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

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

[nongnu] elpa/dslide f3ae2af0cc 039/230: changed sequence-callbacks to n


From: ELPA Syncer
Subject: [nongnu] elpa/dslide f3ae2af0cc 039/230: changed sequence-callbacks to not include sequence as a key
Date: Sun, 7 Jul 2024 19:00:13 -0400 (EDT)

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

    changed sequence-callbacks to not include sequence as a key
    
    I had expected that targeting a specific parent sequence might be useful, 
but
    using these keys means obtaining them, and I can't think of a good way to 
obtain
    them that isn't reaching through places that should not be reached.
    
    Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com>
---
 macro-slides.el | 56 ++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 22 deletions(-)

diff --git a/macro-slides.el b/macro-slides.el
index c6e34c3cf7..a7e701ae98 100644
--- a/macro-slides.el
+++ b/macro-slides.el
@@ -769,9 +769,10 @@ sequence ends or makes progress..")
    (sequence-callbacks
     :initform '(nil)
     "Steps that run only when sequences end.
-Form is an alist of (SEQUENCE . STEPS) where STEPS is a list
-of step callbacks.  When sub-sequences are started, (SEQUENCE) is
-pushed onto this list."))
+Form is a list of STEPS where STEPS is a list of callbacks.  The
+length of this list is equal to the depth of the current
+sequence.  See `ms-push-step' for information about how to push a
+step deeper into the sequences."))
 
   "The Deck is responsible for selecting the parent node and
 maintaining state between mode activations or when switching
@@ -841,12 +842,13 @@ their init."
         ;; callback and see if it can make progress.
         (unless result
           ;; Burn up a step callback until one returns non-nil
-          (when-let ((steps (and (slot-boundp obj 'sequence-callbacks)
-                                 (oref obj sequence-callbacks))))
-            (while (and (not progress)
-                        steps)
+          (when-let* ((sequence-callbacks (oref obj sequence-callbacks))
+                      (steps (car sequence-callbacks)))
+            (while (and (not progress) steps)
               (setq progress (funcall (pop steps) 'forward)))
-            (oset obj sequence-callbacks steps)))
+            ;; If all the steps for this sequence were consumed, pop a layer.
+            (unless steps
+              (oset obj sequence-callbacks (cdr sequence-callbacks)))))
 
         (unless (or progress result)
           ;; Next check if there is a parent slide, which is true unless the
@@ -866,11 +868,15 @@ their init."
         (when next-slide
           (ms--debug next-slide))
 
-        ;; When switching to a parent slide, we will finalize the old slide.
-        ;; When switching to a child, we will not finalize the parent.
         (when next-slide
+          (unless switching-to-parent
+            ;; Push a new sequence-callbacks level
+            (push nil (oref obj sequence-callbacks)))
 
           (oset obj slide next-slide)
+
+          ;; When switching to a parent slide, we will finalize the old slide.
+          ;; When switching to a child, we will not finalize the parent.
           (cond
            (switching-to-parent
             ;; TODO slide re-entry when parent can still make progress
@@ -878,6 +884,7 @@ their init."
            (t
             (when switching-to-sibling
               (ms-final current-slide))
+
             ;; TODO extract behavior and add to other navigation actions
             (when ms-base-follows-slide
               (let ((pos (marker-position (oref next-slide begin))))
@@ -943,12 +950,13 @@ their init."
         ;; callback and see if it can make progress.
         (unless result
           ;; Burn up a step callback until one returns non-nil
-          (when-let ((steps (and (slot-boundp obj 'sequence-callbacks)
-                                 (oref obj sequence-callbacks))))
-            (while (and (not progress)
-                        steps)
+          (when-let* ((sequence-callbacks (oref obj sequence-callbacks))
+                      (steps (car sequence-callbacks)))
+            (while (and (not progress) steps)
               (setq progress (funcall (pop steps) 'backward)))
-            (oset obj sequence-callbacks steps)))
+            ;; If all the steps for this sequence were consumed, pop a layer.
+            (unless steps
+              (oset obj sequence-callbacks (cdr sequence-callbacks)))))
 
         (unless (or progress result)
           ;; Next check if there is a parent slide, which is true unless the
@@ -969,15 +977,19 @@ their init."
         (when previous-slide
           (ms--debug previous-slide))
 
-        ;; When switching to a parent slide, we will finalize the old slide.
-        ;; When switching to a child, we will not finalize the parent.
         (when previous-slide
-          ;; TODO exhaust next slide callbacks
+          (unless switching-to-parent
+            ;; Push a new sequence-callbacks level
+            (push nil (oref obj sequence-callbacks)))
+
           (oset obj slide previous-slide)
+
+          ;; When switching to a parent slide, we will finalize the old slide.
+          ;; When switching to a child, we will not finalize the parent.
           (cond
            (switching-to-parent
             ;; TODO slide re-entry when parent can still make progress?
-            (ms-final current-slide)
+            (ms-final current-slide))
            (t
             (when switching-to-sibling
               (ms-final current-slide))
@@ -1105,12 +1117,12 @@ once, which requires the functions to be removed or 
return nil."
          (push fun (oref ms--deck step-callbacks)))
         ((or (eq pop-when 'sequence)
              (eq pop-when 0))
-         (push fun (cdar (oref ms--deck sequence-callbacks))))
+         (push fun (car (oref ms--deck sequence-callbacks))))
         ((integerp pop-when)
          (if (>= pop-when (length (oref ms--deck sequence-callbacks)))
              (error "Requested depth exceeds sequence depth")
-           (push fun (cdr (nth pop-when
-                               (oref ms--deck sequence-callbacks))))))))
+           (push fun (nth pop-when
+                          (oref ms--deck sequence-callbacks)))))))
 
 ;; * Slide
 (defclass ms-slide (ms-parent ms-stateful-sequence)



reply via email to

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