From e74afc608718343103e4784d8848b123100b8046 Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Sun, 12 Apr 2026 23:07:55 +0200 Subject: [PATCH] Auto-update Elfeed on open --- .../desktop/.emacs.d/lisp/core/keybindings.el | 2 +- .../.emacs.d/lisp/misc/custom-functions.el | 35 ++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/dotfiles/desktop/.emacs.d/lisp/core/keybindings.el b/dotfiles/desktop/.emacs.d/lisp/core/keybindings.el index 965c713..6eab859 100644 --- a/dotfiles/desktop/.emacs.d/lisp/core/keybindings.el +++ b/dotfiles/desktop/.emacs.d/lisp/core/keybindings.el @@ -55,7 +55,7 @@ ;; -------- elfeed -------- (autoload 'elfeed "elfeed" nil t) -(define-key fscotto/open (kbd "f") #'elfeed) +(define-key fscotto/open (kbd "f") #'fscotto/elfeed-load-db-and-open) ;; -------- gptel -------- (autoload 'gptel "gptel" nil t) diff --git a/dotfiles/desktop/.emacs.d/lisp/misc/custom-functions.el b/dotfiles/desktop/.emacs.d/lisp/misc/custom-functions.el index 82c0623..5ba7705 100644 --- a/dotfiles/desktop/.emacs.d/lisp/misc/custom-functions.el +++ b/dotfiles/desktop/.emacs.d/lisp/misc/custom-functions.el @@ -1,15 +1,40 @@ ;;functions to support syncing .elfeed between machines ;;makes sure elfeed reads index from disk before launching +(defvar fscotto/elfeed-initial-update-done nil + "Non-nil once Elfeed has triggered its first automatic update this session.") + +(defvar fscotto/elfeed-update-timer nil + "Timer used for periodic Elfeed updates.") + +(defun fscotto/elfeed-auto-update () + "Refresh Elfeed feeds in the background." + (when (require 'elfeed nil 'noerror) + (require 'elfeed-db) + (elfeed-db-load) + (elfeed-update))) + +(defun fscotto/elfeed-start-auto-update () + "Start the periodic Elfeed update timer if needed." + (unless (timerp fscotto/elfeed-update-timer) + (setq fscotto/elfeed-update-timer + (run-at-time "15 min" (* 15 60) #'fscotto/elfeed-auto-update)))) + (defun fscotto/elfeed-load-db-and-open () - "Wrapper to load the elfeed db from disk before opening URL https://pragmaticemacs.wordpress.com/2016/08/17/read-your-rss-feeds-in-emacs-with-elfeed/ + "Open Elfeed, updating once per session and then every 15 minutes. + +Based on https://pragmaticemacs.wordpress.com/2016/08/17/read-your-rss-feeds-in-emacs-with-elfeed/ Created: 2016-08-17 Updated: 2025-06-13" (interactive) - (elfeed) + (require 'elfeed) + (require 'elfeed-db) (elfeed-db-load) - ;; (elfeed-search-update--force) - (elfeed-update) - (elfeed-db-save)) + (elfeed) + (fscotto/elfeed-start-auto-update) + (unless fscotto/elfeed-initial-update-done + (setq fscotto/elfeed-initial-update-done t) + (message "Updating Elfeed feeds...") + (elfeed-update))) (defun fscotto/project-root () "Return projectile project root or fallback to default-directory."