0

I have this

(setq org-agenda-files (directory-files-recursively "~/Dropbox/org/journal/" "\\.org$"))

but I don't know where to place it in order to make sure that on the event of a new daily org-journal file creation in my journal directory (e.g. ~Dropbox/org/journal/2021/02/) the agenda file list will immediately be updated. At the moment I have it placed early in my init.el, which thereafter calls a big, general config.org full of package initializations and tweaks, then a private custom-set-variables file. Does this sexp need to be part of some special trigger/hook/event code to know to update the org-agenda-files list when a new org-journal day file appears?

1

TL;DR: set the variable org-agenda-files to be a list of all the directories that you want to scan recursively for *.org files:

(setq org-agenda-files '("~/Dropbox/org/journal/"))

Explanation:

There are two org-agenda-files objects: a function and a variable. Org mode calls the function when it needs the list. The function looks at the org-agenda-files variable and proceeds accordingly:

  • if the variable is a filename, then it is interpreted as a file that contains the names of all the agenda files. So this is static: you need to add any additional files that you want.

  • if the variable is a list of filenames, then that's the list of agenda files, except that if an entry in the list is a directory it is scanned recursively for any files that match org-agenda-file-regexp. The latter matches files of the form foo.org so you don't have to do this yourself.

If you look at the implementation of the function org-agenda-files, you'll see that it does already the recursive scan, so you don't have to. And it uses the org-agenda-file-regexp so you don't have to.

Untested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.