11

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?

Daniel Dinnyes
  • 4,898
  • 3
  • 32
  • 44
  • Just in case, I did notice that the `org-agenda-files` docs say that instead of a list of absolute paths, one single absolute path to a text-file can be added, where the text-file can contain a list of relative paths based on `org-directory` per line, but it sounds like a [PITA](https://www.urbandictionary.com/define.php?term=pita), or "reasonably inelegant" to me. – Daniel Dinnyes Apr 26 '16 at 20:05
  • 1
    `M-x describe-variable RET org-directory RET` provides two (2) express situations when the variable `org-directory` is used -- the doc-string uses the word "only". The call of the question suggests that the original poster expects or hopes for a more robust usage, however, such a usage was never intended by `org-mode` authors. – lawlist May 08 '16 at 01:58

1 Answers1

24

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 ;)

Daniel Dinnyes
  • 4,898
  • 3
  • 32
  • 44
  • 1
    You can use `C-[` (org-agenda-file-to-front &optional TO-END). To Move/add the current file to the top of the agenda file list. `C-]` will remove the file from org-agenda-file list. – DJJ May 05 '16 at 17:57