branch: externals/doc-view-follow
commit 61040e84461c694a97d0ffedce08c0c4480427d0
Author: Paul Nelson <ultr...@gmail.com>
Commit: Paul Nelson <ultr...@gmail.com>

    Define and extract delay value for page synchronization
    
    * doc-dual-view.el (doc-dual-view--sync-delay): Define new constant
    for the synchronization delay time to avoid hardcoding the value.
    (doc-dual-view--sync-pages): Use the constant.  Make lambda parameter
    names more concise.
---
 doc-dual-view.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/doc-dual-view.el b/doc-dual-view.el
index 883cbac20c..9ff7755292 100644
--- a/doc-dual-view.el
+++ b/doc-dual-view.el
@@ -85,6 +85,9 @@ by adding entries to this list.")
 (defvar doc-dual-view--sync-in-progress nil
   "Flag to prevent recursive sync operations.")
 
+(defconst doc-dual-view--sync-delay 0.001
+  "Short delay in seconds before syncing windows to avoid timing issues.")
+
 (defun doc-dual-view--sync-pages (&rest _args)
   "Sync pages between windows showing the same document."
   (unless doc-dual-view--sync-in-progress
@@ -108,11 +111,11 @@ by adding entries to this list.")
                    (unless (= target-page
                               (doc-dual-view--call-func mode-config :current))
                      (run-with-idle-timer
-                      0.001 nil
-                      (lambda (target-win config page)
-                        (when (window-live-p target-win)
-                          (with-selected-window target-win
-                            (doc-dual-view--call-func config :goto page))))
+                      doc-dual-view--sync-delay nil
+                      (lambda (w cfg page)
+                        (when (window-live-p w)
+                          (with-selected-window w
+                            (doc-dual-view--call-func cfg :goto page))))
                       win mode-config target-page))))))
            windows))))))
 

Reply via email to