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

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

[nongnu] elpa/scroll-on-jump ea74496fa1 10/31: Fix recursive calls to an


From: ELPA Syncer
Subject: [nongnu] elpa/scroll-on-jump ea74496fa1 10/31: Fix recursive calls to animate scrolling
Date: Thu, 7 Jul 2022 12:03:12 -0400 (EDT)

branch: elpa/scroll-on-jump
commit ea74496fa172783f27c8ae509f84398e151bfb28
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Fix recursive calls to animate scrolling
    
    It's possible that advice to animate scrolling is called
    from a function which is already animating scrolling.
    
    In this case only respect the outer-most call to perform animation.
---
 scroll-on-jump.el | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/scroll-on-jump.el b/scroll-on-jump.el
index 6925bc72f4..5bf22eb27f 100644
--- a/scroll-on-jump.el
+++ b/scroll-on-jump.el
@@ -395,9 +395,7 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as 
well."
       (window (selected-window))
 
       (point-prev (point))
-      (point-next nil)
-
-      (has-context-changed t))
+      (point-next nil))
 
     (prog1
       (save-excursion
@@ -413,20 +411,20 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as 
well."
             ,@body)
           (setq point-next (point))))
 
-      (when
-        (and
-          (eq buf (current-buffer))
-          (eq window (selected-window))
-          (eq buf (window-buffer window)))
-        (setq has-context-changed nil))
-
       (cond
-        (has-context-changed
-          ;; Context changed, use a fallback.
-          (goto-char point-next))
-        (t
-          ;; Calculate the new window start.
-          (scroll-on-jump-auto-center window point-prev point-next))))))
+        ( ;; Perform animated scroll.
+          (and
+            ;; Buffer/Context changed.
+            (eq buf (window-buffer window)) (eq buf (current-buffer)) (eq 
window (selected-window))
+
+            ;; Disallow recursion.
+            (not (boundp 'scroll-on-jump--resurse)))
+
+          (let ((scroll-on-jump--resurse t))
+            (scroll-on-jump-auto-center window point-prev point-next)))
+
+        (t ;; Context changed or recursed, simply jump.
+          (goto-char point-next))))))
 
 ;;;###autoload
 (defmacro scroll-on-jump-interactive (fn)



reply via email to

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