minmo : minmo--start-timer
This commit is contained in:
parent
3ea2317e94
commit
4fe87a7660
1 changed files with 21 additions and 11 deletions
|
|
@ -208,9 +208,6 @@ Optional FORCE means ignore the minmo--git-directory-table."
|
||||||
;; auto-revert-check-vc-info is t, but restrict to visible windows. Which is
|
;; auto-revert-check-vc-info is t, but restrict to visible windows. Which is
|
||||||
;; somewhat an obvious optimization.
|
;; somewhat an obvious optimization.
|
||||||
|
|
||||||
(defcustom minmo-git-cache-timer-interval 5
|
|
||||||
"interval for `minmo-git-cache-timer'")
|
|
||||||
|
|
||||||
(defvar minmo-git-cache-timer nil)
|
(defvar minmo-git-cache-timer nil)
|
||||||
|
|
||||||
(defun minmo--update-git-cache-visible ()
|
(defun minmo--update-git-cache-visible ()
|
||||||
|
|
@ -219,14 +216,27 @@ Optional FORCE means ignore the minmo--git-directory-table."
|
||||||
(with-current-buffer (window-buffer win)
|
(with-current-buffer (window-buffer win)
|
||||||
(minmo--update-git-cache))))
|
(minmo--update-git-cache))))
|
||||||
|
|
||||||
;; guard against spawning multiple when this file is eval'd :
|
(defun minmo--start-timer (symbol value)
|
||||||
(when minmo-git-cache-timer (cancel-timer minmo-git-cache-timer))
|
"Apply the new timer VALUE to SYMBOL and restart the timer."
|
||||||
(setq minmo-git-cache-timer
|
;; explicitly set the variable, otherwise :set swallows it
|
||||||
;; TODO: run-with-idle-timer ?
|
(set-default symbol value)
|
||||||
(run-with-timer
|
;; guard against spawning multiple:
|
||||||
minmo-git-cache-timer-interval
|
(when minmo-git-cache-timer
|
||||||
minmo-git-cache-timer-interval
|
(cancel-timer minmo-git-cache-timer)
|
||||||
'minmo--update-git-cache-visible))
|
(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
|
;;;; disk
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue