summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Nelson <ultrono@gmail.com>2025-04-02 08:34:14 +0200
committerPaul Nelson <ultrono@gmail.com>2025-04-02 08:34:14 +0200
commit0b71ebc30717b541c5669aa6b2e78f17cba6f24d (patch)
treeb80ea735960f3f0e622c4a09c46b18930c8651df
parent693467470c7b6c618d805c175593dafb9cd6dd19 (diff)
Refactor doc-dual-view--sync-pages to use seq-do-indexed
* doc-dual-view.el (doc-dual-view--sync-pages): Replace manual iteration with seq-do-indexed.
-rw-r--r--doc-dual-view.el53
1 files changed, 28 insertions, 25 deletions
diff --git a/doc-dual-view.el b/doc-dual-view.el
index 4983107..37f6a76 100644
--- a/doc-dual-view.el
+++ b/doc-dual-view.el
@@ -101,31 +101,34 @@ redisplay-func)."
(max-page (funcall max-page-func))
(redisplay-func (nth 4 mode-funcs))
(current-window (selected-window))
- (window-index (seq-position windows current-window))
- (i 0))
- (dolist (win windows)
- (let ((target-page (min max-page (max 1 (+ current-page
- (- i window-index))))))
- (when (and (not (eq win current-window))
- (window-live-p win))
- (with-selected-window win
- (let ((current (funcall current-page-func)))
- (when (not (= current target-page))
- (funcall goto-func target-page)
- (let ((timer-sym
- (intern (format
- "doc-dual-view--redisplay-timer-%d" i))))
- (when (and (boundp timer-sym)
- (timerp (symbol-value timer-sym)))
- (cancel-timer (symbol-value timer-sym)))
- (set timer-sym
- (run-with-idle-timer
- 0.001 nil
- (lambda (w f p)
- (when (window-live-p w)
- (with-selected-window w
- (funcall f p))))
- win redisplay-func target-page))))))))))))))
+ (window-index (seq-position windows current-window)))
+ (seq-do-indexed
+ (lambda (win i)
+ (when (and (not (eq win current-window))
+ (window-live-p win))
+ (let ((target-page
+ (min max-page
+ (max 1 (+ current-page (- i window-index))))))
+ (with-selected-window win
+ (let ((current (funcall current-page-func)))
+ (when (not (= current target-page))
+ (funcall goto-func target-page)
+ (let ((timer-sym
+ (intern (format
+ "doc-dual-view--redisplay-timer-%d" i))))
+ (when (and (boundp timer-sym)
+ (timerp (symbol-value timer-sym)))
+ (cancel-timer (symbol-value timer-sym)))
+ (set timer-sym
+ (run-with-idle-timer
+ 0.001 nil
+ (lambda (w f p)
+ (when (window-live-p w)
+ (with-selected-window w
+ (funcall f p))))
+ win redisplay-func target-page)))))))))
+ windows))))))
+
;;;###autoload
(define-minor-mode doc-dual-view-mode