Enable +elfeed-update-command to run only sometimes
This commit is contained in:
parent
8383d8cb8b
commit
abf24e71c7
13
init.el
13
init.el
|
@ -1394,8 +1394,17 @@ See also `crux-reopen-as-root-mode'."
|
|||
(:hook #'reading-mode)
|
||||
(:option +elfeed--update-repeat (* 60 30) ; 1/2 hour
|
||||
+elfeed--update-first-time 60))
|
||||
(+elfeed-update-async-mode -1) ; It really messes with stuff for work
|
||||
)
|
||||
(+elfeed-update-async-mode +1)
|
||||
(add-hook '+elfeed-update-proceed-hook (defun non-work-hours? ()
|
||||
"Return nil if during work hours, t otherwise."
|
||||
(let* ((now (current-time))
|
||||
(now* (decode-time now))
|
||||
(work-start* (append '(0 0 8) (cdddr now*))) ; 8:00 AM
|
||||
(work-end* (append '(0 0 18) (cdddr now*))) ; 6:00 PM
|
||||
(work-start (encode-time work-start*))
|
||||
(work-end (encode-time work-end*)))
|
||||
(or (time-less-p now work-start)
|
||||
(time-less-p work-end now))))))
|
||||
|
||||
(setup (:straight elfeed-org)
|
||||
(:also-load +org-capture)
|
||||
|
|
|
@ -133,6 +133,19 @@ If multiple items are selected, don't advance."
|
|||
(defvar +elfeed--update-first-time 6 "How long to wait for the first time.")
|
||||
(defvar +elfeed--update-repeat (* 60 15) "How long between updates.")
|
||||
|
||||
(defcustom +elfeed-update-proceed-hook nil
|
||||
"Predicates to query before running `+elfeed-update-command'.
|
||||
Each hook is passed no arguments."
|
||||
:type 'hook)
|
||||
|
||||
(defun +elfeed-update-command-wrapper ()
|
||||
"Run `+elfeed-update-command', but only sometimes.
|
||||
If any of the predicates in `+elfeed-update-proceed-hook' return
|
||||
nil, don't run `+elfeed-update-command'. If they all return
|
||||
non-nil, proceed."
|
||||
(when (run-hook-with-args-until-failure '+elfeed-update-proceed-hook)
|
||||
(+elfeed-update-command)))
|
||||
|
||||
(defun +elfeed--cancel-update-timer ()
|
||||
"Cancel `+elfeed--update-timer'."
|
||||
(unless +elfeed--update-running
|
||||
|
@ -142,12 +155,10 @@ If multiple items are selected, don't advance."
|
|||
(defun +elfeed--reinstate-update-timer ()
|
||||
"Reinstate `+elfeed--update-timer'."
|
||||
;; First, unload the db
|
||||
(elfeed-db-save)
|
||||
(elfeed-db-unload)
|
||||
(setq +elfeed--update-timer
|
||||
(run-at-time +elfeed--update-first-time
|
||||
+elfeed--update-repeat
|
||||
#'+elfeed-update-command)))
|
||||
#'+elfeed-update-command-wrapper)))
|
||||
|
||||
(define-minor-mode +elfeed-update-async-mode
|
||||
"Minor mode to update elfeed async-style."
|
||||
|
|
Loading…
Reference in New Issue