From 6814d0bbb3b874bbe0c2b63e242d6b8145df0a39 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 13 Feb 2026 12:47:27 -0600 Subject: fix(agenda): scope file scan to immediate subdirs of ~/projects Replace recursive directory-files-recursively with shallow scan that only checks ~/projects/*/todo.org. Excludes nested archive todo.org files and keeps ~/code and ~/.emacs.d out of agenda. --- modules/org-agenda-config.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'modules/org-agenda-config.el') diff --git a/modules/org-agenda-config.el b/modules/org-agenda-config.el index df95f31e..9d382750 100644 --- a/modules/org-agenda-config.el +++ b/modules/org-agenda-config.el @@ -95,17 +95,20 @@ Set to nil to invalidate cache.") Prevents duplicate builds if user opens agenda before async build completes.") ;; ------------------------ Add Files To Org Agenda List ----------------------- -;; finds files named 'todo.org' (case insensitive) and adds them to -;; org-agenda-files list. +;; Checks immediate subdirectories of DIRECTORY for todo.org files and adds +;; them to org-agenda-files. Does NOT recurse into nested subdirectories. (defun cj/add-files-to-org-agenda-files-list (directory) - "Search for files named \\='todo.org\\=' add them to org-project-files. -DIRECTORY is a string of the path to begin the search." + "Add todo.org files from immediate subdirectories of DIRECTORY. +Only checks DIRECTORY/*/todo.org — does not recurse deeper." (interactive "D") - (setq org-agenda-files - (append (directory-files-recursively directory - "^[Tt][Oo][Dd][Oo]\\.[Oo][Rr][Gg]$" t) - org-agenda-files))) + (let ((todo-files + (seq-filter + #'file-exists-p + (mapcar (lambda (dir) (expand-file-name "todo.org" dir)) + (seq-filter #'file-directory-p + (directory-files directory t "^[^.]")))))) + (setq org-agenda-files (append todo-files org-agenda-files)))) ;; ---------------------------- Rebuild Org Agenda --------------------------- ;; builds the org agenda list from all agenda targets with caching. @@ -297,7 +300,7 @@ This uses all org-agenda targets and presents three sections: The agenda is rebuilt from all sources before display, including: - inbox-file and schedule-file - Org-roam nodes tagged as \"Project\" -- All todo.org files in projects-dir and code-dir" +- All todo.org files in immediate subdirectories of projects-dir" (interactive) (cj/build-org-agenda-list) (org-agenda "a" "d")) -- cgit v1.2.3