Org Mode Manual
***************

This manual is for Org-mode (version 3.04).

Copyright © 2004 Free Software Foundation

     Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being ``A GNU Manual,'' and with the Back-Cover Texts as in (a) below.  A copy of the license is included in the section entitled ``GNU Free Documentation License.''

     (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify this GNU Manual, like GNU software.  Copies published by the Free Software Foundation raise funds for GNU development.''

Introduction
************

Summary
=======

Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing project planning with a fast and effective plain-text system.

Org-mode develops organizational tasks around NOTES files that contain information about projects as plain text.  Org-mode is implemented on top of outline-mode, which makes it possible to keep the content of large files well structured.  Visibility cycling and structure editing help to work with the tree.  Tables are easily created with a built-in table editor.  Org-mode supports ToDo items, deadlines, time stamps, and scheduling.  It dynamically compiles entries into an agenda. Plain text URL-like links connect to websites, emails, usenet messages, BBDB entries, and any files related to the projects.  For printing and sharing of notes, an Org-mode file can be exported as a structured ASCII file, or as HTML.

Org-mode keeps simple things simple.  Not every outline branch needs to be an action item, not every action item needs to have priority or scheduling information associated with it.  Org-mode can be used on different levels and in different ways, for example

     * as an outline extension with visibility cycling and structure editing
     * as an ASCII system and table editor to take structured notes
     * as a simple hypertext system, with HTML export
     * as a TODO list editor
     * as a full agenda and planner with deadlines and work scheduling

The Org-mode table editor can be used integrated into any major mode by activating the minor Ortbl-mode.

There is a website for Org-mode which provides links to the newest version of Org-mode, as well as additional information, screen shots and example files.  This page is located at http://www.astro.uva.nl/~dominik/Tools/org/.

Installation
============

The instructions below assume that you have downloaded Org-mode from the web.  If Org-mode is part of the Emacs distribution or an XEmacs package, you only need to add to .emacs the last three Lisp lines below - all the rest will be taken care of automatically.

Byte-compile org.el and put it on your load path.  If you'd like to use the Info documentation, copy the file org into the directory containing info files and run the command install-info org.

Then copy the following lines into .emacs.  The last two lines define global keys for the commands org-store-link and org-agenda - please choose suitable keys yourself.

     (autoload 'org-mode "org" "Org mode" t)
     (autoload 'org-diary "org" "Diary entries from Org mode")
     (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t)
     (autoload 'org-store-link "org" "Store a link to the current location" t)
     (autoload 'orgtbl-mode "org" "Org tables as a minor mode" t)
     (autoload 'turn-on-orgtbl "org" "Org tables as a minor mode")
     (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
     (define-key global-map "\C-cl" 'org-store-link)
     (define-key global-map "\C-ca" 'org-agenda)

This will put all files with extension .org into Org-mode.  As an alternative, make the first line of a file look like this:

     MY PROJECTS    -*- mode: org; -*-

which will select Org-mode for this buffer no matter what the file's name is.

Document Structure
******************

Org-mode is based on outline mode and provides flexible commands to edit the structure of the document.

Outlines
========

Org-mode is implemented on top of outline-mode.  Outlines allow to organize a document in a hierarchical structure, which (at least for me) is the best representation of notes and thoughts.  Overview over this structure is achieved by folding (hiding) large parts of the document to show only the general document structure and the parts currently being worked on.  Org-mode greatly simplifies the use of outlines by compressing the entire show/hide functionality into a single command org-cycle, which is bound to the TAB key.

Headlines
=========

Headlines define the structure of an outline tree.  The Headlines in Org-mode start with one or more stars, for example

     * Top level headline
     ** Second level
     *** 3rd level
         some text
     *** 3rd level
         more text
     * Another top level headline

Visibility cycling
==================

Outlines make it possible to hide parts of the text in the buffer. Org-mode uses a single command bound to the TAB key to change the visibility in the buffer.

TAB
     Rotate current subtree between the states

          ,-> FOLDED -> CHILDREN -> SUBTREE --.
          '-----------------------------------'

     At the beginning of the buffer (or when called with C-u), this does the same as the command S-TAB below.

S-TAB
     Rotate the entire buffer between the states

          ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
          '--------------------------------------'

     Note that inside tables, S-TAB jumps to the previous field.

C-c C-a
     Show all.

Motion
======

The following commands jump to other headlines in the buffer.

C-c C-n
     Next heading.

C-c C-p
     Previous heading.

C-c C-f
     Next heading same level.

C-c C-b
     Previous heading same level.

C-c C-u
     Backward to higher level heading.

C-c C-j
     Jump to a different place without changing the current outline visibility.  Shows the document structure in a temporary buffer, where you can use visibility cycling (TAB) to find your destination. After pressing RET, the cursor moves to the selected location in the original buffer, and the headings hierarchy above it is made visible.

Structure editing
=================

M-RET
     Insert new heading with same level as current

M-left
     Promote current heading by one level

M-right
     Demote current heading by one level

M-S-left
     Promote the current subtree by one level

M-S-right
     Demote the current subtree by one level

M-S-up
     Move subtree up (swap with previous subtree of same level)

M-S-down
     Move subtree down (swap with next subtree of same level)

C-c C-h C-w
     Kill subtree, i.e. remove it from buffer but save in kill ring.

C-c C-h M-w
     Copy subtree to kill ring.

C-c C-h C-y
     Yank subtree from kill ring.  This does modify the level of subtree to make sure the tree fits in nicely at the yank position.  The yank level can also be specified with a prefix arg, or by yanking after a headline marker like ****.

When there is an active region (transient-mark-mode), promotion and demotion work on all headlines in the region.  To select a region of headlines, it is best to place both point and mark at the beginning of a line, mark at the beginning of the first headline, and point at the line just after the last headline to change.  Note that when the cursor is inside a table (see Tables), the Meta-Cursor keys have different functionality.

Sparse trees
============

An important feature of Org-mode is the ability to construct sparse trees for selected information in an outline tree.  A sparse tree means that the entire document is folded as much as possible, but the selected information is made visible along with the headline structure above it.  Just try it out and you will see immediately how it works.

Org-mode contains several commands creating such trees.  The most basic one is org-occur:

C-c /
     Occur.  Prompts for a regexp and shows a sparse tree with all matches. If the match is in a headline, the headline is made visible.  If the match is in the body of an entry, headline and body are made visible. In order to provide minimal context, also the full hierarchy of headlines above the match is shown, as well as the headline following the match.

Other commands are using this feature as well.  For example C-c C-v creates a sparse TODO tree (see TODO basics).

TODO items
**********

Org-mode does not maintain TODO lists as a separate document.  TODO items are an integral part of the notes file, because TODO items usually come up while taking notes!  With Org-mode, you simply mark any entry in a tree as being a TODO item.  In this way, the information is not duplicated, and the entire context from which the item emerged is always present when you check.

Of course, this technique causes TODO items to be scattered throughout your file.  Org-mode provides methods to give you an overview over all things you have to do.

Basic TODO functionality
========================

Any headline can become a TODO item by starting it with the word TODO, for example

     *** TODO Write letter to Sam Fortune

The most important commands to work with TODO entries are:

C-c C-t
     Rotate the TODO state of the current item between

          ,-> (unmarked) -> TODO -> DONE --.
          '--------------------------------'

C-c C-v
     View TODO items in a sparse tree (see Sparse trees).  Folds the entire buffer, but shows all TODO items and the headings hierarchy above them.  With prefix arg, show also the DONE entries.

Priorities
==========

If you use Org-mode extensively to organize your work, you may end up with a number of TODO entries so large that you'd like to prioritize them.  You can do this by placing a priority cookie into the headline, like this

     *** TODO [#A] Write letter to Sam Fortune

With its standard setup, Org-mode supports priorities A, B, and C.  A is the highest priority.  An entry without a cookie is treated as priority B.  Priorities make a difference only in the multi-file agenda (see Agenda (multiple files)).

C-c ,
     Set the priority of the current item.  The command prompts for a priority character A, B or C.  When you press SPC instead, the priority cookie is removed from the headline.

S-up
S-down
     Increase/decrease priority of current item.  Note that these keys are also used to modify time stamps (see Creating timestamps).

Extended use of TODO keywords
=============================

The default implementation of TODO entries is just two states:  TODO and DONE.  You can, however, use the TODO feature for more complicated things by configuring the variables org-todo-keywords and org-todo-interpretation.  Using special setup, you can even use TODO keywords in different ways in different org files.

TODO keywords as workflow states
--------------------------------

You can use TODO keywords to indicate different states in the process of working on an item, for example

     (setq org-todo-keywords '("TODO" "FEEDBACK" "VERIFY" "DONE")
           org-todo-interpretation 'sequence)

With this setup, the command C-c C-t will cycle an entry from TODO to FEEDBACK, then to VERIFY, and finally too DONE.  You may also use a prefix argument to quickly select a specific state.  For example C-3 C-c C-t will change the state immediately to VERIFY. If you define many keywords, you can use in-buffer completion (see Completion) to insert these words into the buffer.

TODO keywords as types
----------------------

The second possibility is to use TODO keywords to indicate different types of action items.  For example, when you work with several people on a single project, you might want to assign action items to persons.

     (setq org-todo-keywords '("Fred" "Sara" "Lucy" "Mike" "DONE")
           org-todo-interpretation 'type)

In this case, different keywords do not indicate a sequence, but rather different levels.  This changes the behavior of the command C-c C-t slightly.  When used several times in succession, it will still cycle through all names.  But when when you return to the item after some time and execute C-c C-t again, it will switch from each name directly to DONE.  Use prefix arguments or completion to quickly select a specific name.

Setting up TODO keywords for individual files
---------------------------------------------

It can be very useful to use different aspects of the TODO mechanism in different files.  For this you need to add special lines to the file which set the keywords and interpretation for that file only. For example, to set one of the two examples discussed above, you need one of the following lines, starting in column zero anywhere in the file:

     #+SEQ_TODO: TODO FEEDBACK VERIFY DONE
     #+TYP_TODO: Fred Sara Lucy Mike DONE

To make sure you are using the correct keyword, type #+ into the buffer and then use M-TAB completion.

Remember that the last keyword must always mean that the item is DONE (you may use a different word, though).  After changing these lines, use M-x normal-mode to make the changes known to Org-mode.  Also note that in each file, only one of the two aspects of TODO keywords can be used.

If you want to use very many keywords, for example when working with a large group of people, you may split the names over several lines:

     #+TYP_TODO: Fred Sara Lucy Mike
     #+TYP_TODO: Luis George Jules Jessica
     #+TYP_TODO: Kim Arnold Peter
     #+TYP_TODO: DONE

Tables
******

For taking notes, tables are an essential tool because they allow immediate and clear structuring of data.  Org-mode has a very fast and intuitive table editor built-in.  More complex tables can be created with the Emacs table.el package.

The built-in table editor
=========================

Org-mode makes it easy to format tables in plain ASCII.  Any line with | as the first non-white character is considered part of a table.  | is also the column separator.  A table might look like this:

     | Name  | Phone | Age |
     |-------+-------+-----|
     | Peter |  1234 |  17 |
     | Anna  |  4321 |  25 |

A table is re-aligned automatically each time you press TAB or RET inside the table.  TAB also moves to the next field (RET to the next row) and creates new table rows at the end of the table or before horizontal lines.  The indentation of the table is set by the first line.  Any line starting with |- is considered as a horizontal separator line and will be expanded on the next re-align to span the whole table width.  So, to create the above table, you would only type

     |Name|Phone|Age
     |-

and then press TAB to align the table and start filling in fields.

Creation and conversion
.......................

C-c C-c
Recognize table.el table.  Works when the cursor is in a table.el table

C-c C-c
Convert region to table.  Works when the cursor is not in an existing table, and when there is a region defined.  If every line contains at least one TAB character, the function assumes that the material is tab separated.  If not, lines are split at whitespace into fields.  You can use a prefix argument to indicate how many consecutive spaces are at least required to indicate a field separator (default: just one).

M-x org-table-create
Creates an empty Org-mode table.  However, it is much easier to just start typing, like |Name|Phone|Age RET |- TAB

Re-aligning and field motion
............................

C-c C-c
Re-align the table without moving the cursor.

TAB
Re-align the table, move to the next field.  Creates a new row if necessary.

S-TAB
Move to previous field.

RET
Re-align the table and move down to next row.  Creates a new row if necessary.  At the beginning or end of a line, RET still does NEWLINE, so it can be used to split a table.

S-RET
Copy from first non-empty field above current field.

Column and row editing
......................

M-left
M-right
Move the current column left/right

M-S-left
Kill the current column.

M-S-right
Insert a new column to the left of the cursor position.

M-up
M-down
Move the current row up/down

M-S-up
Kill the current row or horizontal line.

M-S-down
Insert a new row above (with arg: below) the current row.

C-c -
Insert a horizontal line below current row. With prefix arg, line is created above the current line.

Regions
.......

C-c C-h M-w
Copy an rectangular region from a table to a special clipboard.  Point and mark determine edge fields of the rectangle.  The process ignores horizontal separator lines.
C-c C-h C-w
Copy an rectangular region from a table to a special clipboard, and blank all fields in the rectangle.
C-c C-h C-y
Paste a rectangluar region into a table. The upper right corner ends up in the current field.  All involved fields will be overwritten.  If the rectangle does not fit into the present table, the table is enlarged as needed.  The process ignores horizontal separator lines.
C-c C-q
Wrap several fields in a column like a paragraph.  If there is an active region, and both point and mark are in the same column, the text in the column is wrapped to minimum width for the given number of lines.  A prefix ARG may be used to change the number of desired lines.  If there is no region, the current field is split at the cursor position and the text fragment to the right of the cursor is prepended to the field one line down. If there is no region, but you specify a prefix ARG, the current field gets blank, and the content is appended to the field above.

Calculations
............

C-c ?
Which table column is the cursor in?  Displays number >0 in echo area.

C-c +
Sum the numbers in the current column, or in the rectangle defined by the active region.  The result is displayed in the echo area and can be inserted with C-y.

C-c =
Replace current field with the result of a formula.  Requires the Emacs calc package.  The formula can access the current field with $, and the other fields in the current row with $1, $2,...  For details see the documentation of the command org-table-eval-formula.

Miscellaneous
.............

C-c |
Toggle the visibility of vertical lines in tables.  The lines are still there, only made invisible with a text property.  Any | added by hand will become invisible on the next align. Typographically it is good style to have no vertical lines in tables.

M-x org-table-import
Import a file as a table.  The table should be TAB- or whitespace separated.  Useful for example to import an Excel table or data from a database, because these programs generally can write TAB-separated text files.  This command works by inserting the file into the buffer and then converting the region to a table.  Any prefix argument is passed on to the converter, which uses it to determine the separator.

M-x org-table-export
Export the table as a TAB-separated file.  Useful for data exchange with for example Excel or database programs.

If you don't like the automatic table editor because it gets into your way in lines which you would like to start with |, you can turn it off with

     (setq org-enable-table-editor nil)

The only table command which then still works is C-c C-c to do a manual re-align.

The table.el package
====================

More complex ASCII tables (with automatic line wrapping, column- and row-spanning, and alignment) can be created using the Emacs table package by Takaaki Ota (http://sourceforge.net/projects/table). When TAB or C-c C-c is pressed in such a table, Org-mode will call table-recognize-table and move the cursor into the table.  Inside a table, the keymap of Org-mode is inactive.  In order to execute org-related commands, leave the table.

C-c #
     Insert a table.el table.  If there is already a table at point, this command converts it between the table.el format and the Org-mode format.  See the documentation string of the command org-convert-table for the restrictions under which this is possible.

The Orgtbl minor mode
=====================

If you like the intuitive way the Org-mode table editor works, you might want to use it also in other modes like text-mode or mail-mode. The minor mode Orgtbl-mode make this possible.  You can always toggle the mode with M-x orgtbl-mode.  To turn it on by default, for example in mail mode, use

     (add-hook 'mail-mode-hook 'turn-on-orgtbl)

Hyperlinks
**********

Just like HMTL, Org-mode provides links to other files, usenet articles, emails and much more.

Links
=====

Org-mode supports links to files, websites, usenet and email messages; and BBDB database entries.  Links are just plain-text URL-like locators. The following list shows examples for each link type.

     http://www.astro.uva.nl/~dominik         on the web
     file:/home/dominik/images/jupiter.jpg    file, absolute path
     file:papers/last.pdf                     file, relative path
     file:~/code/main.c:255                   file, with line number
     news:comp.emacs                          Usenet link
     mailto:adent@galaxy.net                  Mail link
     vm:folder                                VM folder link
     vm:folder#id                             VM message link
     vm://myself@some.where.org/folder#id     VM on remote machine
     wl:folder                                WANDERLUST folder link
     wl:folder#id                             WANDERLUST message link
     rmail:folder                             RMAIL folder link
     rmail:folder#id                          RMAIL message link
     gnus:group                               GNUS group link
     gnus:group#id                            GNUS article link
     bbdb:Richard Stallman                    BBDB link
     shell:ls *.org                           A shell command

A link may contain space characters and is terminated by the end of the line.  Therefore, there can be only one link per line (but see the variable org-allow-space-in-links).

C-c l
     Store a link to the current location.  This is a global command which can be used in any buffer to create a link.  The link will be stored for later insertion into an Org-mode buffer (see below).  For VM, RMAIL, WANDERLUST, GNUS and BBDB buffers, the link will point to the current article/entry.  For W3 and W3M buffer, the link goes to the current URL.  For any other files, the link will just point to the file. The key binding C-c l is only a suggestion - see Installation.

C-c C-l
     Insert a link.  This prompts for a link to be inserted into the buffer.  You can just type a link, using one of the link type prefixes mentioned in the examples above.  Through completion, all links stored during the current session can be accessed.  When called with prefix arg, you can use file name completion to enter a file link.  Note that you don't have to use this command to insert a link.  Links in Org-mode are plain text, and you can type or paste them straight into the buffer.

C-c C-o
     Open link at point.  This will launch a web browser for URLs (using browse-url-at-point), run vm/gnus/bbdb for the corresponding links, execute the command in a shell link, visit text files with Emacs and select a suitable application for non-text files. Classification of files is based on file extension only.  See option org-file-apps.  If there is no link at point, the current subtree will be searched for one.  If you want to override the default application and visit the file with Emacs, use a C-u prefix. If the cursor is on a time stamp, compiles the agenda for that date.

     IMPORTANT: Be careful not to use any dangerous commands in a shell link.

mouse-2
     On links, mouse-2 will open the link just like C-c C-o would.

mouse-3
     Like mouse-2, but force file links to be opened with Emacs.

Remember
========

Another way to create org entries with links to other files is through the Remember package by John Wiegley.  Remember lets you store quick notes with little interruption of your work flow.  See http://www.emacswiki.org/cgi-bin/wiki/RememberMode for more information.  The notes produced by Remember can be stored in different ways, and Org-mode files are a good target. Org-mode allows to file away notes either to a default file, or directly to the correct location in your Org-mode outline tree.  The following customization will tell Remember to use org files as target, and to create annotations compatible with Org-mode links.

     (autoload 'org-remember-annotation "org")
     (autoload 'org-remember-handler "org")
     (setq org-directory "~/path/to/my/orgfiles/")
     (setq org-default-notes-file "~/.notes")
     (setq remember-annotation-functions '(org-remember-annotation))
     (setq remember-handler-functions '(org-remember-handler))

When you compose a note with remember, you have to press C-c C-c to exit remember-mode and to file away the note.  The handler first prompts for a target file - if you press RET, the value of org-default-notes-file is used.  Then the command offers the headings tree of the selected file.  You can either immediately press RET to get the note appended to the file.  Or you can use vertical cursor motion (up and down) and visibility cycling (TAB) to find a better place.  Pressing RET or left or right leads to the following result.

Cursor position   Key   Note gets inserted
buffer-start   RET   as level 2 heading at end of file
on headline   RET   as sublevel of the heading at cursor
  left    as same level, before current heading
  right   as same level, after current heading
not on headline   RET
at cursor position, level taken from context.
Or use prefix arg to specify level manually.

So the fastest way to store the note is to press C-c C-c RET RET to append it to the default file.  But with little extra effort, you can push it directly to the correct location.

Before inserting the text into a tree, the function ensures that the text has a headline, i.e. a first line that starts with a *. If not, a headline is constructed from the current date and some additional data.  If the variable org-adapt-indentation is non-nil, the entire text is also indented so that it starts in the same column as the headline (after the asterixes).

Timestamps
**********

Items can be labeled with timestamps to make them useful for project planning.

Time stamps, deadlines and scheduling
=====================================

A time stamp is a specification of a date (possibly with time) in a special format, either <2003-09-16 Tue> or <2003-09-16 Tue 09:39>.  A time stamp can appear anywhere in the headline or body of an org-tree entry.  Its presence allows to show entries on specific dates in the agenda (see Agenda (multiple files)).  We distinguish:

TIMESTAMP
     A simple time stamp just assigns a date/time to an item.  In the timeline and agenda displays, the headline of the entry will be shown exactly on that date.

TIMERANGE
     Two time stamps connected by -- denote a time range.  The headline will be shown on the first and last day of the range, and on any dates that are displayed and fall in the range.  Here is an example:

          ** Meeting in Amsterdam
             <2004-08-23 Mon>--<2004-08-26 Thu>

DEADLINE
     If a time stamp is preceded by the word DEADLINE:, the task (most likely a TODO item) is supposed to be finished on that date, and it will be listed then.  In addition, the compilation for the current day will carry a warning about the approaching or missed deadline, starting org-deadline-warning-days before the due date, and continuing until the entry is marked DONE.  An example:

          *** TODO write article about the Earth for the Guide
              The editor in charge is bbdb:Ford Prefect
              DEADLINE: <2004-02-29 Sun>

SCHEDULED
     If a time stamp is preceded by the word SCHEDULED:, it means you are planning to start working on that task on the given date.  The headline will be listed under the given date.  In addition, a reminder that the scheduled date has passed will be present in the compilation for the current day, until the entry is marked DONE.  I.e., the task will automatically be forwarded.

Creating timestamps
===================

For Org-mode to recognize time stamps, they need to be in the specific format.  All commands listed below produce time stamps in the correct format.

C-c .
     Prompt for a date and insert a corresponding time stamp.  When the cursor is at a previously used time stamp, it is updated to NOW.  When this command is used twice in succession, a time range is inserted.

C-u C-c .
     Like C-c ., but use the alternative format which contains date and time.

C-c <
     Insert a time stamp corresponding to the cursor date in the Calendar.

C-c >
     Access the Emacs calendar for the current date.  If there is a timestamp in the current line, goto the corresponding date instead.

C-c C-o
     Access the agenda for the date given by the time stamp at point (see Agenda (multiple files)).

C-c C-d
     Insert DEADLINE keyword along with a stamp.

C-c C-w
     Create a sparse tree with all deadlines that are either past-due, or which will become due within org-deadline-warning-days. With C-u prefix, show all deadlines in the file.  With a numeric prefix, check that many days.  For example, C-1 C-c C-w shows all deadlines due tomorrow.

C-c C-s
     Insert SCHEDULED keyword along with a stamp.

S-left
S-right
     Change date at cursor by one day.

S-up
S-down
     Change the item under the cursor in a timestamp.  The cursor can be on a year, month, day, hour or minute.  Note that if the cursor is not at a time stamp, these same keys modify the priority of an item (see Priorities).

C-c C-y
     Evaluate a time range by computing the difference between start and end.  With prefix arg, insert result after the time range (in a table: into the following column).

When org prompts for a date/time, the function reading your input will replace anything you choose not to specify with the current date and time.  For details, see the documentation string of org-read-date.  Also, a calender will pop up to allow selecting a date.  The calendar can be fully controlled from the minibuffer, and a date can be selected with the following commands:

<
     Scroll calendar backwards by one month.

>
     Scroll calendar forwards by one month.

mouse-1
     Select date by clicking on it.

S-right
     One day forward.

S-left
     One day back.

S-down
     One week forward.

S-up
     One week back.

M-S-right
     One month forward.

M-S-left
     One month back.

RET
     Choose date in calendar (only if nothing typed into minibuffer).

Timeline and Agenda
*******************

We have already described three commands to filter important information in an org file into a sparse tree (see Sparse trees):

  * The TODO tree, (C-c C-v), see TODO items.

  * The occur tree C-c /, see TODO items.

  * Checking upcoming deadlines with C-c C-w, see Creating timestamps.

Instead of using the sparse trees, Org-mode can also collect and time-sort the important items into a separate buffer, which we call the timeline of the org file.  It can also collect information from a list of files and in this way provide an agenda which covers all of your current projects, action items and appointments.

Timeline for a single file
==========================

The timeline shows all time-stamped items in a single Org-mode file, in time-sorted view.  The main purpose of this command is to give an overview over events in a project.

C-c C-r
     Show a time-sorted view of the org file, with all time-stamped items of today or later.  When called with a C-u prefix, past dates will be included as well.  When called with two C-u C-u prefixes, all unfinished TODO entries (scheduled or not) are also listed under the current date.

The timeline is shown in a temporary buffer *Org Agenda*.  The commands available in the Agenda buffer are listed in Agenda commands.

Agenda from multiple files
==========================

An agenda can be compiled from one or more org files.  The main purpose of this command is to act like a planner, in order to show you what tasks are up for the current week, similar to a paper agenda.

The Org-mode files to be processed in order to generate the agenda are listed in the variable org-agenda-files.  You can customize this variable, but the easiest way to maintain it is through the following commands

C-c [
     Add current file to the list of agenda files

C-c ]
     Remove current file from the list of agenda files.

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

The global command org-agenda compiles the agenda from all listed files.

C-c a
     Compile an agenda for the current week from a list of org files.  The agenda shows the entries for each day.  With a C-u prefix (or when the variable org-agenda-include-all-todo is t), all unfinished TODO items (also those without a date) are also listed at the beginning of the buffer, before the first date.

     The key binding C-c a is only a suggestion - see Installation.

The commands available in the Agenda buffer are listed in Agenda commands.

Categories
----------

In the agenda buffer, each entry is preceded by a category, which is derived from the file name.  You can also set the category of a file through file variables, for example by making the first line of the file look like this:

     Planet Finder -*- mode: org; org-category: Cheops -*-

Or, like with TODO keywords (see Per file keywords), you can insert a special line anywhere in the file:

     #+CATEGORY: Cheops

The display looks best if the category is no longer than 10 characters.

Sorting of agenda items
-----------------------

The entries for each day are sorted.  The default order is to first collect all items containing an explicit time-of-day specification. These entries will be 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 priority (see Priorities).

A time-of-day specification looks like 12:45 or 3pm and must appear in the headline.  For example, a timestamp in a headline that contains not only a date but also a time will trigger this mechanism.  Specifications of a time in diary entries are recognized as well, so the schedule will be mixed from diary entries and Org-mode files.

The priority is a numerical quantity composed of the base priority (2000 for priority A, 1000 for B, and 0 for C), plus additional increments for overdue scheduled or deadline items.

Sorting can be customized using the variable org-agenda-sorting-strategy.

Commands in the agenda buffer
=============================

Entries in the agenda buffer are linked back to the org file.  You are not allowed to edit the agenda buffer itself, but commands are provided to edit the org-files ``remotely'' from the agenda buffer.  In this way, all information is stored only once, and you don't risk that your agenda and note files diverge.

Some commands can be executed with mouse clicks on agenda lines.  For the other commands, the cursor needs to be in the desired line.  Most commands are available for both timelines and the agenda.  The exceptions are marked.

View/GoTo org file
..................

mouse-3
SPC
Display the original location of the item in another window.

l
Display original location and recenter that window.

mouse-2
TAB
Go to the original location of the item in another window.

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

f
Toggle follow mode.  In follow mode, as you move the cursor through the agenda buffer, the other window always shows the corresponding location in the org file.

Change display
..............

o
Delete other windows.

w
Toggle between weekly and daily view.

d
Toggle the inclusion of diary entries.  See Calendar/Diary integration.

r
Recreate the agenda buffer, for example to reflect the changes after modification of the time stamps of items with S-left and S-right.

right
Display the following org-agenda-ndays days.  For example, if the display covers a week, switch to the following week.  With prefix arg, go forward that many times org-agenda-ndays days.  Not available in timlines.

left
Display the previous dates.  Not available in timelines.

.
Goto today.

Remote editing
..............

0-9
Digit argument.

t
Change the TODO state of the item, both in the agenda and in the original org file.

p
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.

p
Display weighted priority of current item.

+
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.

-
Decrease the priority of the current item.

S-right
Change the time stamp associated with the current line by one day into the future.  With prefix argument, change it by that many days.  For example, 3 6 5 S-right will change it by a year.  The stamp is changed in the original org file, but the change is not directly reflected in the agenda buffer.  Use the r key to update the buffer.

S-left
Change the time stamp associated with the current line by one day into the past.

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

i
Insert a new entry into the diary.  Prompts for the type of entry (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new entry in the diary, just like i d etc. would do in the calendar. The date is taken from the cursor position.

Quit and Exit
.............

q
Quit Agenda, remove the agenda buffer.

x
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 will not be removed.

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 to keep track of anniversaries, lunar phases, sunrise/set, recurrent appointments (weekly, monthly) and more.  In this way, it is quite complementary to Org-mode.  It can be very useful to combine output from Org-mode with the diary.

The interaction between Org-mode and diary works both ways: You can list entries from the diary in the Org-mode agenda, or you can display entries from the org agenda in the Emacs diary.

Including the diary into the agenda
-----------------------------------

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 will happen automatically.

Including the agenda into the diary
-----------------------------------

If you prefer to use the Emacs diary as your main instrument and if you wish to include the Org-mode agenda into it, the following steps are necessary: Autoload the function org-diary as shown above under Installation.  You also need to use fancy diary display by setting in .emacs:

     (add-hook 'diary-display-hook 'fancy-diary-display)

Then include the following line into your ~/diary file, in order to get the entries from all files listed in the variable org-agenda-files:

     &%%(org-diary)

You may also select specific files with

     &%%(org-diary) ~/path/to/some/org-file.org
     &%%(org-diary) ~/path/to/another/org-file.org

If you now launch the calendar and press d to display a diary, the headlines of entries containing a timestamp, date range, schedule, or deadline referring to the selected date will be listed.  Just like in Org-mode's agenda view, the diary for today contains additional entries for overdue deadlines and scheduled items.  See also the documentation of the org-diary function.

Exporting
*********

For printing and sharing of notes, an Org-mode document can be exported as an ASCII file, or as HTML.  In the exported version, the first 3 outline levels will become headlines, defining a general document structure.  Additional levels will be exported as itemize lists.  If you want that transition to occur at a different level, specify it with a prefix argument.  For example,

     M-1 M-x org-export-as-html

creates only top level headlines and does the rest as items.

Export commands
===============

C-c C-x a
     Export as ASCII file.  If there is an active region, only the region will be exported.  For an org file myfile.org, the ASCII file will be myfile.txt.  The file will be overwritten without warning.

C-c C-x h
     Export as HTML file myfile.html.

C-c C-x C-h
     Export as HTML file and open it with a browser.

C-c C-x t
     Insert template with export options, see below.

C-c :
     Toggle fixed-width for line or region, see below.

HTML formatting
===============

Not all text is transferred literally to the exported HTML file.  The exporter implements the following interpretation:

  * You can make words *bold*, /italic/, and _underlined_

  * Simple TeX-like math constructs are interpreted:

       - 10^22 and J_n are super- and subscripts.  You can quote ^ and _ with a backslash: \_ and \^

       - \alpha indicates a Greek letter, \to an arrow.  You can use completion for these macros, just type \ and maybe a few letters, and press M-TAB to see possible completions.

  * Tables are transformed into HTML tables.

  * Lines starting with : are typeset in a fixed-width font, to allow quoting of computer code etc.

  * If you want to include HTML tags which should be interpreted as such, mark them with a @ like in @<b>bold text@</b>. Plain < and > are always transformed to &lt; and &gt; in HTML export.

If these conversions conflict with your habits of typing ASCII text, they can all be turned off with corresponding variables.

Export options
==============

The exporter recognizes special lines in the buffer which provide additional information.  These lines may be put anywhere in the file. The whole set of lines can be inserted into the buffer with C-c C-x t.  For individual lines, a good way to make sure the keyword is correct it to type #+ and then use M-TAB completion (see Completion).

     #+TITLE:     the title to be shown (default is the buffer name)
     #+AUTHOR:    the author (default taken from user-full-name)
     #+EMAIL:     his/her email address (default from user-mail-address)
     #+LANGUAGE:  language for HTML, e.g. en (org-export-default-language)
     #+TEXT:      Some descriptive text to be inserted at the beginning.
     #+TEXT:      Several lines may be given.
     #+OPTIONS:   H:2  num:t  toc:t  \n:nil  t  ::t  |:t  ^:t  *:nil  TeX:t

The OPTIONS line is a compact form to specify export settings.  Here you can

     H:      set the number of headline levels for export
     num:    turn on/off section-numbers
     toc:    turn on/off table of contents
     \n:     turn on/off linebreak-preservation
     @:      turn on/off quoted html tags
     ::      turn on/off fixed-width sections
     |:      turn on/off tables
     ^:      turn on/off TeX-like syntax for sub- and superscripts.
     *:      turn on/off emphasized text (bold, italic, underlined)
     TeX:    turn on/off TeX macros

Comment lines
=============

Lines starting with # in column zero are treated as comments and will never be exported.  Also entire subtrees starting with the word COMMENT will never be exported.  Finally, any text before the first headline will not be exported either.

C-c ;
     Toggle the COMMENT keyword at the beginning of an entry.

Miscellaneous
*************

Completion
==========

Org-mode supports in-buffer completion.  This type of completion does not make use of the minibuffer.  You simply type a few letters into the buffer and use the key to complete text right there.

M-TAB
     Complete word at point

       * At the beginning of a headline, complete TODO keywords.

       * After \, complete TeX symbols supported by the exporter.

       * After #+, complete the special keywords like TYP_TODO or OPTIONS which set file-specific options for Org-mode.  When the option keyword is already complete, pressing M-TAB again will insert example settings for this keyword.

       * Elsewhere, complete dictionary words using ispell.

Customization
=============

There is a large number of variables which can be used to customize Org-mode.  For the sake of compactness of the manual, we are not describing the variables here.  For an overview of customization variables, use M-x org-customize.  Or select Browse Org Group from the Org->Customization menu.

Tips and Tricks
===============

  * I find Org-mode very useful for the many README files I have scattered through my directories.  So I turn on org-mode for all README files with

          (add-to-list 'auto-mode-alist '("README$" . org-mode))

  * It can be useful to have two different windows showing the same Org-mode file.  However, a problem here is that changes to the visibility in one window immediately affect the other window.  On Emacs (not on XEmacs because it uses the old outline-mode) a way out is the use of indirect buffers, which visit the same file, but have separate settings, also for outline visibility.  See the documentation on the command make-indirect-buffer.

  * Paste URLs into Org-mode whenever this seems useful.  For example, if you are writing notes about a paper which is available on the web, put the corresponding URL there and a direct look at the paper is only a mouse click away.  If you have a local copy of the paper, use a file:path link.

  * If you plan to use ASCII or HTML export, make sure things you want to be exported as item lists are level 4 at least, even if that does mean there is a level jump.  For example

          * Todays top priorities
          **** TODO write a letter to xyz
          **** TODO Finish the paper
          **** Pick up kids at the school

     Alternatively, if you need a specific value for the heading/item transition in a particular file, use the +OPTIONS line to configure the H switch.

          +OPTIONS:   H:2; ...

  * If you want to export a subtree, mark the subtree as region and then export.  Marking can be done with C-c @ C-x C-x, for example.

  * To insert an empty table template, just type |- and use TAB.

  * In a table, to add a new column at the end, just type some text anywhere after the final |.  Upon the next re-align, a new column will be created.

  * In tables, TAB creates new rows before horizontal separator lines.  If the cursor is at Age in the following table,

          | Name  | Phone | Age |
          |-------+-------+-----|
          |       |       |     |

     the next TAB would create a second header line.  If you want instead to go to the first empty field below the horizontal line, press down (to get on the separator line) and then TAB.

  * To change the indentation of a table, just change the first line and realign with TAB.

Interaction with other packages
===============================

Org.el can cooperate with the following packages:

remember.el by John Wiegley
     Org mode cooperates with remember, see Remember.

planner.el by John Wiegley
     Planner is another tool to plan work and keep track of tasks.  Planner uses a multi-file approach with project pages and day pages.  Is based on Emacs-Wiki.  It can be useful to display the agenda entries resulting from org files in day-pages of the planner.  This can be done through the diary of the calendar: Integrate org files into the diary as described above, and then turn on the diary support of planner.

table.el by Takaaki Ota
     Org mode cooperates with table.el, see table.el.

Acknowledgments
===============

Org-mode was written by Carsten Dominik, who still maintains it at the Org-mode homepage http://www.astro.uva.nl/~dominik/Tools/org/.  The following people have helped the development along with ideas, suggestions and patches.

  * Matthias Rempe (Oelde) provided ideas and suggestions, a patch introducing Windows NT/2000 support, and quality control.

  * Kevin Rogers contributed code to access VM files on remote hosts.

  * Juergen Vollmer contributed code generating the table of contents in HTML output, and other export improvements.

  * Christian Egli converted the documentation into TeXInfo format.  He also showed me his plans for a multifile summary for Org-mode. Some of his ideas have found their way into the agenda.

  * Philip Rooke created the Org-mode reference card and did some beta-testing.

  * Linking to VM/BBDB/GNUS was inspired by Tom Shannon's organizer-mode.el.

  * Scheduling TODO items was inspired by John Wiegley's planner.el.

  * Sacha Chua, the current maintainer of Planner suggested to take some linking code from Planner, which I did (for RMAIL and Wanderlust).

  * Oliver Oppitz sent several useful suggestions.

  * Carsten Wimmer suggested some changes and helped fix a bug in linking to GNUS.

Bugs
====

Here is a list of things which should work differently, but which I have found too hard to fix.

  * When the application called by C-c C-o to open a file link fails (for example because the application does not exits or refuses to open the file), it does so silently.  No error message is displayed.

  * Under XEmacs, if Org-mode entries are included into the diary, it is not possible to jump back from the diary to the org file.  Apparently, the text properties are lost when the fancy-diary-display is used. However, from Org-mode's agenda (created with C-c C-r or M-x org-agenda), things do work correctly.

  * Linux should also have a default viewer application, using mailcap. Maybe we can use GNUS or VM mime code?  Or dired's guessing commands? Any hints (or even patches) are appreciated.

  * When you write x = a /b/ c, b will be exported in italics.

  * The exporters work well, but could be made more efficient.