How to add .org files under org-directory to agend

2020-06-18 03:41发布

问题:

I am facing the following problem: Org mode has the customizable variable org-agenda-files. The files listed by absolute path under this variable are used for building the org agenda window. If an element in the list is a directory, then all .org files matching the org-agenda-regex are processed to build the agenda view. On the other hand there is also another customizable variable: org-directory. Shockingly though, if org-agenda-files is undefined, the agenda view does not try to use the matching .org files under org-directory. Also, listing the paths of the agenda files relative to org-directory in org-agenda-files is not accepted, as it complains that the files are not found.

My question is, is there an reasonably elegant way to make use of the org-directory in the lookup of agenda files, either by using it as the default to look for all .org files, or to describe the agenda files list with relative paths to org-directory?

回答1:

Actually just managed to get it working the way I wanted. So this is how the relevant config code should look like:

(custom-set-variables
 '(org-directory "~/Documents/org")
 '(org-agenda-files (list org-directory)))

This way the agenda reads from all .org files under the org-directory, and when org-directory changes it follows it. Just what I was looking for ;)