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

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

[nongnu] elpa/dslide c0e4aff0ac 7/8: Catch errors in step callbacks, rem


From: ELPA Syncer
Subject: [nongnu] elpa/dslide c0e4aff0ac 7/8: Catch errors in step callbacks, remove, warn user
Date: Thu, 28 Nov 2024 06:59:38 -0500 (EST)

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

    Catch errors in step callbacks, remove, warn user
    
    I don't like the idea of opening the warnings all the time.  It is 
completely
    forseeable that a function might error and the user might want to quickly do
    something and retry, such as when working with team members to orchestrate
    different parts of a prototype demo.
---
 dslide.el | 41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/dslide.el b/dslide.el
index 69423eb64f..27b0ec9b00 100644
--- a/dslide.el
+++ b/dslide.el
@@ -714,9 +714,15 @@ Class can be overridden to affect root behaviors.  See
 
     ;; Burn up a step callback until one returns non-nil
     (when-let ((steps (oref obj step-callbacks)))
-      (while (and (not progress)
-                  steps)
-        (setq progress (funcall (pop steps) 'forward)))
+      (while (and steps (not progress))
+        (setq
+         progress
+         (let ((step (pop steps)))
+           (condition-case nil
+               (funcall step 'forward)
+             ((debug error) (delay-warning
+                             '(dslide dslide-step-callback)
+                             "A step callback failed and was removed!"))))))
       (oset obj step-callbacks steps))
 
     (while (not (or progress reached-end))
@@ -775,11 +781,16 @@ Class can be overridden to affect root behaviors.  See
       (delete-overlay (pop dslide--step-overlays)))
 
     ;; Burn up a step callback until one returns non-nil
-    (when-let ((steps (and (slot-boundp obj 'step-callbacks)
-                           (oref obj step-callbacks))))
-      (while (and (not progress)
-                  steps)
-        (setq progress (funcall (pop steps) 'backward)))
+    (when-let ((steps (oref obj step-callbacks)))
+      (while (and steps (not progress))
+        (setq
+         progress
+         (let ((step (pop steps)))
+           (condition-case nil
+               (funcall step 'backward)
+             ((debug error) (delay-warning
+                             '(dslide dslide-step-callback)
+                             "A step callback failed and was removed!"))))))
       (oset obj step-callbacks steps))
 
     (while (not (or progress reached-beginning))
@@ -847,6 +858,16 @@ Class can be overridden to affect root behaviors.  See
        (eq (oref obj base-buffer) (buffer-base-buffer
                                    (oref obj slide-buffer)))))
 
+(cl-defmethod dslide--cleanup-step-callbacks ((obj dslide-deck))
+  "Run and dispose of all callbacks."
+  (mapc (lambda (f)
+          (condition-case nil
+              (funcall f nil)
+            ((debug error) (delay-warning
+                            '(dslide dslide-step-callback)
+                            "A step callback failed in cleanup!"))))
+        (oref obj step-callbacks)))
+
 (defun dslide-push-window-config (&optional step)
   "Save the window configuration and narrowing for restoration.
 
@@ -2725,9 +2746,7 @@ and the value of `point-max' should contain a newline 
somewhere."
              t nil))
   (dslide--delete-overlays)
   (dslide--animation-cleanup)
-  ;; TODO oref & oset outside of class
-  (mapc (lambda (f) (funcall f nil))
-        (oref dslide--deck step-callbacks))
+  (dslide--cleanup-step-callbacks dslide--deck)
   (oset dslide--deck step-callbacks nil)
   (remove-hook 'post-command-hook #'dslide--contents-hl-line t))
 



reply via email to

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