From 17ae3e2a30eba73898ca4b5758d2923ece6528db Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 17 Jul 2026 19:04:51 -0500 Subject: feat(org-agenda): raise file-cache TTL to 24h and bind S- force-refresh The agenda file-list cache held a 1h TTL, so once an hour the next agenda open re-walked projects-dir from scratch. That cache tracks only which files exist, never their contents, so task edits and completions are never staled by it. The only thing a long TTL delays is a new project's todo.org appearing. That's rare, so I raised it to 24h. For that case I bound cj/org-agenda-refresh-files (the manual force-rescan) to S-, the free slot in the F8 agenda family (, s-, C-, M-). --- modules/org-agenda-config.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'modules/org-agenda-config.el') diff --git a/modules/org-agenda-config.el b/modules/org-agenda-config.el index 632184e5..3cff9d95 100644 --- a/modules/org-agenda-config.el +++ b/modules/org-agenda-config.el @@ -123,8 +123,15 @@ the file keeps precedence." ;; Cache agenda file list to avoid expensive directory scanning on every view. ;; The TTL+building cache lifecycle is provided by `cj-cache.el'. -(defvar cj/--org-agenda-files-cache (cj/cache-make :ttl 3600) - "Cache state for the agenda files list. See `cj-cache.el'.") +(defvar cj/--org-agenda-files-cache (cj/cache-make :ttl 86400) + "Cache state for the agenda files list. See `cj-cache.el'. + +TTL is 24h. The cache holds only the file *list* (which files are agenda +files), never their contents -- task edits and completions are re-read on +every agenda build/redo regardless of cache age. The list only changes when +a project directory with a todo.org is created or removed, which is rare, so a +long TTL costs little; use `cj/org-agenda-refresh-files' (S-) to force a +re-scan the moment a new project is added.") ;; ------------------------ Add Files To Org Agenda List ----------------------- ;; Checks immediate subdirectories of DIRECTORY for todo.org files and adds @@ -216,9 +223,13 @@ improves performance from several seconds to instant." "Force rebuild of agenda files cache. Use this after adding new projects or todo.org files. -Bypasses cache and scans directories from scratch." +Bypasses cache and scans directories from scratch. + +Bound to S-, the force-rebuild sibling of the F8 agenda family +\( display, s- all files, C- single project, M- this buffer)." (interactive) (cj/build-org-agenda-list 'force-rebuild)) +(global-set-key (kbd "S-") #'cj/org-agenda-refresh-files) (defun cj/todo-list-all-agenda-files () "Displays an \\='org-agenda\\=' todo list. -- cgit v1.2.3