GNU Emacs
Org
Agenda Views

Agenda Views

Due to the way Org works, TODO items, time-stamped items, and tagged headlines can be scattered throughout a file or even a number of files. To get an overview of open action items, or of events that are important for a particular date, this information must be collected, sorted and displayed in an organized way.

Org can select items based on various criteria and display them in a separate buffer. Six 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 text search view that shows all entries from multiple files that contain specified keywords,
  • a stuck projects view showing projects that currently do not move along, and
  • custom views that are special searches and combinations of different views.

The extracted information is displayed in a special agenda buffer. This buffer is read-only, but provides commands to visit the corresponding locations in the original Org files, and even to edit these files remotely.

By default, the report ignores commented (see Comment Lines) and archived (see Internal archiving) entries. You can override this by setting org-agenda-skip-comment-trees and org-agenda-skip-archived-trees to nil.

Two variables control how the agenda buffer is displayed and whether the window configuration is restored when the agenda exits: org-agenda-window-setup and org-agenda-restore-windows-after-quit.

Agenda Files

The information to be shown is normally collected from all agenda files, the files listed in the variable ~org-agenda-files~(note: If the value of that variable is not a list, but a single file name, then the list of agenda files in maintained in that external file.). If a directory is part of this list, all files with the extension .org in this directory are part of the list.

Thus, even if you only work with a single Org file, that file should be put into the list(note: When using the dispatcher, pressing < before selecting a command actually limits the command to the current file, and ignores org-agenda-files until the next dispatcher command.). You can customize org-agenda-files, but the easiest way to maintain it is through the following commands

C-c [ (org-agenda-file-to-front)

Add current file to the list of agenda files. The file is added to the front of the list. If it was already in the list, it is moved to the front. With a prefix argument, file is added/moved to the end.

C-c ] (org-remove-file)

Remove current file from the list of agenda files.

C-' and C-\, (org-cycle-agenda-files)

Cycle through agenda file list, visiting one file after the other.

M-x org-switchb

Command to use an Iswitchb-like interface to switch to and between Org buffers.

The Org menu contains the current list of files and can be used to visit any of them.

If you would like to focus the agenda temporarily on a file not in this list, or on just one file in the list, or even on only a subtree in a file, then this can be done in different ways. For a single agenda command, you may press < once or several times in the dispatcher (see The Agenda Dispatcher). To restrict the agenda scope for an extended period, use the following commands:

C-c C-x < (org-agenda-set-restriction-lock)

Restrict the agenda to the current subtree. If there already is a restriction at point, remove it. When called with a universal prefix argument or with point before the first headline in a file, set the agenda scope to the entire file. This restriction remains in effect until removed with C-c C-x >, or by typing either < or > in the agenda dispatcher. If there is a window displaying an agenda view, the new restriction takes effect immediately.

C-c C-x > (org-agenda-remove-restriction-lock)

Remove the restriction created by C-c C-x <.

When working with Speedbar, you can use the following commands in the Speedbar frame:

< (org-speedbar-set-agenda-restriction)

Restrict the agenda to the item—either an Org file or a subtree in such a file—at point in the Speedbar frame. If agenda is already restricted there, remove the restriction. If there is a window displaying an agenda view, the new restriction takes effect immediately.

> (org-agenda-remove-restriction-lock)

Remove the restriction.

The Agenda Dispatcher

The views are created through a dispatcher, accessible with M-x org-agenda, or, better, bound to a global key (see Activation). It displays a menu from which an additional letter is required to execute a command. The dispatcher offers the following default commands:

a
Create the calendar-like agenda (see Weekly/daily agenda).
t, T
Create a list of all TODO items (see The global TODO list).
m, M
Create a list of headlines matching a given expression (see Matching tags and properties).
s

Create a list of entries selected by a boolean expression of keywords and/or regular expressions that must or must not occur in the entry.

/

Search for a regular expression in all agenda files and additionally in the files listed in org-agenda-text-search-extra-files. This uses the Emacs command multi-occur. A prefix argument can be used to specify the number of context lines for each match, the default is 1.

#
Create a list of stuck projects (see Stuck projects).
!
Configure the list of stuck projects (see Stuck projects).
<

Restrict an agenda command to the current buffer(note: For backward compatibility, you can also press 1 to restrict to the current buffer.). If narrowing is in effect restrict to the narrowed part of the buffer. After pressing <, you still need to press the character selecting the command.

< <

If there is an active region, restrict the following agenda command to the region. Otherwise, restrict it to the current subtree. After pressing < <, you still need to press the character selecting the command.

*

Toggle sticky agenda views. By default, Org maintains only a single agenda buffer and rebuilds it each time you change the view, to make sure everything is always up to date. If you switch between views often and the build time bothers you, you can turn on sticky agenda buffers (make this the default by customizing the variable org-agenda-sticky). With sticky agendas, the dispatcher only switches to the selected view, you need to update it by hand with r or g. You can toggle sticky agenda view any time with org-toggle-sticky-agenda.

You can also define custom commands that are accessible through the dispatcher, just like the default commands. This includes the possibility to create extended agenda buffers that contain several blocks together, for example the weekly agenda, the global TODO list and a number of special tags matches. See Custom Agenda Views.

The Built-in Agenda Views

In this section we describe the built-in views.

Weekly/daily agenda

The purpose of the weekly/daily agenda is to act like a page of a paper agenda, showing all the tasks for the current week or day.

M-x org-agenda a (org-agenda-list)

Compile an agenda for the current week from a list of Org files. The agenda shows the entries for each day. With a numeric prefix

argument33—like C-u 2 1 M-x org-agenda a—you may set the number of days to be displayed.

The default number of days displayed in the agenda is set by the variable org-agenda-span. This variable can be set to any number of days you want to see by default in the agenda, or to a span name, such a day, week, month or year. For weekly agendas, the default is to start on the previous Monday (see org-agenda-start-on-weekday). You can also set the start date using a date shift: (setq org-agenda-start-day "+10d") starts the agenda ten days from today in the future. org-agenda-start-on-weekday takes precedence over org-agenda-start-day in weekly and bi-weekly agendas.

Remote editing from the agenda buffer means, for example, that you can change the dates of deadlines and appointments from the agenda buffer. The commands available in the Agenda buffer are listed in Commands in the Agenda Buffer.

Calendar/Diary integration

Emacs contains the calendar and diary by Edward M. Reingold. The calendar displays a three-month calendar with holidays from different countries and cultures. The diary allows you to keep track of anniversaries, lunar phases, sunrise/set, recurrent appointments (weekly, monthly) and more. In this way, it is quite complementary to Org. It can be very useful to combine output from Org with the diary.

In order to include entries from the Emacs diary into Org mode's agenda, you only need to customize the variable

(setq org-agenda-include-diary t)

After that, everything happens automatically. All diary entries including holidays, anniversaries, etc., are included in the agenda buffer created by Org mode. SPC, TAB, and RET can be used from the agenda buffer to jump to the diary file in order to edit existing diary entries. The i command to insert new entries for the current date works in the agenda buffer, as well as the commands S, M, and C to display Sunrise/Sunset times, show lunar phases and to convert to other calendars, respectively. c can be used to switch back and forth between calendar and agenda.

If you are using the diary only for expression entries and holidays, it is faster to not use the above setting, but instead to copy or even move the entries into an Org file. Org mode evaluates diary-style expression entries, and does it faster because there is no overhead for first creating the diary display. Note that the expression entries must start at the left margin, no whitespace is allowed before them, as seen in the following segment of an Org file:(note: The variable org-anniversary used in the example is just like diary-anniversary, but the argument order is always according to ISO and therefore independent of the value of calendar-date-style.)

* Holidays
  :PROPERTIES:
  :CATEGORY: Holiday
  :END:
%%(org-calendar-holiday)   ; special function for holiday names

* Birthdays
  :PROPERTIES:
  :CATEGORY: Ann
  :END:
%%(org-anniversary 1956  5 14) Arthur Dent is %d years old
%%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
Anniversaries from BBDB

If you are using the Insidious Big Brother Database to store your contacts, you very likely prefer to store anniversaries in BBDB rather than in a separate Org or diary file. Org supports this and can show BBDB anniversaries as part of the agenda. All you need to do is to add the following to one of your agenda files:

* Anniversaries
  :PROPERTIES:
  :CATEGORY: Anniv
  :END:
%%(org-bbdb-anniversaries)

You can then go ahead and define anniversaries for a BBDB record. Basically, you need a field named anniversary for the BBDB record which contains the date in the format YYYY-MM-DD or MM-DD, followed by a space and the class of the anniversary (birthday, wedding, or a format string). If you omit the class, it defaults to birthday. Here are a few examples, the header for the file ol-bbdb.el contains more detailed information.

1973-06-22
06-22
1955-08-02 wedding
2008-04-14 %s released version 6.01 of Org mode, %d years ago

After a change to BBDB, or for the first agenda display during an Emacs session, the agenda display suffers a short delay as Org updates its hash with anniversaries. However, from then on things will be very fast, much faster in fact than a long list of %%(diary-anniversary) entries in an Org or Diary file.

If you would like to see upcoming anniversaries with a bit of forewarning, you can use the following instead:

* Anniversaries
  :PROPERTIES:
  :CATEGORY: Anniv
  :END:
%%(org-bbdb-anniversaries-future 3)

That will give you three days' warning: on the anniversary date itself and the two days prior. The argument is optional: if omitted, it defaults to 7.

Appointment reminders

Org can interact with Emacs appointments notification facility. To add the appointments of your agenda files, use the command org-agenda-to-appt. This command lets you filter through the list of your appointments and add only those belonging to a specific category or matching a regular expression. It also reads a APPT_WARNTIME property which overrides the value of appt-message-warning-time for this appointment. See the docstring for details.

The global TODO list

The global TODO list contains all unfinished TODO items formatted and collected into a single place.

M-x org-agenda t (org-todo-list)

Show the global TODO list. This collects the TODO items from all agenda files (see Agenda Views) into a single buffer. By default, this lists items with a state that is not a DONE state. The buffer is in Agenda mode, so there are commands to examine and manipulate the TODO entries directly from that buffer (see Commands in the Agenda Buffer).

M-x org-agenda T (org-todo-list)

Like the above, but allows selection of a specific TODO keyword. You can also do this by specifying a prefix argument to t. You are prompted for a keyword, and you may also specify several keywords by separating them with | as the boolean OR operator. With a numeric prefix, the Nth keyword in org-todo-keywords is selected.

The r key in the agenda buffer regenerates it, and you can give a prefix argument to this command to change the selected TODO keyword, for example 3 r. If you often need a search for a specific keyword, define a custom command for it (see The Agenda Dispatcher).

Matching specific TODO keywords can also be done as part of a tags search (see Tag Searches).

Remote editing of TODO items means that you can change the state of a TODO entry with a single key press. The commands available in the TODO list are described in Commands in the Agenda Buffer.

Normally the global TODO list simply shows all headlines with TODO keywords. This list can become very long. There are two ways to keep it more compact:

Some people view a TODO item that has been scheduled for execution or have a deadline (see Timestamps) as no longer open. Configure the variables org-agenda-todo-ignore-scheduled to exclude some or all scheduled items from the global TODO list, org-agenda-todo-ignore-deadlines to exclude some or all items with a deadline set, org-agenda-todo-ignore-timestamp to exclude some or all items with an active timestamp other than a DEADLINE or a SCHEDULED timestamp and/or org-agenda-todo-ignore-with-date to exclude items with at least one active timestamp.

TODO items may have sublevels to break up the task into subtasks. In such cases it may be enough to list only the highest level TODO headline and omit the sublevels from the global list. Configure the variable org-agenda-todo-list-sublevels to get this behavior.

Matching tags and properties

If headlines in the agenda files are marked with tags (see Tags), or have properties (see Properties and Columns), 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.

M-x org-agenda m (org-tags-view)

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 The Agenda Dispatcher).

M-x org-agenda M (org-tags-view)

Like m, but only select headlines that are also TODO items. To exclude scheduled/deadline items, see the variable org-agenda-tags-todo-honor-ignore-options. Matching specific TODO keywords together with a tags match is also possible, see Tag Searches.

The commands available in the tags list are described in Commands in the Agenda Buffer.

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.

+work-boss
Select headlines tagged work, but discard those also tagged boss.
work|laptop
Selects lines tagged work or laptop.
work|laptop+night
Like before, but require the laptop lines to be tagged also night.

Instead of a tag, you may also specify a regular expression enclosed in curly braces (see Regular Expressions). For example, work+{^boss.*} matches headlines that contain the tag :work: and any tag starting with boss.

Group tags (see Tag Hierarchy) are expanded as regular expressions. E.g., if work is a group tag for the group :work:lab:conf:, then searching for work also searches for {\(?:work\|lab\|conf\)} and searching for -work searches for all headlines but those with one of the tags in the group (i.e., -{\(?:work\|lab\|conf\)}).

You may also test for properties (see Properties and Columns) at the same time as matching tags. The properties may be real properties, or special properties that represent other metadata (see Special Properties). For example, the property TODO represents the TODO keyword of the entry. Or, the property LEVEL represents the level of an entry. So searching +LEVEL=3+boss-TODO​"DONE"= lists all level three headlines that have the tag boss and are not marked with the TODO keyword DONE. In buffers with org-odd-levels-only set, LEVEL does not count the number of stars, but LEVEL=2 corresponds to 3 stars etc.

Here are more examples:

work+TODO​"WAITING"=
Select work-tagged TODO lines with the specific TODO keyword WAITING.
work+TODO​"WAITING"|home+TODO​="WAITING"=
Waiting tasks both at work and at home.

When matching properties, a number of different operators can be used to test the value of a property. Here is a complex example:

+work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<*2
         +With={Sarah\|Denny}+SCHEDULED>="<2008-10-11>"

The type of comparison depends on how the comparison value is written:

  • If the comparison value is a plain number, a numerical comparison is done, and the allowed operators are <, =, >, <=, >=, and <>. As a synonym for the equality operator =, there is also ==; != and /= are synonyms of the inequality operator <>.
  • If the comparison value is enclosed in double-quotes, a string comparison is done, and the same operators are allowed.
  • If the comparison value is enclosed in double-quotes and angular brackets (like DEADLINE<​"<2008-12-24 Wed 18:30>"=), both values are assumed to be date/time specifications in the standard Org way, and the comparison is done accordingly. Valid values also include "<now>" for now (including time), "<today>", and "<tomorrow>" for these days at 0:00 hours, i.e., without a time specification. You can also use strings like "<+5d>" or "<-2m>" with units d, w, m, and y for day, week, month, and year, respectively.
  • If the comparison value is enclosed in curly braces, a regexp match is performed, with = meaning that the regexp matches the property value, and <> meaning that it does not match.
  • All operators may be optionally followed by an asterisk *, like in <*, !=*, etc. Such starred operators work like their regular, unstarred counterparts except that they match only headlines where the tested property is actually present. This is most useful for search terms that logically exclude results, like the inequality operator.

So the search string in the example finds entries tagged work but not boss, which also have a priority value A, a Coffee property with the value unlimited, an EFFORT property that is numerically smaller than 2, a With property that is matched by the regular expression Sarah\|Denny, and that are scheduled on or after October 11, 2008.

Note that the test on the EFFORT property uses operator <*, so that the search result will include only entries that actually have an EFFORT property defined and with numerical value smaller than 2. With the regular < operator, the search would handle entries without an EFFORT property as having a zero effort and would include them in the result as well.

You can use all characters valid in property names when matching properties. However, you have to quote some characters in property names with backslashes when using them in search strings, namely all characters different from alphanumerics and underscores(note: If you quote alphanumeric characters or underscores with a backslash, that backslash is ignored.). For example, to search for all entries having a property boss-prio, boss:prio, or boss\prio, respectively, with value C, use search strings

boss\-prio="C"
boss\:prio="C"
boss\\prio="C"

You can configure Org mode to use property inheritance during a search, but beware that this can slow down searches considerably. See Property Inheritance, for details.

For backward compatibility, and also for typing speed, there is also a different way to test TODO states in a search. For this, terminate the tags/property part of the search string (which may include several terms connected with |) with a / and then specify a Boolean expression just for TODO keywords. The syntax is then similar to that for tags, but should be applied with care: for example, a positive selection on several TODO keywords cannot meaningfully be combined with boolean AND. However, negative selection combined with AND can be meaningful. To make sure that only lines are checked that actually have any TODO keyword (resulting in a speed-up), use M-x org-agenda M, or equivalently start the TODO part after the slash with !. Using M-x org-agenda M or /! does not match TODO keywords in a DONE state. Examples:

work/WAITING
Same as work+TODO​"WAITING"=.
work/!-WAITING-NEXT
Select work-tagged TODO lines that are neither WAITING nor NEXT.
work/!+WAITING|+NEXT
Select work-tagged TODO lines that are either WAITING or NEXT.

Search view

This agenda view is a general text search facility for Org mode entries. It is particularly useful to find notes.

M-x org-agenda s (org-search-view)

This is a special search that lets you select entries by matching a substring or specific words using a boolean logic.

For example, the search string computer equipment matches entries that contain computer equipment as a substring, even if the two words are separated by more space or a line break.

Search view can also search for specific keywords in the entry, using Boolean logic. The search string +computer +wifi -ethernet -{8\.11[bg]} matches note entries that contain the keywords computer and wifi, but not the keyword ethernet, and which are also not matched by the regular expression 8\.11[bg], meaning to exclude both 8.11b and 8.11g. The first + is necessary to turn on boolean search, other + characters are optional. For more details, see the docstring of the command org-search-view.

You can incrementally and conveniently adjust a boolean search from the agenda search view with the following keys

[ Add a positive search word
] Add a negative search word
{ Add a positive regular expression
} Add a negative regular expression

Note that in addition to the agenda files, this command also searches the files listed in org-agenda-text-search-extra-files.

Stuck projects

If you are following a system like David Allen's GTD to organize your work, one of the "duties" you have is a regular review to make sure that all projects move along. A stuck project is a project that has no defined next actions, so it never shows up in the TODO lists Org mode produces. During the review, you need to identify such projects and define next actions for them.

M-x org-agenda # (org-agenda-list-stuck-projects)

List projects that are stuck.

M-x org-agenda !

Customize the variable org-stuck-projects to define what a stuck project is and how to find it.

You almost certainly need to configure this view before it works for you. The built-in default assumes that all your projects are level-2 headlines, and that a project is not stuck if it has at least one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.

Let's assume that you, in your own way of using Org mode, identify projects with a tag :PROJECT:, and that you use a TODO keyword MAYBE to indicate a project that should not be considered yet. Let's further assume that the TODO keyword DONE marks finished projects, and that NEXT and TODO indicate next actions. The tag :@shop: indicates shopping and is a next action even without the NEXT tag. Finally, if the project contains the special word IGNORE anywhere, it should not be listed either. In this case you would start by identifying eligible projects with a tags/TODO match (see Tag Searches) +PROJECT/-MAYBE-DONE, and then check for TODO, NEXT, @shop, and IGNORE in the subtree to identify projects that are not stuck. The correct customization for this is:

(setq org-stuck-projects
      '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@shop")
        "\\<IGNORE\\>"))

Note that if a project is identified as non-stuck, the subtree of this entry is searched for stuck projects.

Presentation and Sorting

Before displaying items in an agenda view, Org mode visually prepares the items and sorts them. Each item occupies a single line. The line starts with a prefix that contains the category (see Categories) of the item and other important information. You can customize in which column tags are displayed through org-agenda-tags-column. You can also customize the prefix using the option org-agenda-prefix-format. This prefix is followed by a cleaned-up version of the outline headline associated with the item.

Categories

The category is a broad label assigned to each agenda item. By default, the category is simply derived from the file name, but you can also specify it with a special line in the buffer, like this:

#+CATEGORY: Thesis

If you would like to have a special category for a single entry or a (sub)tree, give the entry a CATEGORY property with the special category you want to apply as the value.

The display in the agenda buffer looks best if the category is not longer than 10 characters. You can set up icons for category by customizing the org-agenda-category-icon-alist variable.

Time-of-day specifications

Org mode checks each agenda item for a time-of-day specification. The time can be part of the timestamp that triggered inclusion into the agenda, for example

<2005-05-10 Tue 19:00>

Time ranges can be specified with two timestamps:

<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>

In the headline of the entry itself, a time(range)—like 12:45 or a 8:30-1pm—may also appear as plain text(note: You can, however, disable this by setting org-agenda-search-headline-for-time variable to a nil value.).

If the agenda integrates the Emacs diary (see Weekly/daily agenda), time specifications in diary entries are recognized as well.

For agenda display, Org mode extracts the time and displays it in a standard 24 hour format as part of the prefix. The example times in the previous paragraphs would end up in the agenda like this:

 8:30-13:00 Arthur Dent lies in front of the bulldozer
12:45...... Ford Prefect arrives and takes Arthur to the pub
19:00...... The Vogon reads his poem
20:30-22:15 Marvin escorts the Hitchhikers to the bridge

If the agenda is in single-day mode, or for the display of today, the timed entries are embedded in a time grid, like

 8:00...... ------------------
 8:30-13:00 Arthur Dent lies in front of the bulldozer
10:00...... ------------------
12:00...... ------------------
12:45...... Ford Prefect arrives and takes Arthur to the pub
14:00...... ------------------
16:00...... ------------------
18:00...... ------------------
19:00...... The Vogon reads his poem
20:00...... ------------------
20:30-22:15 Marvin escorts the Hitchhikers to the bridge

The time grid can be turned on and off with the variable org-agenda-use-time-grid, and can be configured with org-agenda-time-grid.

Sorting of agenda items

Before being inserted into a view, the items are sorted. How this is done depends on the type of view.

For the daily/weekly agenda, the items for each day are sorted. The default order is to first collect all items containing an explicit time-of-day specification. These entries are shown at the beginning of the list, as a schedule for the day. After that, items remain grouped in categories, in the sequence given by org-agenda-files. Within each category, items are sorted by urgency, which is composed of the base priority (see Priorities; 2000 for priority A, 1000 for B, and 0 for C), plus additional increments for overdue scheduled or deadline items.

  • For the TODO list, items remain in the order of categories, but within each category, sorting takes place according to urgency. The urgency used for sorting derives from the priority cookie, with additions depending on how close an item is to its due or scheduled date.
  • For tags matches, items are not sorted at all, but just appear in the sequence in which they are found in the agenda files.

Sorting can be customized using the variable org-agenda-sorting-strategy, and may also include criteria based on the estimated effort of an entry (see Effort Estimates).

Filtering/limiting agenda items

Agenda built-in or custom commands are statically defined. Agenda filters and limits allow flexibly narrowing down the list of agenda entries.

Filters only change the visibility of items, are very fast and are

mostly used interactively34. You can switch quickly between different filters without having to recreate the agenda. Limits on the other hand take effect before the agenda buffer is populated, so they are mostly useful when defined as local variables within custom agenda commands.

Filtering in the agenda

The general filtering command is org-agenda-filter, bound to /. Before we introduce it, we describe commands for individual filter types. All filtering commands handle prefix arguments in the same way: A single C-u prefix negates the filter, so it removes lines selected by the filter. A double prefix adds the new filter condition to the one(s) already in place, so filter elements are accumulated.

\ (org-agenda-filter-by-tag)

Filter the agenda view with respect to a tag. You are prompted for a tag selection letter; SPC means any tag at all. Pressing TAB at that prompt offers completion to select a tag, including any tags that do not have a selection character. The command then hides all entries that do not contain or inherit this tag. Pressing + or - at the prompt switches between filtering for and against the next tag. To clear the filter, press \ twice (once to call the command again, and once at the prompt).

< (org-agenda-filter-by-category)

Filter by category of the line at point, and show only entries with this category. When called with a prefix argument, hide all entries with the category at point. To clear the filter, call this command again by pressing <.

= (org-agenda-filter-by-regexp)

Filter the agenda view by a regular expression: only show agenda entries matching the regular expression the user entered. To clear the filter, call the command again by pressing =.

_ (org-agenda-filter-by-effort)

Filter the agenda view with respect to effort estimates, so select tasks that take the right amount of time. You first need to set up a list of efforts globally, for example

(setq org-global-properties
      '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))

You can then filter for an effort by first typing an operator, one of <, > and =, and then the one-digit index of an effort estimate in your array of allowed values, where 0 means the 10th value. The filter then restricts to entries with effort smaller-or-equal, equal, or larger-or-equal than the selected value. For application of the operator, entries without a defined effort are treated according to the value of org-sort-agenda-noeffort-is-high. To clear the filter, press _ twice (once to call the command again, and once at the first prompt).

^ (org-agenda-filter-by-top-headline)

Filter the current agenda view and only display items that fall under the same top-level headline as the current entry. To clear the filter, call this command again by pressing ^.

/ (org-agenda-filter)

This is the unified interface to four of the five filter methods described above. At the prompt, specify different filter elements in a single string, with full completion support. For example,

+work-John+<0:10-/plot/

selects entries with category work and effort estimates below 10 minutes, and deselects entries with tag John or matching the regexp plot (see Regular Expressions). You can leave + out if that does not lead to ambiguities. The sequence of elements is arbitrary. The filter syntax assumes that there is no overlap between categories and tags. Otherwise, tags take priority. If you reply to the prompt with the empty string, all filtering is removed. If a filter is specified, it replaces all current filters. But if you call the command with a double prefix argument, or if you add an additional + (e.g., ++work) to the front of the string, the new filter elements are added to the active ones. A single prefix argument applies the entire filter in a negative sense.

| (org-agenda-filter-remove-all)
Remove all filters in the current agenda view.
Computed tag filtering

If the variable org-agenda-auto-exclude-function is set to a user-defined function, that function can select tags that should be used as a tag filter when requested. The function will be called with lower-case versions of all tags represented in the current view. The function should return "-tag" if the filter should remove entries with that tag, "+tag" if only entries with this tag should be kept, or nil if that tag is irrelevant. For example, let's say you use a Net tag to identify tasks which need network access, an Errand tag for errands in town, and a Call tag for making phone calls. You could auto-exclude these tags based on the availability of the Internet, and outside of business hours, with something like this:

(defun my-auto-exclude-fn (tag)
  (when (cond ((string= tag "net")
               (/= 0 (call-process "/sbin/ping" nil nil nil
                                   "-c1" "-q" "-t1" "mail.gnu.org")))
              ((member tag '("errand" "call"))
               (let ((hr (nth 2 (decode-time))))
                 (or (< hr 8) (> hr 21)))))
    (concat "-" tag)))

(setq org-agenda-auto-exclude-function #'my-auto-exclude-fn)

You can apply this self-adapting filter by using a triple prefix argument to org-agenda-filter, i.e. press C-u C-u C-u /, or by pressing RET in org-agenda-filter-by-tag.

Setting limits for the agenda

Here is a list of options that you can set, either globally, or locally in your custom agenda views (see Custom Agenda Views).

org-agenda-max-entries

Limit the number of entries.

org-agenda-max-effort

Limit the duration of accumulated efforts (as minutes).

org-agenda-max-todos

Limit the number of entries with TODO keywords.

org-agenda-max-tags

Limit the number of tagged entries.

When set to a positive integer, each option excludes entries from other categories: for example, (setq org-agenda-max-effort 100) limits the agenda to 100 minutes of effort and exclude any entry that has no effort property. If you want to include entries with no effort property, use a negative value for org-agenda-max-effort. One useful setup is to use org-agenda-max-entries locally in a custom command. For example, this custom command displays the next five entries with a NEXT TODO keyword.

(setq org-agenda-custom-commands
      '(("n" todo "NEXT"
         ((org-agenda-max-entries 5)))))

Once you mark one of these five entry as DONE, rebuilding the agenda will again the next five entries again, including the first entry that was excluded so far.

You can also dynamically set temporary limits, which are lost when rebuilding the agenda:

~ (org-agenda-limit-interactively)

This prompts for the type of limit to apply and its value.

Commands in the Agenda Buffer

Entries in the agenda buffer are linked back to the Org file or diary file where they originate. You are not allowed to edit the agenda buffer itself, but commands are provided to show and jump to the original entry location, and to edit the Org files "remotely" from the agenda buffer. In this way, all information is stored only once, removing the risk that your agenda and note files may diverge.

Some commands can be executed with mouse clicks on agenda lines. For the other commands, point needs to be in the desired line.

Motion

n (org-agenda-next-line)

Next line (same as DOWN and C-n).

p (org-agenda-previous-line)

Previous line (same as UP and C-p).

View/Go to Org file

SPC or mouse-3 (org-agenda-show-and-scroll-up)

Display the original location of the item in another window. With a prefix argument, make sure that drawers stay folded.

L (org-agenda-recenter)

Display original location and recenter that window.

TAB or mouse-2 (org-agenda-goto)

Go to the original location of the item in another window.

RET (org-agenda-switch-to)

Go to the original location of the item and delete other windows.

F (org-agenda-follow-mode)

Toggle Follow mode. In Follow mode, as you move point through the agenda buffer, the other window always shows the corresponding location in the Org file. The initial setting for this mode in new agenda buffers can be set with the variable org-agenda-start-with-follow-mode.

C-c C-x b (org-agenda-tree-to-indirect-buffer)

Display the entire subtree of the current item in an indirect buffer. With a numeric prefix argument N, go up to level N and then take that tree. If N is negative, go up that many levels. With a C-u prefix, do not remove the previously used indirect buffer.

C-c C-o (org-agenda-open-link)

Follow a link in the entry. This offers a selection of any links in the text belonging to the referenced Org node. If there is only one link, follow it without a selection prompt.

Change display

A

Interactively select another agenda view and append it to the current view.

o

Delete other windows.

v d or short d (org-agenda-day-view)

Switch to day view. When switching to day view, this setting becomes the default for subsequent agenda refreshes. A numeric prefix argument may be used to jump directly to a specific day of the year. For example, 32 d jumps to February 1st. When setting day view, a year may be encoded in the prefix argument as well. For example, 200712 d jumps to January 12, 2007. If such a year specification has only one or two digits, it is expanded into one of the 30 next years or the last 69 years.

v w or short w (org-agenda-week-view)

Switch to week view. When switching week view, this setting becomes the default for subsequent agenda refreshes. A numeric prefix argument may be used to jump directly to a specific day of the ISO week. For example 9 w to ISO week number 9. When setting week view, a year may be encoded in the prefix argument as well. For example, 200712 w jumps to week 12 in 2007. If such a year specification has only one or two digits, it is expanded into one of the 30 next years or the last 69 years.

v m (org-agenda-month-view)

Switch to month view. Because month views are slow to create, they do not become the default for subsequent agenda refreshes. A numeric prefix argument may be used to jump directly to a specific day of the month. When setting month view, a year may be encoded in the prefix argument as well. For example, 200712 m jumps to December, 2007. If such a year specification has only one or two digits, it is expanded into one of the 30 next years or the last 69 years.

v y (org-agenda-year-view)

Switch to year view. Because year views are slow to create, they do not become the default for subsequent agenda refreshes. A numeric prefix argument may be used to jump directly to a specific day of the year.

v SPC (org-agenda-reset-view)

Reset the current view to org-agenda-span.

f (org-agenda-later)

Go forward in time to display the span following the current one. For example, if the display covers a week, switch to the following week. With a prefix argument, repeat that many times.

b (org-agenda-earlier)

Go backward in time to display earlier dates.

. (org-agenda-goto-today)

Go to today.

j (org-agenda-goto-date)

Prompt for a date and go there.

J (org-agenda-clock-goto)

Go to the currently clocked-in task in the agenda buffer.

D (org-agenda-toggle-diary)

Toggle the inclusion of diary entries. See Weekly/daily agenda.

v l or v L or short l (org-agenda-log-mode)

Toggle Logbook mode. In Logbook mode, entries that were marked as done while logging was on (see the variable org-log-done) are shown in the agenda, as are entries that have been clocked on that day. You can configure the entry types that should be included in log mode using the variable org-agenda-log-mode-items. When called with a C-u prefix argument, show all possible logbook entries, including state changes. When called with two prefix arguments C-u C-u, show only logging information, nothing else. v L is equivalent to C-u v l.

v [ or short [ (org-agenda-manipulate-query-add)

Include inactive timestamps into the current view. Only for weekly/daily agenda.

v a (org-agenda-archives-mode)

Toggle Archives mode. In Archives mode, trees that are archived (see Internal archiving) are also scanned when producing the agenda. To exit archives mode, press v a again. The initial setting for this mode in new agenda buffers can set with the variable org-agenda-start-with-archives-mode, which can be set with the same values as org-agenda-archives-mode.

v A

Toggle Archives mode. Include all archive files as well.

v R or short R (org-agenda-clockreport-mode)

Toggle Clockreport mode. In Clockreport mode, the daily/weekly agenda always shows a table with the clocked times for the time span and file scope covered by the current agenda view. The initial setting for this mode in new agenda buffers can be set with the variable org-agenda-start-with-clockreport-mode. By using a prefix argument when toggling this mode (i.e., C-u R), the clock table does not show contributions from entries that are hidden by agenda filtering(note: Only tags filtering is respected here, effort filtering is ignored.). See also the variables org-clock-report-include-clocking-task and org-agenda-clock-report-header.

v c

Show overlapping clock entries, clocking gaps, and other clocking problems in the current agenda range. You can then visit clocking lines and fix them manually. See the variable org-agenda-clock-consistency-checks for information on how to customize the definition of what constituted a clocking problem. To return to normal agenda display, press l to exit Logbook mode.

v E or short E (org-agenda-entry-text-mode)

Toggle entry text mode. In entry text mode, a number of lines from the Org outline node referenced by an agenda line are displayed below the line. The maximum number of lines is given by the variable org-agenda-entry-text-maxlines. Calling this command with a numeric prefix argument temporarily modifies that number to the prefix value.

G (org-agenda-toggle-time-grid)

Toggle the time grid on and off. See also the variables org-agenda-use-time-grid and org-agenda-time-grid.

r (org-agenda-redo), g

Recreate the agenda buffer, for example to reflect the changes after modification of the timestamps of items with S-LEFT and S-RIGHT. When the buffer is the global TODO list, a prefix argument is interpreted to create a selective list for a specific TODO keyword.

C-x C-s or short s (org-save-all-org-buffers)

Save all Org buffers in the current Emacs session, and also the locations of IDs.

C-c C-x C-c (org-agenda-columns)

Invoke column view (see Column View) in the agenda buffer. The column view format is taken from the entry at point, or, if there is no entry at point, from the first entry in the agenda view. So whatever the format for that entry would be in the original buffer (taken from a property, from a COLUMNS keyword, or from the default variable org-columns-default-format) is used in the agenda.

C-c C-x > (org-agenda-remove-restriction-lock)

Remove the restriction lock on the agenda, if it is currently restricted to a file or subtree (see Agenda Files).

M-UP (org-agenda-drag-line-backward)

Drag the line at point backward one line. With a numeric prefix argument, drag backward by that many lines.

Moving agenda lines does not persist after an agenda refresh and does not modify the contributing Org files.

M-DOWN (org-agenda-drag-line-forward)

Drag the line at point forward one line. With a numeric prefix argument, drag forward by that many lines.

Remote editing

0--9
Digit argument.
C-_ (org-agenda-undo)

Undo a change due to a remote editing command. The change is undone both in the agenda buffer and in the remote buffer.

t (org-agenda-todo)

Change the TODO state of the item, both in the agenda and in the original Org file. A prefix arg is passed through to the org-todo command, so for example a C-u prefix are will trigger taking a note to document the state change.

C-S-RIGHT (org-agenda-todo-nextset)

Switch to the next set of TODO keywords.

C-S-LEFT, org-agenda-todo-previousset

Switch to the previous set of TODO keywords.

C-k (org-agenda-kill)

Delete the current agenda item along with the entire subtree belonging to it in the original Org file. If the text to be deleted remotely is longer than one line, the kill needs to be confirmed by the user. See variable org-agenda-confirm-kill.

C-c C-w (org-agenda-refile)

Refile the entry at point.

C-c C-x C-a or short a (org-agenda-archive-default-with-confirmation)

Archive the subtree corresponding to the entry at point using the default archiving command set in org-archive-default-command. When using the a key, confirmation is required.

C-c C-x a (org-agenda-toggle-archive-tag)

Toggle the archive tag (see Internal archiving) for the current headline.

C-c C-x A (org-agenda-archive-to-archive-sibling)

Move the subtree corresponding to the current entry to its archive sibling.

C-c C-x C-s or short $ (org-agenda-archive)

Archive the subtree corresponding to the current headline. This means the entry is moved to the configured archive location, most likely a different file.

T (org-agenda-show-tags)

Show all tags associated with the current item. This is useful if you have turned off org-agenda-show-inherited-tags, but still want to see all tags of a headline occasionally.

: (org-agenda-set-tags)

Set tags for the current headline. If there is an active region in the agenda, change a tag for all headings in the region.

\, (org-agenda-priority)

Set the priority for the current item. Org mode prompts for the priority character. If you reply with SPC, the priority cookie is removed from the entry.

+ or S-UP (org-agenda-priority-up)

Increase the priority of the current item. The priority is changed in the original buffer, but the agenda is not resorted. Use the r key for this.

- or S-DOWN (org-agenda-priority-down)

Decrease the priority of the current item.

C-c C-x e or short e (org-agenda-set-effort)

Set the effort property for the current item.

C-c C-z or short z (org-agenda-add-note)

Add a note to the entry. This note is recorded, and then filed to the same location where state change notes are put. Depending on org-log-into-drawer, this may be inside a drawer.

C-c C-a (org-attach)

Dispatcher for all command related to attachments.

C-c C-s (org-agenda-schedule)

Schedule this item. With a prefix argument, remove the scheduling timestamp

C-c C-d (org-agenda-deadline)

Set a deadline for this item. With a prefix argument, remove the deadline.

S-RIGHT (org-agenda-do-date-later)

Change the timestamp associated with the current line by one day into the future. If the date is in the past, the first call to this command moves it to today. With a numeric prefix argument, change it by that many days. For example, 3 6 5 S-RIGHT changes it by a year. With a C-u prefix, change the time by one hour. If you immediately repeat the command, it will continue to change hours even without the prefix argument. With a double C-u C-u prefix, do the same for changing minutes. The stamp is changed in the original Org file, but the change is not directly reflected in the agenda buffer. Use r or g to update the buffer.

S-LEFT (org-agenda-do-date-earlier)

Change the timestamp associated with the current line by one day into the past.

> (org-agenda-date-prompt)

Change the timestamp associated with the current line. The key > has been chosen, because it is the same as S-. on my keyboard.

I (org-agenda-clock-in)

Start the clock on the current item. If a clock is running already, it is stopped first.

O (org-agenda-clock-out)

Stop the previously started clock.

X (org-agenda-clock-cancel)

Cancel the currently running clock.

J (org-agenda-clock-goto)

Jump to the running clock in another window.

k (org-agenda-capture)

Like org-capture, but use the date at point as the default date for the capture template. See org-capture-use-agenda-date to make this the default behavior of org-capture.

Bulk remote editing selected entries

m (org-agenda-bulk-mark)

Mark the entry at point for bulk action. If there is an active region in the agenda, mark the entries in the region. With numeric prefix argument, mark that many successive entries.

* (org-agenda-bulk-mark-all)

Mark all visible agenda entries for bulk action.

u (org-agenda-bulk-unmark)

Unmark entry for bulk action.

U (org-agenda-bulk-unmark-all)

Unmark all marked entries for bulk action.

M-m (org-agenda-bulk-toggle)

Toggle mark of the entry at point for bulk action.

M-* (org-agenda-bulk-toggle-all)

Toggle mark of every entry for bulk action.

% (org-agenda-bulk-mark-regexp)

Mark entries matching a regular expression for bulk action.

B (org-agenda-bulk-action)

Bulk action: act on all marked entries in the agenda. This prompts for another key to select the action to be applied. The prefix argument to B is passed through to the s and d commands, to bulk-remove these special timestamps. By default, marks are removed after the bulk. If you want them to persist, set org-agenda-bulk-persistent-marks to t or hit p at the prompt.

p
Toggle persistent marks.
$
Archive all selected entries.
A
Archive entries by moving them to their respective archive siblings.
t
Change TODO state. This prompts for a single TODO keyword and changes the state of all selected entries, bypassing blocking and suppressing logging notes—but not timestamps.
+
Add a tag to all selected entries.
-
Remove a tag from all selected entries.
s
Schedule all items to a new date. To shift existing schedule dates by a fixed number of days, use something starting with double plus at the prompt, for example ++8d or ++2w.
d
Set deadline to a specific date.
r
Prompt for a single refile target and move all entries. The entries are no longer in the agenda; refresh (g) to bring them back.
S
Reschedule randomly into the coming N days. N is prompted for. With a prefix argument (C-u B S), scatter only across weekdays.
f

Apply a function(note: You can also create persistent custom functions through org-agenda-bulk-custom-functions.) to marked entries. For example, the function below sets the CATEGORY property of the entries to web.

(defun set-category ()
  (interactive "P")
  (let ((marker (or (org-get-at-bol 'org-hd-marker)
                    (org-agenda-error))))
    (org-with-point-at marker
      (org-back-to-heading t)
      (org-set-property "CATEGORY" "web"))))

Calendar commands

c (org-agenda-goto-calendar)

Open the Emacs calendar and go to the date at point in the agenda.

c (org-calendar-goto-agenda)

When in the calendar, compute and show the Org agenda for the date at point.

i (org-agenda-diary-entry)

Insert a new entry into the diary, using the date at point and (for block entries) the date at the mark. This adds to the Emacs diary file(note: This file is parsed for the agenda when org-agenda-include-diary is set.), in a way similar to the i command in the calendar. The diary file pops up in another window, where you can add the entry.

If you configure org-agenda-diary-file to point to an Org file, Org creates entries in that file instead. Most entries are stored in a date-based outline tree that will later make it easy to archive appointments from previous months/years. The tree is built under an entry with a DATE_TREE property, or else with years as top-level entries. Emacs prompts you for the entry text—if you specify it, the entry is created in org-agenda-diary-file without further interaction. If you directly press RET at the prompt without typing text, the target file is shown in another window for you to finish the entry there. See also the k r command.

M (org-agenda-phases-of-moon)

Show the phases of the moon for the three months around current date.

S (org-agenda-sunrise-sunset)

Show sunrise and sunset times. The geographical location must be set with calendar variables, see the documentation for the Emacs calendar.

C (org-agenda-convert-date)

Convert the date at point into many other cultural and historic calendars.

H (org-agenda-holidays)

Show holidays for three months around point date.

Quit and exit

q (org-agenda-quit)

Quit agenda, remove the agenda buffer.

x (org-agenda-exit)

Exit agenda, remove the agenda buffer and all buffers loaded by Emacs for the compilation of the agenda. Buffers created by the user to visit Org files are not removed.

Custom Agenda Views

Custom agenda commands serve two purposes: to store and quickly access frequently used TODO and tags searches, and to create special composite agenda buffers. Custom agenda commands are accessible through the dispatcher (see The Agenda Dispatcher), just like the default commands.

Storing searches

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
      '(("x" agenda)
        ("y" agenda*)
        ("w" todo "WAITING")
        ("W" todo-tree "WAITING")
        ("u" tags "+boss-urgent")
        ("v" tags-todo "+boss-urgent")
        ("U" tags-tree "+boss-urgent")
        ("f" occur-tree "\\<FIXME\\>")
        ("h" . "HOME+Name tags searches") ;description for "h" prefix
        ("hl" tags "+home+Lisa")
        ("hp" tags "+home+Peter")
        ("hk" tags "+home+Kim")))

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, but if you have many similar commands, you can also define two-letter combinations where the first character is the same in several combinations and serves as a prefix key(note: You can provide a description for a prefix key by inserting a cons cell with the prefix and the description.). 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:

x

as a global search for agenda entries planned35 this week/day.

y
as the same search, but only for entries with an hour specification like [h]h:mm—think of them as appointments.
w
as a global search for TODO entries with WAITING as the TODO keyword.
W
as the same search, but only in the current buffer and displaying the results as a sparse tree.
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.
U
as the same search, but only in the current buffer and displaying the result as a sparse tree.
f
to create a sparse tree (again, current buffer only) with all entries containing the word FIXME.
h
as a prefix command for a HOME tags search where you have to press an additional key (l, p or k) to select a name (Lisa, Peter, or Kim) as additional tag to match.

Note that *-tree agenda views need to be called from an Org buffer as they operate on the current buffer only.

Block agenda

Another possibility is the construction of agenda views that comprise the results of several commands, each of which creates a block in the agenda buffer. The available commands include agenda for the daily or weekly agenda (as created with a) , alltodo for the global TODO list (as constructed with t), stuck for the list of stuck projects (as obtained with #) and the matching commands discussed above: todo, tags, and tags-todo.

Here are two examples:

(setq org-agenda-custom-commands
      '(("h" "Agenda and Home-related tasks"
         ((agenda "")
          (tags-todo "home")
          (tags "garden")))
        ("o" "Agenda and Office-related tasks"
         ((agenda "")
          (tags-todo "work")
          (tags "office")))))

This defines h to create a multi-block view for stuff you need to attend to at home. The resulting agenda buffer contains your agenda for the current week, all TODO items that carry the tag home, and also all lines tagged with garden. Finally the command o provides a similar view for office tasks.

Setting options for custom commands

Org mode contains a number of variables regulating agenda construction and display. The global variables define the behavior for all agenda commands, including the custom commands. However, if you want to change some settings just for a single custom view, you can do so. Setting options requires inserting a list of variable names and values at the right spot in org-agenda-custom-commands. For example:

(setq org-agenda-custom-commands
      '(("w" todo "WAITING"
         ((org-agenda-sorting-strategy '(priority-down))
          (org-agenda-prefix-format "  Mixed: ")))
        ("U" tags-tree "+boss-urgent"
         ((org-show-context-detail 'minimal)))
        ("N" search ""
         ((org-agenda-files '("~org/notes.org"))
          (org-agenda-text-search-extra-files nil)))))

Now the w command sorts the collected entries only by priority, and the prefix format is modified to just say Mixed: instead of giving the category of the entry. The sparse tags tree of U now turns out ultra-compact, because neither the headline hierarchy above the match, nor the headline following the match are shown. The command N does a text search limited to only a single file.

For command sets creating a block agenda, org-agenda-custom-commands has two separate spots for setting options. You can add options that should be valid for just a single command in the set, and options that should be valid for all commands in the set. The former are just added to the command entry; the latter must come after the list of command entries. Going back to the block agenda example (see Block agenda), let's change the sorting strategy for the h commands to priority-down, but let's sort the results for garden tags query in the opposite order, priority-up. This would look like this:

(setq org-agenda-custom-commands
      '(("h" "Agenda and Home-related tasks"
         ((agenda)
          (tags-todo "home")
          (tags "garden"
                ((org-agenda-sorting-strategy '(priority-up)))))
         ((org-agenda-sorting-strategy '(priority-down))))
        ("o" "Agenda and Office-related tasks"
         ((agenda)
          (tags-todo "work")
          (tags "office")))))

As you see, the values and parentheses setting is a little complex. When in doubt, use the customize interface to set this variable—it fully supports its structure. Just one caveat: when setting options in this interface, the values are just Lisp expressions. So if the value is a string, you need to add the double-quotes around the value yourself.

To control whether an agenda command should be accessible from a specific context, you can customize org-agenda-custom-commands-contexts. Let's say for example that you have an agenda command o displaying a view that you only need when reading emails. Then you would configure this option like this:

(setq org-agenda-custom-commands-contexts
      '(("o" (in-mode . "message-mode"))))

You can also tell that the command key o should refer to another command key r. In that case, add this command key like this:

(setq org-agenda-custom-commands-contexts
      '(("o" "r" (in-mode . "message-mode"))))

See the docstring of the variable for more information.

Exporting Agenda Views

If you are away from your computer, it can be very useful to have a printed version of some agenda views to carry around. Org mode can export custom agenda views as plain text, HTML(note: For HTML you need to install Hrvoje Nikšić's htmlize.el as an Emacs package from NonGNU ELPA or from Hrvoje Nikšić's repository.),

Postscript, PDF36, and iCalendar files. If you want to do this only occasionally, use the following command:

C-x C-w (org-agenda-write)

Write the agenda view to a file.

If you need to export certain agenda views frequently, you can associate any custom agenda command with a list of output file names(note: If you want to store standard views like the weekly agenda or the global TODO list as well, you need to define custom commands for them in order to be able to specify file names.). Here is an example that first defines custom commands for the agenda and the global TODO list, together with a number of files to which to export them. Then we define two block agenda commands and specify file names for them as well. File names can be relative to the current working directory, or absolute.

(setq org-agenda-custom-commands
      '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
        ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
        ("h" "Agenda and Home-related tasks"
         ((agenda "")
          (tags-todo "home")
          (tags "garden"))
         nil
         ("~/views/home.html"))
        ("o" "Agenda and Office-related tasks"
         ((agenda)
          (tags-todo "work")
          (tags "office"))
         nil
         ("~/views/office.ps" "~/calendars/office.ics"))))

The extension of the file name determines the type of export. If it is .html, Org mode uses the htmlize package to convert the buffer to HTML and save it to this file name. If the extension is .ps, ps-print-buffer-with-faces is used to produce Postscript output. If the extension is .ics, iCalendar export is run export over all files that were used to construct the agenda, and limit the export to entries listed in the agenda. Any other extension produces a plain ASCII file.

The export files are not created when you use one of those commands interactively because this might use too much overhead. Instead, there is a special command to produce all specified files in one step:

e (org-store-agenda-views)

Export all agenda views that have export file names associated with them.

You can use the options section of the custom agenda commands to also set options for the export commands. For example:

(setq org-agenda-custom-commands
      '(("X" agenda ""
         ((ps-number-of-columns 2)
          (ps-landscape-mode t)
          (org-agenda-prefix-format " [ ] ")
          (org-agenda-with-colors nil)
          (org-agenda-remove-tags t))
         ("theagenda.ps"))))

This command sets two options for the Postscript exporter, to make it print in two columns in landscape format—the resulting page can be cut in two and then used in a paper agenda. The remaining settings modify the agenda prefix to omit category and scheduling information, and instead include a checkbox to check off items. We also remove the tags to make the lines compact, and we do not want to use colors for the black-and-white printer. Settings specified in org-agenda-exporter-settings also apply, e.g.,

(setq org-agenda-exporter-settings
      '((ps-number-of-columns 2)
        (ps-landscape-mode t)
        (org-agenda-add-entry-text-maxlines 5)
        (htmlize-output-type 'css)))

but the settings in org-agenda-custom-commands take precedence.

From the command line you may also use:

emacs -eval (org-batch-store-agenda-views) -kill

or, if you need to modify some parameters(note: Quoting depends on the system you use, please check the FAQ for examples.)

emacs -eval '(org-batch-store-agenda-views                      \
              org-agenda-span (quote month)                     \
              org-agenda-start-day "2007-11-01"                 \
              org-agenda-include-diary nil                      \
              org-agenda-files (quote ("~/org/project.org")))'  \
      -kill

which creates the agenda views restricted to the file ~/org/project.org, without diary entries and with a 30-day extent.

You can also extract agenda information in a way that allows further processing by other programs. See Extracting Agenda Information, for more information.

Using Column View in the Agenda

Column view (see Column View) is normally used to view and edit properties embedded in the hierarchical structure of an Org file. It can be quite useful to use column view also from the agenda, where entries are collected by certain criteria.

C-c C-x C-c (org-agenda-columns)

Turn on column view in the agenda.

To understand how to use this properly, it is important to realize that the entries in the agenda are no longer in their proper outline environment. This causes the following issues:

Org needs to make a decision which columns format to use. Since the entries in the agenda are collected from different files, and different files may have different columns formats, this is a non-trivial problem. Org first checks if org-overriding-columns-format is currently set, and if so, takes the format from there. You should set this variable only in the local settings section of a custom agenda command (see Custom Agenda Views) to make it valid for that specific agenda view. If no such binding exists, it checks, in sequence, org-columns-default-format-for-agenda, the format associated with the first item in the agenda (through a property or a #+COLUMNS setting in that buffer) and finally org-columns-default-format.

If any of the columns has a summary type defined (see Column attributes), turning on column view in the agenda visits all relevant agenda files and make sure that the computations of this property are up to date. This is also true for the special CLOCKSUM property. Org then sums the values displayed in the agenda. In the daily/weekly agenda, the sums cover a single day; in all other views they cover the entire block.

It is important to realize that the agenda may show the same entry twice—for example as scheduled and as a deadline—and it may show two entries from the same hierarchy (for example a parent and its child). In these cases, the summation in the agenda leads to incorrect results because some values count double.

  1. When the column view in the agenda shows the CLOCKSUM property, that is always the entire clocked time for this item. So even in the daily/weekly agenda, the clocksum listed in column view may originate from times outside the current view. This has the advantage that you can compare these values with a column listing the planned total effort for a task—one of the major applications for column view in the agenda. If you want information about clocked time in the displayed period use clock table mode (press R in the agenda).

When the column view in the agenda shows the CLOCKSUM_T property, that is always today's clocked time for this item. So even in the weekly agenda, the clocksum listed in column view only originates from today. This lets you compare the time you spent on a task for today, with the time already spent—via CLOCKSUM—and with the planned total effort for it.

Footnotes

  1. 33

    For backward compatibility, the universal prefix argument C-u causes all TODO entries to be listed before the agenda. This feature is deprecated, use the dedicated TODO list, or a block agenda instead (see Block agenda).

    Backrefs: 1

  2. 34

    Custom agenda commands can preset a filter by binding one of the variables org-agenda-tag-filter-preset, org-agenda-category-filter-preset, org-agenda-effort-filter-preset or org-agenda-regexp-filter-preset as an option. This filter is then applied to the view and persists as a basic filter through refreshes and more secondary filtering. The filter is a global property of the entire agenda view—in a block agenda, you should only set this in the global options section, not in the section of an individual block.

    Backrefs: 1

  3. 35

    Planned means here that these entries have some planning information attached to them, like a timestamp, a scheduled or a deadline string. See org-agenda-entry-types on how to set what planning information is taken into account.

    Backrefs: 1

  4. 36

    To create PDF output, the Ghostscript ps2pdf utility must be installed on the system. Selecting a PDF file also creates the postscript file.

    Backrefs: 1

Manual
Org Mode 9.7.39
Source
View upstream