about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-04-02 13:53:11 -0500
committerCase Duckworth2022-04-02 13:53:39 -0500
commitabf24e71c784111a65f56dc6613c020495c49927 (patch)
tree67b5b1c80617d4514e1e6ffcf49d7f96d9b10592 /lisp
parentChange default mpv viewer to cache (diff)
downloademacs-abf24e71c784111a65f56dc6613c020495c49927.tar.gz
emacs-abf24e71c784111a65f56dc6613c020495c49927.zip
Enable +elfeed-update-command to run only sometimes
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+elfeed.el17
1 files changed, 14 insertions, 3 deletions
diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el index 7f9e193..c0b74f0 100644 --- a/lisp/+elfeed.el +++ b/lisp/+elfeed.el
@@ -133,6 +133,19 @@ If multiple items are selected, don't advance."
133(defvar +elfeed--update-first-time 6 "How long to wait for the first time.") 133(defvar +elfeed--update-first-time 6 "How long to wait for the first time.")
134(defvar +elfeed--update-repeat (* 60 15) "How long between updates.") 134(defvar +elfeed--update-repeat (* 60 15) "How long between updates.")
135 135
136(defcustom +elfeed-update-proceed-hook nil
137 "Predicates to query before running `+elfeed-update-command'.
138Each hook is passed no arguments."
139 :type 'hook)
140
141(defun +elfeed-update-command-wrapper ()
142 "Run `+elfeed-update-command', but only sometimes.
143If any of the predicates in `+elfeed-update-proceed-hook' return
144nil, don't run `+elfeed-update-command'. If they all return
145non-nil, proceed."
146 (when (run-hook-with-args-until-failure '+elfeed-update-proceed-hook)
147 (+elfeed-update-command)))
148
136(defun +elfeed--cancel-update-timer () 149(defun +elfeed--cancel-update-timer ()
137 "Cancel `+elfeed--update-timer'." 150 "Cancel `+elfeed--update-timer'."
138 (unless +elfeed--update-running 151 (unless +elfeed--update-running
@@ -142,12 +155,10 @@ If multiple items are selected, don't advance."
142(defun +elfeed--reinstate-update-timer () 155(defun +elfeed--reinstate-update-timer ()
143 "Reinstate `+elfeed--update-timer'." 156 "Reinstate `+elfeed--update-timer'."
144 ;; First, unload the db 157 ;; First, unload the db
145 (elfeed-db-save)
146 (elfeed-db-unload)
147 (setq +elfeed--update-timer 158 (setq +elfeed--update-timer
148 (run-at-time +elfeed--update-first-time 159 (run-at-time +elfeed--update-first-time
149 +elfeed--update-repeat 160 +elfeed--update-repeat
150 #'+elfeed-update-command))) 161 #'+elfeed-update-command-wrapper)))
151 162
152(define-minor-mode +elfeed-update-async-mode 163(define-minor-mode +elfeed-update-async-mode
153 "Minor mode to update elfeed async-style." 164 "Minor mode to update elfeed async-style."