10.8 Custom Agenda Views

The first application of custom searches is the definition of keyboard shortcuts for frequently used searches, either creating an agenda buffer, or a sparse tree (the latter covering of course only the current buffer).

Custom commands are configured in the variable org-agenda-custom-commands. You can customize this variable, for example by pressing C from the agenda dispatcher (see The Agenda Dispatcher). You can also directly set it with Emacs Lisp in the Emacs init file. The following example contains all valid agenda views:

(setq org-agenda-custom-commands
      '(("w" todo "WAITING")
        ("u" tags "+boss-urgent")
        ("v" tags-todo "+boss-urgent")))

The initial string in each entry defines the keys you have to press after the dispatcher command in order to access the command. Usually this is just a single character. The second parameter is the search type, followed by the string or regular expression to be used for the matching. The example above will therefore define:

w

as a global search for TODO entries with ‘WAITING’ as the TODO keyword.

u

as a global tags search for headlines tagged ‘boss’ but not ‘urgent’.

v

The same search, but limiting it to headlines that are also TODO items.