From bfaf1bcf210d8f21eb7aa7f89912c18621eea82d Mon Sep 17 00:00:00 2001 From: bth Date: Tue, 9 Jun 2026 11:25:27 -0700 Subject: [PATCH] minmo : timer reorg --- packages/minmo.el | 74 +++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/packages/minmo.el b/packages/minmo.el index 291d4ba..b047905 100644 --- a/packages/minmo.el +++ b/packages/minmo.el @@ -213,43 +213,6 @@ Optional FORCE means ignore the minmo--git-directory-table." ;; if we don't use vc-responsible-backend and vc-git--symbolic-ref ;; (remove-hook 'find-file-hook #'vc-refresh-state) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; timer - -;; NOTE: the idea here is to keep the timer like vc-mode uses when -;; auto-revert-check-vc-info is t, but restrict to visible windows. Which is -;; somewhat an obvious optimization. - -(defvar minmo-git-cache-timer nil) - -(defun minmo--update-git-cache-visible () - "Update vc cache for visible windows." - (dolist (win (window-list)) - (with-current-buffer (window-buffer win) - (minmo--update-git-cache)))) - -(defun minmo--start-timer (symbol value) - "Apply the new timer VALUE to SYMBOL and restart the timer." - ;; explicitly set the variable, otherwise :set swallows it - (set-default symbol value) - ;; guard against spawning multiple: - (when minmo-git-cache-timer - (cancel-timer minmo-git-cache-timer) - (setq minmo-git-cache-timer nil)) - ;; allow disabling: - (when (and (numberp value) (> value 0)) - (setq minmo-git-cache-timer - (run-with-timer value value #'minmo--update-git-cache-visible)))) - -(defcustom minmo-git-cache-timer-interval 5 - "Interval in seconds for background git caching. Set to nil or 0 to disable." - :type '(choice (integer :tag "Seconds") - (const :tag "Disable" nil)) - :set #'minmo--start-timer) - -(minmo--start-timer 'minmo-git-cache-timer-interval - minmo-git-cache-timer-interval) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; disk @@ -293,6 +256,43 @@ Optional FORCE means ignore the minmo--git-directory-table." (t (minmo--status 'unmodified 'disk)) )) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; timer + +;; NOTE: the idea here is to keep the timer like vc-mode uses when +;; auto-revert-check-vc-info is t, but restrict to visible windows. Which is +;; somewhat an obvious optimization. + +(defvar minmo-git-cache-timer nil) + +(defun minmo--update-git-cache-visible () + "Update vc cache for visible windows." + (dolist (win (window-list)) + (with-current-buffer (window-buffer win) + (minmo--update-git-cache)))) + +(defun minmo--start-timer (symbol value) + "Apply the new timer VALUE to SYMBOL and restart the timer." + ;; explicitly set the variable, otherwise :set swallows it + (set-default symbol value) + ;; guard against spawning multiple: + (when minmo-git-cache-timer + (cancel-timer minmo-git-cache-timer) + (setq minmo-git-cache-timer nil)) + ;; allow disabling: + (when (and (numberp value) (> value 0)) + (setq minmo-git-cache-timer + (run-with-timer value value #'minmo--update-git-cache-visible)))) + +(defcustom minmo-git-cache-timer-interval 5 + "Interval in seconds for background git caching. Set to nil or 0 to disable." + :type '(choice (integer :tag "Seconds") + (const :tag "Disable" nil)) + :set #'minmo--start-timer) + +(minmo--start-timer 'minmo-git-cache-timer-interval + minmo-git-cache-timer-interval) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; project