If headlines in the agenda files are marked with tags (see Tags), or have properties (see Properties), you can select headlines based on this metadata and collect them into an agenda buffer. The match syntax described here also applies when creating sparse trees with C-c / m.
Produce a list of all headlines that match a given set of tags. The command prompts for a selection criterion, which is a boolean logic expression with tags, like ‘+work+urgent-withboss’ or ‘work|home’ (see Tags). If you often need a specific search, define a custom command for it (see Agenda Dispatcher).
Like m, but only select headlines that are also TODO items.
A search string can use Boolean operators ‘&’ for AND and ‘|’ for OR. ‘&’ binds more strongly than ‘|’. Parentheses are currently not implemented. Each element in the search is either a tag, a regular expression matching tags, or an expression like ‘PROPERTY OPERATOR VALUE’ with a comparison operator, accessing a property value. Each element may be preceded by ‘-’ to select against it, and ‘+’ is syntactic sugar for positive selection. The AND operator ‘&’ is optional when ‘+’ or ‘-’ is present. Here are some examples, using only tags.
Select headlines tagged ‘work’, but discard those also tagged ‘boss’.
Selects lines tagged ‘work’ or ‘laptop’.
Like before, but require the ‘laptop’ lines to be tagged also ‘night’.
You may also test for properties at the same time as matching tags, see the manual for more information.