minmo : timer reorg
This commit is contained in:
parent
8562c0c1f3
commit
bfaf1bcf21
1 changed files with 37 additions and 37 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue