Org itself provides a facility for filtering/searching information stored in .org
files in various ways. It is called the "Agenda". The org-mode
manual provides extensive information on how to use it (check the link above or do C-h i m Org Mode
RET from within Emacs and navigate to the "Agenda Views" chapter), so it does not make sense to repeat all of this information here. The introductory text from the manual summarizes what you can do with it (emphasis mine):
Org can select items based on various criteria and display them in a separate buffer. Seven different view types are provided:
- an agenda that is like a calendar and shows information for specific dates,
- a TODO list that covers all unfinished action items,
- a match view, showings headlines based on the tags, properties, and TODO state associated with them,
- a timeline view that shows all events in a single Org file, in time-sorted view,
- a text search view that shows all entries from multiple files that contain specified keywords,
- a stuck projects view showing projects that currently don't move along, and
- custom views that are special searches and combinations of different views.
The only thing you need to do to start using the agenda for searching your notes is add any files you want to search to org-agenda-files
:
The information to be shown is normally collected from all agenda files, the files listed in the variable org-agenda-files
. If a directory is part of this list, all files with the extension .org
in this directory will be part of the list.
So in your case you'll want to add something like this to your init-file:
(setq org-agenda-files '("/path/to/Notes/Linux" "/path/to/Notes/Programming"))
For lots of examples and practical advice I also recommend you check out the article on Advanced Searching on Worg.
[UPDATE] Limiting search to specific file sets
As mentioned in the comments, OP wants to be able to restrict searches to specific sets of files. In technical terms, this means setting org-agenda-files
to different values depending on context. This can be achieved using directory-local variables:
The usual way to define directory-local variables is to put a file named .dir-locals.el
in a directory. Whenever Emacs visits any file in that directory or any of its subdirectories, it will apply the directory-local variables specified in .dir-locals.el
, [...].
For example, let's say that
while visiting files stored in Notes/Linux
you want to use the agenda to only search .org
files stored in Notes/Linux
.
while visiting files stored in Notes/Programming
, you want to use the agenda to only search .org
files stored in Notes/Programming
.
Here's what to do to enable this behavior:
Add a .dir-locals.el
file with the following content to both Notes/Linux
and Notes/Programming
:
((nil . ((org-agenda-files . (".")))))
This sets the list of org-agenda-files
to include all files in the current directory.
Add the following code to your init-file:
(add-hook 'org-agenda-mode-hook #'hack-dir-local-variables-non-file-buffer)
This step is necessary to ensure that *Org Agenda*
(a non-file buffer) respects your directory-local settings for org-agenda-files
.
Next time you visit a file stored in Notes/Linux
or Notes/Programming
, Emacs will ask you whether you would like to apply the settings stored in .dir-locals.el
. Hit ! to tell Emacs to apply the settings and mark them as safe for future sessions (you will not be prompted again for files in the same directory).