6.3 Tag Hierarchy
Tags can be defined in hierarchies. A tag can be defined as a group tag for a set of other tags. The group tag can be seen as the βbroader term" for its set of tags. Defining multiple group tags and nesting them creates a tag hierarchy.
One use-case is to create a taxonomy of terms (tags) that can be used to classify nodes in a document or set of documents.
When you search for a group tag, it return matches for all members in the group and its subgroups. In an agenda view, filtering by a group tag displays or hide headlines tagged with at least one of the members of the group or any of its subgroups. This makes tag searches and filters even more flexible.
You can set group tags by using brackets and inserting a colon between the group tag and its related tagsβbeware that all whitespaces are mandatory so that Org can parse this line correctly:
#+TAGS: [ GTD : Control Persp ]
In this example, βGTD
β is the group tag and it is related to two other tags: βControl
β, βPersp
β. Defining βControl
β and βPersp
β as group tags creates a hierarchy of tags:
#+TAGS: [ Control : Context Task ]
#+TAGS: [ Persp : Vision Goal AOF Project ]
That can conceptually be seen as a hierarchy of tags:
β
GTD
ββ
Persp
β- β
Vision
β - β
Goal
β - β
AOF
β - β
Project
β
- β
β
Control
β- β
Context
β - β
Task
β
- β
You can use the :startgrouptag
, :grouptags
and :endgrouptag
keyword directly when setting org-tag-alist
directly:
(setq org-tag-alist '((:startgrouptag)
("GTD")
(:grouptags)
("Control")
("Persp")
(:endgrouptag)
(:startgrouptag)
("Control")
(:grouptags)
("Context")
("Task")
(:endgrouptag)))
The tags in a group can be mutually exclusive if using the same group syntax as is used for grouping mutually exclusive tags together; using curly brackets.
#+TAGS: { Context : @Home @Work @Call }
When setting org-tag-alist
you can use :startgroup
and :endgroup
instead of :startgrouptag
and :endgrouptag
to make the tags mutually exclusive.
Furthermore, the members of a group tag can also be regular expressions, creating the possibility of a more dynamic and rule-based tag structure. The regular expressions in the group must be specified within curly brackets. Here is an expanded example:
#+TAGS: [ Vision : {V@.+} ]
#+TAGS: [ Goal : {G@.+} ]
#+TAGS: [ AOF : {AOF@.+} ]
#+TAGS: [ Project : {P@.+} ]
Searching for the tag βProject
β now lists all tags also including regular expression matches for βP@.+
β, and similarly for tag searches on βVision
β, βGoal
β and βAOF
β. For example, this would work well for a project tagged with a common project-identifier, e.g., βP@2014_OrgTags
β.
If you want to ignore group tags temporarily, toggle group tags support with org-toggle-tags-groups
, bound to C-c C-x q
. If you want to disable tag groups completely, set org-group-tags
to nil
.