mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Don't start github timer if doom-modeline-github is nil.
Also watch the change of doom-modeline-github to run or cancel the timer. This only support 26 and above. Need to restart Emacs to effect in 25. See https://github.com/seagle0128/doom-modeline/issues/66#issuecomment-451397481.
This commit is contained in:
parent
47bed3c0a4
commit
5adedd5953
1 changed files with 20 additions and 3 deletions
|
@ -1859,9 +1859,26 @@ mouse-3: Describe current input method")
|
|||
(setq doom-modeline--github-notifications-number
|
||||
(length result))))))
|
||||
|
||||
(run-with-timer 30
|
||||
doom-modeline-github-interval
|
||||
#'doom-modeline--github-fetch-notifications)
|
||||
(defvar doom-modeline--github-timer nil)
|
||||
(defun doom-modeline-github-timer ()
|
||||
"Start/Stop the timer for github fetching."
|
||||
(if (timerp doom-modeline--github-timer)
|
||||
(cancel-timer doom-modeline--github-timer))
|
||||
(setq doom-modeline--github-timer
|
||||
(and doom-modeline-github
|
||||
(run-with-timer 30
|
||||
doom-modeline-github-interval
|
||||
#'doom-modeline--github-fetch-notifications))))
|
||||
|
||||
(when (>= emacs-major-version 26)
|
||||
(add-variable-watcher
|
||||
'doom-modeline-github
|
||||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq doom-modeline-github val)
|
||||
(doom-modeline-github-timer)))))
|
||||
|
||||
(doom-modeline-github-timer)
|
||||
|
||||
(defun doom-modeline--github-open-notifications ()
|
||||
"Open GitHub Notifications page."
|
||||
|
|
Loading…
Reference in a new issue