I am using org-mode to write notes and org-agenda to organize all notes, especially to search some info. by keyword or tag.
C-c a m can search some files by tag inputed, C-c a s by keyword ,those functions from org-agenda are well to utilize, however, I need to add org-file into the agenda-list by hand.
I added some codes into .emacs, such as
(setq org-agenda-files (list "path/folder/*.org"))
or
(setq org-agenda-files (file-expand-wildcards "path/folder/*.org"))
but, both failed to add files under the folder specified into agenda-list automatically, so I can't search keyword or tag among those org-files, unless that I open a org-file and type C-c [ to add it into agenda-list.
How can I make all org-files under a folder automatically added in agenda?
Best Answer
Just naming the directory should be enough. For example this works for me very well:
Also take a look at
org-agenda-text-search-extra-files
; it lets you add extra files included only in text searches. A typical value might be,Caveat: If you add a file to the directory after you have started Emacs, it will not be included.
Edit: (2018) To include all files with a certain extension in the extra files list you can try the following function I wrote sometime back (a more recent version might be available here).
You can use it like this:
Edit: (2019) As mentioned in the answer by @mingwei-zhang and the comment by @xiaobing,
find-lisp-find-files
fromfind-lisp
anddirectory-files-recursively
also provides this functionality. However, please note in these cases the file name argument is a (greedy) regex. So something like(directory-files-recursively "~/my-dir" "org")
will give you all Org files including backup files (*.org~
). To include only*.org
files, you may use(directory-files-recursively "~/my-dir" "org$")
.