summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-02-13 12:47:27 -0600
committerCraig Jennings <c@cjennings.net>2026-02-13 12:47:27 -0600
commit6814d0bbb3b874bbe0c2b63e242d6b8145df0a39 (patch)
treecaf8e781159d14ebefc8fc96720133543256910e /modules
parentcbdd0729f75721f246de94661a6ee83505d83399 (diff)
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.
Diffstat (limited to 'modules')
-rw-r--r--modules/org-agenda-config.el21
1 files changed, 12 insertions, 9 deletions
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"))