From abf24e71c784111a65f56dc6613c020495c49927 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 2 Apr 2022 13:53:11 -0500 Subject: Enable +elfeed-update-command to run only sometimes --- lisp/+elfeed.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lisp/+elfeed.el') 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." (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." -- cgit 1.4.1-21-gabe81