Fix typo in documentation.
[org-mode.git] / doc / org.texi
blobf7902cdf83664b4ad080ab7c46887941502328dd
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.06b
7 @set DATE July 2008
9 @dircategory Emacs
10 @direntry
11 * Org Mode: (org).      Outline-based notes management and organizer
12 @end direntry
14 @c Version and Contact Info
15 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
16 @set AUTHOR Carsten Dominik
17 @set MAINTAINER Carsten Dominik
18 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
19 @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
20 @c %**end of header
21 @finalout
23 @c Macro definitions
25 @c Subheadings inside a table.
26 @macro tsubheading{text}
27 @ifinfo
28 @subsubheading \text\
29 @end ifinfo
30 @ifnotinfo
31 @item @b{\text\}
32 @end ifnotinfo
33 @end macro
35 @copying
36 This manual is for Org (version @value{VERSION}).
38 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008 Free Software Foundation
40 @quotation
41 Permission is granted to copy, distribute and/or modify this document
42 under the terms of the GNU Free Documentation License, Version 1.2 or
43 any later version published by the Free Software Foundation; with no
44 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
45 and with the Back-Cover Texts as in (a) below.  A copy of the license
46 is included in the section entitled ``GNU Free Documentation License.''
48 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
49 modify this GNU manual.  Buying copies from the FSF supports it in
50 developing GNU and promoting software freedom.''
52 This document is part of a collection distributed under the GNU Free
53 Documentation License.  If you want to distribute this document
54 separately from the collection, you can do so by adding a copy of the
55 license to the document, as described in section 6 of the license.
56 @end quotation
57 @end copying
59 @titlepage
60 @title The Org Manual
62 @subtitle Release @value{VERSION}
63 @author by Carsten Dominik
65 @c The following two commands start the copyright page.
66 @page
67 @vskip 0pt plus 1filll
68 @insertcopying
69 @end titlepage
71 @c Output the table of contents at the beginning.
72 @contents
74 @ifnottex
75 @node Top, Introduction, (dir), (dir)
76 @top Org Mode Manual
78 @insertcopying
79 @end ifnottex
81 @menu
82 * Introduction::                Getting started
83 * Document Structure::          A tree works like your brain
84 * Tables::                      Pure magic for quick formatting
85 * Hyperlinks::                  Notes in context
86 * TODO Items::                  Every tree branch can be a TODO item
87 * Tags::                        Tagging headlines and matching sets of tags
88 * Properties and Columns::      Storing information about an entry
89 * Dates and Times::             Making items useful for planning
90 * Remember::                    Quickly adding nodes to the outline tree
91 * Agenda Views::                Collecting information into views
92 * Embedded LaTeX::              LaTeX fragments and formulas
93 * Exporting::                   Sharing and publishing of notes
94 * Publishing::                  Create a web site of linked Org files
95 * Miscellaneous::               All the rest which did not fit elsewhere
96 * Extensions::                  Add-ons for Org mode
97 * Hacking::                     How hack your way around
98 * History and Acknowledgments::  How Org came into being
99 * Main Index::                  An index of Org's concepts and features
100 * Key Index::                   Key bindings and where they are described
102 @detailmenu
103  --- The Detailed Node Listing ---
105 Introduction
107 * Summary::                     Brief summary of what Org does
108 * Installation::                How to install a downloaded version of Org
109 * Activation::                  How to activate Org for certain buffers
110 * Feedback::                    Bug reports, ideas, patches etc.
111 * Conventions::                 Type-setting conventions in the manual
113 Document Structure
115 * Outlines::                    Org is based on Outline mode
116 * Headlines::                   How to typeset Org tree headlines
117 * Visibility cycling::          Show and hide, much simplified
118 * Motion::                      Jumping to other headlines
119 * Structure editing::           Changing sequence and level of headlines
120 * Archiving::                   Move done task trees to a different place
121 * Sparse trees::                Matches embedded in context
122 * Plain lists::                 Additional structure within an entry
123 * Drawers::                     Tucking stuff away
124 * Orgstruct mode::              Structure editing outside Org
126 Archiving
128 * ARCHIVE tag::                 Marking a tree as inactive
129 * Moving subtrees::             Moving a tree to an archive file
131 Tables
133 * Built-in table editor::       Simple tables
134 * Narrow columns::              Stop wasting space in tables
135 * Column groups::               Grouping to trigger vertical lines
136 * Orgtbl mode::                 The table editor as minor mode
137 * The spreadsheet::             The table editor has spreadsheet capabilities
139 The spreadsheet
141 * References::                  How to refer to another field or range
142 * Formula syntax for Calc::     Using Calc to compute stuff
143 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
144 * Field formulas::              Formulas valid for a single field
145 * Column formulas::             Formulas valid for an entire column
146 * Editing and debugging formulas::  Fixing formulas
147 * Updating the table::          Recomputing all dependent fields
148 * Advanced features::           Field names, parameters and automatic recalc
150 Hyperlinks
152 * Link format::                 How links in Org are formatted
153 * Internal links::              Links to other places in the current file
154 * External links::              URL-like links to the world
155 * Handling links::              Creating, inserting and following
156 * Using links outside Org::     Linking from my C source code?
157 * Link abbreviations::          Shortcuts for writing complex links
158 * Search options::              Linking to a specific location
159 * Custom searches::             When the default search is not enough
161 Internal links
163 * Radio targets::               Make targets trigger links in plain text
165 TODO Items
167 * TODO basics::                 Marking and displaying TODO entries
168 * TODO extensions::             Workflow and assignments
169 * Progress logging::            Dates and notes for progress
170 * Priorities::                  Some things are more important than others
171 * Breaking down tasks::         Splitting a task into manageable pieces
172 * Checkboxes::                  Tick-off lists
174 Extended use of TODO keywords
176 * Workflow states::             From TODO to DONE in steps
177 * TODO types::                  I do this, Fred does the rest
178 * Multiple sets in one file::   Mixing it all, and still finding your way
179 * Fast access to TODO states::  Single letter selection of a state
180 * Per-file keywords::           Different files, different requirements
181 * Faces for TODO keywords::     Highlighting states
183 Progress logging
185 * Closing items::               When was this entry marked DONE?
186 * Tracking TODO state changes::  When did the status change?
188 Tags
190 * Tag inheritance::             Tags use the tree structure of the outline
191 * Setting tags::                How to assign tags to a headline
192 * Tag searches::                Searching for combinations of tags
194 Properties and Columns
196 * Property syntax::             How properties are spelled out
197 * Special properties::          Access to other Org mode features
198 * Property searches::           Matching property values
199 * Property inheritance::        Passing values down the tree
200 * Column view::                 Tabular viewing and editing
201 * Property API::                Properties for Lisp programmers
203 Column view
205 * Defining columns::            The COLUMNS format property
206 * Using column view::           How to create and use column view
207 * Capturing column view::       A dynamic block for column view
209 Defining columns
211 * Scope of column definitions::  Where defined, where valid?
212 * Column attributes::           Appearance and content of a column
214 Dates and Times
216 * Timestamps::                  Assigning a time to a tree entry
217 * Creating timestamps::         Commands which insert timestamps
218 * Deadlines and scheduling::    Planning your work
219 * Clocking work time::          Tracking how long you spend on a task
220 * Effort estimates::            Planning work effort in advance
222 Creating timestamps
224 * The date/time prompt::        How Org mode helps you entering date and time
225 * Custom time format::          Making dates look different
227 Deadlines and scheduling
229 * Inserting deadline/schedule::  Planning items
230 * Repeated tasks::              Items that show up again and again
232 Remember
234 * Setting up Remember::         Some code for .emacs to get things going
235 * Remember templates::          Define the outline of different note types
236 * Storing notes::               Directly get the note to where it belongs
237 * Refiling notes::              Moving a note or task to a project
239 Agenda Views
241 * Agenda files::                Files being searched for agenda information
242 * Agenda dispatcher::           Keyboard access to agenda views
243 * Built-in agenda views::       What is available out of the box?
244 * Presentation and sorting::    How agenda items are prepared for display
245 * Agenda commands::             Remote editing of Org trees
246 * Custom agenda views::         Defining special searches and views
247 * Agenda column view::          Using column view for collected entries
249 The built-in agenda views
251 * Weekly/daily agenda::         The calendar page with current tasks
252 * Global TODO list::            All unfinished action items
253 * Matching tags and properties::  Structured information with fine-tuned search
254 * Timeline::                    Time-sorted view for single file
255 * Keyword search::              Finding entries by keyword
256 * Stuck projects::              Find projects you need to review
258 Presentation and sorting
260 * Categories::                  Not all tasks are equal
261 * Time-of-day specifications::  How the agenda knows the time
262 * Sorting of agenda items::     The order of things
264 Custom agenda views
266 * Storing searches::            Type once, use often
267 * Block agenda::                All the stuff you need in a single buffer
268 * Setting Options::             Changing the rules
269 * Exporting Agenda Views::      Writing agendas to files
270 * Using the agenda elsewhere::  Using agenda information in other programs
272 Embedded LaTeX
274 * Math symbols::                TeX macros for symbols and Greek letters
275 * Subscripts and superscripts::  Simple syntax for raising/lowering text
276 * LaTeX fragments::             Complex formulas made easy
277 * Processing LaTeX fragments::  Previewing LaTeX processing
278 * CDLaTeX mode::                Speed up entering of formulas
280 Exporting
282 * Markup rules::                Which structures are recognized?
283 * Export options::              Per-file export settings
284 * The export dispatcher::       How to access exporter commands
285 * ASCII export::                Exporting to plain ASCII
286 * HTML export::                 Exporting to HTML
287 * LaTeX export::                Exporting to LaTeX
288 * XOXO export::                 Exporting to XOXO
289 * iCalendar export::            Exporting in iCalendar format
291 Markup rules
293 * Document title::              How the document title is determined
294 * Headings and sections::       The main structure of the exported document
295 * Table of contents::           If, where, how to create a table of contents
296 * Initial text::                Text before the first headline
297 * Lists::                       Plain lists are exported
298 * Paragraphs::                  What determines beginning and ending
299 * Literal examples::            Source code and other examples
300 * Include files::               Include the contents of a file during export
301 * Tables exported::             Tables are exported richly
302 * Footnotes::                   Numbers like [1]
303 * Emphasis and monospace::      To bold or not to bold
304 * TeX macros and LaTeX fragments::  Create special, rich export.
305 * Horizontal rules::            A line across the page
306 * Comment lines::               Some lines will not be exported
308 HTML export
310 * HTML Export commands::        How to invoke HTML export
311 * Quoting HTML tags::           Using direct HTML in Org mode
312 * Links::                       Transformation of links for HTML
313 * Images::                      How to include images
314 * CSS support::                 Changing the appearance of the output
315 * Javascript support::          Info and Folding in a web browser
317 LaTeX export
319 * LaTeX export commands::       How to invoke LaTeX export
320 * Quoting LaTeX code::          Incorporating literal LaTeX code
321 * Sectioning structure::        Changing sectioning in LaTeX output
323 Publishing
325 * Configuration::               Defining projects
326 * Sample configuration::        Example projects
327 * Triggering publication::      Publication commands
329 Configuration
331 * Project alist::               The central configuration variable
332 * Sources and destinations::    From here to there
333 * Selecting files::             What files are part of the project?
334 * Publishing action::           Setting the function doing the publishing
335 * Publishing options::          Tweaking HTML export
336 * Publishing links::            Which links keep working after publishing?
337 * Project page index::          Publishing a list of project files
339 Sample configuration
341 * Simple example::              One-component publishing
342 * Complex example::             A multi-component publishing example
344 Miscellaneous
346 * Completion::                  M-TAB knows what you need
347 * Customization::               Adapting Org to your taste
348 * In-buffer settings::          Overview of the #+KEYWORDS
349 * The very busy C-c C-c key::   When in doubt, press C-c C-c
350 * Clean view::                  Getting rid of leading stars in the outline
351 * TTY keys::                    Using Org on a tty
352 * Interaction::                 Other Emacs packages
353 * Bugs::                        Things which do not work perfectly
355 Interaction with other packages
357 * Cooperation::                 Packages Org cooperates with
358 * Conflicts::                   Packages that lead to conflicts
360 Extensions
362 * Extensions in the contrib directory::  These come with the Org distro
363 * Other extensions::            These you have to find on the web.
365 Hacking
367 * Adding hyperlink types::      New custom link types
368 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
369 * Dynamic blocks::              Automatically filled blocks
370 * Special agenda views::        Customized views
371 * Using the property API::      Writing programs that use entry properties
372 * Using the mapping API::       Mapping over all or selected entries
374 Tables and lists in arbitrary syntax
376 * Radio tables::                Sending and receiving
377 * A LaTeX example::             Step by step, almost a tutorial
378 * Translator functions::        Copy and modify
379 * Radio lists::                 Doing the same for lists
381 @end detailmenu
382 @end menu
384 @node Introduction, Document Structure, Top, Top
385 @chapter Introduction
386 @cindex introduction
388 @menu
389 * Summary::                     Brief summary of what Org does
390 * Installation::                How to install a downloaded version of Org
391 * Activation::                  How to activate Org for certain buffers
392 * Feedback::                    Bug reports, ideas, patches etc.
393 * Conventions::                 Type-setting conventions in the manual
394 @end menu
396 @node Summary, Installation, Introduction, Introduction
397 @section Summary
398 @cindex summary
400 Org is a mode for keeping notes, maintaining TODO lists, and doing
401 project planning with a fast and effective plain-text system.
403 Org develops organizational tasks around NOTES files that contain
404 lists or information about projects as plain text.  Org is
405 implemented on top of Outline mode, which makes it possible to keep the
406 content of large files well structured.  Visibility cycling and
407 structure editing help to work with the tree.  Tables are easily created
408 with a built-in table editor.  Org supports TODO items, deadlines,
409 time stamps, and scheduling.  It dynamically compiles entries into an
410 agenda that utilizes and smoothly integrates much of the Emacs calendar
411 and diary.  Plain text URL-like links connect to websites, emails,
412 Usenet messages, BBDB entries, and any files related to the projects.
413 For printing and sharing of notes, an Org file can be exported as a
414 structured ASCII file, as HTML, or (TODO and agenda items only) as an
415 iCalendar file.  It can also serve as a publishing tool for a set of
416 linked web pages.
418 An important design aspect that distinguishes Org from for example
419 Planner/Muse is that it encourages to store every piece of information
420 only once.  In Planner, you have project pages, day pages and possibly
421 other files, duplicating some information such as tasks.  In Org,
422 you only have notes files.  In your notes you mark entries as tasks,
423 label them with tags and timestamps.  All necessary lists like a
424 schedule for the day, the agenda for a meeting, tasks lists selected by
425 tags etc are created dynamically when you need them.
427 Org keeps simple things simple.  When first fired up, it should
428 feel like a straightforward, easy to use outliner.  Complexity is not
429 imposed, but a large amount of functionality is available when you need
430 it.  Org is a toolbox and can be used in different ways, for
431 example as:
433 @example
434 @r{@bullet{} outline extension with visibility cycling and structure editing}
435 @r{@bullet{} ASCII system and table editor for taking structured notes}
436 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
437 @r{@bullet{} TODO list editor}
438 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
439 @r{@bullet{} environment to implement David Allen's GTD system}
440 @r{@bullet{} a basic database application}
441 @r{@bullet{} simple hypertext system, with HTML and LaTeX export}
442 @r{@bullet{} publishing tool to create a set of interlinked webpages}
443 @end example
445 Org's automatic, context sensitive table editor with spreadsheet
446 capabilities can be integrated into any major mode by activating the
447 minor Orgtbl mode.  Using a translation step, it can be used to maintain
448 tables in arbitrary file types, for example in La@TeX{}.  The structure
449 editing and list creation capabilities can be used outside Org with
450 the minor Orgstruct mode.
452 @cindex FAQ
453 There is a website for Org which provides links to the newest
454 version of Org, as well as additional information, frequently asked
455 questions (FAQ), links to tutorials etc.  This page is located at
456 @uref{http://orgmode.org}.
458 @page
461 @node Installation, Activation, Summary, Introduction
462 @section Installation
463 @cindex installation
464 @cindex XEmacs
466 @b{Important:} @i{If Org is part of the Emacs distribution or an
467 XEmacs package, please skip this section and go directly to
468 @ref{Activation}.}
470 If you have downloaded Org from the Web, either as a distribution @file{.zip}
471 or @file{.tar} file, or as a GIT archive, you must take the following steps
472 to install it: Go into the unpacked Org distribution directory and edit the
473 top section of the file @file{Makefile}.  You must set the name of the Emacs
474 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
475 directories where local Lisp and Info files are kept.  If you don't have
476 access to the system-wide directories, you can simply run Org directly from
477 the distribution directory by adding the @file{lisp} subdirectory to the
478 Emacs load path.  To do this, add the following line to @file{.emacs}:
480 @example
481 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
482 @end example
484 @noindent
485 If you plan to use code from the @file{contrib} subdirectory, do a similar
486 step for this directory:
488 @example
489 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
490 @end example
492 @b{XEmacs users now need to install the file @file{noutline.el} from
493 the @file{xemacs} sub-directory of the Org distribution.  Use the
494 command:}
496 @example
497 @b{make install-noutline}
498 @end example
500 @noindent Now byte-compile the Lisp files with the shell command:
502 @example
503 make
504 @end example
506 @noindent If you are running Org from the distribution directory, this is
507 all.  If you want to install into the system directories, use
509 @example
510 make install
511 make install-info
512 @end example
514 @noindent Then add to @file{.emacs}:
516 @lisp
517 ;; This line only if Org is not part of the X/Emacs distribution.
518 (require 'org-install)
519 @end lisp
522 @node Activation, Feedback, Installation, Introduction
523 @section Activation
524 @cindex activation
525 @cindex autoload
526 @cindex global key bindings
527 @cindex key bindings, global
529 @iftex
530 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
531 PDF documentation as viewed by some PDF viewers to your .emacs file, the
532 single quote character comes out incorrectly and the code will not work.
533 You need to fix the single quotes by hand, or copy from Info
534 documentation.}
535 @end iftex
537 Add the following lines to your @file{.emacs} file.  The last two lines
538 define @emph{global} keys for the commands @command{org-store-link},
539 @command{org-agenda}, and @command{org-iswitchb} - please choose suitable
540 keys yourself.
542 @lisp
543 ;; The following lines are always needed.  Choose your own keys.
544 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
545 (global-set-key "\C-cl" 'org-store-link)
546 (global-set-key "\C-ca" 'org-agenda)
547 (global-set-key "\C-cb" 'org-iswitchb)
548 @end lisp
550 Furthermore, you must activate @code{font-lock-mode} in Org
551 buffers, because significant functionality depends on font-locking being
552 active.  You can do this with either one of the following two lines
553 (XEmacs user must use the second option):
554 @lisp
555 (global-font-lock-mode 1)                     ; for all buffers
556 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
557 @end lisp
559 @cindex Org mode, turning on
560 With this setup, all files with extension @samp{.org} will be put
561 into Org mode.  As an alternative, make the first line of a file look
562 like this:
564 @example
565 MY PROJECTS    -*- mode: org; -*-
566 @end example
568 @noindent which will select Org mode for this buffer no matter what
569 the file's name is.  See also the variable
570 @code{org-insert-mode-line-in-empty-file}.
572 @node Feedback, Conventions, Activation, Introduction
573 @section Feedback
574 @cindex feedback
575 @cindex bug reports
576 @cindex maintainer
577 @cindex author
579 If you find problems with Org, or if you have questions, remarks, or ideas
580 about it, please mail to the Org mailing list @code{emacs-orgmode@@gnu.org}.
581 If you are not a member of the mailing list, your mail will be reviewed by a
582 moderator and then passed through to the list.
584 For bug reports, please provide as much information as possible,
585 including the version information of Emacs (@kbd{C-h v emacs-version
586 @key{RET}}) and Org (@kbd{C-h v org-version @key{RET}}), as well as
587 the Org related setup in @file{.emacs}.  If an error occurs, a
588 backtrace can be very useful (see below on how to create one).  Often a
589 small example file helps, along with clear information about:
591 @enumerate
592 @item What exactly did you do?
593 @item What did you expect to happen?
594 @item What happened instead?
595 @end enumerate
596 @noindent Thank you for helping to improve this mode.
598 @subsubheading How to create a useful backtrace
600 @cindex backtrace of an error
601 If working with Org produces an error with a message you don't
602 understand, you may have hit a bug.  The best way to report this is by
603 providing, in addition to what was mentioned above, a @emph{Backtrace}.
604 This is information from the built-in debugger about where and how the
605 error occurred.  Here is how to produce a useful backtrace:
607 @enumerate
608 @item
609 Start a fresh Emacs or XEmacs, and make sure that it will load the
610 original Lisp code in @file{org.el} instead of the compiled version in
611 @file{org.elc}.  The backtrace contains much more information if it is
612 produced with uncompiled code.  To do this, either rename @file{org.elc}
613 to something else before starting Emacs, or ask Emacs explicitly to load
614 @file{org.el} by using the command line
615 @example
616 emacs -l /path/to/org.el
617 @end example
618 @item
619 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
620 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
621 @item
622 Do whatever you have to do to hit the error.  Don't forget to
623 document the steps you take.
624 @item
625 When you hit the error, a @file{*Backtrace*} buffer will appear on the
626 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
627 attach it to your bug report.
628 @end enumerate
630 @node Conventions,  , Feedback, Introduction
631 @section Typesetting conventions used in this manual
633 Org uses three types of keywords: TODO keywords, tags, and property
634 names.  In this manual we use the following conventions:
636 @table @code
637 @item TODO
638 @itemx WAITING
639 TODO keywords are written with all capitals, even if they are
640 user-defined.
641 @item boss
642 @itemx ARCHIVE
643 User-defined tags are written in lowercase; built-in tags with special
644 meaning are written with all capitals.
645 @item Release
646 @itemx PRIORITY
647 User-defined properties are capitalized; built-in properties with
648 special meaning are written with all capitals.
649 @end table
651 @node Document Structure, Tables, Introduction, Top
652 @chapter Document Structure
653 @cindex document structure
654 @cindex structure of document
656 Org is based on outline mode and provides flexible commands to
657 edit the structure of the document.
659 @menu
660 * Outlines::                    Org is based on Outline mode
661 * Headlines::                   How to typeset Org tree headlines
662 * Visibility cycling::          Show and hide, much simplified
663 * Motion::                      Jumping to other headlines
664 * Structure editing::           Changing sequence and level of headlines
665 * Archiving::                   Move done task trees to a different place
666 * Sparse trees::                Matches embedded in context
667 * Plain lists::                 Additional structure within an entry
668 * Drawers::                     Tucking stuff away
669 * Orgstruct mode::              Structure editing outside Org
670 @end menu
672 @node Outlines, Headlines, Document Structure, Document Structure
673 @section Outlines
674 @cindex outlines
675 @cindex Outline mode
677 Org is implemented on top of Outline mode.  Outlines allow a
678 document to be organized in a hierarchical structure, which (at least
679 for me) is the best representation of notes and thoughts.  An overview
680 of this structure is achieved by folding (hiding) large parts of the
681 document to show only the general document structure and the parts
682 currently being worked on.  Org greatly simplifies the use of
683 outlines by compressing the entire show/hide functionality into a single
684 command @command{org-cycle}, which is bound to the @key{TAB} key.
686 @node Headlines, Visibility cycling, Outlines, Document Structure
687 @section Headlines
688 @cindex headlines
689 @cindex outline tree
691 Headlines define the structure of an outline tree.  The headlines in
692 Org start with one or more stars, on the left margin@footnote{See
693 the variable @code{org-special-ctrl-a/e} to configure special behavior
694 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
696 @example
697 * Top level headline
698 ** Second level
699 *** 3rd level
700     some text
701 *** 3rd level
702     more text
704 * Another top level headline
705 @end example
707 @noindent Some people find the many stars too noisy and would prefer an
708 outline that has whitespace followed by a single star as headline
709 starters.  @ref{Clean view} describes a setup to realize this.
711 An empty line after the end of a subtree is considered part of it and
712 will be hidden when the subtree is folded.  However, if you leave at
713 least two empty lines, one empty line will remain visible after folding
714 the subtree, in order to structure the collapsed view.  See the
715 variable @code{org-cycle-separator-lines} to modify this behavior.
717 @node Visibility cycling, Motion, Headlines, Document Structure
718 @section Visibility cycling
719 @cindex cycling, visibility
720 @cindex visibility cycling
721 @cindex trees, visibility
722 @cindex show hidden text
723 @cindex hide text
725 Outlines make it possible to hide parts of the text in the buffer.
726 Org uses just two commands, bound to @key{TAB} and
727 @kbd{S-@key{TAB}} to change the visibility in the buffer.
729 @cindex subtree visibility states
730 @cindex subtree cycling
731 @cindex folded, subtree visibility state
732 @cindex children, subtree visibility state
733 @cindex subtree, subtree visibility state
734 @table @kbd
735 @kindex @key{TAB}
736 @item @key{TAB}
737 @emph{Subtree cycling}: Rotate current subtree among the states
739 @example
740 ,-> FOLDED -> CHILDREN -> SUBTREE --.
741 '-----------------------------------'
742 @end example
744 The cursor must be on a headline for this to work@footnote{see, however,
745 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
746 beginning of the buffer and the first line is not a headline, then
747 @key{TAB} actually runs global cycling (see below)@footnote{see the
748 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
749 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
751 @cindex global visibility states
752 @cindex global cycling
753 @cindex overview, global visibility state
754 @cindex contents, global visibility state
755 @cindex show all, global visibility state
756 @kindex S-@key{TAB}
757 @item S-@key{TAB}
758 @itemx C-u @key{TAB}
759 @emph{Global cycling}: Rotate the entire buffer among the states
761 @example
762 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
763 '--------------------------------------'
764 @end example
766 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
767 CONTENTS view up to headlines of level N will be shown.  Note that inside
768 tables, @kbd{S-@key{TAB}} jumps to the previous field.
770 @cindex show all, command
771 @kindex C-c C-a
772 @item C-c C-a
773 Show all.
774 @kindex C-c C-r
775 @item C-c C-r
776 Reveal context around point, showing the current entry, the following heading
777 and the hierarchy above.  Useful for working near a location that has been
778 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
779 (@pxref{Agenda commands}).  With a prefix argument show, on each
780 level, all sibling headings.
781 @kindex C-c C-x b
782 @item C-c C-x b
783 Show the current subtree in an indirect buffer@footnote{The indirect
784 buffer
785 @ifinfo
786 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
787 @end ifinfo
788 @ifnotinfo
789 (see the Emacs manual for more information about indirect buffers)
790 @end ifnotinfo
791 will contain the entire buffer, but will be narrowed to the current
792 tree.  Editing the indirect buffer will also change the original buffer,
793 but without affecting visibility in that buffer.}.  With a numeric
794 prefix argument N, go up to level N and then take that tree.  If N is
795 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
796 the previously used indirect buffer.
797 @end table
799 When Emacs first visits an Org file, the global state is set to
800 OVERVIEW, i.e. only the top level headlines are visible.  This can be
801 configured through the variable @code{org-startup-folded}, or on a
802 per-file basis by adding one of the following lines anywhere in the
803 buffer:
805 @example
806 #+STARTUP: overview
807 #+STARTUP: content
808 #+STARTUP: showall
809 @end example
811 @noindent
812 Forthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
813 and Columns}) will get their visibility adapted accordingly.  Allowed values
814 for this property are @code{folded}, @code{children}, @code{content}, and
815 @code{all}.
816 @table @kbd
817 @kindex C-u C-u @key{TAB}
818 @item C-u C-u @key{TAB}
819 Switch back to the startup visibility of the buffer, i.e. whatever is
820 requested by startup options and @samp{VISIBILITY} properties in individual
821 entries.
822 @end table
824 @node Motion, Structure editing, Visibility cycling, Document Structure
825 @section Motion
826 @cindex motion, between headlines
827 @cindex jumping, to headlines
828 @cindex headline navigation
829 The following commands jump to other headlines in the buffer.
831 @table @kbd
832 @kindex C-c C-n
833 @item C-c C-n
834 Next heading.
835 @kindex C-c C-p
836 @item C-c C-p
837 Previous heading.
838 @kindex C-c C-f
839 @item C-c C-f
840 Next heading same level.
841 @kindex C-c C-b
842 @item C-c C-b
843 Previous heading same level.
844 @kindex C-c C-u
845 @item C-c C-u
846 Backward to higher level heading.
847 @kindex C-c C-j
848 @item C-c C-j
849 Jump to a different place without changing the current outline
850 visibility.  Shows the document structure in a temporary buffer, where
851 you can use the following keys to find your destination:
852 @example
853 @key{TAB}         @r{Cycle visibility.}
854 @key{down} / @key{up}   @r{Next/previous visible headline.}
855 n / p        @r{Next/previous visible headline.}
856 f / b        @r{Next/previous headline same level.}
857 u            @r{One level up.}
858 0-9          @r{Digit argument.}
859 @key{RET}         @r{Select this location.}
860 @end example
861 @end table
863 @node Structure editing, Archiving, Motion, Document Structure
864 @section Structure editing
865 @cindex structure editing
866 @cindex headline, promotion and demotion
867 @cindex promotion, of subtrees
868 @cindex demotion, of subtrees
869 @cindex subtree, cut and paste
870 @cindex pasting, of subtrees
871 @cindex cutting, of subtrees
872 @cindex copying, of subtrees
873 @cindex subtrees, cut and paste
875 @table @kbd
876 @kindex M-@key{RET}
877 @item M-@key{RET}
878 Insert new heading with same level as current.  If the cursor is in a
879 plain list item, a new item is created (@pxref{Plain lists}).  To force
880 creation of a new headline, use a prefix argument, or first press @key{RET}
881 to get to the beginning of the next line.  When this command is used in
882 the middle of a line, the line is split and the rest of the line becomes
883 the new headline@footnote{If you do not want the line to be split,
884 customize the variable @code{org-M-RET-may-split-line}.}.  If the
885 command is used at the beginning of a headline, the new headline is
886 created before the current line.  If at the beginning of any other line,
887 the content of that line is made the new heading.  If the command is
888 used at the end of a folded subtree (i.e. behind the ellipses at the end
889 of a headline), then a headline like the current one will be inserted
890 after the end of the subtree.
891 @kindex C-@key{RET}
892 @item C-@key{RET}
893 Just like @kbd{M-@key{RET}}, but if the heading is inserted after the current,
894 insert it actually after the entire subtree.
895 @kindex M-S-@key{RET}
896 @item M-S-@key{RET}
897 Insert new TODO entry with same level as current heading.
898 @kindex C-S-@key{RET}
899 @item C-S-@key{RET}
900 Insert new TODO entry with same level as current heading.  Like
901 @kbd{C-@key{RET}}, the new headline will be inserted after the current
902 subtree.
903 @kindex M-@key{left}
904 @item M-@key{left}
905 Promote current heading by one level.
906 @kindex M-@key{right}
907 @item M-@key{right}
908 Demote current heading by one level.
909 @kindex M-S-@key{left}
910 @item M-S-@key{left}
911 Promote the current subtree by one level.
912 @kindex M-S-@key{right}
913 @item M-S-@key{right}
914 Demote the current subtree by one level.
915 @kindex M-S-@key{up}
916 @item M-S-@key{up}
917 Move subtree up (swap with previous subtree of same
918 level).
919 @kindex M-S-@key{down}
920 @item M-S-@key{down}
921 Move subtree down (swap with next subtree of same level).
922 @kindex C-c C-x C-w
923 @kindex C-c C-x C-k
924 @item C-c C-x C-w
925 @itemx C-c C-x C-k
926 Kill subtree, i.e. remove it from buffer but save in kill ring.
927 With a numeric prefix argument N, kill N sequential subtrees.
928 @kindex C-c C-x M-w
929 @item C-c C-x M-w
930 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
931 sequential subtrees.
932 @kindex C-c C-x C-y
933 @item C-c C-x C-y
934 Yank subtree from kill ring.  This does modify the level of the subtree to
935 make sure the tree fits in nicely at the yank position.  The yank level can
936 also be specified with a numeric prefix argument, or by yanking after a
937 headline marker like @samp{****}.
938 @kindex C-c C-w
939 @item C-c C-w
940 Refile entry to a different location.  @xref{Refiling notes}.
941 @kindex C-c ^
942 @item C-c ^
943 Sort same-level entries.  When there is an active region, all entries in the
944 region will be sorted.  Otherwise the children of the current headline are
945 sorted.  The command prompts for the sorting method, which can be
946 alphabetically, numerically, by time (using the first time stamp in each
947 entry), by priority, or by TODO keyword (in the sequence the keywords have
948 been defined in the setup).  Reverse sorting is possible as well.  You can
949 also supply your own function to extract the sorting key.  With a @kbd{C-u}
950 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes,
951 duplicate entries will also be removed.
952 @kindex C-x n s
953 @item C-x n s
954 Narrow buffer to current subtree.
955 @kindex C-x n w
956 @item C-x n w
957 Widen buffer to remove a narrowing.
958 @kindex C-c *
959 @item C-c *
960 Turn a normal line or plain list item into a headline (so that it
961 becomes a subheading at its location).  Also turn a headline into a
962 normal line by removing the stars.  If there is an active region, turn
963 all lines in the region into headlines.  Or, if the first line is a
964 headline, remove the stars from all headlines in the region.
965 @end table
967 @cindex region, active
968 @cindex active region
969 @cindex Transient mark mode
970 When there is an active region (Transient mark mode), promotion and
971 demotion work on all headlines in the region.  To select a region of
972 headlines, it is best to place both point and mark at the beginning of a
973 line, mark at the beginning of the first headline, and point at the line
974 just after the last headline to change.  Note that when the cursor is
975 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
976 functionality.
978 @node Archiving, Sparse trees, Structure editing, Document Structure
979 @section Archiving
980 @cindex archiving
982 When a project represented by a (sub)tree is finished, you may want
983 to move the tree out of the way and to stop it from contributing to the
984 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
985 the ARCHIVE tag, or you can move an entire (sub)tree to a different
986 location.
988 @menu
989 * ARCHIVE tag::                 Marking a tree as inactive
990 * Moving subtrees::             Moving a tree to an archive file
991 @end menu
993 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
994 @subsection The ARCHIVE tag
995 @cindex internal archiving
997 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
998 its location in the outline tree, but behaves in the following way:
999 @itemize @minus
1000 @item
1001 It does not open when you attempt to do so with a visibility cycling
1002 command (@pxref{Visibility cycling}).  You can force cycling archived
1003 subtrees with @kbd{C-@key{TAB}}, or by setting the option
1004 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
1005 @code{show-all} will open archived subtrees.
1006 @item
1007 During sparse tree construction (@pxref{Sparse trees}), matches in
1008 archived subtrees are not exposed, unless you configure the option
1009 @code{org-sparse-tree-open-archived-trees}.
1010 @item
1011 During agenda view construction (@pxref{Agenda Views}), the content of
1012 archived trees is ignored unless you configure the option
1013 @code{org-agenda-skip-archived-trees}, in which case these trees will always
1014 be included.  In the agenda you can press the @kbd{v} key to get archives
1015 temporarily included.
1016 @item
1017 Archived trees are not exported (@pxref{Exporting}), only the headline
1018 is.  Configure the details using the variable
1019 @code{org-export-with-archived-trees}.
1020 @end itemize
1022 The following commands help managing the ARCHIVE tag:
1024 @table @kbd
1025 @kindex C-c C-x a
1026 @item C-c C-x a
1027 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
1028 the headline changes to a shadowed face, and the subtree below it is
1029 hidden.
1030 @kindex C-u C-c C-x a
1031 @item C-u C-c C-x a
1032 Check if any direct children of the current headline should be archived.
1033 To do this, each subtree is checked for open TODO entries.  If none are
1034 found, the command offers to set the ARCHIVE tag for the child.  If the
1035 cursor is @emph{not} on a headline when this command is invoked, the
1036 level 1 trees will be checked.
1037 @kindex C-@kbd{TAB}
1038 @item C-@kbd{TAB}
1039 Cycle a tree even if it is tagged with ARCHIVE.
1040 @end table
1042 @node Moving subtrees,  , ARCHIVE tag, Archiving
1043 @subsection Moving subtrees
1044 @cindex external archiving
1046 Once an entire project is finished, you may want to move it to a different
1047 location.  Org can move it to an @emph{Archive Sibling} in the same tree, to a
1048 different tree in the current file, or to a different file, the archive file.
1050 @table @kbd
1051 @kindex C-c C-x A
1052 @item C-c C-x A
1053 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
1054 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}
1055 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1056 way retains a lot of its original context, including inherited tags and
1057 approximate position in the outline.
1058 @kindex C-c C-x C-s
1059 @item C-c C-x C-s
1060 Archive the subtree starting at the cursor position to the location
1061 given by @code{org-archive-location}.  Context information that could be
1062 lost like the file name, the category, inherited tags, and the TODO
1063 state will be store as properties in the entry.
1064 @kindex C-u C-c C-x C-s
1065 @item C-u C-c C-x C-s
1066 Check if any direct children of the current headline could be moved to
1067 the archive.  To do this, each subtree is checked for open TODO entries.
1068 If none are found, the command offers to move it to the archive
1069 location.  If the cursor is @emph{not} on a headline when this command
1070 is invoked, the level 1 trees will be checked.
1071 @end table
1073 @cindex archive locations
1074 The default archive location is a file in the same directory as the
1075 current file, with the name derived by appending @file{_archive} to the
1076 current file name.  For information and examples on how to change this,
1077 see the documentation string of the variable
1078 @code{org-archive-location}.  There is also an in-buffer option for
1079 setting this variable, for example@footnote{For backward compatibility,
1080 the following also works: If there are several such lines in a file,
1081 each specifies the archive location for the text below it.  The first
1082 such line also applies to any text before its definition.  However,
1083 using this method is @emph{strongly} deprecated as it is incompatible
1084 with the outline structure of the document.  The correct method for
1085 setting multiple archive locations in a buffer is using a property.}:
1087 @example
1088 #+ARCHIVE: %s_done::
1089 @end example
1091 @noindent
1092 If you would like to have a special ARCHIVE location for a single entry
1093 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1094 location as the value (@pxref{Properties and Columns}).
1096 When a subtree is moved, it receives a number of special properties that
1097 record context information like the file from where the entry came, it's
1098 outline path the archiving time etc.  Configure the variable
1099 @code{org-archive-save-context-info} to adjust the amount of information
1100 added.
1102 @node Sparse trees, Plain lists, Archiving, Document Structure
1103 @section Sparse trees
1104 @cindex sparse trees
1105 @cindex trees, sparse
1106 @cindex folding, sparse trees
1107 @cindex occur, command
1109 An important feature of Org mode is the ability to construct @emph{sparse
1110 trees} for selected information in an outline tree, so that the entire
1111 document is folded as much as possible, but the selected information is made
1112 visible along with the headline structure above it@footnote{See also the
1113 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1114 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1115 control on how much context is shown around each match.}.  Just try it out
1116 and you will see immediately how it works.
1118 Org mode contains several commands creating such trees, all these
1119 commands can be accessed through a dispatcher:
1121 @table @kbd
1122 @kindex C-c /
1123 @item C-c /
1124 This prompts for an extra key to select a sparse-tree creating command.
1125 @kindex C-c / r
1126 @item C-c / r
1127 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
1128 the match is in a headline, the headline is made visible.  If the match is in
1129 the body of an entry, headline and body are made visible.  In order to
1130 provide minimal context, also the full hierarchy of headlines above the match
1131 is shown, as well as the headline following the match.  Each match is also
1132 highlighted; the highlights disappear when the buffer is changed by an
1133 editing command@footnote{depending on the option
1134 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1135 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1136 so several calls to this command can be stacked.
1137 @end table
1139 @noindent
1140 For frequently used sparse trees of specific search strings, you can
1141 use the variable @code{org-agenda-custom-commands} to define fast
1142 keyboard access to specific sparse trees.  These commands will then be
1143 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1144 For example:
1146 @lisp
1147 (setq org-agenda-custom-commands
1148       '(("f" occur-tree "FIXME")))
1149 @end lisp
1151 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1152 a sparse tree matching the string @samp{FIXME}.
1154 The other sparse tree commands select headings based on TODO keywords,
1155 tags, or properties and will be discussed later in this manual.
1157 @kindex C-c C-e v
1158 @cindex printing sparse trees
1159 @cindex visible text, printing
1160 To print a sparse tree, you can use the Emacs command
1161 @code{ps-print-buffer-with-faces} which does not print invisible parts
1162 of the document @footnote{This does not work under XEmacs, because
1163 XEmacs uses selective display for outlining, not text properties.}.
1164 Or you can use the command @kbd{C-c C-e v} to export only the visible
1165 part of the document and print the resulting file.
1167 @node Plain lists, Drawers, Sparse trees, Document Structure
1168 @section Plain lists
1169 @cindex plain lists
1170 @cindex lists, plain
1171 @cindex lists, ordered
1172 @cindex ordered lists
1174 Within an entry of the outline tree, hand-formatted lists can provide
1175 additional structure.  They also provide a way to create lists of
1176 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1177 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1179 Org knows ordered lists, unordered lists, and description lists.
1180 @itemize @bullet
1181 @item
1182 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1183 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1184 they will be seen as top-level headlines.  Also, when you are hiding leading
1185 stars to get a clean outline view, plain list items starting with a star are
1186 visually indistinguishable from true headlines.  In short: even though
1187 @samp{*} is supported, it may be better to not use it for plain list items.}
1188 as bullets.
1189 @item
1190 @emph{Ordered} list items start with a numeral followed by either a period or
1191 a right parenthesis, such as @samp{1.} or @samp{1)}.
1192 @item
1193 @emph{Description} list items are like unordered list items, but contain the
1194 separator @samp{ :: } to separate the description @emph{term} from the
1195 desciption.
1196 @end itemize
1198 Items belonging to the same list must have the same indentation on the first
1199 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1200 2--digit numbers must be written left-aligned with the other numbers in the
1201 list.  Indentation also determines the end of a list item.  It ends before
1202 the next line that is indented like the bullet/number, or less.  Empty lines
1203 are part of the previous item, so you can have several paragraphs in one
1204 item.  If you would like an empty line to terminate all currently open plain
1205 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1206 Here is an example:
1208 @example
1209 @group
1210 ** Lord of the Rings
1211    My favorite scenes are (in this order)
1212    1. The attack of the Rohirrim
1213    2. Eowyns fight with the witch king
1214       + this was already my favorite scene in the book
1215       + I really like Miranda Otto.
1216    3. Peter Jackson being shot by Legolas
1217        - on DVD only
1218       He makes a really funny face when it happens.
1219    But in the end, not individual scenes matter but the film as a whole.
1220    Important actors in this film are:
1221    - @b{Elijah Wood} :: He plays the Frodo
1222    - @b{Sean Austin} :: He plays the Sam, Frodos friend.  I still remember
1223      him very well from his role as Mikey Walsh a in the Goonies.
1224 @end group
1225 @end example
1227 Org supports these lists by tuning filling and wrapping commands to
1228 deal with them correctly@footnote{Org only changes the filling
1229 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1230 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1231 @code{(require 'filladapt)}}, and by exporting them properly
1232 (@pxref{Exporting}).
1234 The following commands act on items when the cursor is in the first line
1235 of an item (the line with the bullet or number).
1237 @table @kbd
1238 @kindex @key{TAB}
1239 @item @key{TAB}
1240 Items can be folded just like headline levels if you set the variable
1241 @code{org-cycle-include-plain-lists}.  The level of an item is then
1242 given by the indentation of the bullet/number.  Items are always
1243 subordinate to real headlines, however; the hierarchies remain
1244 completely separated.
1246 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1247 fixes the indentation of the current line in a heuristic way.
1248 @kindex M-@key{RET}
1249 @item M-@key{RET}
1250 Insert new item at current level.  With a prefix argument, force a new
1251 heading (@pxref{Structure editing}).  If this command is used in the middle
1252 of a line, the line is @emph{split} and the rest of the line becomes the new
1253 item@footnote{If you do not want the line to be split, customize the variable
1254 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1255 @emph{whitespace before a bullet or number}, the new item is created
1256 @emph{before} the current item.  If the command is executed in the white
1257 space before the text that is part of an item but does not contain the
1258 bullet, a bullet is added to the current line.
1259 @kindex M-S-@key{RET}
1260 @item M-S-@key{RET}
1261 Insert a new item with a checkbox (@pxref{Checkboxes}).
1262 @kindex S-@key{up}
1263 @kindex S-@key{down}
1264 @item S-@key{up}
1265 @itemx S-@key{down}
1266 Jump to the previous/next item in the current list.
1267 @kindex M-S-@key{up}
1268 @kindex M-S-@key{down}
1269 @item M-S-@key{up}
1270 @itemx M-S-@key{down}
1271 Move the item including subitems up/down (swap with previous/next item
1272 of same indentation).  If the list is ordered, renumbering is
1273 automatic.
1274 @kindex M-S-@key{left}
1275 @kindex M-S-@key{right}
1276 @item M-S-@key{left}
1277 @itemx M-S-@key{right}
1278 Decrease/increase the indentation of the item, including subitems.
1279 Initially, the item tree is selected based on current indentation.
1280 When these commands are executed several times in direct succession,
1281 the initially selected region is used, even if the new indentation
1282 would imply a different hierarchy.  To use the new hierarchy, break
1283 the command chain with a cursor motion or so.
1284 @kindex C-c C-c
1285 @item C-c C-c
1286 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1287 state of the checkbox.  If not, this command makes sure that all the
1288 items on this list level use the same bullet.  Furthermore, if this is
1289 an ordered list, make sure the numbering is OK.
1290 @kindex C-c -
1291 @item C-c -
1292 Cycle the entire list level through the different itemize/enumerate bullets
1293 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1294 argument N, select the Nth bullet from this list.  If there is an active
1295 region when calling this, all lines will be converted to list items.  If the
1296 first line already was a list item, any item markers will be removed from the
1297 list.  Finally, even without an active region, a normal line will be
1298 converted into a list item.
1299 @end table
1301 @node Drawers, Orgstruct mode, Plain lists, Document Structure
1302 @section Drawers
1303 @cindex drawers
1304 @cindex visibility cycling, drawers
1306 Sometimes you want to keep information associated with an entry, but you
1307 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1308 Drawers need to be configured with the variable
1309 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1310 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1311 look like this:
1313 @example
1314 ** This is a headline
1315    Still outside the drawer
1316    :DRAWERNAME:
1317       This is inside the drawer.
1318    :END:
1319    After the drawer.
1320 @end example
1322 Visibility cycling (@pxref{Visibility cycling}) on the headline will
1323 hide and show the entry, but keep the drawer collapsed to a single line.
1324 In order to look inside the drawer, you need to move the cursor to the
1325 drawer line and press @key{TAB} there.  Org mode uses a drawer for
1326 storing properties (@pxref{Properties and Columns}), and another one for
1327 storing clock times (@pxref{Clocking work time}).
1329 @node Orgstruct mode,  , Drawers, Document Structure
1330 @section The Orgstruct minor mode
1331 @cindex Orgstruct mode
1332 @cindex minor mode for structure editing
1334 If you like the intuitive way the Org mode structure editing and list
1335 formatting works, you might want to use these commands in other modes
1336 like Text mode or Mail mode as well.  The minor mode Orgstruct mode
1337 makes this possible.  You can always toggle the mode with @kbd{M-x
1338 orgstruct-mode}.  To turn it on by default, for example in Mail mode,
1341 @lisp
1342 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1343 @end lisp
1345 When this mode is active and the cursor is on a line that looks to
1346 Org like a headline of the first line of a list item, most
1347 structure editing commands will work, even if the same keys normally
1348 have different functionality in the major mode you are using.  If the
1349 cursor is not in one of those special lines, Orgstruct mode lurks
1350 silently in the shadow.
1352 @node Tables, Hyperlinks, Document Structure, Top
1353 @chapter Tables
1354 @cindex tables
1355 @cindex editing tables
1357 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1358 calculations are supported in connection with the Emacs @file{calc}
1359 package
1360 @ifinfo
1361 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1362 @end ifinfo
1363 @ifnotinfo
1364 (see the Emacs Calculator manual for more information about the Emacs
1365 calculator).
1366 @end ifnotinfo
1368 @menu
1369 * Built-in table editor::       Simple tables
1370 * Narrow columns::              Stop wasting space in tables
1371 * Column groups::               Grouping to trigger vertical lines
1372 * Orgtbl mode::                 The table editor as minor mode
1373 * The spreadsheet::             The table editor has spreadsheet capabilities
1374 @end menu
1376 @node Built-in table editor, Narrow columns, Tables, Tables
1377 @section The built-in table editor
1378 @cindex table editor, built-in
1380 Org makes it easy to format tables in plain ASCII.  Any line with
1381 @samp{|} as the first non-whitespace character is considered part of a
1382 table.  @samp{|} is also the column separator.  A table might look like
1383 this:
1385 @example
1386 | Name  | Phone | Age |
1387 |-------+-------+-----|
1388 | Peter |  1234 |  17 |
1389 | Anna  |  4321 |  25 |
1390 @end example
1392 A table is re-aligned automatically each time you press @key{TAB} or
1393 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1394 the next field (@key{RET} to the next row) and creates new table rows
1395 at the end of the table or before horizontal lines.  The indentation
1396 of the table is set by the first line.  Any line starting with
1397 @samp{|-} is considered as a horizontal separator line and will be
1398 expanded on the next re-align to span the whole table width.  So, to
1399 create the above table, you would only type
1401 @example
1402 |Name|Phone|Age|
1404 @end example
1406 @noindent and then press @key{TAB} to align the table and start filling in
1407 fields.
1409 When typing text into a field, Org treats @key{DEL},
1410 @key{Backspace}, and all character keys in a special way, so that
1411 inserting and deleting avoids shifting other fields.  Also, when
1412 typing @emph{immediately after the cursor was moved into a new field
1413 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1414 field is automatically made blank.  If this behavior is too
1415 unpredictable for you, configure the variables
1416 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1418 @table @kbd
1419 @tsubheading{Creation and conversion}
1420 @kindex C-c |
1421 @item C-c |
1422 Convert the active region to table. If every line contains at least one
1423 TAB character, the function assumes that the material is tab separated.
1424 If every line contains a comma, comma-separated values (CSV) are assumed.
1425 If not, lines are split at whitespace into fields.  You can use a prefix
1426 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1427 C-u} forces TAB, and a numeric argument N indicates that at least N
1428 consecutive spaces, or alternatively a TAB will be the separator.
1430 If there is no active region, this command creates an empty Org
1431 table.  But it's easier just to start typing, like
1432 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1434 @tsubheading{Re-aligning and field motion}
1435 @kindex C-c C-c
1436 @item C-c C-c
1437 Re-align the table without moving the cursor.
1439 @kindex @key{TAB}
1440 @item @key{TAB}
1441 Re-align the table, move to the next field.  Creates a new row if
1442 necessary.
1444 @kindex S-@key{TAB}
1445 @item S-@key{TAB}
1446 Re-align, move to previous field.
1448 @kindex @key{RET}
1449 @item @key{RET}
1450 Re-align the table and move down to next row.  Creates a new row if
1451 necessary.  At the beginning or end of a line, @key{RET} still does
1452 NEWLINE, so it can be used to split a table.
1454 @tsubheading{Column and row editing}
1455 @kindex M-@key{left}
1456 @kindex M-@key{right}
1457 @item M-@key{left}
1458 @itemx M-@key{right}
1459 Move the current column left/right.
1461 @kindex M-S-@key{left}
1462 @item M-S-@key{left}
1463 Kill the current column.
1465 @kindex M-S-@key{right}
1466 @item M-S-@key{right}
1467 Insert a new column to the left of the cursor position.
1469 @kindex M-@key{up}
1470 @kindex M-@key{down}
1471 @item M-@key{up}
1472 @itemx M-@key{down}
1473 Move the current row up/down.
1475 @kindex M-S-@key{up}
1476 @item M-S-@key{up}
1477 Kill the current row or horizontal line.
1479 @kindex M-S-@key{down}
1480 @item M-S-@key{down}
1481 Insert a new row above the current row.  With a prefix argument, the line is
1482 created below the current one.
1484 @kindex C-c -
1485 @item C-c -
1486 Insert a horizontal line below current row. With a prefix argument, the line
1487 is created above the current line.
1489 @kindex C-c ^
1490 @item C-c ^
1491 Sort the table lines in the region.  The position of point indicates the
1492 column to be used for sorting, and the range of lines is the range
1493 between the nearest horizontal separator lines, or the entire table.  If
1494 point is before the first column, you will be prompted for the sorting
1495 column.  If there is an active region, the mark specifies the first line
1496 and the sorting column, while point should be in the last line to be
1497 included into the sorting.  The command prompts for the sorting type
1498 (alphabetically, numerically, or by time).  When called with a prefix
1499 argument, alphabetic sorting will be case-sensitive.
1501 @tsubheading{Regions}
1502 @kindex C-c C-x M-w
1503 @item C-c C-x M-w
1504 Copy a rectangular region from a table to a special clipboard.  Point
1505 and mark determine edge fields of the rectangle.  The process ignores
1506 horizontal separator lines.
1508 @kindex C-c C-x C-w
1509 @item C-c C-x C-w
1510 Copy a rectangular region from a table to a special clipboard, and
1511 blank all fields in the rectangle.  So this is the ``cut'' operation.
1513 @kindex C-c C-x C-y
1514 @item C-c C-x C-y
1515 Paste a rectangular region into a table.
1516 The upper right corner ends up in the current field.  All involved fields
1517 will be overwritten.  If the rectangle does not fit into the present table,
1518 the table is enlarged as needed.  The process ignores horizontal separator
1519 lines.
1521 @kindex C-c C-q
1522 @kindex M-@key{RET}
1523 @item C-c C-q
1524 @itemx M-@kbd{RET}
1525 Wrap several fields in a column like a paragraph.  If there is an active
1526 region, and both point and mark are in the same column, the text in the
1527 column is wrapped to minimum width for the given number of lines.  A numeric
1528 prefix argument may be used to change the number of desired lines.  If there
1529 is no region, the current field is split at the cursor position and the text
1530 fragment to the right of the cursor is prepended to the field one line
1531 down. If there is no region, but you specify a prefix argument, the current
1532 field is made blank, and the content is appended to the field above.
1534 @tsubheading{Calculations}
1535 @cindex formula, in tables
1536 @cindex calculations, in tables
1537 @cindex region, active
1538 @cindex active region
1539 @cindex Transient mark mode
1540 @kindex C-c +
1541 @item C-c +
1542 Sum the numbers in the current column, or in the rectangle defined by
1543 the active region.  The result is shown in the echo area and can
1544 be inserted with @kbd{C-y}.
1546 @kindex S-@key{RET}
1547 @item S-@key{RET}
1548 When current field is empty, copy from first non-empty field above.  When not
1549 empty, copy current field down to next row and move cursor along with it.
1550 Depending on the variable @code{org-table-copy-increment}, integer field
1551 values will be incremented during copy.  Integers that are too large will not
1552 be incremented.  Also, a @code{0} prefix argument temporarily dispables the
1553 increment.  This key is also used by CUA mode (@pxref{Cooperation}).
1555 @tsubheading{Miscellaneous}
1556 @kindex C-c `
1557 @item C-c `
1558 Edit the current field in a separate window.  This is useful for fields
1559 that are not fully visible (@pxref{Narrow columns}).  When called with a
1560 @kbd{C-u} prefix, just make the full field visible, so that it can be
1561 edited in place.
1563 @item M-x org-table-import
1564 Import a file as a table.  The table should be TAB- or whitespace
1565 separated.  Useful, for example, to import a spreadsheet table or data
1566 from a database, because these programs generally can write
1567 TAB-separated text files.  This command works by inserting the file into
1568 the buffer and then converting the region to a table.  Any prefix
1569 argument is passed on to the converter, which uses it to determine the
1570 separator.
1571 @item C-c |
1572 Tables can also be imported by pasting tabular text into the Org
1573 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1574 @kbd{C-c |} command (see above under @i{Creation and conversion}).
1576 @item M-x org-table-export
1577 Export the table, by default as a TAB-separated file.  Useful for data
1578 exchange with, for example, spreadsheet or database programs.  The format
1579 used to export the file can be configured in the variable
1580 @code{org-table-export-default-format}.  You may also use properties
1581 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1582 name and the format for table export in a subtree.  Org supports quite
1583 general formats for exported tables.  The exporter format is the same as the
1584 format used by Orgtbl radio tables, see @ref{Translator functions} for a
1585 detailed description.
1586 @end table
1588 If you don't like the automatic table editor because it gets in your
1589 way on lines which you would like to start with @samp{|}, you can turn
1590 it off with
1592 @lisp
1593 (setq org-enable-table-editor nil)
1594 @end lisp
1596 @noindent Then the only table command that still works is
1597 @kbd{C-c C-c} to do a manual re-align.
1599 @node Narrow columns, Column groups, Built-in table editor, Tables
1600 @section Narrow columns
1601 @cindex narrow columns in tables
1603 The width of columns is automatically determined by the table editor.
1604 Sometimes a single field or a few fields need to carry more text,
1605 leading to inconveniently wide columns.  To limit@footnote{This feature
1606 does not work on XEmacs.} the width of a column, one field anywhere in
1607 the column may contain just the string @samp{<N>} where @samp{N} is an
1608 integer specifying the width of the column in characters.  The next
1609 re-align will then set the width of this column to no more than this
1610 value.
1612 @example
1613 @group
1614 |---+------------------------------|               |---+--------|
1615 |   |                              |               |   | <6>    |
1616 | 1 | one                          |               | 1 | one    |
1617 | 2 | two                          |     ----\     | 2 | two    |
1618 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1619 | 4 | four                         |               | 4 | four   |
1620 |---+------------------------------|               |---+--------|
1621 @end group
1622 @end example
1624 @noindent
1625 Fields that are wider become clipped and end in the string @samp{=>}.
1626 Note that the full text is still in the buffer, it is only invisible.
1627 To see the full text, hold the mouse over the field - a tool-tip window
1628 will show the full content.  To edit such a field, use the command
1629 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1630 open a new window with the full field.  Edit it and finish with @kbd{C-c
1631 C-c}.
1633 When visiting a file containing a table with narrowed columns, the
1634 necessary character hiding has not yet happened, and the table needs to
1635 be aligned before it looks nice.  Setting the option
1636 @code{org-startup-align-all-tables} will realign all tables in a file
1637 upon visiting, but also slow down startup.  You can also set this option
1638 on a per-file basis with:
1640 @example
1641 #+STARTUP: align
1642 #+STARTUP: noalign
1643 @end example
1645 @node Column groups, Orgtbl mode, Narrow columns, Tables
1646 @section Column groups
1647 @cindex grouping columns in tables
1649 When Org exports tables, it does so by default without vertical
1650 lines because that is visually more satisfying in general.  Occasionally
1651 however, vertical lines can be useful to structure a table into groups
1652 of columns, much like horizontal lines can do for groups of rows.  In
1653 order to specify column groups, you can use a special row where the
1654 first field contains only @samp{/}.  The further fields can either
1655 contain @samp{<} to indicate that this column should start a group,
1656 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1657 a group of its own.  Boundaries between column groups will upon export be
1658 marked with vertical lines.  Here is an example:
1660 @example
1661 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1662 |---+----+-----+-----+-----+---------+------------|
1663 | / | <> |   < |     |   > |       < |          > |
1664 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1665 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1666 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1667 |---+----+-----+-----+-----+---------+------------|
1668 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2)))
1669 @end example
1671 It is also sufficient to just insert the column group starters after
1672 every vertical line you'd like to have:
1674 @example
1675 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1676 |----+-----+-----+-----+---------+------------|
1677 | /  | <   |     |     | <       |            |
1678 @end example
1680 @node Orgtbl mode, The spreadsheet, Column groups, Tables
1681 @section The Orgtbl minor mode
1682 @cindex Orgtbl mode
1683 @cindex minor mode for tables
1685 If you like the intuitive way the Org table editor works, you
1686 might also want to use it in other modes like Text mode or Mail mode.
1687 The minor mode Orgtbl mode makes this possible.  You can always toggle
1688 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1689 example in mail mode, use
1691 @lisp
1692 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1693 @end lisp
1695 Furthermore, with some special setup, it is possible to maintain tables
1696 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
1697 construct La@TeX{} tables with the underlying ease and power of
1698 Orgtbl mode, including spreadsheet capabilities.  For details, see
1699 @ref{Tables in arbitrary syntax}.
1701 @node The spreadsheet,  , Orgtbl mode, Tables
1702 @section The spreadsheet
1703 @cindex calculations, in tables
1704 @cindex spreadsheet capabilities
1705 @cindex @file{calc} package
1707 The table editor makes use of the Emacs @file{calc} package to implement
1708 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1709 derive fields from other fields.  While fully featured, Org's
1710 implementation is not identical to other spreadsheets.  For example,
1711 Org knows the concept of a @emph{column formula} that will be
1712 applied to all non-header fields in a column without having to copy the
1713 formula to each relevant field.
1715 @menu
1716 * References::                  How to refer to another field or range
1717 * Formula syntax for Calc::     Using Calc to compute stuff
1718 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1719 * Field formulas::              Formulas valid for a single field
1720 * Column formulas::             Formulas valid for an entire column
1721 * Editing and debugging formulas::  Fixing formulas
1722 * Updating the table::          Recomputing all dependent fields
1723 * Advanced features::           Field names, parameters and automatic recalc
1724 @end menu
1726 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1727 @subsection References
1728 @cindex references
1730 To compute fields in the table from other fields, formulas must
1731 reference other fields or ranges.  In Org, fields can be referenced
1732 by name, by absolute coordinates, and by relative coordinates.  To find
1733 out what the coordinates of a field are, press @kbd{C-c ?} in that
1734 field, or press @kbd{C-c @}} to toggle the display of a grid.
1736 @subsubheading Field references
1737 @cindex field references
1738 @cindex references, to fields
1740 Formulas can reference the value of another field in two ways.  Like in
1741 any other spreadsheet, you may reference fields with a letter/number
1742 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1743 @c Such references are always fixed to that field, they don't change
1744 @c when you copy and paste a formula to a different field.  So
1745 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1747 @noindent
1748 Org also uses another, more general operator that looks like this:
1749 @example
1750 @@row$column
1751 @end example
1753 @noindent
1754 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1755 or relative to the current column like @samp{+1} or @samp{-2}.
1757 The row specification only counts data lines and ignores horizontal
1758 separator lines (hlines).  You can use absolute row numbers
1759 @samp{1}...@samp{N}, and row numbers relative to the current row like
1760 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1761 hlines: @samp{I} refers to the first hline@footnote{Note that only
1762 hlines are counted that @emph{separate} table lines.  If the table
1763 starts with a hline above the header, it does not count.}, @samp{II} to
1764 the second etc.  @samp{-I} refers to the first such line above the
1765 current line, @samp{+I} to the first such line below the current line.
1766 You can also write @samp{III+2} which is the second data line after the
1767 third hline in the table.  Relative row numbers like @samp{-3} will not
1768 cross hlines if the current line is too close to the hline.  Instead,
1769 the value directly at the hline is used.
1771 @samp{0} refers to the current row and column.  Also, if you omit
1772 either the column or the row part of the reference, the current
1773 row/column is implied.
1775 Org's references with @emph{unsigned} numbers are fixed references
1776 in the sense that if you use the same reference in the formula for two
1777 different fields, the same field will be referenced each time.
1778 Org's references with @emph{signed} numbers are floating
1779 references because the same reference operator can reference different
1780 fields depending on the field being calculated by the formula.
1782 Here are a few examples:
1784 @example
1785 @@2$3      @r{2nd row, 3rd column}
1786 C2        @r{same as previous}
1787 $5        @r{column 5 in the current row}
1788 E&        @r{same as previous}
1789 @@2        @r{current column, row 2}
1790 @@-1$-3    @r{the field one row up, three columns to the left}
1791 @@-I$2     @r{field just under hline above current row, column 2}
1792 @end example
1794 @subsubheading Range references
1795 @cindex range references
1796 @cindex references, to ranges
1798 You may reference a rectangular range of fields by specifying two field
1799 references connected by two dots @samp{..}.  If both fields are in the
1800 current row, you may simply use @samp{$2..$7}, but if at least one field
1801 is in a different row, you need to use the general @code{@@row$column}
1802 format at least for the first field (i.e the reference must start with
1803 @samp{@@} in order to be interpreted correctly).  Examples:
1805 @example
1806 $1..$3        @r{First three fields in the current row.}
1807 $P..$Q        @r{Range, using column names (see under Advanced)}
1808 @@2$1..@@4$3    @r{6 fields between these two fields.}
1809 A2..C4        @r{Same as above.}
1810 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1811 @end example
1813 @noindent Range references return a vector of values that can be fed
1814 into Calc vector functions.  Empty fields in ranges are normally
1815 suppressed, so that the vector contains only the non-empty fields (but
1816 see the @samp{E} mode switch below).  If there are no non-empty fields,
1817 @samp{[0]} is returned to avoid syntax errors in formulas.
1819 @subsubheading Named references
1820 @cindex named references
1821 @cindex references, named
1822 @cindex name, of column or field
1823 @cindex constants, in calculations
1825 @samp{$name} is interpreted as the name of a column, parameter or
1826 constant.  Constants are defined globally through the variable
1827 @code{org-table-formula-constants}, and locally (for the file) through a
1828 line like
1830 @example
1831 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1832 @end example
1834 @noindent
1835 Also properties (@pxref{Properties and Columns}) can be used as
1836 constants in table formulas: For a property @samp{:Xyz:} use the name
1837 @samp{$PROP_Xyz}, and the property will be searched in the current
1838 outline entry and in the hierarchy above it.  If you have the
1839 @file{constants.el} package, it will also be used to resolve constants,
1840 including natural constants like @samp{$h} for Planck's constant, and
1841 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
1842 supply the values of constants in two different unit systems, @code{SI}
1843 and @code{cgs}.  Which one is used depends on the value of the variable
1844 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1845 @code{constSI} and @code{constcgs} to set this value for the current
1846 buffer.}.  Column names and parameters can be specified in special table
1847 lines.  These are described below, see @ref{Advanced features}.  All
1848 names must start with a letter, and further consist of letters and
1849 numbers.
1851 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1852 @subsection Formula syntax for Calc
1853 @cindex formula syntax, Calc
1854 @cindex syntax, of formulas
1856 A formula can be any algebraic expression understood by the Emacs
1857 @file{Calc} package.  @b{Note that @file{calc} has the
1858 non-standard convention that @samp{/} has lower precedence than
1859 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1860 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1861 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
1862 Emacs Calc Manual}),
1863 @c FIXME:  The link to the Calc manual in HTML does not work.
1864 variable substitution takes place according to the rules described above.
1865 @cindex vectors, in table calculations
1866 The range vectors can be directly fed into the Calc vector functions
1867 like @samp{vmean} and @samp{vsum}.
1869 @cindex format specifier
1870 @cindex mode, for @file{calc}
1871 A formula can contain an optional mode string after a semicolon.  This
1872 string consists of flags to influence Calc and other modes during
1873 execution.  By default, Org uses the standard Calc modes (precision
1874 12, angular units degrees, fraction and symbolic modes off).  The display
1875 format, however, has been changed to @code{(float 5)} to keep tables
1876 compact.  The default settings can be configured using the variable
1877 @code{org-calc-default-modes}.
1879 @example
1880 p20           @r{switch the internal precision to 20 digits}
1881 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1882 D R           @r{angle modes: degrees, radians}
1883 F S           @r{fraction and symbolic modes}
1884 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1885 T             @r{force text interpretation}
1886 E             @r{keep empty fields in ranges}
1887 @end example
1889 @noindent
1890 In addition, you may provide a @code{printf} format specifier to
1891 reformat the final result.  A few examples:
1893 @example
1894 $1+$2                @r{Sum of first and second field}
1895 $1+$2;%.2f           @r{Same, format result to two decimals}
1896 exp($2)+exp($1)      @r{Math functions can be used}
1897 $0;%.1f              @r{Reformat current cell to 1 decimal}
1898 ($3-32)*5/9          @r{Degrees F -> C conversion}
1899 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1900 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1901 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1902 vmean($2..$7)        @r{Compute column range mean, using vector function}
1903 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1904 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1905 @end example
1907 Calc also contains a complete set of logical operations.  For example
1909 @example
1910 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1911 @end example
1913 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1914 @subsection Emacs Lisp forms as formulas
1915 @cindex Lisp forms, as table formulas
1917 It is also possible to write a formula in Emacs Lisp; this can be useful
1918 for string manipulation and control structures, if the Calc's
1919 functionality is not enough.  If a formula starts with a single quote
1920 followed by an opening parenthesis, then it is evaluated as a lisp form.
1921 The evaluation should return either a string or a number.  Just as with
1922 @file{calc} formulas, you can specify modes and a printf format after a
1923 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
1924 field references are interpolated into the form.  By default, a
1925 reference will be interpolated as a Lisp string (in double quotes)
1926 containing the field.  If you provide the @samp{N} mode switch, all
1927 referenced elements will be numbers (non-number fields will be zero) and
1928 interpolated as Lisp numbers, without quotes.  If you provide the
1929 @samp{L} flag, all fields will be interpolated literally, without quotes.
1930 I.e., if you want a reference to be interpreted as a string by the Lisp
1931 form, enclose the reference operator itself in double quotes, like
1932 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
1933 embed them in list or vector syntax.  A few examples, note how the
1934 @samp{N} mode is used when we do computations in lisp.
1936 @example
1937 @r{Swap the first two characters of the content of column 1}
1938   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1939 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1940   '(+ $1 $2);N
1941 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1942   '(apply '+ '($1..$4));N
1943 @end example
1945 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1946 @subsection Field formulas
1947 @cindex field formula
1948 @cindex formula, for individual table field
1950 To assign a formula to a particular field, type it directly into the
1951 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1952 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1953 the field, the formula will be stored as the formula for this field,
1954 evaluated, and the current field replaced with the result.
1956 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1957 directly below the table.  If you typed the equation in the 4th field of
1958 the 3rd data line in the table, the formula will look like
1959 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1960 with the appropriate commands, @i{absolute references} (but not relative
1961 ones) in stored formulas are modified in order to still reference the
1962 same field.  Of cause this is not true if you edit the table structure
1963 with normal editing commands - then you must fix the equations yourself.
1965 Instead of typing an equation into the field, you may also use the
1966 following command
1968 @table @kbd
1969 @kindex C-u C-c =
1970 @item C-u C-c =
1971 Install a new formula for the current field.  The command prompts for a
1972 formula, with default taken from the @samp{#+TBLFM:} line, applies
1973 it to the current field and stores it.
1974 @end table
1976 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1977 @subsection Column formulas
1978 @cindex column formula
1979 @cindex formula, for table column
1981 Often in a table, the same formula should be used for all fields in a
1982 particular column.  Instead of having to copy the formula to all fields
1983 in that column, Org allows to assign a single formula to an entire
1984 column.  If the table contains horizontal separator hlines, everything
1985 before the first such line is considered part of the table @emph{header}
1986 and will not be modified by column formulas.
1988 To assign a formula to a column, type it directly into any field in the
1989 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1990 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1991 field, the formula will be stored as the formula for the current column,
1992 evaluated and the current field replaced with the result.  If the field
1993 contains only @samp{=}, the previously stored formula for this column is
1994 used.  For each column, Org will only remember the most recently
1995 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1996 @samp{$4=$1+$2}.
1998 Instead of typing an equation into the field, you may also use the
1999 following command:
2001 @table @kbd
2002 @kindex C-c =
2003 @item C-c =
2004 Install a new formula for the current column and replace current field with
2005 the result of the formula.  The command prompts for a formula, with default
2006 taken from the @samp{#+TBLFM} line, applies it to the current field and
2007 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
2008 will apply it to that many consecutive fields in the current column.
2009 @end table
2011 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2012 @subsection Editing and debugging formulas
2013 @cindex formula editing
2014 @cindex editing, of table formulas
2016 You can edit individual formulas in the minibuffer or directly in the
2017 field.  Org can also prepare a special buffer with all active
2018 formulas of a table.  When offering a formula for editing, Org
2019 converts references to the standard format (like @code{B3} or @code{D&})
2020 if possible.  If you prefer to only work with the internal format (like
2021 @code{@@3$2} or @code{$4}), configure the variable
2022 @code{org-table-use-standard-references}.
2024 @table @kbd
2025 @kindex C-c =
2026 @kindex C-u C-c =
2027 @item C-c =
2028 @itemx C-u C-c =
2029 Edit the formula associated with the current column/field in the
2030 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
2031 @kindex C-u C-u C-c =
2032 @item C-u C-u C-c =
2033 Re-insert the active formula (either a
2034 field formula, or a column formula) into the current field, so that you
2035 can edit it directly in the field.  The advantage over editing in the
2036 minibuffer is that you can use the command @kbd{C-c ?}.
2037 @kindex C-c ?
2038 @item C-c ?
2039 While editing a formula in a table field, highlight the field(s)
2040 referenced by the reference at the cursor position in the formula.
2041 @kindex C-c @}
2042 @item C-c @}
2043 Toggle the display of row and column numbers for a table, using
2044 overlays.  These are updated each time the table is aligned, you can
2045 force it with @kbd{C-c C-c}.
2046 @kindex C-c @{
2047 @item C-c @{
2048 Toggle the formula debugger on and off.  See below.
2049 @kindex C-c '
2050 @item C-c '
2051 Edit all formulas for the current table in a special buffer, where the
2052 formulas will be displayed one per line.  If the current field has an
2053 active formula, the cursor in the formula editor will mark it.
2054 While inside the special buffer, Org will automatically highlight
2055 any field or range reference at the cursor position.  You may edit,
2056 remove and add formulas, and use the following commands:
2057 @table @kbd
2058 @kindex C-c C-c
2059 @kindex C-x C-s
2060 @item C-c C-c
2061 @itemx C-x C-s
2062 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2063 prefix, also apply the new formulas to the entire table.
2064 @kindex C-c C-q
2065 @item C-c C-q
2066 Exit the formula editor without installing changes.
2067 @kindex C-c C-r
2068 @item C-c C-r
2069 Toggle all references in the formula editor between standard (like
2070 @code{B3}) and internal (like @code{@@3$2}).
2071 @kindex @key{TAB}
2072 @item @key{TAB}
2073 Pretty-print or indent lisp formula at point.  When in a line containing
2074 a lisp formula, format the formula according to Emacs Lisp rules.
2075 Another @key{TAB} collapses the formula back again.  In the open
2076 formula, @key{TAB} re-indents just like in Emacs lisp mode.
2077 @kindex M-@key{TAB}
2078 @item M-@key{TAB}
2079 Complete Lisp symbols, just like in Emacs lisp mode.
2080 @kindex S-@key{up}
2081 @kindex S-@key{down}
2082 @kindex S-@key{left}
2083 @kindex S-@key{right}
2084 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2085 Shift the reference at point.  For example, if the reference is
2086 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2087 This also works for relative references, and for hline references.
2088 @kindex M-S-@key{up}
2089 @kindex M-S-@key{down}
2090 @item M-S-@key{up}/@key{down}
2091 Move the test line for column formulas in the Org buffer up and
2092 down.
2093 @kindex M-@key{up}
2094 @kindex M-@key{down}
2095 @item M-@key{up}/@key{down}
2096 Scroll the window displaying the table.
2097 @kindex C-c @}
2098 @item C-c @}
2099 Turn the coordinate grid in the table on and off.
2100 @end table
2101 @end table
2103 Making a table field blank does not remove the formula associated with
2104 the field, because that is stored in a different line (the @samp{TBLFM}
2105 line) - during the next recalculation the field will be filled again.
2106 To remove a formula from a field, you have to give an empty reply when
2107 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2109 @kindex C-c C-c
2110 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2111 equations with @kbd{C-c C-c} in that line, or with the normal
2112 recalculation commands in the table.
2114 @subsubheading Debugging formulas
2115 @cindex formula debugging
2116 @cindex debugging, of table formulas
2117 When the evaluation of a formula leads to an error, the field content
2118 becomes the string @samp{#ERROR}.  If you would like see what is going
2119 on during variable substitution and calculation in order to find a bug,
2120 turn on formula debugging in the @code{Tbl} menu and repeat the
2121 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2122 field.  Detailed information will be displayed.
2124 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2125 @subsection Updating the table
2126 @cindex recomputing table fields
2127 @cindex updating, table
2129 Recalculation of a table is normally not automatic, but needs to be
2130 triggered by a command.  See @ref{Advanced features} for a way to make
2131 recalculation at least semi-automatically.
2133 In order to recalculate a line of a table or the entire table, use the
2134 following commands:
2136 @table @kbd
2137 @kindex C-c *
2138 @item C-c *
2139 Recalculate the current row by first applying the stored column formulas
2140 from left to right, and all field formulas in the current row.
2142 @kindex C-u C-c *
2143 @item C-u C-c *
2144 @kindex C-u C-c C-c
2145 @itemx C-u C-c C-c
2146 Recompute the entire table, line by line.  Any lines before the first
2147 hline are left alone, assuming that these are part of the table header.
2149 @kindex C-u C-u C-c *
2150 @kindex C-u C-u C-c C-c
2151 @item C-u C-u C-c *
2152 @itemx C-u C-u C-c C-c
2153 Iterate the table by recomputing it until no further changes occur.
2154 This may be necessary if some computed fields use the value of other
2155 fields that are computed @i{later} in the calculation sequence.
2156 @end table
2158 @node Advanced features,  , Updating the table, The spreadsheet
2159 @subsection Advanced features
2161 If you want the recalculation of fields to happen automatically, or if
2162 you want to be able to assign @i{names} to fields and columns, you need
2163 to reserve the first column of the table for special marking characters.
2164 @table @kbd
2165 @kindex C-#
2166 @item C-#
2167 Rotate the calculation mark in first column through the states @samp{},
2168 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
2169 is discussed below.  When there is an active region, change all marks in
2170 the region.
2171 @end table
2173 Here is an example of a table that collects exam results of students and
2174 makes use of these features:
2176 @example
2177 @group
2178 |---+---------+--------+--------+--------+-------+------|
2179 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2180 |---+---------+--------+--------+--------+-------+------|
2181 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2182 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2183 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2184 |---+---------+--------+--------+--------+-------+------|
2185 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2186 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
2187 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2188 |---+---------+--------+--------+--------+-------+------|
2189 |   | Average |        |        |        |  29.7 |      |
2190 | ^ |         |        |        |        |    at |      |
2191 | $ | max=50  |        |        |        |       |      |
2192 |---+---------+--------+--------+--------+-------+------|
2193 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2194 @end group
2195 @end example
2197 @noindent @b{Important}: Please note that for these special tables,
2198 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2199 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2200 to the field itself.  The column formulas are not applied in rows with
2201 empty first field.
2203 @cindex marking characters, tables
2204 The marking characters have the following meaning:
2205 @table @samp
2206 @item !
2207 The fields in this line define names for the columns, so that you may
2208 refer to a column as @samp{$Tot} instead of @samp{$6}.
2209 @item ^
2210 This row defines names for the fields @emph{above} the row.  With such
2211 a definition, any formula in the table may use @samp{$m1} to refer to
2212 the value @samp{10}.  Also, if you assign a formula to a names field, it
2213 will be stored as @samp{$name=...}.
2214 @item _
2215 Similar to @samp{^}, but defines names for the fields in the row
2216 @emph{below}.
2217 @item $
2218 Fields in this row can define @emph{parameters} for formulas.  For
2219 example, if a field in a @samp{$} row contains @samp{max=50}, then
2220 formulas in this table can refer to the value 50 using @samp{$max}.
2221 Parameters work exactly like constants, only that they can be defined on
2222 a per-table basis.
2223 @item #
2224 Fields in this row are automatically recalculated when pressing
2225 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2226 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2227 lines will be left alone by this command.
2228 @item *
2229 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2230 not for automatic recalculation.  Use this when automatic
2231 recalculation slows down editing too much.
2232 @item
2233 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2234 All lines that should be recalculated should be marked with @samp{#}
2235 or @samp{*}.
2236 @item /
2237 Do not export this line.  Useful for lines that contain the narrowing
2238 @samp{<N>} markers.
2239 @end table
2241 Finally, just to whet your appetite on what can be done with the
2242 fantastic @file{calc} package, here is a table that computes the Taylor
2243 series of degree @code{n} at location @code{x} for a couple of
2244 functions.
2246 @example
2247 @group
2248 |---+-------------+---+-----+--------------------------------------|
2249 |   | Func        | n | x   | Result                               |
2250 |---+-------------+---+-----+--------------------------------------|
2251 | # | exp(x)      | 1 | x   | 1 + x                                |
2252 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2253 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2254 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2255 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2256 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2257 |---+-------------+---+-----+--------------------------------------|
2258 #+TBLFM: $5=taylor($2,$4,$3);n3
2259 @end group
2260 @end example
2262 @node Hyperlinks, TODO Items, Tables, Top
2263 @chapter Hyperlinks
2264 @cindex hyperlinks
2266 Like HTML, Org provides links inside a file, external links to
2267 other files, Usenet articles, emails, and much more.
2269 @menu
2270 * Link format::                 How links in Org are formatted
2271 * Internal links::              Links to other places in the current file
2272 * External links::              URL-like links to the world
2273 * Handling links::              Creating, inserting and following
2274 * Using links outside Org::     Linking from my C source code?
2275 * Link abbreviations::          Shortcuts for writing complex links
2276 * Search options::              Linking to a specific location
2277 * Custom searches::             When the default search is not enough
2278 @end menu
2280 @node Link format, Internal links, Hyperlinks, Hyperlinks
2281 @section Link format
2282 @cindex link format
2283 @cindex format, of links
2285 Org will recognize plain URL-like links and activate them as
2286 clickable links.  The general link format, however, looks like this:
2288 @example
2289 [[link][description]]       @r{or alternatively}           [[link]]
2290 @end example
2292 Once a link in the buffer is complete (all brackets present), Org
2293 will change the display so that @samp{description} is displayed instead
2294 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2295 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2296 which by default is an underlined face.  You can directly edit the
2297 visible part of a link.  Note that this can be either the @samp{link}
2298 part (if there is no description) or the @samp{description} part.  To
2299 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2300 cursor on the link.
2302 If you place the cursor at the beginning or just behind the end of the
2303 displayed text and press @key{BACKSPACE}, you will remove the
2304 (invisible) bracket at that location.  This makes the link incomplete
2305 and the internals are again displayed as plain text.  Inserting the
2306 missing bracket hides the link internals again.  To show the
2307 internal structure of all links, use the menu entry
2308 @code{Org->Hyperlinks->Literal links}.
2310 @node Internal links, External links, Link format, Hyperlinks
2311 @section Internal links
2312 @cindex internal links
2313 @cindex links, internal
2314 @cindex targets, for links
2316 If the link does not look like a URL, it is considered to be internal in
2317 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2318 Target][Find my target]]} lead to a text search in the current file.
2319 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2320 link, or with a mouse click (@pxref{Handling links}).  The preferred
2321 match for such a link is a dedicated target: the same string in double
2322 angular brackets.  Targets may be located anywhere; sometimes it is
2323 convenient to put them into a comment line. For example
2325 @example
2326 # <<My Target>>
2327 @end example
2329 @noindent In HTML export (@pxref{HTML export}), such targets will become
2330 named anchors for direct access through @samp{http} links@footnote{Note
2331 that text before the first headline is usually not exported, so the
2332 first such target should be after the first headline.}.
2334 If no dedicated target exists, Org will search for the words in the
2335 link.  In the above example the search would be for @samp{my target}.
2336 Links starting with a star like @samp{*My Target} restrict the search to
2337 headlines.  When searching, Org mode will first try an exact match, but
2338 then move on to more and more lenient searches.  For example, the link
2339 @samp{[[*My Targets]]} will find any of the following:
2341 @example
2342 ** My targets
2343 ** TODO my targets are bright
2344 ** my 20 targets are
2345 @end example
2347 To insert a link targeting a headline, in-buffer completion can be used.
2348 Just type a star followed by a few optional letters into the buffer and
2349 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2350 offered as completions.  @xref{Handling links}, for more commands
2351 creating links.
2353 Following a link pushes a mark onto Org's own mark ring.  You can
2354 return to the previous position with @kbd{C-c &}.  Using this command
2355 several times in direct succession goes back to positions recorded
2356 earlier.
2358 @menu
2359 * Radio targets::               Make targets trigger links in plain text
2360 @end menu
2362 @node Radio targets,  , Internal links, Internal links
2363 @subsection Radio targets
2364 @cindex radio targets
2365 @cindex targets, radio
2366 @cindex links, radio targets
2368 Org can automatically turn any occurrences of certain target names
2369 in normal text into a link.  So without explicitly creating a link, the
2370 text connects to the target radioing its position.  Radio targets are
2371 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2372 Target>>>} causes each occurrence of @samp{my target} in normal text to
2373 become activated as a link.  The Org file is scanned automatically
2374 for radio targets only when the file is first loaded into Emacs.  To
2375 update the target list during editing, press @kbd{C-c C-c} with the
2376 cursor on or at a target.
2378 @node External links, Handling links, Internal links, Hyperlinks
2379 @section External links
2380 @cindex links, external
2381 @cindex external links
2382 @cindex links, external
2383 @cindex Gnus links
2384 @cindex BBDB links
2385 @cindex IRC links
2386 @cindex URL links
2387 @cindex file links
2388 @cindex VM links
2389 @cindex RMAIL links
2390 @cindex WANDERLUST links
2391 @cindex MH-E links
2392 @cindex USENET links
2393 @cindex SHELL links
2394 @cindex Info links
2395 @cindex elisp links
2397 Org supports links to files, websites, Usenet and email messages,
2398 BBDB database entries and links to both IRC conversations and their
2399 logs.  External links are URL-like locators.  They start with a short
2400 identifying string followed by a colon.  There can be no space after
2401 the colon.  The following list shows examples for each link type.
2403 @example
2404 http://www.astro.uva.nl/~dominik          @r{on the web}
2405 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2406 /home/dominik/images/jupiter.jpg          @r{same as above}
2407 file:papers/last.pdf                      @r{file, relative path}
2408 ./papers/last.pdf                         @r{same as above}
2409 news:comp.emacs                           @r{Usenet link}
2410 mailto:adent@@galaxy.net                 @r{Mail link}
2411 vm:folder                                 @r{VM folder link}
2412 vm:folder#id                              @r{VM message link}
2413 vm://myself@@some.where.org/folder#id    @r{VM on remote machine}
2414 wl:folder                                 @r{WANDERLUST folder link}
2415 wl:folder#id                              @r{WANDERLUST message link}
2416 mhe:folder                                @r{MH-E folder link}
2417 mhe:folder#id                             @r{MH-E message link}
2418 rmail:folder                              @r{RMAIL folder link}
2419 rmail:folder#id                           @r{RMAIL message link}
2420 gnus:group                                @r{Gnus group link}
2421 gnus:group#id                             @r{Gnus article link}
2422 bbdb:Richard Stallman                     @r{BBDB link}
2423 irc:/irc.com/#emacs/bob                   @r{IRC link}
2424 shell:ls *.org                            @r{A shell command}
2425 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2426 @end example
2428 A link should be enclosed in double brackets and may contain a
2429 descriptive text to be displayed instead of the URL (@pxref{Link
2430 format}), for example:
2432 @example
2433 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2434 @end example
2436 @noindent
2437 If the description is a file name or URL that points to an image, HTML
2438 export (@pxref{HTML export}) will inline the image as a clickable
2439 button.  If there is no description at all and the link points to an
2440 image,
2441 that image will be inlined into the exported HTML file.
2443 @cindex angular brackets, around links
2444 @cindex plain text external links
2445 Org also finds external links in the normal text and activates them
2446 as links.  If spaces must be part of the link (for example in
2447 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2448 about the end of the link, enclose them in angular brackets.
2450 @node Handling links, Using links outside Org, External links, Hyperlinks
2451 @section Handling links
2452 @cindex links, handling
2454 Org provides methods to create a link in the correct syntax, to
2455 insert it into an Org file, and to follow the link.
2457 @table @kbd
2458 @kindex C-c l
2459 @cindex storing links
2460 @item C-c l
2461 Store a link to the current location.  This is a @emph{global} command
2462 which can be used in any buffer to create a link.  The link will be
2463 stored for later insertion into an Org buffer (see below).  For
2464 Org files, if there is a @samp{<<target>>} at the cursor, the
2465 link points to the target.  Otherwise it points to the current
2466 headline.  For VM, Rmail, Wanderlust, MH-E, Gnus and BBDB buffers, the
2467 link will indicate the current article/entry.  For W3 and W3M buffers,
2468 the link goes to the current URL.  For IRC links, if you set the
2469 variable @code{org-irc-link-to-logs} to non-nil then @kbd{C-c l} will
2470 store a @samp{file:/} style link to the relevant point in the logs for
2471 the current conversation. Otherwise an @samp{irc:/} style link to the
2472 user/channel/server under the point will be stored.  For any other
2473 files, the link will point to the file, with a search string
2474 (@pxref{Search options}) pointing to the contents of the current line.
2475 If there is an active region, the selected words will form the basis
2476 of the search string.  If the automatically created link is not
2477 working correctly or accurately enough, you can write custom functions
2478 to select the search string and to do the search for particular file
2479 types - see @ref{Custom searches}.  The key binding @kbd{C-c l} is
2480 only a suggestion - see @ref{Installation}.
2482 @kindex C-c C-l
2483 @cindex link completion
2484 @cindex completion, of links
2485 @cindex inserting links
2486 @item C-c C-l
2487 Insert a link.  This prompts for a link to be inserted into the buffer.  You
2488 can just type a link, using text for an internal link, or one of the link
2489 type prefixes mentioned in the examples above.  All links stored during the
2490 current session are part of the history for this prompt, so you can access
2491 them with @key{up} and @key{down} (or @kbd{M-p/n}).  Completion, on the other
2492 hand, will help you to insert valid link prefixes like @samp{http:} or
2493 @samp{ftp:}, including the prefixes defined through link abbreviations
2494 (@pxref{Link abbreviations}).  The link will be inserted into the
2495 buffer@footnote{After insertion of a stored link, the link will be removed
2496 from the list of stored links.  To keep it in the list later use, use a
2497 triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2498 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2499 If some text was selected when this command is called, the selected text
2500 becomes the default description.@* Note that you don't have to use this
2501 command to insert a link.  Links in Org are plain text, and you can type
2502 or paste them straight into the buffer.  By using this command, the links are
2503 automatically enclosed in double brackets, and you will be asked for the
2504 optional descriptive text.
2506 @c  If the link is a @samp{file:} link and
2507 @c the linked file is located in the same directory as the current file or
2508 @c a subdirectory of it, the path of the file will be inserted relative to
2509 @c the current directory.
2511 @kindex C-u C-c C-l
2512 @cindex file name completion
2513 @cindex completion, of file names
2514 @item C-u C-c C-l
2515 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2516 a file will be inserted and you may use file name completion to select
2517 the name of the file.  The path to the file is inserted relative to the
2518 directory of the current org file, if the linked file is in the current
2519 directory or in a sub-directory of it, or if the path is written relative
2520 to the current directory using @samp{../}.  Otherwise an absolute path
2521 is used, if possible with @samp{~/} for your home directory.  You can
2522 force an absolute path with two @kbd{C-u} prefixes.
2524 @item C-c C-l @r{(with cursor on existing link)}
2525 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2526 link and description parts of the link.
2528 @cindex following links
2529 @kindex C-c C-o
2530 @item C-c C-o
2531 Open link at point.  This will launch a web browser for URLs (using
2532 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
2533 for the corresponding links, and execute the command in a shell link.
2534 When the cursor is on an internal link, this commands runs the
2535 corresponding search.  When the cursor is on a TAG list in a headline,
2536 it creates the corresponding TAGS view.  If the cursor is on a time
2537 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2538 text and remote files in @samp{file:} links with Emacs and select a
2539 suitable application for local non-text files.  Classification of files
2540 is based on file extension only.  See option @code{org-file-apps}.  If
2541 you want to override the default application and visit the file with
2542 Emacs, use a @kbd{C-u} prefix.
2544 @kindex mouse-2
2545 @kindex mouse-1
2546 @item mouse-2
2547 @itemx mouse-1
2548 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2549 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2551 @kindex mouse-3
2552 @item mouse-3
2553 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2554 internal links to be displayed in another window@footnote{See the
2555 variable @code{org-display-internal-link-with-indirect-buffer}}.
2557 @cindex mark ring
2558 @kindex C-c %
2559 @item C-c %
2560 Push the current position onto the mark ring, to be able to return
2561 easily. Commands following an internal link do this automatically.
2563 @cindex links, returning to
2564 @kindex C-c &
2565 @item C-c &
2566 Jump back to a recorded position.  A position is recorded by the
2567 commands following internal links, and by @kbd{C-c %}.  Using this
2568 command several times in direct succession moves through a ring of
2569 previously recorded positions.
2571 @kindex C-c C-x C-n
2572 @kindex C-c C-x C-p
2573 @cindex links, finding next/previous
2574 @item C-c C-x C-n
2575 @itemx C-c C-x C-p
2576 Move forward/backward to the next link in the buffer.  At the limit of
2577 the buffer, the search fails once, and then wraps around.  The key
2578 bindings for this are really too long, you might want to bind this also
2579 to @kbd{C-n} and @kbd{C-p}
2580 @lisp
2581 (add-hook 'org-load-hook
2582   (lambda ()
2583     (define-key 'org-mode-map "\C-n" 'org-next-link)
2584     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2585 @end lisp
2586 @end table
2588 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
2589 @section Using links outside Org
2591 You can insert and follow links that have Org syntax not only in
2592 Org, but in any Emacs buffer.  For this, you should create two
2593 global commands, like this (please select suitable global keys
2594 yourself):
2596 @lisp
2597 (global-set-key "\C-c L" 'org-insert-link-global)
2598 (global-set-key "\C-c o" 'org-open-at-point-global)
2599 @end lisp
2601 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
2602 @section Link abbreviations
2603 @cindex link abbreviations
2604 @cindex abbreviation, links
2606 Long URLs can be cumbersome to type, and often many similar links are
2607 needed in a document.  For this you can use link abbreviations.  An
2608 abbreviated link looks like this
2610 @example
2611 [[linkword:tag][description]]
2612 @end example
2614 @noindent
2615 where the tag is optional.  Such abbreviations are resolved according to
2616 the information in the variable @code{org-link-abbrev-alist} that
2617 relates the linkwords to replacement text.  Here is an example:
2619 @lisp
2620 @group
2621 (setq org-link-abbrev-alist
2622   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2623     ("google"   . "http://www.google.com/search?q=")
2624     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2625                    nph-abs_connect?author=%s&db_key=AST")))
2626 @end group
2627 @end lisp
2629 If the replacement text contains the string @samp{%s}, it will be
2630 replaced with the tag.  Otherwise the tag will be appended to the string
2631 in order to create the link.  You may also specify a function that will
2632 be called with the tag as the only argument to create the link.
2634 With the above setting, you could link to a specific bug with
2635 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2636 @code{[[google:OrgMode]]} and find out what the Org author is
2637 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2639 If you need special abbreviations just for a single Org buffer, you
2640 can define them in the file with
2642 @example
2643 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2644 #+LINK: google    http://www.google.com/search?q=%s
2645 @end example
2647 @noindent
2648 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2649 complete link abbreviations.
2651 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2652 @section Search options in file links
2653 @cindex search option in file links
2654 @cindex file links, searching
2656 File links can contain additional information to make Emacs jump to a
2657 particular location in the file when following a link.  This can be a
2658 line number or a search option after a double@footnote{For backward
2659 compatibility, line numbers can also follow a single colon.} colon. For
2660 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2661 links}) to a file, it encodes the words in the current line as a search
2662 string that can be used to find this line back later when following the
2663 link with @kbd{C-c C-o}.
2665 Here is the syntax of the different ways to attach a search to a file
2666 link, together with an explanation:
2668 @example
2669 [[file:~/code/main.c::255]]
2670 [[file:~/xx.org::My Target]]
2671 [[file:~/xx.org::*My Target]]
2672 [[file:~/xx.org::/regexp/]]
2673 @end example
2675 @table @code
2676 @item 255
2677 Jump to line 255.
2678 @item My Target
2679 Search for a link target @samp{<<My Target>>}, or do a text search for
2680 @samp{my target}, similar to the search in internal links, see
2681 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2682 link will become an HTML reference to the corresponding named anchor in
2683 the linked file.
2684 @item *My Target
2685 In an Org file, restrict search to headlines.
2686 @item /regexp/
2687 Do a regular expression search for @code{regexp}.  This uses the Emacs
2688 command @code{occur} to list all matches in a separate window.  If the
2689 target file is in Org mode, @code{org-occur} is used to create a
2690 sparse tree with the matches.
2691 @c If the target file is a directory,
2692 @c @code{grep} will be used to search all files in the directory.
2693 @end table
2695 As a degenerate case, a file link with an empty file name can be used
2696 to search the current file.  For example, @code{[[file:::find me]]} does
2697 a search for @samp{find me} in the current file, just as
2698 @samp{[[find me]]} would.
2700 @node Custom searches,  , Search options, Hyperlinks
2701 @section Custom Searches
2702 @cindex custom search strings
2703 @cindex search strings, custom
2705 The default mechanism for creating search strings and for doing the
2706 actual search related to a file link may not work correctly in all
2707 cases.  For example, BibTeX database files have many entries like
2708 @samp{year="1993"} which would not result in good search strings,
2709 because the only unique identification for a BibTeX entry is the
2710 citation key.
2712 If you come across such a problem, you can write custom functions to set
2713 the right search string for a particular file type, and to do the search
2714 for the string in the file.  Using @code{add-hook}, these functions need
2715 to be added to the hook variables
2716 @code{org-create-file-search-functions} and
2717 @code{org-execute-file-search-functions}.  See the docstring for these
2718 variables for more information.  Org actually uses this mechanism
2719 for Bib@TeX{} database files, and you can use the corresponding code as
2720 an implementation example.  See the file @file{org-bibtex.el}.
2722 @node TODO Items, Tags, Hyperlinks, Top
2723 @chapter TODO Items
2724 @cindex TODO items
2726 Org mode does not maintain TODO lists as separate documents@footnote{Of
2727 course, you can make a document that contains inly long lists of TODO items,
2728 but this is not required.}.  Instead, TODO items are an integral part of the
2729 notes file, because TODO items usually come up while taking notes!  With Org
2730 mode, simply mark any entry in a tree as being a TODO item.  In this way,
2731 information is not duplicated, and the entire context from which the TODO
2732 item emerged is always present.
2734 Of course, this technique for managing TODO items scatters them
2735 throughout your notes file.  Org mode compensates for this by providing
2736 methods to give you an overview of all the things that you have to do.
2738 @menu
2739 * TODO basics::                 Marking and displaying TODO entries
2740 * TODO extensions::             Workflow and assignments
2741 * Progress logging::            Dates and notes for progress
2742 * Priorities::                  Some things are more important than others
2743 * Breaking down tasks::         Splitting a task into manageable pieces
2744 * Checkboxes::                  Tick-off lists
2745 @end menu
2747 @node TODO basics, TODO extensions, TODO Items, TODO Items
2748 @section Basic TODO functionality
2750 Any headline becomes a TODO item when it starts with the word
2751 @samp{TODO}, for example:
2753 @example
2754 *** TODO Write letter to Sam Fortune
2755 @end example
2757 @noindent
2758 The most important commands to work with TODO entries are:
2760 @table @kbd
2761 @kindex C-c C-t
2762 @cindex cycling, of TODO states
2763 @item C-c C-t
2764 Rotate the TODO state of the current item among
2766 @example
2767 ,-> (unmarked) -> TODO -> DONE --.
2768 '--------------------------------'
2769 @end example
2771 The same rotation can also be done ``remotely'' from the timeline and
2772 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2774 @kindex C-u C-c C-t
2775 @item C-u C-c C-t
2776 Select a specific keyword using completion or (if it has been set up)
2777 the fast selection interface.  For the latter, you need to assign keys
2778 to TODO states, see @ref{Per-file keywords} and @ref{Setting tags} for
2779 more information.
2781 @kindex S-@key{right}
2782 @kindex S-@key{left}
2783 @item S-@key{right}
2784 @itemx S-@key{left}
2785 Select the following/preceding TODO state, similar to cycling.  Useful
2786 mostly if more than two TODO states are possible (@pxref{TODO
2787 extensions}).
2788 @kindex C-c C-v
2789 @kindex C-c / t
2790 @cindex sparse tree, for TODO
2791 @item C-c C-v
2792 @itemx C-c / t
2793 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2794 the entire buffer, but shows all TODO items and the headings hierarchy
2795 above them.  With a prefix argument, search for a specific TODO.  You will be
2796 prompted for the keyword, and you can also give a list of keywords like
2797 @code{KWD1|KWD2|...}.  With numeric prefix argument N, show the tree for the
2798 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2799 arguments, find all TODO and DONE entries.
2800 @kindex C-c a t
2801 @item C-c a t
2802 Show the global TODO list.  Collects the TODO items from all agenda
2803 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
2804 be in @code{agenda-mode}, which provides commands to examine and
2805 manipulate the TODO entries from the new buffer (@pxref{Agenda
2806 commands}).  @xref{Global TODO list}, for more information.
2807 @kindex S-M-@key{RET}
2808 @item S-M-@key{RET}
2809 Insert a new TODO entry below the current one.
2810 @end table
2812 @node TODO extensions, Progress logging, TODO basics, TODO Items
2813 @section Extended use of TODO keywords
2814 @cindex extended TODO keywords
2816 By default, marked TODO entries have one of only two states: TODO and
2817 DONE.  Org mode allows you to classify TODO items in more complex ways
2818 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
2819 special setup, the TODO keyword system can work differently in different
2820 files.
2822 Note that @i{tags} are another way to classify headlines in general and
2823 TODO items in particular (@pxref{Tags}).
2825 @menu
2826 * Workflow states::             From TODO to DONE in steps
2827 * TODO types::                  I do this, Fred does the rest
2828 * Multiple sets in one file::   Mixing it all, and still finding your way
2829 * Fast access to TODO states::  Single letter selection of a state
2830 * Per-file keywords::           Different files, different requirements
2831 * Faces for TODO keywords::     Highlighting states
2832 @end menu
2834 @node Workflow states, TODO types, TODO extensions, TODO extensions
2835 @subsection TODO keywords as workflow states
2836 @cindex TODO workflow
2837 @cindex workflow states as TODO keywords
2839 You can use TODO keywords to indicate different @emph{sequential} states
2840 in the process of working on an item, for example@footnote{Changing
2841 this variable only becomes effective after restarting Org mode in a
2842 buffer.}:
2844 @lisp
2845 (setq org-todo-keywords
2846   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2847 @end lisp
2849 The vertical bar separates the TODO keywords (states that @emph{need
2850 action}) from the DONE states (which need @emph{no further action}).  If
2851 you don't provide the separator bar, the last state is used as the DONE
2852 state.
2853 @cindex completion, of TODO keywords
2854 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2855 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2856 also use a numeric prefix argument to quickly select a specific state.  For
2857 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2858 Or you can use @kbd{S-left} to go backward through the sequence.  If you
2859 define many keywords, you can use in-buffer completion
2860 (@pxref{Completion}) or even a special one-key selection scheme
2861 (@pxref{Fast access to TODO states}) to insert these words into the
2862 buffer.  Changing a TODO state can be logged with a timestamp, see
2863 @ref{Tracking TODO state changes} for more information.
2865 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2866 @subsection TODO keywords as types
2867 @cindex TODO types
2868 @cindex names as TODO keywords
2869 @cindex types as TODO keywords
2871 The second possibility is to use TODO keywords to indicate different
2872 @emph{types} of action items.  For example, you might want to indicate
2873 that items are for ``work'' or ``home''.  Or, when you work with several
2874 people on a single project, you might want to assign action items
2875 directly to persons, by using their names as TODO keywords.  This would
2876 be set up like this:
2878 @lisp
2879 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2880 @end lisp
2882 In this case, different keywords do not indicate a sequence, but rather
2883 different types.  So the normal work flow would be to assign a task to a
2884 person, and later to mark it DONE.  Org mode supports this style by adapting
2885 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
2886 @kbd{t} command in the timeline and agenda buffers.}.  When used several
2887 times in succession, it will still cycle through all names, in order to first
2888 select the right type for a task.  But when you return to the item after some
2889 time and execute @kbd{C-c C-t} again, it will switch from any name directly
2890 to DONE.  Use prefix arguments or completion to quickly select a specific
2891 name.  You can also review the items of a specific TODO type in a sparse tree
2892 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
2893 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
2894 from all agenda files into a single buffer, you would use the numeric prefix
2895 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
2897 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
2898 @subsection Multiple keyword sets in one file
2899 @cindex TODO keyword sets
2901 Sometimes you may want to use different sets of TODO keywords in
2902 parallel.  For example, you may want to have the basic
2903 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2904 separate state indicating that an item has been canceled (so it is not
2905 DONE, but also does not require action).  Your setup would then look
2906 like this:
2908 @lisp
2909 (setq org-todo-keywords
2910       '((sequence "TODO" "|" "DONE")
2911         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2912         (sequence "|" "CANCELED")))
2913 @end lisp
2915 The keywords should all be different, this helps Org mode to keep track
2916 of which subsequence should be used for a given entry.  In this setup,
2917 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2918 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2919 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2920 select the correct sequence.  Besides the obvious ways like typing a
2921 keyword or using completion, you may also apply the following commands:
2923 @table @kbd
2924 @kindex C-S-@key{right}
2925 @kindex C-S-@key{left}
2926 @item C-S-@key{right}
2927 @itemx C-S-@key{left}
2928 These keys jump from one TODO subset to the next.  In the above example,
2929 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2930 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2931 @kindex S-@key{right}
2932 @kindex S-@key{left}
2933 @item S-@key{right}
2934 @itemx S-@key{left}
2935 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2936 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2937 would switch from @code{DONE} to @code{REPORT} in the example above.
2938 @end table
2940 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
2941 @subsection Fast access to TODO states
2943 If you would like to quickly change an entry to an arbitrary TODO state
2944 instead of cycling through the states, you can set up keys for
2945 single-letter access to the states.  This is done by adding the section
2946 key after each keyword, in parenthesis.  For example:
2948 @lisp
2949 (setq org-todo-keywords
2950       '((sequence "TODO(t)" "|" "DONE(d)")
2951         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
2952         (sequence "|" "CANCELED(c)")))
2953 @end lisp
2955 If you then press @code{C-u C-c C-t} followed by the selection key, the
2956 entry will be switched to this state.  @key{SPC} can be used to remove
2957 any TODO keyword from an entry.  Should you like this way of selecting
2958 TODO states a lot, you might want to set the variable
2959 @code{org-use-fast-todo-selection} to @code{t} and make this behavior
2960 the default.  Check also the variable
2961 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
2962 state through the tags interface (@pxref{Setting tags}), in case you
2963 like to mingle the two concepts.
2965 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
2966 @subsection Setting up keywords for individual files
2967 @cindex keyword options
2968 @cindex per-file keywords
2970 It can be very useful to use different aspects of the TODO mechanism in
2971 different files.  For file-local settings, you need to add special lines
2972 to the file which set the keywords and interpretation for that file
2973 only.  For example, to set one of the two examples discussed above, you
2974 need one of the following lines, starting in column zero anywhere in the
2975 file:
2977 @example
2978 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2979 @end example
2981 @example
2982 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2983 @end example
2985 A setup for using several sets in parallel would be:
2987 @example
2988 #+SEQ_TODO: TODO | DONE
2989 #+SEQ_TODO: REPORT BUG KNOWNCAUSE | FIXED
2990 #+SEQ_TODO: | CANCELED
2991 @end example
2993 @cindex completion, of option keywords
2994 @kindex M-@key{TAB}
2995 @noindent To make sure you are using the correct keyword, type
2996 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2998 @cindex DONE, final TODO keyword
2999 Remember that the keywords after the vertical bar (or the last keyword
3000 if no bar is there) must always mean that the item is DONE (although you
3001 may use a different word).  After changing one of these lines, use
3002 @kbd{C-c C-c} with the cursor still in the line to make the changes
3003 known to Org mode@footnote{Org mode parses these lines only when
3004 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
3005 cursor in a line starting with @samp{#+} is simply restarting Org mode
3006 for the current buffer.}.
3008 @node Faces for TODO keywords,  , Per-file keywords, TODO extensions
3009 @subsection Faces for TODO keywords
3010 @cindex faces, for TODO keywords
3012 Org mode highlights TODO keywords with special faces: @code{org-todo}
3013 for keywords indicating that an item still has to be acted upon, and
3014 @code{org-done} for keywords indicating that an item is finished.  If
3015 you are using more than 2 different states, you might want to use
3016 special faces for some of them.  This can be done using the variable
3017 @code{org-todo-keyword-faces}.  For example:
3019 @lisp
3020 (setq org-todo-keyword-faces
3021       '(("TODO"      . org-warning)
3022         ("DEFERRED"  . shadow)
3023         ("CANCELED"  . (:foreground "blue" :weight bold))))
3024 @end lisp
3026 While using a list with face properties as shown for CANCELED
3027 @emph{should} work, this does not aways seem to be the case.  If
3028 necessary, define a special face and use that.
3030 @page
3031 @node Progress logging, Priorities, TODO extensions, TODO Items
3032 @section Progress logging
3033 @cindex progress logging
3034 @cindex logging, of progress
3036 Org mode can automatically record a time stamp and possibly a note when
3037 you mark a TODO item as DONE, or even each time you change the state of
3038 a TODO item.  This system is highly configurable, settings can be on a
3039 per-keyword basis and can be localized to a file or even a subtree.  For
3040 information on how to clock working time for a task, see @ref{Clocking
3041 work time}.
3043 @menu
3044 * Closing items::               When was this entry marked DONE?
3045 * Tracking TODO state changes::  When did the status change?
3046 @end menu
3048 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3049 @subsection Closing items
3051 The most basic logging is to keep track of @emph{when} a certain TODO
3052 item was finished.  This is achieved with@footnote{The corresponding
3053 in-buffer setting is: @code{#+STARTUP: logdone}}.
3055 @lisp
3056 (setq org-log-done 'time)
3057 @end lisp
3059 @noindent
3060 Then each time you turn an entry from a TODO (not-done) state into any
3061 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3062 just after the headline.  If you turn the entry back into a TODO item
3063 through further state cycling, that line will be removed again.  If you
3064 want to record a note along with the timestamp, use@footnote{The
3065 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3067 @lisp
3068 (setq org-log-done 'note)
3069 @end lisp
3071 @noindent
3072 You will then be prompted for a note, and that note will be stored below
3073 the entry with a @samp{Closing Note} heading.
3075 In the timeline (@pxref{Timeline}) and in the agenda
3076 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3077 display the TODO items with a @samp{CLOSED} timestamp on each day,
3078 giving you an overview of what has been done.
3080 @node Tracking TODO state changes,  , Closing items, Progress logging
3081 @subsection Tracking TODO state changes
3083 When TODO keywords are used as workflow states (@pxref{Workflow
3084 states}), you might want to keep track of when a state change occurred
3085 and maybe take a note about this change.  Since it is normally too much
3086 to record a note for every state, Org mode expects configuration on a
3087 per-keyword basis for this.  This is achieved by adding special markers
3088 @samp{!} (for a time stamp) and @samp{@@} (for a note) in parenthesis
3089 after each keyword.  For example, with the setting
3091 @lisp
3092 (setq org-todo-keywords
3093   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3094 @end lisp
3096 @noindent
3097 you not only define global TODO keywords and fast access keys, but also
3098 request that a time is recorded when the entry is turned into
3099 DONE@footnote{It is possible that Org mode will record two time stamps
3100 when you are using both @code{org-log-done} and state change logging.
3101 However, it will never prompt for two notes - if you have configured
3102 both, the state change recording note will take precedence and cancel
3103 the @samp{Closing Note}.}, and that a note is recorded when switching to
3104 WAIT or CANCELED.  The setting for WAIT is even more special: The
3105 @samp{!} after the slash means that in addition to the note taken when
3106 entering the state, a time stamp should be recorded when @i{leaving} the
3107 WAIT state, if and only if the @i{target} state does not configure
3108 logging for entering it.  So it has no effect when switching from WAIT
3109 to DONE, because DONE is configured to record a timestamp only.  But
3110 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3111 setting now triggers a timestamp even though TODO has no logging
3112 configured.
3114 You can use the exact same syntax for setting logging preferences local
3115 to a buffer:
3116 @example
3117 #+SEQ_TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3118 @end example
3120 In order to define logging settings that are local to a subtree or a
3121 single item, define a LOGGING property in this entry.  Any non-empty
3122 LOGGING property resets all logging settings to nil.  You may then turn
3123 on logging for this specific tree using STARTUP keywords like
3124 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3125 settings like @code{TODO(!)}.  For example
3127 @example
3128 * TODO Log each state with only a time
3129   :PROPERTIES:
3130   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3131   :END:
3132 * TODO Only log when switching to WAIT, and when repeating
3133   :PROPERTIES:
3134   :LOGGING: WAIT(@@) logrepeat
3135   :END:
3136 * TODO No logging at all
3137   :PROPERTIES:
3138   :LOGGING: nil
3139   :END:
3140 @end example
3143 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3144 @section Priorities
3145 @cindex priorities
3147 If you use Org mode extensively, you may end up enough TODO items that
3148 it starts to make sense to prioritize them.  Prioritizing can be done by
3149 placing a @emph{priority cookie} into the headline of a TODO item, like
3150 this
3152 @example
3153 *** TODO [#A] Write letter to Sam Fortune
3154 @end example
3156 @noindent
3157 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3158 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3159 is treated as priority @samp{B}.  Priorities make a difference only in
3160 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3161 no inherent meaning to Org mode.
3163 Priorities can be attached to any outline tree entries; they do not need
3164 to be TODO items.
3166 @table @kbd
3167 @kindex @kbd{C-c ,}
3168 @item @kbd{C-c ,}
3169 Set the priority of the current headline.  The command prompts for a
3170 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3171 @key{SPC} instead, the priority cookie is removed from the headline.
3172 The priorities can also be changed ``remotely'' from the timeline and
3173 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3175 @kindex S-@key{up}
3176 @kindex S-@key{down}
3177 @item S-@key{up}
3178 @itemx S-@key{down}
3179 Increase/decrease priority of current headline@footnote{See also the
3180 option @code{org-priority-start-cycle-with-default'}.}.  Note that these
3181 keys are also used to modify time stamps (@pxref{Creating timestamps}).
3182 Furthermore, these keys are also used by CUA mode (@pxref{Conflicts}).
3183 @end table
3185 You can change the range of allowed priorities by setting the variables
3186 @code{org-highest-priority}, @code{org-lowest-priority}, and
3187 @code{org-default-priority}.  For an individual buffer, you may set
3188 these values (highest, lowest, default) like this (please make sure that
3189 the highest priority is earlier in the alphabet than the lowest
3190 priority):
3192 @example
3193 #+PRIORITIES: A C B
3194 @end example
3196 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3197 @section Breaking tasks down into subtasks
3198 @cindex tasks, breaking down
3200 It is often advisable to break down large tasks into smaller, manageable
3201 subtasks.  You can do this by creating an outline tree below a TODO item,
3202 with detailed subtasks on the tree@footnote{To keep subtasks out of the
3203 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
3204 the overview over the fraction of subtasks that are already completed, insert
3205 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
3206 be updates each time the todo status of a child changes.  For example:
3208 @example
3209 * Organize Party [33%]
3210 ** TODO Call people [1/2]
3211 *** TODO Peter
3212 *** DONE Sarah
3213 ** TODO Buy food
3214 ** DONE Talk to neighbor
3215 @end example
3217 If you would like a TODO entry to automatically change to DONE when all
3218 chilrden are done, you can use the following setup:
3220 @example
3221 (defun org-summary-todo (n-done n-not-done)
3222   "Switch entry to DONE when all subentries are done, to TODO otherwise."
3223   (let (org-log-done org-log-states)   ; turn off logging
3224     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3226 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3227 @end example
3230 Another possibility is the use of checkboxes to identify (a hierarchy of) a
3231 large number of subtasks (@pxref{Checkboxes}).
3234 @node Checkboxes,  , Breaking down tasks, TODO Items
3235 @section Checkboxes
3236 @cindex checkboxes
3238 Every item in a plain list (@pxref{Plain lists}) can be made into a
3239 checkbox by starting it with the string @samp{[ ]}.  This feature is
3240 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3241 Checkboxes are not included into the global TODO list, so they are often
3242 great to split a task into a number of simple steps.  Or you can use
3243 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3244 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3246 Here is an example of a checkbox list.
3248 @example
3249 * TODO Organize party [2/4]
3250   - [-] call people [1/3]
3251     - [ ] Peter
3252     - [X] Sarah
3253     - [ ] Sam
3254   - [X] order food
3255   - [ ] think about what music to play
3256   - [X] talk to the neighbors
3257 @end example
3259 Checkboxes work hierarchically, so if a checkbox item has children that
3260 are checkboxes, toggling one of the children checkboxes will make the
3261 parent checkbox reflect if none, some, or all of the children are
3262 checked.
3264 @cindex statistics, for checkboxes
3265 @cindex checkbox statistics
3266 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
3267 cookies indicating how many checkboxes present in this entry have been
3268 checked off, and the total number of checkboxes are present.  This can
3269 give you an idea on how many checkboxes remain, even without opening a
3270 folded entry.  The cookies can be placed into a headline or into (the
3271 first line of) a plain list item. Each cookie covers all checkboxes
3272 structurally below the headline/item on which the cookie appear.  You
3273 have to insert the cookie yourself by typing either @samp{[/]} or
3274 @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
3275 the examples above.  With @samp{[%]} you get information about the
3276 percentage of checkboxes checked (in the above example, this would be
3277 @samp{[50%]} and @samp{[33%]}, respectively).
3279 @noindent The following commands work with checkboxes:
3281 @table @kbd
3282 @kindex C-c C-c
3283 @item C-c C-c
3284 Toggle checkbox at point.  With a prefix argument, set it to @samp{[-]},
3285 which is considered to be an intermediate state.
3286 @kindex C-c C-x C-b
3287 @item C-c C-x C-b
3288 Toggle checkbox at point.
3289 @itemize @minus
3290 @item
3291 If there is an active region, toggle the first checkbox in the region
3292 and set all remaining boxes to the same status as the first.  If you
3293 want to toggle all boxes in the region independently, use a prefix
3294 argument.
3295 @item
3296 If the cursor is in a headline, toggle checkboxes in the region between
3297 this headline and the next (so @emph{not} the entire subtree).
3298 @item
3299 If there is no active region, just toggle the checkbox at point.
3300 @end itemize
3301 @kindex M-S-@key{RET}
3302 @item M-S-@key{RET}
3303 Insert a new item with a checkbox.
3304 This works only if the cursor is already in a plain list item
3305 (@pxref{Plain lists}).
3306 @kindex C-c #
3307 @item C-c #
3308 Update the checkbox statistics in the current outline entry.  When
3309 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3310 statistic cookies are updated automatically if you toggle checkboxes
3311 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3312 delete boxes or add/change them by hand, use this command to get things
3313 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3314 @end table
3316 @node Tags, Properties and Columns, TODO Items, Top
3317 @chapter Tags
3318 @cindex tags
3319 @cindex headline tagging
3320 @cindex matching, tags
3321 @cindex sparse tree, tag based
3323 An excellent way to implement labels and contexts for cross-correlating
3324 information is to assign @i{tags} to headlines.  Org mode has extensive
3325 support for tags.
3327 Every headline can contain a list of tags; they occur at the end of the
3328 headline.  Tags are normal words containing letters, numbers, @samp{_},
3329 and @samp{@@}.  Tags must be preceded and followed by a single colon,
3330 e.g., @samp{:work:}.  Several tags can be specified, as in
3331 @samp{:work:urgent:}.
3333 @menu
3334 * Tag inheritance::             Tags use the tree structure of the outline
3335 * Setting tags::                How to assign tags to a headline
3336 * Tag searches::                Searching for combinations of tags
3337 @end menu
3339 @node Tag inheritance, Setting tags, Tags, Tags
3340 @section Tag inheritance
3341 @cindex tag inheritance
3342 @cindex inheritance, of tags
3343 @cindex sublevels, inclusion into tags match
3345 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3346 heading has a certain tag, all subheadings will inherit the tag as
3347 well.  For example, in the list
3349 @example
3350 * Meeting with the French group      :work:
3351 ** Summary by Frank                  :boss:notes:
3352 *** TODO Prepare slides for him      :action:
3353 @end example
3355 @noindent
3356 the final heading will have the tags @samp{:work:}, @samp{:boss:},
3357 @samp{:notes:}, and @samp{:action:} even though the final heading is not
3358 explicitly marked with those tags.  You can also set tags that all entries in
3359 a file should inherit as if these tags would be defined in a hypothetical
3360 level zero that surounds the entire file.
3362 @example
3363 #+FILETAGS: :Peter:Boss:Secret:
3364 @end example
3366 @noindent
3367 To limit tag inheritance to specific tags, or to turn it off entirely, use
3368 the variable @code{org-use-tag-inheritance}.
3370 When a headline matches during a tags search while tag inheritance is turned
3371 on, all the sublevels in the same tree will match as well@footnote{This is
3372 only true if the the search does not involve more complex tests including
3373 properties (@pxref{Property searches}).}.  The list of matches may then
3374 become very long.  If you only want to see the first tags match in a subtree,
3375 configure the variable @code{org-tags-match-list-sublevels}.
3377 @node Setting tags, Tag searches, Tag inheritance, Tags
3378 @section Setting tags
3379 @cindex setting tags
3380 @cindex tags, setting
3382 @kindex M-@key{TAB}
3383 Tags can simply be typed into the buffer at the end of a headline.
3384 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3385 also a special command for inserting tags:
3387 @table @kbd
3388 @kindex C-c C-c
3389 @item C-c C-c
3390 @cindex completion, of tags
3391 Enter new tags for the current headline.  Org mode will either offer
3392 completion or a special single-key interface for setting tags, see
3393 below.  After pressing @key{RET}, the tags will be inserted and aligned
3394 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3395 tags in the current buffer will be aligned to that column, just to make
3396 things look nice.  TAGS are automatically realigned after promotion,
3397 demotion, and TODO state changes (@pxref{TODO basics}).
3398 @end table
3400 Org will support tag insertion based on a @emph{list of tags}.  By
3401 default this list is constructed dynamically, containing all tags
3402 currently used in the buffer.  You may also globally specify a hard list
3403 of tags with the variable @code{org-tag-alist}.  Finally you can set
3404 the default tags for a given file with lines like
3406 @example
3407 #+TAGS: @@work @@home @@tennisclub
3408 #+TAGS: laptop car pc sailboat
3409 @end example
3411 If you have globally defined your preferred set of tags using the
3412 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3413 in a specific file, add an empty TAGS option line to that file:
3415 @example
3416 #+TAGS:
3417 @end example
3419 By default Org mode uses the standard minibuffer completion facilities for
3420 entering tags.  However, it also implements another, quicker, tag selection
3421 method called @emph{fast tag selection}.  This allows you to select and
3422 deselect tags with just a single key press.  For this to work well you should
3423 assign unique letters to most of your commonly used tags.  You can do this
3424 globally by configuring the variable @code{org-tag-alist} in your
3425 @file{.emacs} file.  For example, you may find the need to tag many items in
3426 different files with @samp{:@@home:}.  In this case you can set something
3427 like:
3429 @lisp
3430 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
3431 @end lisp
3433 @noindent If the tag is only relevant to the file you are working on then you
3434 can, instead, set the TAGS option line as:
3436 @example
3437 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
3438 @end example
3440 @noindent
3441 You can also group together tags that are mutually exclusive.  By using
3442 braces, as in:
3444 @example
3445 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
3446 @end example
3448 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
3449 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
3451 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3452 these lines to activate any changes.
3454 @noindent
3455 To set these mutually exclusive groups in the variable @code{org-mode-alist}
3456 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
3457 of the braces.  The previous example would be set globally by the following
3458 configuration:
3460 @lisp
3461 (setq org-tag-alist '((:startgroup . nil)
3462                       ("@@work" . ?w) ("@@home" . ?h)
3463                       ("@@tennisclub" . ?t)
3464                       (:endgroup . nil)
3465                       ("laptop" . ?l) ("pc" . ?p)))
3466 @end lisp
3468 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
3469 automatically present you with a special interface, listing inherited tags,
3470 the tags of the current headline, and a list of all valid tags with
3471 corresponding keys@footnote{Keys will automatically be assigned to tags which
3472 have no configured keys.}.  In this interface, you can use the following
3473 keys:
3475 @table @kbd
3476 @item a-z...
3477 Pressing keys assigned to tags will add or remove them from the list of
3478 tags in the current line.  Selecting a tag in a group of mutually
3479 exclusive tags will turn off any other tags from that group.
3480 @kindex @key{TAB}
3481 @item @key{TAB}
3482 Enter a tag in the minibuffer, even if the tag is not in the predefined
3483 list.  You will be able to complete on all tags present in the buffer.
3484 @kindex @key{SPC}
3485 @item @key{SPC}
3486 Clear all tags for this line.
3487 @kindex @key{RET}
3488 @item @key{RET}
3489 Accept the modified set.
3490 @item C-g
3491 Abort without installing changes.
3492 @item q
3493 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3494 @item !
3495 Turn off groups of mutually exclusive tags.  Use this to (as an
3496 exception) assign several tags from such a group.
3497 @item C-c
3498 Toggle auto-exit after the next change (see below).
3499 If you are using expert mode, the first @kbd{C-c} will display the
3500 selection window.
3501 @end table
3503 @noindent
3504 This method lets you assign tags to a headline with very few keys.  With
3505 the above setup, you could clear the current tags and set @samp{@@home},
3506 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
3507 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
3508 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
3509 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3510 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3511 @key{RET} @key{RET}}.
3513 If you find that most of the time, you need only a single key press to
3514 modify your list of tags, set the variable
3515 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3516 press @key{RET} to exit fast tag selection - it will immediately exit
3517 after the first change.  If you then occasionally need more keys, press
3518 @kbd{C-c} to turn off auto-exit for the current tag selection process
3519 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3520 C-c}).  If you set the variable to the value @code{expert}, the special
3521 window is not even shown for single-key tag selection, it comes up only
3522 when you press an extra @kbd{C-c}.
3524 @node Tag searches,  , Setting tags, Tags
3525 @section Tag searches
3526 @cindex tag searches
3527 @cindex searching for tags
3529 Once a system of tags has been set up, it can be used to collect related
3530 information into special lists.
3532 @table @kbd
3533 @kindex C-c \
3534 @kindex C-c / T
3535 @item C-c \
3536 @itemx C-c / T
3537 Create a sparse tree with all headlines matching a tags search.  With a
3538 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3539 @kindex C-c a m
3540 @item C-c a m
3541 Create a global list of tag matches from all agenda files.
3542 @xref{Matching tags and properties}.
3543 @kindex C-c a M
3544 @item C-c a M
3545 Create a global list of tag matches from all agenda files, but check
3546 only TODO items and force checking subitems (see variable
3547 @code{org-tags-match-list-sublevels}).
3548 @end table
3550 @cindex Boolean logic, for tag searches
3551 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3552 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3553 Parenthesis are currently not implemented.  A tag may also be preceded
3554 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3555 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3556 or @samp{-} is present.  Examples:
3558 @table @samp
3559 @item +work-boss
3560 Select headlines tagged @samp{:work:}, but discard those also tagged
3561 @samp{:boss:}.
3562 @item work|laptop
3563 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
3564 @item work|laptop&night
3565 Like before, but require the @samp{:laptop:} lines to be tagged also
3566 @samp{:night:}.
3567 @end table
3569 @cindex TODO keyword matching, with tags search
3570 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3571 can be useful to also match on the TODO keyword.  This can be done by
3572 adding a condition after a slash to a tags match.  The syntax is similar
3573 to the tag matches, but should be applied with consideration: For
3574 example, a positive selection on several TODO keywords can not
3575 meaningfully be combined with boolean AND.  However, @emph{negative
3576 selection} combined with AND can be meaningful.  To make sure that only
3577 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3578 M}, or equivalently start the TODO part after the slash with @samp{!}.
3579 Examples:
3581 @table @samp
3582 @item work/WAITING
3583 Select @samp{:work:}-tagged TODO lines with the specific TODO
3584 keyword @samp{WAITING}.
3585 @item work/!-WAITING-NEXT
3586 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
3587 nor @samp{NEXT}
3588 @item work/+WAITING|+NEXT
3589 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
3590 @samp{NEXT}.
3591 @end table
3593 @cindex regular expressions, with tags search
3594 Any element of the tag/todo match can be a regular expression - in this
3595 case it must be enclosed in curly braces.  For example,
3596 @samp{work+@{^boss.*@}} matches headlines that contain the tag
3597 @samp{:work:} and any tag @i{starting} with @samp{boss}.
3599 @cindex level, require for tags/property match
3600 @cindex category, require for tags/property match
3601 You can also require a headline to be of a certain level or category, by
3602 writing instead of any TAG an expression like @samp{LEVEL=3} or
3603 @samp{CATEGORY="work"}, respectively.  For example, a search
3604 @samp{+LEVEL=3+boss/-DONE} lists all level three headlines that have the
3605 tag @samp{boss} and are @emph{not} marked with the TODO keyword DONE.
3607 @node Properties and Columns, Dates and Times, Tags, Top
3608 @chapter Properties and Columns
3609 @cindex properties
3611 Properties are a set of key-value pairs associated with an entry.  There
3612 are two main applications for properties in Org mode.  First, properties
3613 are like tags, but with a value.  Second, you can use properties to
3614 implement (very basic) database capabilities in an Org buffer.  For
3615 an example of the first application, imagine maintaining a file where
3616 you document bugs and plan releases of a piece of software.  Instead of
3617 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
3618 property, say @code{:Release:}, that in different subtrees has different
3619 values, such as @code{1.0} or @code{2.0}.  For an example of the second
3620 application of properties, imagine keeping track of your music CD's,
3621 where properties could be things such as the album artist, date of
3622 release, number of tracks, and so on.
3624 Properties can be conveniently edited and viewed in column view
3625 (@pxref{Column view}).
3627 Properties are like tags, but with a value.  For example, in a file
3628 where you document bugs and plan releases of a piece of software,
3629 instead of using tags like @code{:release_1:}, @code{:release_2:}, it
3630 can be more efficient to use a property @code{:Release:} with a value
3631 @code{1.0} or @code{2.0}.  Second, you can use properties to implement
3632 (very basic) database capabilities in an Org buffer, for example to
3633 create a list of Music CD's you own.  You can edit and view properties
3634 conveniently in column view (@pxref{Column view}).
3636 @menu
3637 * Property syntax::             How properties are spelled out
3638 * Special properties::          Access to other Org mode features
3639 * Property searches::           Matching property values
3640 * Property inheritance::        Passing values down the tree
3641 * Column view::                 Tabular viewing and editing
3642 * Property API::                Properties for Lisp programmers
3643 @end menu
3645 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
3646 @section Property syntax
3647 @cindex property syntax
3648 @cindex drawer, for properties
3650 Properties are key-value pairs.  They need to be inserted into a special
3651 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
3652 is specified on a single line, with the key (surrounded by colons)
3653 first, and the value after it.  Here is an example:
3655 @example
3656 * CD collection
3657 ** Classic
3658 *** Goldberg Variations
3659     :PROPERTIES:
3660     :Title:     Goldberg Variations
3661     :Composer:  J.S. Bach
3662     :Artist:    Glen Gould
3663     :Publisher: Deutsche Grammphon
3664     :NDisks:    1
3665     :END:
3666 @end example
3668 You may define the allowed values for a particular property @samp{:Xyz:}
3669 by setting a property @samp{:Xyz_ALL:}.  This special property is
3670 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
3671 the entire tree.  When allowed values are defined, setting the
3672 corresponding property becomes easier and is less prone to typing
3673 errors.  For the example with the CD collection, we can predefine
3674 publishers and the number of disks in a box like this:
3676 @example
3677 * CD collection
3678   :PROPERTIES:
3679   :NDisks_ALL:  1 2 3 4
3680   :Publisher_ALL: "Deutsche Grammophon" Phillips EMI
3681   :END:
3682 @end example
3684 If you want to set properties that can be inherited by any entry in a
3685 file, use a line like
3687 @example
3688 #+PROPERTY: NDisks_ALL 1 2 3 4
3689 @end example
3691 Property values set with the global variable
3692 @code{org-global-properties} can be inherited by all entries in all
3693 Org files.
3695 @noindent
3696 The following commands help to work with properties:
3698 @table @kbd
3699 @kindex M-@key{TAB}
3700 @item M-@key{TAB}
3701 After an initial colon in a line, complete property keys.  All keys used
3702 in the current file will be offered as possible completions.
3703 @kindex C-c C-x p
3704 @item C-c C-x p
3705 Set a property.  This prompts for a property name and a value.  If
3706 necessary, the property drawer is created as well.
3707 @item M-x org-insert-property-drawer
3708 Insert a property drawer into the current entry.  The drawer will be
3709 inserted early in the entry, but after the lines with planning
3710 information like deadlines.
3711 @kindex C-c C-c
3712 @item C-c C-c
3713 With the cursor in a property drawer, this executes property commands.
3714 @item C-c C-c s
3715 Set a property in the current entry.  Both the property and the value
3716 can be inserted using completion.
3717 @kindex S-@key{right}
3718 @kindex S-@key{left}
3719 @item S-@key{left}/@key{right}
3720 Switch property at point to the next/previous allowed value.
3721 @item C-c C-c d
3722 Remove a property from the current entry.
3723 @item C-c C-c D
3724 Globally remove a property, from all entries in the current file.
3725 @item C-c C-c c
3726 Compute the property at point, using the operator and scope from the
3727 nearest column format definition.
3728 @end table
3730 @node Special properties, Property searches, Property syntax, Properties and Columns
3731 @section Special properties
3732 @cindex properties, special
3734 Special properties provide alternative access method to Org mode
3735 features discussed in the previous chapters, like the TODO state or the
3736 priority of an entry.  This interface exists so that you can include
3737 these states into columns view (@pxref{Column view}), or to use them in
3738 queries.  The following property names are special and should not be
3739 used as keys in the properties drawer:
3741 @example
3742 TODO         @r{The TODO keyword of the entry.}
3743 TAGS         @r{The tags defined directly in the headline.}
3744 ALLTAGS      @r{All tags, including inherited ones.}
3745 PRIORITY     @r{The priority of the entry, a string with a single letter.}
3746 DEADLINE     @r{The deadline time string, without the angular brackets.}
3747 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
3748 TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
3749 TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
3750 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
3751              @r{must be run first to compute the values.}
3752 @end example
3754 @node Property searches, Property inheritance, Special properties, Properties and Columns
3755 @section Property searches
3756 @cindex properties, searching
3757 @cindex searching, of properties
3759 To create sparse trees and special lists with selection based on properties,
3760 the same commands are used as for tag searches (@pxref{Tag searches}), and
3761 the same logic applies.  For example, here is a search string:
3763 @example
3764 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
3765          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
3766 @end example
3768 @noindent
3769 The type of comparison will depend on how the comparison value is written:
3770 @itemize @minus
3771 @item
3772 If the comparison value is a plain number, a numerical comparison is done,
3773 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
3774 @samp{>=}, and @samp{<>}.
3775 @item
3776 If the comparison value is enclosed in double
3777 quotes, a string comparison is done, and the same operators are allowed.  
3778 @item
3779 If the comparison value is enclosed in double quotes @emph{and} angular
3780 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
3781 assumed to be date/time specifications in the standard Org way@footnote{The
3782 only special values that will be recognized are @samp{"<now>"} for now, and
3783 @samp{"<today"} today at 0:00 hours, i.e. without a time specification.}, and
3784 the comparison will be done accordingly.
3785 @item
3786 If the comparison value is enclosed
3787 in curly braces, a regexp match is performed, with @samp{=} meaning that the
3788 regexp matches the property value, and @samp{<>} meaning that it does not
3789 match.  
3790 @end itemize
3792 So the search string in the example finds entries tagged @samp{:work:} but
3793 not @samp{:boss:}, which also have a priority value @samp{A}, a
3794 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
3795 property that is numerically smaller than 2, a @samp{:With:} property that is
3796 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
3797 on or after October 11, 2008.
3799 You can configure Org mode to use property inheritance during a search, but
3800 beware that this can slow down searches considerably.  See @ref{Property
3801 inheritance} for details.
3803 There is also a special command for creating sparse trees based on a
3804 single property:
3806 @table @kbd
3807 @kindex C-c / p
3808 @item C-c / p
3809 Create a sparse tree based on the value of a property.  This first
3810 prompts for the name of a property, and then for a value.  A sparse tree
3811 is created with all entries that define this property with the given
3812 value.  If you enclose the value into curly braces, it is interpreted as
3813 a regular expression and matched against the property values.
3814 @end table
3816 @node Property inheritance, Column view, Property searches, Properties and Columns
3817 @section Property Inheritance
3818 @cindex properties, inheritance
3819 @cindex inheritance, of properties
3821 The outline structure of Org mode documents lends itself for an
3822 inheritance model of properties: If the parent in a tree has a certain
3823 property, the children can inherit this property.  Org mode does not
3824 turn this on by default, because it can slow down property searches
3825 significantly and is often not needed.  However, if you find inheritance
3826 useful, you can turn it on by setting the variable
3827 @code{org-use-property-inheritance}.  It may be set to @code{t}, to make
3828 all properties inherited from the parent, to a list of properties
3829 that should be inherited, or to a regular expression that matches
3830 inherited properties.
3832 Org mode has a few properties for which inheritance is hard-coded, at
3833 least for the special applications for which they are used:
3835 @table @code
3836 @item COLUMNS
3837 The @code{:COLUMNS:} property defines the format of column view
3838 (@pxref{Column view}).  It is inherited in the sense that the level
3839 where a @code{:COLUMNS:} property is defined is used as the starting
3840 point for a column view table, independently of the location in the
3841 subtree from where columns view is turned on.
3842 @item CATEGORY
3843 For agenda view, a category set through a @code{:CATEGORY:} property
3844 applies to the entire subtree.
3845 @item ARCHIVE
3846 For archiving, the @code{:ARCHIVE:} property may define the archive
3847 location for the entire subtree (@pxref{Moving subtrees}).
3848 @item LOGGING
3849 The LOGGING property may define logging settings for an entry or a
3850 subtree (@pxref{Tracking TODO state changes}).
3851 @end table
3853 @node Column view, Property API, Property inheritance, Properties and Columns
3854 @section Column view
3856 A great way to view and edit properties in an outline tree is
3857 @emph{column view}.  In column view, each outline item is turned into a
3858 table row.  Columns in this table provide access to properties of the
3859 entries.  Org mode implements columns by overlaying a tabular structure
3860 over the headline of each item.  While the headlines have been turned
3861 into a table row, you can still change the visibility of the outline
3862 tree.  For example, you get a compact table by switching to CONTENTS
3863 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
3864 is active), but you can still open, read, and edit the entry below each
3865 headline.  Or, you can switch to column view after executing a sparse
3866 tree command and in this way get a table only for the selected items.
3867 Column view also works in agenda buffers (@pxref{Agenda Views}) where
3868 queries have collected selected items, possibly from a number of files.
3870 @menu
3871 * Defining columns::            The COLUMNS format property
3872 * Using column view::           How to create and use column view
3873 * Capturing column view::       A dynamic block for column view
3874 @end menu
3876 @node Defining columns, Using column view, Column view, Column view
3877 @subsection Defining columns
3878 @cindex column view, for properties
3879 @cindex properties, column view
3881 Setting up a column view first requires defining the columns.  This is
3882 done by defining a column format line.
3884 @menu
3885 * Scope of column definitions::  Where defined, where valid?
3886 * Column attributes::           Appearance and content of a column
3887 @end menu
3889 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
3890 @subsubsection Scope of column definitions
3892 To define a column format for an entire file, use a line like
3894 @example
3895 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3896 @end example
3898 To specify a format that only applies to a specific tree, add a
3899 @code{:COLUMNS:} property to the top node of that tree, for example:
3901 @example
3902 ** Top node for columns view
3903    :PROPERTIES:
3904    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3905    :END:
3906 @end example
3908 If a @code{:COLUMNS:} property is present in an entry, it defines columns
3909 for the entry itself, and for the entire subtree below it.  Since the
3910 column definition is part of the hierarchical structure of the document,
3911 you can define columns on level 1 that are general enough for all
3912 sublevels, and more specific columns further down, when you edit a
3913 deeper part of the tree.
3915 @node Column attributes,  , Scope of column definitions, Defining columns
3916 @subsubsection Column attributes
3917 A column definition sets the attributes of a column.  The general
3918 definition looks like this:
3920 @example
3921  %[width]property[(title)][@{summary-type@}]
3922 @end example
3924 @noindent
3925 Except for the percent sign and the property name, all items are
3926 optional.  The individual parts have the following meaning:
3928 @example
3929 width           @r{An integer specifying the width of the column in characters.}
3930                 @r{If omitted, the width will be determined automatically.}
3931 property        @r{The property that should be edited in this column.}
3932 (title)         @r{The header text for the column. If omitted, the}
3933                 @r{property name is used.}
3934 @{summary-type@}  @r{The summary type.  If specified, the column values for}
3935                 @r{parent nodes are computed from the children.}
3936                 @r{Supported summary types are:}
3937                 @{+@}       @r{Sum numbers in this column.}
3938                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
3939                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
3940                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
3941                 @{X@}       @r{Checkbox status, [X] if all children are [X].}
3942                 @{X/@}      @r{Checkbox status, [n/m].}
3943                 @{X%@}      @r{Checkbox status, [n%].}
3944 @end example
3946 @noindent
3947 Here is an example for a complete columns definition, along with allowed
3948 values.
3950 @example
3951 :COLUMNS:  %20ITEM %9Approved(Approved?)@{X@} %Owner %11Status \@footnote{Please note that the COLUMNS definition must be on a single line - it is wrapped here only because of formatting constraints.}
3952                    %10Time_Estimate@{:@} %CLOCKSUM
3953 :Owner_ALL:    Tammy Mark Karl Lisa Don
3954 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
3955 :Approved_ALL: "[ ]" "[X]"
3956 @end example
3958 The first column, @samp{%25ITEM}, means the first 25 characters of the
3959 item itself, i.e. of the headline.  You probably always should start the
3960 column definition with the @samp{ITEM} specifier.  The other specifiers
3961 create columns @samp{Owner} with a list of names as allowed values, for
3962 @samp{Status} with four different possible values, and for a checkbox
3963 field @samp{Approved}.  When no width is given after the @samp{%}
3964 character, the column will be exactly as wide as it needs to be in order
3965 to fully display all values.  The @samp{Approved} column does have a
3966 modified title (@samp{Approved?}, with a question mark).  Summaries will
3967 be created for the @samp{Time_Estimate} column by adding time duration
3968 expressions like HH:MM, and for the @samp{Approved} column, by providing
3969 an @samp{[X]} status if all children have been checked.  The
3970 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
3971 in the subtree.
3973 @node Using column view, Capturing column view, Defining columns, Column view
3974 @subsection Using column view
3976 @table @kbd
3977 @tsubheading{Turning column view on and off}
3978 @kindex C-c C-x C-c
3979 @item C-c C-x C-c
3980 Create the column view for the local environment.  This command searches
3981 the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
3982 a format.  When one is found, the column view table is established for
3983 the entire tree, starting from the entry that contains the @code{:COLUMNS:}
3984 property.  If none is found, the format is taken from the @code{#+COLUMNS}
3985 line or from the variable @code{org-columns-default-format}, and column
3986 view is established for the current entry and its subtree.
3987 @kindex r
3988 @item r
3989 Recreate the column view, to include recent changes made in the buffer.
3990 @kindex g
3991 @item g
3992 Same as @kbd{r}.
3993 @kindex q
3994 @item q
3995 Exit column view.
3996 @tsubheading{Editing values}
3997 @item @key{left} @key{right} @key{up} @key{down}
3998 Move through the column view from field to field.
3999 @kindex S-@key{left}
4000 @kindex S-@key{right}
4001 @item  S-@key{left}/@key{right}
4002 Switch to the next/previous allowed value of the field.  For this, you
4003 have to have specified allowed values for a property.
4004 @item 1..9,0
4005 Directly select the nth allowed value, @kbd{0} selects the 10th value.
4006 @kindex n
4007 @kindex p
4008 @itemx  n / p
4009 Same as @kbd{S-@key{left}/@key{right}}
4010 @kindex e
4011 @item e
4012 Edit the property at point.  For the special properties, this will
4013 invoke the same interface that you normally use to change that
4014 property.  For example, when editing a TAGS property, the tag completion
4015 or fast selection interface will pop up.
4016 @kindex C-c C-c
4017 @item C-c C-c
4018 When there is a checkbox at point, toggle it.
4019 @kindex v
4020 @item v
4021 View the full value of this property.  This is useful if the width of
4022 the column is smaller than that of the value.
4023 @kindex a
4024 @item a
4025 Edit the list of allowed values for this property.  If the list is found
4026 in the hierarchy, the modified values is stored there.  If no list is
4027 found, the new value is stored in the first entry that is part of the
4028 current column view.
4029 @tsubheading{Modifying the table structure}
4030 @kindex <
4031 @kindex >
4032 @item < / >
4033 Make the column narrower/wider by one character.
4034 @kindex S-M-@key{right}
4035 @item S-M-@key{right}
4036 Insert a new column, to the right of the current column.
4037 @kindex S-M-@key{left}
4038 @item S-M-@key{left}
4039 Delete the current column.
4040 @end table
4042 @node Capturing column view,  , Using column view, Column view
4043 @subsection Capturing column view
4045 Since column view is just an overlay over a buffer, it cannot be
4046 exported or printed directly.  If you want to capture a column view, use
4047 this @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
4048 of this block looks like this:
4050 @cindex #+BEGIN: columnview
4051 @example
4052 * The column view
4053 #+BEGIN: columnview :hlines 1 :id "label"
4055 #+END:
4056 @end example
4058 @noindent This dynamic block has the following parameters:
4060 @table @code
4061 @item :id
4062 This is most important parameter.  Column view is a feature that is
4063 often localized to a certain (sub)tree, and the capture block might be
4064 in a different location in the file.  To identify the tree whose view to
4065 capture, you can use 3 values:
4066 @example
4067 local     @r{use the tree in which the capture block is located}
4068 global    @r{make a global view, including all headings in the file}
4069 "label"   @r{call column view in the tree that has an @code{:ID:}}
4070           @r{property with the value @i{label}.  You can use}
4071           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4072           @r{the current entry and copy it to the kill-ring.}
4073 @end example
4074 @item :hlines
4075 When @code{t}, insert a hline after every line.  When a number N, insert
4076 a hline before each headline with level @code{<= N}.
4077 @item :vlines
4078 When set to @code{t}, enforce column groups to get vertical lines.
4079 @item :maxlevel
4080 When set to a number, don't capture entries below this level.
4081 @item :skip-empty-rows
4082 When set to @code{t}, skip row where the only non-empty specifier of the
4083 column view is @code{ITEM}.
4085 @end table
4087 @noindent
4088 The following commands insert or update the dynamic block:
4090 @table @kbd
4091 @kindex C-c C-x i
4092 @item C-c C-x i
4093 Insert a dynamic block capturing a column view.  You will be prompted
4094 for the scope or id of the view.
4095 @kindex C-c C-c
4096 @item C-c C-c
4097 @kindex C-c C-x C-u
4098 @itemx C-c C-x C-u
4099 Update dynamical block at point.  The cursor needs to be in the
4100 @code{#+BEGIN} line of the dynamic block.
4101 @kindex C-u C-c C-x C-u
4102 @item C-u C-c C-x C-u
4103 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4104 you have several clock table blocks in a buffer.
4105 @end table
4107 You can add formulas to the column view table and you may add plotting
4108 instructions in front of the table - these will survive an update of the
4109 block.  If there is a @code{#+TBLFM:} after the table, the table will actually
4110 be recalculated automatically after an update.
4112 @node Property API,  , Column view, Properties and Columns
4113 @section The Property API
4114 @cindex properties, API
4115 @cindex API, for properties
4117 There is a full API for accessing and changing properties.  This API can
4118 be used by Emacs Lisp programs to work with properties and to implement
4119 features based on them.  For more information see @ref{Using the
4120 property API}.
4122 @node Dates and Times, Remember, Properties and Columns, Top
4123 @chapter Dates and Times
4124 @cindex dates
4125 @cindex times
4126 @cindex time stamps
4127 @cindex date stamps
4129 To assist project planning, TODO items can be labeled with a date and/or
4130 a time.  The specially formatted string carrying the date and time
4131 information is called a @emph{timestamp} in Org mode.  This may be a
4132 little confusing because timestamp is often used as indicating when
4133 something was created or last changed.  However, in Org mode this term
4134 is used in a much wider sense.
4136 @menu
4137 * Timestamps::                  Assigning a time to a tree entry
4138 * Creating timestamps::         Commands which insert timestamps
4139 * Deadlines and scheduling::    Planning your work
4140 * Clocking work time::          Tracking how long you spend on a task
4141 * Effort estimates::            Planning work effort in advance
4142 @end menu
4145 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4146 @section Timestamps, deadlines and scheduling
4147 @cindex time stamps
4148 @cindex ranges, time
4149 @cindex date stamps
4150 @cindex deadlines
4151 @cindex scheduling
4153 A time stamp is a specification of a date (possibly with time or a range
4154 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4155 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4156 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4157 use an alternative format, see @ref{Custom time format}.}.  A time stamp
4158 can appear anywhere in the headline or body of an Org tree entry.  Its
4159 presence causes entries to be shown on specific dates in the agenda
4160 (@pxref{Weekly/daily agenda}).  We distinguish:
4162 @table @var
4163 @item Plain time stamp; Event; Appointment
4164 @cindex timestamp
4165 A simple time stamp just assigns a date/time to an item.  This is just
4166 like writing down an appointment or event in a paper agenda.  In the
4167 timeline and agenda displays, the headline of an entry associated with a
4168 plain time stamp will be shown exactly on that date.
4170 @example
4171 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4172 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4173 @end example
4175 @item Time stamp with repeater interval
4176 @cindex timestamp, with repeater interval
4177 A time stamp may contain a @emph{repeater interval}, indicating that it
4178 applies not only on the given date, but again and again after a certain
4179 interval of N days (d), weeks (w), months(m), or years(y).  The
4180 following will show up in the agenda every Wednesday:
4182 @example
4183 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4184 @end example
4186 @item Diary-style sexp entries
4187 For more complex date specifications, Org mode supports using the
4188 special sexp diary entries implemented in the Emacs calendar/diary
4189 package.  For example
4191 @example
4192 * The nerd meeting on every 2nd Thursday of the month
4193   <%%(diary-float t 4 2)>
4194 @end example
4196 @item Time/Date range
4197 @cindex timerange
4198 @cindex date range
4199 Two time stamps connected by @samp{--} denote a range.  The headline
4200 will be shown on the first and last day of the range, and on any dates
4201 that are displayed and fall in the range.  Here is an example:
4203 @example
4204 ** Meeting in Amsterdam
4205    <2004-08-23 Mon>--<2004-08-26 Thu>
4206 @end example
4208 @item Inactive time stamp
4209 @cindex timestamp, inactive
4210 @cindex inactive timestamp
4211 Just like a plain time stamp, but with square brackets instead of
4212 angular ones.  These time stamps are inactive in the sense that they do
4213 @emph{not} trigger an entry to show up in the agenda.
4215 @example
4216 * Gillian comes late for the fifth time [2006-11-01 Wed]
4217 @end example
4219 @end table
4221 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4222 @section Creating timestamps
4223 @cindex creating timestamps
4224 @cindex timestamps, creating
4226 For Org mode to recognize time stamps, they need to be in the specific
4227 format.  All commands listed below produce time stamps in the correct
4228 format.
4230 @table @kbd
4231 @kindex C-c .
4232 @item C-c .
4233 Prompt for a date and insert a corresponding time stamp.  When the cursor is
4234 at an existing time stamp in the buffer, the command is used to modify this
4235 timestamp instead of inserting a new one.  When this command is used twice in
4236 succession, a time range is inserted.
4238 @kindex C-u C-c .
4239 @item C-u C-c .
4240 Like @kbd{C-c .}, but use the alternative format which contains date
4241 and time.  The default time can be rounded to multiples of 5 minutes,
4242 see the option @code{org-time-stamp-rounding-minutes}.
4244 @kindex C-c !
4245 @item C-c !
4246 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
4247 an agenda entry.
4249 @kindex C-c <
4250 @item C-c <
4251 Insert a time stamp corresponding to the cursor date in the Calendar.
4253 @kindex C-c >
4254 @item C-c >
4255 Access the Emacs calendar for the current date.  If there is a
4256 timestamp in the current line, go to the corresponding date
4257 instead.
4259 @kindex C-c C-o
4260 @item C-c C-o
4261 Access the agenda for the date given by the time stamp or -range at
4262 point (@pxref{Weekly/daily agenda}).
4264 @kindex S-@key{left}
4265 @kindex S-@key{right}
4266 @item S-@key{left}
4267 @itemx S-@key{right}
4268 Change date at cursor by one day.  These key bindings conflict with
4269 CUA mode (@pxref{Conflicts}).
4271 @kindex S-@key{up}
4272 @kindex S-@key{down}
4273 @item S-@key{up}
4274 @itemx S-@key{down}
4275 Change the item under the cursor in a timestamp.  The cursor can be on a
4276 year, month, day, hour or minute.  Note that if the cursor is in a
4277 headline and not at a time stamp, these same keys modify the priority of
4278 an item.  (@pxref{Priorities}). The key bindings also conflict with
4279 CUA mode (@pxref{Conflicts}).
4281 @kindex C-c C-y
4282 @cindex evaluate time range
4283 @item C-c C-y
4284 Evaluate a time range by computing the difference between start and end.
4285 With a prefix argument, insert result after the time range (in a table: into
4286 the following column).
4287 @end table
4290 @menu
4291 * The date/time prompt::        How Org mode helps you entering date and time
4292 * Custom time format::          Making dates look different
4293 @end menu
4295 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4296 @subsection The date/time prompt
4297 @cindex date, reading in minibuffer
4298 @cindex time, reading in minibuffer
4300 When Org mode prompts for a date/time, the default is shown as an ISO
4301 date, and the prompt therefore seems to ask for an ISO date.  But it
4302 will in fact accept any string containing some date and/or time
4303 information, and it is really smart about interpreting your input.  You
4304 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4305 copied from an email message.  Org mode will find whatever information
4306 is in there and derive anything you have not specified from the
4307 @emph{default date and time}.  The default is usually the current date
4308 and time, but when modifying an existing time stamp, or when entering
4309 the second stamp of a range, it is taken from the stamp in the buffer.
4310 When filling in information, Org mode assumes that most of the time you
4311 will want to enter a date in the future: If you omit the month/year and
4312 the given day/month is @i{before} today, it will assume that you mean a
4313 future date@footnote{See the variable
4314 @code{org-read-date-prefer-future}.}.
4316 For example, lets assume that today is @b{June 13, 2006}.  Here is how
4317 various inputs will be interpreted, the items filled in by Org mode are
4318 in @b{bold}.
4320 @example
4321 3-2-5         --> 2003-02-05
4322 14            --> @b{2006}-@b{06}-14
4323 12            --> @b{2006}-@b{07}-12
4324 Fri           --> nearest Friday (defaultdate or later)
4325 sep 15        --> @b{2006}-11-15
4326 feb 15        --> @b{2007}-02-15
4327 sep 12 9      --> 2009-09-12
4328 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
4329 22 sept 0:34  --> @b{2006}-09-22 0:34
4330 w4            --> ISO week for of the current year @b{2006}
4331 2012 w4 fri   --> Friday of ISO week 4 in 2012
4332 2012-w04-5    --> Same as above
4333 @end example
4335 Furthermore you can specify a relative date by giving, as the
4336 @emph{first} thing in the input: a plus/minus sign, a number and a
4337 letter [dwmy] to indicate change in days weeks, months, years.  With a
4338 single plus or minus, the date is always relative to today.  With a
4339 double plus or minus, it is relative to the default date.  If instead of
4340 a single letter, you use the abbreviation of day name, the date will be
4341 the nth such day.  E.g.
4343 @example
4344 +0            --> today
4345 .             --> today
4346 +4d           --> four days from today
4347 +4            --> same as above
4348 +2w           --> two weeks from today
4349 ++5           --> five days from default date
4350 +2tue         --> second tuesday from now.
4351 @end example
4353 The function understands English month and weekday abbreviations.  If
4354 you want to use unabbreviated names and/or other languages, configure
4355 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
4357 @cindex calendar, for selecting date
4358 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
4359 you don't need/want the calendar, configure the variable
4360 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
4361 prompt, either by clicking on a date in the calendar, or by pressing
4362 @key{RET}, the date selected in the calendar will be combined with the
4363 information entered at the prompt.  You can control the calendar fully
4364 from the minibuffer:
4366 @kindex <
4367 @kindex >
4368 @kindex mouse-1
4369 @kindex S-@key{right}
4370 @kindex S-@key{left}
4371 @kindex S-@key{down}
4372 @kindex S-@key{up}
4373 @kindex M-S-@key{right}
4374 @kindex M-S-@key{left}
4375 @kindex @key{RET}
4376 @example
4377 > / <          @r{Scroll calendar forward/backward by one month.}
4378 mouse-1        @r{Select date by clicking on it.}
4379 S-@key{right}/@key{left}     @r{One day forward/backward.}
4380 S-@key{down}/@key{up}     @r{One week forward/backward.}
4381 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
4382 @key{RET}           @r{Choose date in calendar.}
4383 @end example
4385 The actions of the date/time prompt may seem complex, but I assure you they
4386 will grow on you, and you will start getting annoyed by pretty much any other
4387 way of entering a date/time out there.  To help you understand what is going
4388 on, the current interpretation of your input will be displayed live in the
4389 minibuffer@footnote{If you find this distracting, turn the display of with
4390 @code{org-read-date-display-live}.}.
4392 @node Custom time format,  , The date/time prompt, Creating timestamps
4393 @subsection Custom time format
4394 @cindex custom date/time format
4395 @cindex time format, custom
4396 @cindex date format, custom
4398 Org mode uses the standard ISO notation for dates and times as it is
4399 defined in ISO 8601.  If you cannot get used to this and require another
4400 representation of date and time to keep you happy, you can get it by
4401 customizing the variables @code{org-display-custom-times} and
4402 @code{org-time-stamp-custom-formats}.
4404 @table @kbd
4405 @kindex C-c C-x C-t
4406 @item C-c C-x C-t
4407 Toggle the display of custom formats for dates and times.
4408 @end table
4410 @noindent
4411 Org mode needs the default format for scanning, so the custom date/time
4412 format does not @emph{replace} the default format - instead it is put
4413 @emph{over} the default format using text properties.  This has the
4414 following consequences:
4415 @itemize @bullet
4416 @item
4417 You cannot place the cursor onto a time stamp anymore, only before or
4418 after.
4419 @item
4420 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4421 each component of a time stamp.  If the cursor is at the beginning of
4422 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4423 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4424 time will be changed by one minute.
4425 @item
4426 If the time stamp contains a range of clock times or a repeater, these
4427 will not be overlayed, but remain in the buffer as they were.
4428 @item
4429 When you delete a time stamp character-by-character, it will only
4430 disappear from the buffer after @emph{all} (invisible) characters
4431 belonging to the ISO timestamp have been removed.
4432 @item
4433 If the custom time stamp format is longer than the default and you are
4434 using dates in tables, table alignment will be messed up.  If the custom
4435 format is shorter, things do work as expected.
4436 @end itemize
4439 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
4440 @section Deadlines and scheduling
4442 A time stamp may be preceded by special keywords to facilitate planning:
4444 @table @var
4445 @item DEADLINE
4446 @cindex DEADLINE keyword
4448 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
4449 to be finished on that date.
4451 On the deadline date, the task will be listed in the agenda.  In
4452 addition, the agenda for @emph{today} will carry a warning about the
4453 approaching or missed deadline, starting
4454 @code{org-deadline-warning-days} before the due date, and continuing
4455 until the entry is marked DONE.  An example:
4457 @example
4458 *** TODO write article about the Earth for the Guide
4459     The editor in charge is [[bbdb:Ford Prefect]]
4460     DEADLINE: <2004-02-29 Sun>
4461 @end example
4463 You can specify a different lead time for warnings for a specific
4464 deadlines using the following syntax.  Here is an example with a warning
4465 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4467 @item SCHEDULED
4468 @cindex SCHEDULED keyword
4470 Meaning: you are planning to start working on that task on the given
4471 date.
4473 The headline will be listed under the given date@footnote{It will still
4474 be listed on that date after it has been marked DONE.  If you don't like
4475 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4476 addition, a reminder that the scheduled date has passed will be present
4477 in the compilation for @emph{today}, until the entry is marked DONE.
4478 I.e., the task will automatically be forwarded until completed.
4480 @example
4481 *** TODO Call Trillian for a date on New Years Eve.
4482     SCHEDULED: <2004-12-25 Sat>
4483 @end example
4485 @noindent
4486 @b{Important:} Scheduling an item in Org mode should @i{not} be
4487 understood in the same way that we understand @i{scheduling a meeting}.
4488 Setting a date for a meeting is just a simple appointment, you should
4489 mark this entry with a simple plain time stamp, to get this item shown
4490 on the date where it applies.  This is a frequent mis-understanding from
4491 Org-users.  In Org mode, @i{scheduling} means setting a date when you
4492 want to start working on an action item.
4493 @end table
4495 You may use time stamps with repeaters in scheduling and deadline
4496 entries.  Org mode will issue early and late warnings based on the
4497 assumption that the time stamp represents the @i{nearest instance} of
4498 the repeater.  However, the use of diary sexp entries like
4500 @code{<%%(diary-float t 42)>}
4502 in scheduling and deadline timestamps is limited.  Org mode does not
4503 know enough about the internals of each sexp function to issue early and
4504 late warnings.  However, it will show the item on each day where the
4505 sexp entry matches.
4507 @menu
4508 * Inserting deadline/schedule::  Planning items
4509 * Repeated tasks::              Items that show up again and again
4510 @end menu
4512 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4513 @subsection Inserting deadlines or schedules
4515 The following commands allow to quickly insert a deadline or to schedule
4516 an item:
4518 @table @kbd
4520 @kindex C-c C-d
4521 @item C-c C-d
4522 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4523 happen in the line directly following the headline.  When called with a
4524 prefix arg, an existing deadline will be removed from the entry.
4525 @c FIXME Any CLOSED timestamp will be removed.????????
4527 @kindex C-c / d
4528 @cindex sparse tree, for deadlines
4529 @item C-c / d
4530 Create a sparse tree with all deadlines that are either past-due, or
4531 which will become due within @code{org-deadline-warning-days}.
4532 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4533 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
4534 all deadlines due tomorrow.
4536 @kindex C-c C-s
4537 @item C-c C-s
4538 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4539 happen in the line directly following the headline.  Any CLOSED
4540 timestamp will be removed.  When called with a prefix argument, remove
4541 the scheduling date from the entry.
4543 @kindex C-c C-x C-k
4544 @kindex k a
4545 @kindex k s
4546 @item C-c C-x C-k
4547 Mark the current entry for agenda action.  After you have marked the entry
4548 like this, you can open the agenda or the calendar to find an appropriate
4549 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
4550 schedule the marked item.
4551 @end table
4553 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4554 @subsection Repeated tasks
4556 Some tasks need to be repeated again and again.  Org mode helps to
4557 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
4558 or plain time stamp.  In the following example
4559 @example
4560 ** TODO Pay the rent
4561    DEADLINE: <2005-10-01 Sat +1m>
4562 @end example
4563 the @code{+1m} is a repeater; the intended interpretation is that the
4564 task has a deadline on <2005-10-01> and repeats itself every (one) month
4565 starting from that time.  If you need both a repeater and a special
4566 warning period in a deadline entry, the repeater comes first and the
4567 warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
4569 Deadlines and scheduled items produce entries in the agenda when they
4570 are over-due, so it is important to be able to mark such an entry as
4571 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
4572 with the TODO keyword DONE, it will no longer produce entries in the
4573 agenda.  The problem with this is, however, that then also the
4574 @emph{next} instance of the repeated entry will not be active.  Org mode
4575 deals with this in the following way: When you try to mark such an entry
4576 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
4577 time stamp by the repeater interval, and immediately set the entry state
4578 back to TODO.  In the example above, setting the state to DONE would
4579 actually switch the date like this:
4581 @example
4582 ** TODO Pay the rent
4583    DEADLINE: <2005-11-01 Tue +1m>
4584 @end example
4586 A timestamp@footnote{You can change this using the option
4587 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
4588 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
4589 will aslo be prompted for a note.} will be added under the deadline, to keep
4590 a record that you actually acted on the previous instance of this deadline.
4592 As a consequence of shifting the base date, this entry will no longer be
4593 visible in the agenda when checking past dates, but all future instances
4594 will be visible.
4596 With the @samp{+1m} cookie, the date shift will always be exactly one
4597 month.  So if you have not payed the rent for three months, marking this
4598 entry DONE will still keep it as an overdue deadline.  Depending on the
4599 task, this may not be the best way to handle it.  For example, if you
4600 forgot to call you father for 3 weeks, it does not make sense to call
4601 him 3 times in a single day to make up for it.  Finally, there are tasks
4602 like changing batteries which should always repeat a certain time
4603 @i{after} the last time you did it.  For these tasks, Org mode has
4604 special repeaters markers with @samp{++} and @samp{.+}.  For example:
4606 @example
4607 ** TODO Call Father
4608    DEADLINE: <2008-02-10 Sun ++1w>
4609    Marking this DONE will shift the date by at least one week,
4610    but also by as many weeks as it takes to get this date into
4611    the future.  However, it stays on a Sunday, even if you called
4612    and marked it done on Saturday.
4613 ** TODO Check the batteries in the smoke detectors
4614    DEADLINE: <2005-11-01 Tue .+1m>
4615    Marking this DONE will shift the date to one month after
4616    today.
4617 @end example
4619 You may have both scheduling and deadline information for a specific
4620 task - just make sure that the repeater intervals on both are the same.
4622 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
4623 @section Clocking work time
4625 Org mode allows you to clock the time you spent on specific tasks in a
4626 project.  When you start working on an item, you can start the clock.
4627 When you stop working on that task, or when you mark the task done, the
4628 clock is stopped and the corresponding time interval is recorded.  It
4629 also computes the total time spent on each subtree of a project.
4631 @table @kbd
4632 @kindex C-c C-x C-i
4633 @item C-c C-x C-i
4634 Start the clock on the current item (clock-in).  This inserts the CLOCK
4635 keyword together with a timestamp.  If this is not the first clocking of
4636 this item, the multiple CLOCK lines will be wrapped into a
4637 @code{:CLOCK:} drawer (see also the variable
4638 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
4639 select the task from a list of recently clocked tasks.  With two @kbd{C-u
4640 C-u} prefixes, clock into the task at point and mark it as the default task.
4641 The default task will always be available when selecting a clocking task,
4642 with letter @kbd{d}.
4643 @kindex C-c C-x C-o
4644 @item C-c C-x C-o
4645 Stop the clock (clock-out).  The inserts another timestamp at the same
4646 location where the clock was last started.  It also directly computes
4647 the resulting time in inserts it after the time range as @samp{=>
4648 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
4649 possibility to record an additional note together with the clock-out
4650 time stamp@footnote{The corresponding in-buffer setting is:
4651 @code{#+STARTUP: lognoteclock-out}}.
4652 @kindex C-c C-y
4653 @item C-c C-y
4654 Recompute the time interval after changing one of the time stamps.  This
4655 is only necessary if you edit the time stamps directly.  If you change
4656 them with @kbd{S-@key{cursor}} keys, the update is automatic.
4657 @kindex C-c C-t
4658 @item C-c C-t
4659 Changing the TODO state of an item to DONE automatically stops the clock
4660 if it is running in this same item.
4661 @kindex C-c C-x C-x
4662 @item C-c C-x C-x
4663 Cancel the current clock.  This is useful if a clock was started by
4664 mistake, or if you ended up working on something else.
4665 @kindex C-c C-x C-j
4666 @item C-c C-x C-j
4667 Jump to the entry that contains the currently running clock.  With a
4668 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
4669 tasks.
4670 @kindex C-c C-x C-d
4671 @item C-c C-x C-d
4672 Display time summaries for each subtree in the current buffer.  This
4673 puts overlays at the end of each headline, showing the total time
4674 recorded under that heading, including the time of any subheadings. You
4675 can use visibility cycling to study the tree, but the overlays disappear
4676 when you change the buffer (see variable
4677 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
4678 @kindex C-c C-x C-r
4679 @item C-c C-x C-r
4680 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
4681 report as an Org mode table into the current file.  When the cursor is
4682 at an existing clock table, just update it.  When called with a prefix
4683 argument, jump to the first clock report in the current document and
4684 update it.
4685 @cindex #+BEGIN: clocktable
4686 @example
4687 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4688 #+END: clocktable
4689 @end example
4690 @noindent
4691 If such a block already exists at point, its content is replaced by the
4692 new table.  The @samp{BEGIN} line can specify options:
4693 @example
4694 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
4695 :emphasize   @r{When @code{t}, emphasize level one and level two items}
4696 :scope       @r{The scope to consider.  This can be any of the following:}
4697              nil        @r{the current buffer or narrowed region}
4698              file       @r{the full current buffer}
4699              subtree    @r{the subtree where the clocktable is located}
4700              treeN      @r{the surrounding level N tree, for example @code{tree3}}
4701              tree       @r{the surrounding level 1 tree}
4702              agenda     @r{all agenda files}
4703              ("file"..) @r{scan these files}
4704              file-with-archives    @r{current file and its archives}
4705              agenda-with-archives  @r{all agenda files, including archives}
4706 :block       @r{The time block to consider.  This block is specified either}
4707              @r{absolute, or relative to the current time and may be any of}
4708              @r{these formats:}
4709              2007-12-31    @r{New year eve 2007}
4710              2007-12       @r{December 2007}
4711              2007-W50      @r{ISO-week 50 in 2007}
4712              2007          @r{the year 2007}
4713              today, yesterday, today-N          @r{a relative day}
4714              thisweek, lastweek, thisweek-N     @r{a relative week}
4715              thismonth, lastmonth, thismonth-N  @r{a relative month}
4716              thisyear, lastyear, thisyear-N     @r{a relative year}
4717              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
4718 :tstart      @r{A time string specifying when to start considering times}
4719 :tend        @r{A time string specifying when to stop considering times}
4720 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
4721              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
4722 :link        @r{Link the item headlines in the table to their origins}
4723 @end example
4724 So to get a clock summary of the current level 1 tree, for the current
4725 day, you could write
4726 @example
4727 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
4728 #+END: clocktable
4729 @end example
4730 and to use a specific time range you could write@footnote{Note that all
4731 parameters must be specified in a single line - the line is broken here
4732 only to fit it onto the manual.}
4733 @example
4734 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
4735                     :tend "<2006-08-10 Thu 12:00>"
4736 #+END: clocktable
4737 @end example
4738 @kindex C-c C-c
4739 @item C-c C-c
4740 @kindex C-c C-x C-u
4741 @itemx C-c C-x C-u
4742 Update dynamical block at point.  The cursor needs to be in the
4743 @code{#+BEGIN} line of the dynamic block.
4744 @kindex C-u C-c C-x C-u
4745 @item C-u C-c C-x C-u
4746 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4747 you have several clock table blocks in a buffer.
4748 @kindex S-@key{left}
4749 @kindex S-@key{right}
4750 @item S-@key{left}
4751 @itemx S-@key{right}
4752 Shift the current @code{:block} interval and update the table.  The cursor
4753 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
4754 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
4755 @end table
4757 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
4758 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
4759 worked on or closed during a day.
4761 @node Effort estimates,  , Clocking work time, Dates and Times
4762 @section Effort estimates
4763 @cindex Effort estimates
4765 If you want to plan your work in a very detailed way, or if you need to
4766 produce offers with quotations of the estimated work effort, you may want to
4767 assign effort estimates to entries.  If you are also clocking your work, you
4768 may later want to compare the planned effort with the actual working time, a
4769 great way to improve planning estimates.  Effort estimates are stored in a
4770 special property @samp{Effort}@footnote{You may change the property being
4771 used with the variable @code{org-effort-property}.}.  Clearly the best way to
4772 work with effort estimates is through column view (@pxref{Column view}).  You
4773 should start by setting up discrete values for effort estimates, and a
4774 @code{COLUMNS} format that displays these values together with clock sums (if
4775 you want to clock your time).  For a specific buffer you can use
4777 @example
4778 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
4779 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
4780 @end example
4782 @noindent
4783 or you can set up these values globally by customizing the variables
4784 @code{org-global-properties} and @code{org-columns-default-format}.  In
4785 particular if you want to use this setup also in the agenda, a global setup
4786 may be advised.
4788 The way to assign estimates to individual items is then to switch to column
4789 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
4790 value.  The values you enter will immediately be summed up in the hierarchy.
4791 In the column next to it, any clocked time will be displayed.
4793 If you switch to column view in the daily/weekly agenda, the effort column
4794 will summarize the estimated work effort for each day@footnote{Please note
4795 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
4796 column view}).}, and you can use this to find space in your schedule.  To get
4797 an overview of the entire part of the day that is committed, you can set the
4798 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
4799 appointments on a day that take place over a specified time interval will
4800 then also be added to the load estimate of the day.
4802 @node Remember, Agenda Views, Dates and Times, Top
4803 @chapter Remember
4804 @cindex @file{remember.el}
4806 The @i{Remember} package by John Wiegley lets you store quick notes with
4807 little interruption of your work flow.  See
4808 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
4809 information.  It is an excellent way to add new notes and tasks to
4810 Org files.  Org significantly expands the possibilities of
4811 @i{remember}: You may define templates for different note types, and
4812 associate target files and headlines with specific templates.  It also
4813 allows you to select the location where a note should be stored
4814 interactively, on the fly.
4816 @menu
4817 * Setting up Remember::         Some code for .emacs to get things going
4818 * Remember templates::          Define the outline of different note types
4819 * Storing notes::               Directly get the note to where it belongs
4820 * Refiling notes::              Moving a note or task to a project
4821 @end menu
4823 @node Setting up Remember, Remember templates, Remember, Remember
4824 @section Setting up Remember
4826 The following customization will tell @i{remember} to use org files as
4827 target, and to create annotations compatible with Org links.
4829 @example
4830 (org-remember-insinuate)
4831 (setq org-directory "~/path/to/my/orgfiles/")
4832 (setq org-default-notes-file (concat org-directory "/notes.org"))
4833 (define-key global-map "\C-cr" 'org-remember)
4834 @end example
4836 The last line binds the command @code{org-remember} to a global
4837 key@footnote{Please select your own key, @kbd{C-c r} is only a
4838 suggestion.}.  @code{org-remember} basically just calls @code{remember},
4839 but it makes a few things easier: If there is an active region, it will
4840 automatically copy the region into the remember buffer.  It also allows
4841 to jump to the buffer and location where remember notes are being
4842 stored: Just call @code{org-remember} with a prefix argument.  If you
4843 use two prefix arguments, Org jumps to the location where the last
4844 remember note was stored.
4846 You can also call @code{org-remember} in a special way from the agenda,
4847 using the @kbd{k r} key combination.  With this access, any time stamps
4848 inserted by the selected remember template (see below) will default to
4849 the cursor date in the agenda, rather than to the current date.
4851 @node Remember templates, Storing notes, Setting up Remember, Remember
4852 @section Remember templates
4853 @cindex templates, for remember
4855 In combination with Org, you can use templates to generate
4856 different types of @i{remember} notes.  For example, if you would like
4857 to use one template to create general TODO entries, another one for
4858 journal entries, and a third one for collecting random ideas, you could
4859 use:
4861 @example
4862 (setq org-remember-templates
4863  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
4864    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
4865    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4866 @end example
4868 @noindent In these entries, the first string is just a name, and the
4869 character specifies how to select the template.  It is useful if the
4870 character is also the first letter of the name.  The next string specifies
4871 the template.  Two more (optional) strings give the file in which, and the
4872 headline under which the new note should be stored.  The file (if not present
4873 or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
4874 @code{org-remember-default-headline}.  If the file name is not an absolute
4875 path, it will be interpreted relative to @code{org-directory}.  The heading
4876 can also be the symbols @code{top} or @code{bottom} to send note as level 1
4877 entries to the beginning or end of the file, respectively.
4879 An optional sixth element specifies the contexts in which the user can select
4880 the template.  This element can be a list of major modes or a function.
4881 @code{org-remember} will first check whether the function returns @code{t} or
4882 if we are in any of the listed major mode, and exclude templates fo which
4883 this condition is not fulfilled.  Templates that do not specify this element
4884 at all, or that use @code{nil} or @code{t} as a value will always be
4885 selectable.
4887 So for example:
4889 @example
4890 (setq org-remember-templates
4891  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
4892    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
4893    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4894 @end example
4896 The first template will only be available when invoking @code{org-remember}
4897 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
4898 available when the function @code{my-check} returns @code{t}.  The third
4899 template will be proposed in any context.
4901 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
4902 something, Org will prompt for a key to select the template (if you have
4903 more than one template) and then prepare the buffer like
4904 @example
4905 * TODO
4906   [[file:link to where you called remember]]
4907 @end example
4909 @noindent
4910 During expansion of the template, special @kbd{%}-escapes allow dynamic
4911 insertion of content:
4912 @example
4913 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
4914             @r{You may specify a default value and a completion table with}
4915             @r{%^@{prompt|default|completion2|completion3...@}}
4916             @r{The arrow keys access a prompt-specific history.}
4917 %a          @r{annotation, normally the link created with @code{org-store-link}}
4918 %A          @r{like @code{%a}, but prompt for the description part}
4919 %i          @r{initial content, the region when remember is called with C-u.}
4920             @r{The entire text will be indented like @code{%i} itself.}
4921 %t          @r{time stamp, date only}
4922 %T          @r{time stamp with date and time}
4923 %u, %U      @r{like the above, but inactive time stamps}
4924 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
4925             @r{You may define a prompt like @code{%^@{Birthday@}t}}
4926 %n          @r{user name (taken from @code{user-full-name})}
4927 %c          @r{Current kill ring head.}
4928 %x          @r{Content of the X clipboard.}
4929 %^C         @r{Interactive selection of which kill or clip to use.}
4930 %^L         @r{Like @code{%^C}, but insert as link.}
4931 %^g         @r{prompt for tags, with completion on tags in target file.}
4932 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
4933 %:keyword   @r{specific information for certain link types, see below}
4934 %[pathname] @r{insert the contents of the file given by @code{pathname}}
4935 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
4936 %!          @r{immediately store note after completing the template}
4937             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
4938 %&          @r{jump to target location immediately after storing note}
4939 @end example
4941 @noindent
4942 For specific link types, the following keywords will be
4943 defined@footnote{If you define your own link types (@pxref{Adding
4944 hyperlink types}), any property you store with
4945 @code{org-store-link-props} can be accessed in remember templates in a
4946 similar way.}:
4948 @example
4949 Link type          |  Available keywords
4950 -------------------+----------------------------------------------
4951 bbdb               |  %:name %:company
4952 bbdb               |  %::server %:port %:nick
4953 vm, wl, mh, rmail  |  %:type %:subject %:message-id
4954                    |  %:from %:fromname %:fromaddress
4955                    |  %:to   %:toname   %:toaddress
4956                    |  %:fromto @r{(either "to NAME" or "from NAME")@footnote{This will always be the other, not the user.  See the variable @code{org-from-is-user-regexp}.}}
4957 gnus               |  %:group, @r{for messages also all email fields}
4958 w3, w3m            |  %:url
4959 info               |  %:file %:node
4960 calendar           |  %:date"
4961 @end example
4963 @noindent
4964 To place the cursor after template expansion use:
4966 @example
4967 %?          @r{After completing the template, position cursor here.}
4968 @end example
4970 @noindent
4971 If you change your mind about which template to use, call
4972 @code{org-remember} in the remember buffer.  You may then select a new
4973 template that will be filled with the previous context information.
4975 @node Storing notes, Refiling notes, Remember templates, Remember
4976 @section Storing notes
4978 When you are finished preparing a note with @i{remember}, you have to press
4979 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
4980 remember buffer, you will first be asked if you want to clock out
4981 now@footnote{To avoid this query, configure the variable
4982 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
4983 will continue to run after the note was filed away.
4985 The handler will then store the note in the file and under the headline
4986 specified in the template, or it will use the default file and headlines.
4987 The window configuration will be restored, sending you back to the working
4988 context before the call to @code{remember}.  To re-use the location found
4989 during the last call to @code{remember}, exit the remember buffer with
4990 @kbd{C-0 C-c C-c}, i.e. specify a zero prefix argument to @kbd{C-c C-c}.
4992 If you want to store the note directly to a different place, use
4993 @kbd{C-1 C-c C-c} instead to exit remember@footnote{Configure the
4994 variable @code{org-remember-store-without-prompt} to make this behavior
4995 the default.}.  The handler will then first prompt for a target file -
4996 if you press @key{RET}, the value specified for the template is used.
4997 Then the command offers the headings tree of the selected file, with the
4998 cursor position at the default headline (if you had specified one in the
4999 template).  You can either immediately press @key{RET} to get the note
5000 placed there.  Or you can use the following keys to find a different
5001 location:
5002 @example
5003 @key{TAB}         @r{Cycle visibility.}
5004 @key{down} / @key{up}   @r{Next/previous visible headline.}
5005 n / p        @r{Next/previous visible headline.}
5006 f / b        @r{Next/previous headline same level.}
5007 u            @r{One level up.}
5008 @c 0-9          @r{Digit argument.}
5009 @end example
5010 @noindent
5011 Pressing @key{RET} or @key{left} or @key{right}
5012 then leads to the following result.
5014 @multitable @columnfractions 0.2 0.15 0.65
5015 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
5016 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
5017 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
5018 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
5019 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
5020 @item                 @tab @tab depending on @code{org-reverse-note-order}.
5021 @item not on headline @tab @key{RET}
5022       @tab at cursor position, level taken from context.
5023 @end multitable
5025 Before inserting the text into a tree, the function ensures that the
5026 text has a headline, i.e. a first line that starts with a @samp{*}.  If
5027 not, a headline is constructed from the current date and some additional
5028 data.  If you have indented the text of the note below the headline, the
5029 indentation will be adapted if inserting the note into the tree requires
5030 demotion from level 1.
5032 @node Refiling notes,  , Storing notes, Remember
5033 @section Refiling notes
5034 @cindex refiling notes
5036 Remember is usually used to quickly capture notes and tasks into one or
5037 a few capture lists.  When reviewing the captured data, you may want to
5038 refile some of the entries into a different list, for example into a
5039 project.  Cutting, finding the right location and then pasting the note
5040 is cumbersome.  To simplify this process, you can use the following
5041 special command:
5043 @table @kbd
5044 @kindex C-c C-w
5045 @item C-c C-w
5046 Refile the entry at point.  This command offers possible locations for
5047 refiling the entry and lets you select one with completion.  The item is
5048 filed below the target heading as a subitem.  Depending on
5049 @code{org-reverse-note-order}, it will be either the first of last
5050 subitem.@* By default, all level 1 headlines in the current buffer are
5051 considered to be targets, but you can have more complex definitions
5052 across a number of files.  See the variable @code{org-refile-targets}
5053 for details.  If you would like to select a location via a file-pathlike
5054 completion along the outline path, see the variable
5055 @code{org-refile-use-outline-path}.
5056 @kindex C-u C-c C-w
5057 @item C-u C-c C-w
5058 Use the refile interface to jump to a heading.
5059 @kindex C-u C-u C-c C-w
5060 @item C-u C-u C-c C-w
5061 Jump to the location where @code{org-refile} last moved a tree to.
5062 @end table
5064 @node Agenda Views, Embedded LaTeX, Remember, Top
5065 @chapter Agenda Views
5066 @cindex agenda views
5068 Due to the way Org works, TODO items, time-stamped items, and
5069 tagged headlines can be scattered throughout a file or even a number of
5070 files.  To get an overview of open action items, or of events that are
5071 important for a particular date, this information must be collected,
5072 sorted and displayed in an organized way.
5074 Org can select items based on various criteria, and display them
5075 in a separate buffer.  Seven different view types are provided:
5077 @itemize @bullet
5078 @item
5079 an @emph{agenda} that is like a calendar and shows information
5080 for specific dates,
5081 @item
5082 a @emph{TODO list} that covers all unfinished
5083 action items,
5084 @item
5085 a @emph{tags view}, showings headlines based on
5086 the tags associated with them,
5087 @item
5088 a @emph{timeline view} that shows all events in a single Org file,
5089 in time-sorted view,
5090 @item
5091 a @emph{keyword search view} that shows all entries from multiple files
5092 that contain specified keywords.
5093 @item
5094 a @emph{stuck projects view} showing projects that currently don't move
5095 along, and
5096 @item
5097 @emph{custom views} that are special tag/keyword searches and
5098 combinations of different views.
5099 @end itemize
5101 @noindent
5102 The extracted information is displayed in a special @emph{agenda
5103 buffer}.  This buffer is read-only, but provides commands to visit the
5104 corresponding locations in the original Org files, and even to
5105 edit these files remotely.
5107 Two variables control how the agenda buffer is displayed and whether the
5108 window configuration is restored when the agenda exits:
5109 @code{org-agenda-window-setup} and
5110 @code{org-agenda-restore-windows-after-quit}.
5112 @menu
5113 * Agenda files::                Files being searched for agenda information
5114 * Agenda dispatcher::           Keyboard access to agenda views
5115 * Built-in agenda views::       What is available out of the box?
5116 * Presentation and sorting::    How agenda items are prepared for display
5117 * Agenda commands::             Remote editing of Org trees
5118 * Custom agenda views::         Defining special searches and views
5119 * Agenda column view::          Using column view for collected entries
5120 @end menu
5122 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
5123 @section Agenda files
5124 @cindex agenda files
5125 @cindex files for agenda
5127 The information to be shown is normally collected from all @emph{agenda
5128 files}, the files listed in the variable
5129 @code{org-agenda-files}@footnote{If the value of that variable is not a
5130 list, but a single file name, then the list of agenda files will be
5131 maintained in that external file.}. If a directory is part of this list,
5132 all files with the extension @file{.org} in this directory will be part
5133 of the list.
5135 Thus even if you only work with a single Org file, this file should
5136 be put into that list@footnote{When using the dispatcher, pressing
5137 @kbd{<} before selecting a command will actually limit the command to
5138 the current file, and ignore @code{org-agenda-files} until the next
5139 dispatcher command.}.  You can customize @code{org-agenda-files}, but
5140 the easiest way to maintain it is through the following commands
5142 @cindex files, adding to agenda list
5143 @table @kbd
5144 @kindex C-c [
5145 @item C-c [
5146 Add current file to the list of agenda files.  The file is added to
5147 the front of the list.  If it was already in the list, it is moved to
5148 the front.  With a prefix argument, file is added/moved to the end.
5149 @kindex C-c ]
5150 @item C-c ]
5151 Remove current file from the list of agenda files.
5152 @kindex C-,
5153 @kindex C-'
5154 @item C-,
5155 @itemx C-'
5156 Cycle through agenda file list, visiting one file after the other.
5157 @kindex M-x org-iswitchb
5158 @item M-x org-iswitchb
5159 Command to use an @code{iswitchb}-like interface to switch to and between Org
5160 buffers.
5161 @end table
5163 @noindent
5164 The Org menu contains the current list of files and can be used
5165 to visit any of them.
5167 If you would like to focus the agenda temporarily onto a file not in
5168 this list, or onto just one file in the list or even only a subtree in a
5169 file, this can be done in different ways.  For a single agenda command,
5170 you may press @kbd{<} once or several times in the dispatcher
5171 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
5172 extended period, use the following commands:
5174 @table @kbd
5175 @kindex C-c C-x <
5176 @item C-c C-x <
5177 Permanently restrict the agenda to the current subtree.  When with a
5178 prefix argument, or with the cursor before the first headline in a file,
5179 the agenda scope is set to the entire file.  This restriction remains in
5180 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
5181 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
5182 agenda view, the new restriction takes effect immediately.
5183 @kindex C-c C-x <
5184 @item C-c C-x <
5185 Remove the permanent restriction created by @kbd{C-c C-x <}.
5186 @end table
5188 @noindent
5189 When working with @file{Speedbar}, you can use the following commands in
5190 the Speedbar frame:
5191 @table @kbd
5192 @kindex <
5193 @item < @r{in the speedbar frame}
5194 Permanently restrict the agenda to the item at the cursor in the
5195 Speedbar frame, either an Org file or a subtree in such a file.
5196 If there is a window displaying an agenda view, the new restriction takes
5197 effect immediately.
5198 @kindex <
5199 @item > @r{in the speedbar frame}
5200 Lift the restriction again.
5201 @end table
5203 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
5204 @section The agenda dispatcher
5205 @cindex agenda dispatcher
5206 @cindex dispatching agenda commands
5207 The views are created through a dispatcher that should be bound to a
5208 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
5209 following we will assume that @kbd{C-c a} is indeed how the dispatcher
5210 is accessed and list keyboard access to commands accordingly.  After
5211 pressing @kbd{C-c a}, an additional letter is required to execute a
5212 command.  The dispatcher offers the following default commands:
5213 @table @kbd
5214 @item a
5215 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
5216 @item t @r{/} T
5217 Create a list of all TODO items (@pxref{Global TODO list}).
5218 @item m @r{/} M
5219 Create a list of headlines matching a TAGS expression (@pxref{Matching
5220 tags and properties}).
5221 @item L
5222 Create the timeline view for the current buffer (@pxref{Timeline}).
5223 @item s
5224 Create a list of entries selected by a boolean expression of keywords
5225 and/or regular expressions that must or must not occur in the entry.
5226 @item /
5227 Search for a regular expression in all agenda files and additionally in
5228 the files listed in @code{org-agenda-multi-occur-extra-files}.  This
5229 uses the Emacs command @code{multi-occur}.  A prefix argument can be
5230 used to specify the number of context lines for each match, default is
5232 @item # @r{/} !
5233 Create a list of stuck projects (@pxref{Stuck projects}).
5234 @item <
5235 Restrict an agenda command to the current buffer@footnote{For backward
5236 compatibility, you can also press @kbd{1} to restrict to the current
5237 buffer.}.  After pressing @kbd{<}, you still need to press the character
5238 selecting the command.
5239 @item < <
5240 If there is an active region, restrict the following agenda command to
5241 the region.  Otherwise, restrict it to the current subtree@footnote{For
5242 backward compatibility, you can also press @kbd{0} to restrict to the
5243 current buffer.}.  After pressing @kbd{< <}, you still need to press the
5244 character selecting the command.
5245 @end table
5247 You can also define custom commands that will be accessible through the
5248 dispatcher, just like the default commands.  This includes the
5249 possibility to create extended agenda buffers that contain several
5250 blocks together, for example the weekly agenda, the global TODO list and
5251 a number of special tags matches.  @xref{Custom agenda views}.
5253 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
5254 @section The built-in agenda views
5256 In this section we describe the built-in views.
5258 @menu
5259 * Weekly/daily agenda::         The calendar page with current tasks
5260 * Global TODO list::            All unfinished action items
5261 * Matching tags and properties::  Structured information with fine-tuned search
5262 * Timeline::                    Time-sorted view for single file
5263 * Keyword search::              Finding entries by keyword
5264 * Stuck projects::              Find projects you need to review
5265 @end menu
5267 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
5268 @subsection The weekly/daily agenda
5269 @cindex agenda
5270 @cindex weekly agenda
5271 @cindex daily agenda
5273 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
5274 paper agenda, showing all the tasks for the current week or day.
5276 @table @kbd
5277 @cindex org-agenda, command
5278 @kindex C-c a a
5279 @item C-c a a
5280 Compile an agenda for the current week from a list of org files.  The
5281 agenda shows the entries for each day.  With a numeric
5282 prefix@footnote{For backward compatibility, the universal prefix
5283 @kbd{C-u} causes all TODO entries to be listed before the agenda.  This
5284 feature is deprecated, use the dedicated TODO list, or a block agenda
5285 instead.}  (like @kbd{C-u 2 1 C-c a a}) you may set the number of days
5286 to be displayed (see also the variable @code{org-agenda-ndays})
5287 @end table
5289 Remote editing from the agenda buffer means, for example, that you can
5290 change the dates of deadlines and appointments from the agenda buffer.
5291 The commands available in the Agenda buffer are listed in @ref{Agenda
5292 commands}.
5294 @subsubheading Calendar/Diary integration
5295 @cindex calendar integration
5296 @cindex diary integration
5298 Emacs contains the calendar and diary by Edward M. Reingold.  The
5299 calendar displays a three-month calendar with holidays from different
5300 countries and cultures.  The diary allows you to keep track of
5301 anniversaries, lunar phases, sunrise/set, recurrent appointments
5302 (weekly, monthly) and more.  In this way, it is quite complementary to
5303 Org.  It can be very useful to combine output from Org with
5304 the diary.
5306 In order to include entries from the Emacs diary into Org mode's
5307 agenda, you only need to customize the variable
5309 @lisp
5310 (setq org-agenda-include-diary t)
5311 @end lisp
5313 @noindent After that, everything will happen automatically.  All diary
5314 entries including holidays, anniversaries etc will be included in the
5315 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
5316 @key{RET} can be used from the agenda buffer to jump to the diary
5317 file in order to edit existing diary entries.  The @kbd{i} command to
5318 insert new entries for the current date works in the agenda buffer, as
5319 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
5320 Sunrise/Sunset times, show lunar phases and to convert to other
5321 calendars, respectively.  @kbd{c} can be used to switch back and forth
5322 between calendar and agenda.
5324 If you are using the diary only for sexp entries and holidays, it is
5325 faster to not use the above setting, but instead to copy or even move
5326 the entries into an Org file. Org mode evaluates diary-style sexp
5327 entries, and does it faster because there is no overhead for first
5328 creating the diary display.  Note that the sexp entries must start at
5329 the left margin, no white space is allowed before them.  For example,
5330 the following segment of an Org file will be processed and entries
5331 will be made in the agenda:
5333 @example
5334 * Birthdays and similar stuff
5335 #+CATEGORY: Holiday
5336 %%(org-calendar-holiday)   ; special function for holiday names
5337 #+CATEGORY: Ann
5338 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
5339 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
5340 @end example
5342 @subsubheading Appointment reminders
5343 @cindex @file{appt.el}
5344 @cindex appointment reminders
5346 Org can interact with Emacs appointments notification facility.
5348 To add all the appointments of your agenda files, use the command
5349 @code{org-agenda-to-appt}.  This commands also lets you filter through
5350 the list of your appointments and add only those belonging to a specific
5351 category or matching a regular expression. See the docstring for
5352 details.
5354 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
5355 @subsection The global TODO list
5356 @cindex global TODO list
5357 @cindex TODO list, global
5359 The global TODO list contains all unfinished TODO items, formatted and
5360 collected into a single place.
5362 @table @kbd
5363 @kindex C-c a t
5364 @item C-c a t
5365 Show the global TODO list.  This collects the TODO items from all
5366 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
5367 @code{agenda-mode}, so there are commands to examine and manipulate
5368 the TODO entries directly from that buffer (@pxref{Agenda commands}).
5369 @kindex C-c a T
5370 @item C-c a T
5371 @cindex TODO keyword matching
5372 Like the above, but allows selection of a specific TODO keyword.  You
5373 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
5374 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
5375 specify several keywords by separating them with @samp{|} as boolean OR
5376 operator.  With a numeric prefix, the Nth keyword in
5377 @code{org-todo-keywords} is selected.
5378 @kindex r
5379 The @kbd{r} key in the agenda buffer regenerates it, and you can give
5380 a prefix argument to this command to change the selected TODO keyword,
5381 for example @kbd{3 r}.  If you often need a search for a specific
5382 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
5383 Matching specific TODO keywords can also be done as part of a tags
5384 search (@pxref{Tag searches}).
5385 @end table
5387 Remote editing of TODO items means that you can change the state of a
5388 TODO entry with a single key press.  The commands available in the
5389 TODO list are described in @ref{Agenda commands}.
5391 @cindex sublevels, inclusion into TODO list
5392 Normally the global TODO list simply shows all headlines with TODO
5393 keywords.  This list can become very long.  There are two ways to keep
5394 it more compact:
5395 @itemize @minus
5396 @item
5397 Some people view a TODO item that has been @emph{scheduled} for
5398 execution (@pxref{Timestamps}) as no longer @emph{open}.  Configure the
5399 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
5400 items from the global TODO list.
5401 @item
5402 TODO items may have sublevels to break up the task into subtasks.  In
5403 such cases it may be enough to list only the highest level TODO headline
5404 and omit the sublevels from the global list.  Configure the variable
5405 @code{org-agenda-todo-list-sublevels} to get this behavior.
5406 @end itemize
5408 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
5409 @subsection Matching tags and properties
5410 @cindex matching, of tags
5411 @cindex matching, of properties
5412 @cindex tags view
5414 If headlines in the agenda files are marked with @emph{tags}
5415 (@pxref{Tags}), you can select headlines based on the tags that apply
5416 to them and collect them into an agenda buffer.
5418 @table @kbd
5419 @kindex C-c a m
5420 @item C-c a m
5421 Produce a list of all headlines that match a given set of tags.  The
5422 command prompts for a selection criterion, which is a boolean logic
5423 expression with tags, like @samp{+work+urgent-withboss} or
5424 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
5425 define a custom command for it (@pxref{Agenda dispatcher}).
5426 @kindex C-c a M
5427 @item C-c a M
5428 Like @kbd{C-c a m}, but only select headlines that are also TODO items
5429 and force checking subitems (see variable
5430 @code{org-tags-match-list-sublevels}).  Matching specific TODO keywords
5431 together with a tags match is also possible, see @ref{Tag searches}.
5432 @end table
5434 The commands available in the tags list are described in @ref{Agenda
5435 commands}.
5437 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
5438 @subsection Timeline for a single file
5439 @cindex timeline, single file
5440 @cindex time-sorted view
5442 The timeline summarizes all time-stamped items from a single Org mode
5443 file in a @emph{time-sorted view}.  The main purpose of this command is
5444 to give an overview over events in a project.
5446 @table @kbd
5447 @kindex C-c a L
5448 @item C-c a L
5449 Show a time-sorted view of the org file, with all time-stamped items.
5450 When called with a @kbd{C-u} prefix, all unfinished TODO entries
5451 (scheduled or not) are also listed under the current date.
5452 @end table
5454 @noindent
5455 The commands available in the timeline buffer are listed in
5456 @ref{Agenda commands}.
5458 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
5459 @subsection Keyword search
5460 @cindex keyword search
5461 @cindex searching, for keywords
5463 This agenda view is a general text search facility for Org mode entries.
5464 It is particularly useful to find notes.
5466 @table @kbd
5467 @kindex C-c a s
5468 @item C-c a s
5469 This is a special search that lets you select entries by keywords or
5470 regular expression, using a boolean logic.  For example, the search
5471 string
5473 @example
5474 +computer +wifi -ethernet -@{8\.11[bg]@}
5475 @end example
5477 @noindent
5478 will search for note entries that contain the keywords @code{computer}
5479 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
5480 not matched by the regular expression @code{8\.11[bg]}, meaning to
5481 exclude both 8.11b and 8.11g.
5483 Note that in addition to the agenda files, this command will also search
5484 the files listed in @code{org-agenda-text-search-extra-files}.
5485 @end table
5487 @node Stuck projects,  , Keyword search, Built-in agenda views
5488 @subsection Stuck projects
5490 If you are following a system like David Allen's GTD to organize your
5491 work, one of the ``duties'' you have is a regular review to make sure
5492 that all projects move along.  A @emph{stuck} project is a project that
5493 has no defined next actions, so it will never show up in the TODO lists
5494 Org mode produces.  During the review, you need to identify such
5495 projects and define next actions for them.
5497 @table @kbd
5498 @kindex C-c a #
5499 @item C-c a #
5500 List projects that are stuck.
5501 @kindex C-c a !
5502 @item C-c a !
5503 Customize the variable @code{org-stuck-projects} to define what a stuck
5504 project is and how to find it.
5505 @end table
5507 You almost certainly will have to configure this view before it will
5508 work for you.  The built-in default assumes that all your projects are
5509 level-2 headlines, and that a project is not stuck if it has at least
5510 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
5512 Lets assume that you, in your own way of using Org mode, identify
5513 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
5514 indicate a project that should not be considered yet.  Lets further
5515 assume that the TODO keyword DONE marks finished projects, and that NEXT
5516 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
5517 is a next action even without the NEXT tag.  Finally, if the project
5518 contains the special word IGNORE anywhere, it should not be listed
5519 either.  In this case you would start by identifying eligible projects
5520 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
5521 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
5522 are not stuck.  The correct customization for this is
5524 @lisp
5525 (setq org-stuck-projects
5526       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
5527                                "\\<IGNORE\\>"))
5528 @end lisp
5531 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
5532 @section Presentation and sorting
5533 @cindex presentation, of agenda items
5535 Before displaying items in an agenda view, Org mode visually prepares
5536 the items and sorts them.  Each item occupies a single line.  The line
5537 starts with a @emph{prefix} that contains the @emph{category}
5538 (@pxref{Categories}) of the item and other important information.  You can
5539 customize the prefix using the option @code{org-agenda-prefix-format}.
5540 The prefix is followed by a cleaned-up version of the outline headline
5541 associated with the item.
5543 @menu
5544 * Categories::                  Not all tasks are equal
5545 * Time-of-day specifications::  How the agenda knows the time
5546 * Sorting of agenda items::     The order of things
5547 @end menu
5549 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
5550 @subsection Categories
5552 @cindex category
5553 The category is a broad label assigned to each agenda item.  By default,
5554 the category is simply derived from the file name, but you can also
5555 specify it with a special line in the buffer, like this@footnote{For
5556 backward compatibility, the following also works: If there are several
5557 such lines in a file, each specifies the category for the text below it.
5558 The first category also applies to any text before the first CATEGORY
5559 line.  However, using this method is @emph{strongly} deprecated as it is
5560 incompatible with the outline structure of the document.  The correct
5561 method for setting multiple categories in a buffer is using a
5562 property.}:
5564 @example
5565 #+CATEGORY: Thesis
5566 @end example
5568 @noindent
5569 If you would like to have a special CATEGORY for a single entry or a
5570 (sub)tree, give the entry a @code{:CATEGORY:} property with the location
5571 as the value (@pxref{Properties and Columns}).
5573 @noindent
5574 The display in the agenda buffer looks best if the category is not
5575 longer than 10 characters.
5577 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
5578 @subsection Time-of-day specifications
5579 @cindex time-of-day specification
5581 Org mode checks each agenda item for a time-of-day specification.  The
5582 time can be part of the time stamp that triggered inclusion into the
5583 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
5584 ranges can be specified with two time stamps, like
5586 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
5588 In the headline of the entry itself, a time(range) may also appear as
5589 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
5590 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
5591 specifications in diary entries are recognized as well.
5593 For agenda display, Org mode extracts the time and displays it in a
5594 standard 24 hour format as part of the prefix.  The example times in
5595 the previous paragraphs would end up in the agenda like this:
5597 @example
5598     8:30-13:00 Arthur Dent lies in front of the bulldozer
5599    12:45...... Ford Prefect arrives and takes Arthur to the pub
5600    19:00...... The Vogon reads his poem
5601    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5602 @end example
5604 @cindex time grid
5605 If the agenda is in single-day mode, or for the display of today, the
5606 timed entries are embedded in a time grid, like
5608 @example
5609     8:00...... ------------------
5610     8:30-13:00 Arthur Dent lies in front of the bulldozer
5611    10:00...... ------------------
5612    12:00...... ------------------
5613    12:45...... Ford Prefect arrives and takes Arthur to the pub
5614    14:00...... ------------------
5615    16:00...... ------------------
5616    18:00...... ------------------
5617    19:00...... The Vogon reads his poem
5618    20:00...... ------------------
5619    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5620 @end example
5622 The time grid can be turned on and off with the variable
5623 @code{org-agenda-use-time-grid}, and can be configured with
5624 @code{org-agenda-time-grid}.
5626 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
5627 @subsection Sorting of agenda items
5628 @cindex sorting, of agenda items
5629 @cindex priorities, of agenda items
5630 Before being inserted into a view, the items are sorted.  How this is
5631 done depends on the type of view.
5632 @itemize @bullet
5633 @item
5634 For the daily/weekly agenda, the items for each day are sorted.  The
5635 default order is to first collect all items containing an explicit
5636 time-of-day specification.  These entries will be shown at the beginning
5637 of the list, as a @emph{schedule} for the day.  After that, items remain
5638 grouped in categories, in the sequence given by @code{org-agenda-files}.
5639 Within each category, items are sorted by priority (@pxref{Priorities}),
5640 which is composed of the base priority (2000 for priority @samp{A}, 1000
5641 for @samp{B}, and 0 for @samp{C}), plus additional increments for
5642 overdue scheduled or deadline items.
5643 @item
5644 For the TODO list, items remain in the order of categories, but within
5645 each category, sorting takes place according to priority
5646 (@pxref{Priorities}).
5647 @item
5648 For tags matches, items are not sorted at all, but just appear in the
5649 sequence in which they are found in the agenda files.
5650 @end itemize
5652 Sorting can be customized using the variable
5653 @code{org-agenda-sorting-strategy}, and may also include criteria based on
5654 the estimated effort of an entry.
5655 @c FIXME: link!!!!!!!!
5658 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
5659 @section Commands in the agenda buffer
5660 @cindex commands, in agenda buffer
5662 Entries in the agenda buffer are linked back to the org file or diary
5663 file where they originate.  You are not allowed to edit the agenda
5664 buffer itself, but commands are provided to show and jump to the
5665 original entry location, and to edit the org-files ``remotely'' from
5666 the agenda buffer.  In this way, all information is stored only once,
5667 removing the risk that your agenda and note files may diverge.
5669 Some commands can be executed with mouse clicks on agenda lines.  For
5670 the other commands, the cursor needs to be in the desired line.
5672 @table @kbd
5673 @tsubheading{Motion}
5674 @cindex motion commands in agenda
5675 @kindex n
5676 @item n
5677 Next line (same as @key{up} and @kbd{C-p}).
5678 @kindex p
5679 @item p
5680 Previous line (same as @key{down} and @kbd{C-n}).
5681 @tsubheading{View/Go to org file}
5682 @kindex mouse-3
5683 @kindex @key{SPC}
5684 @item mouse-3
5685 @itemx @key{SPC}
5686 Display the original location of the item in another window.
5688 @kindex L
5689 @item L
5690 Display original location and recenter that window.
5692 @kindex mouse-2
5693 @kindex mouse-1
5694 @kindex @key{TAB}
5695 @item mouse-2
5696 @itemx mouse-1
5697 @itemx @key{TAB}
5698 Go to the original location of the item in another window.  Under Emacs
5699 22, @kbd{mouse-1} will also works for this.
5701 @kindex @key{RET}
5702 @itemx @key{RET}
5703 Go to the original location of the item and delete other windows.
5705 @kindex f
5706 @item f
5707 Toggle Follow mode.  In Follow mode, as you move the cursor through
5708 the agenda buffer, the other window always shows the corresponding
5709 location in the org file.  The initial setting for this mode in new
5710 agenda buffers can be set with the variable
5711 @code{org-agenda-start-with-follow-mode}.
5713 @kindex b
5714 @item b
5715 Display the entire subtree of the current item in an indirect buffer.  With a
5716 numeric prefix argument N, go up to level N and then take that tree.  If N is
5717 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
5718 previously used indirect buffer.
5720 @kindex l
5721 @item l
5722 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
5723 logging was on (variable @code{org-log-done}) are shown in the agenda,
5724 as are entries that have been clocked on that day.
5726 @kindex v
5727 @item v
5728 Toggle Archives mode.  In archives mode, trees that are marked are also
5729 scanned when producing the agenda.  When you call this command with a
5730 @kbd{C-u} prefix argument, even all archive files are included.  To exit
5731 archives mode, press @kbd{v} again.
5733 @kindex R
5734 @item R
5735 Toggle Clockreport mode.  In clockreport mode, the daily/weekly agenda will
5736 always show a table with the clocked times for the timespan and file scope
5737 covered by the current agenda view.  The initial setting for this mode in new
5738 agenda buffers can be set with the variable
5739 @code{org-agenda-start-with-clockreport-mode}.
5741 @tsubheading{Change display}
5742 @cindex display changing, in agenda
5743 @kindex o
5744 @item o
5745 Delete other windows.
5747 @kindex d
5748 @kindex w
5749 @kindex m
5750 @kindex y
5751 @item d w m y
5752 Switch to day/week/month/year view.  When switching to day or week view,
5753 this setting becomes the default for subsequent agenda commands.  Since
5754 month and year views are slow to create, they do not become the default.
5755 A numeric prefix argument may be used to jump directly to a specific day
5756 of the year, ISO week, month, or year, respectively.  For example,
5757 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
5758 setting day, week, or month view, a year may be encoded in the prefix
5759 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
5760 2007.  If such a year specification has only one or two digits, it will
5761 be mapped to the interval 1938-2037.
5763 @kindex D
5764 @item D
5765 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
5767 @kindex G
5768 @item G
5769 Toggle the time grid on and off.  See also the variables
5770 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
5772 @kindex r
5773 @item r
5774 Recreate the agenda buffer, for example to reflect the changes
5775 after modification of the time stamps of items with S-@key{left} and
5776 S-@key{right}.  When the buffer is the global TODO list, a prefix
5777 argument is interpreted to create a selective list for a specific TODO
5778 keyword.
5779 @kindex g
5780 @item g
5781 Same as @kbd{r}.
5783 @kindex s
5784 @kindex C-x C-s
5785 @item s
5786 @itemx C-x C-s
5787 Save all Org buffers in the current Emacs session.
5789 @kindex @key{right}
5790 @item @key{right}
5791 Display the following @code{org-agenda-ndays} days.  For example, if
5792 the display covers a week, switch to the following week.  With prefix
5793 arg, go forward that many times @code{org-agenda-ndays} days.
5795 @kindex @key{left}
5796 @item @key{left}
5797 Display the previous dates.
5799 @kindex .
5800 @item .
5801 Go to today.
5803 @kindex C-c C-x C-c
5804 @item C-c C-x C-c
5805 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
5806 view format is taken from the entry at point, or (if there is no entry at
5807 point), from the first entry in the agenda view.  So whatever the format for
5808 that entry would be in the original buffer (taken from a property, from a
5809 @code{#+COLUMNS} line, or from the default variable
5810 @code{org-columns-default-format}), will be used in the agenda.
5812 @tsubheading{Secondary filtering and query editing}
5813 @cindex query editing, in agenda
5815 @kindex /
5816 @item /
5817 Filter the current agenda view with respect to a tag.  You will be prompted
5818 for a tag selection letter.  Pressing @key{TAB} at that prompt will offer use
5819 completion to select a tag (including any tags that do not have a selection
5820 character).  The command then hides all entries that do not contain or
5821 inherit this tag.  When called with prefix arg, remove the entries that
5822 @emph{do} have the tag.  A second @kbd{/} at the prompt will unhide any
5823 hidden entries.
5825 @kindex [
5826 @kindex ]
5827 @kindex @{
5828 @kindex @}
5829 @item [ ] @{ @}
5830 In the @i{search view} (@pxref{Keyword search}), these keys add new search
5831 words (@kbd{[} and @kbd{]}) or new regular expressions (@kbd{@{} and
5832 @kbd{@}}) to the query string.  The opening bracket/brace will add a positive
5833 search term prefixed by @samp{+}, indicating that this search term @i{must}
5834 occur/match in the entry.  The closing bracket/brace will add a negative
5835 search term which @i{must not} occur/match in the entry for it to be
5836 selected.
5839 @tsubheading{Remote editing}
5840 @cindex remote editing, from agenda
5842 @item 0-9
5843 Digit argument.
5845 @cindex undoing remote-editing events
5846 @cindex remote editing, undo
5847 @kindex C-_
5848 @item C-_
5849 Undo a change due to a remote editing command.  The change is undone
5850 both in the agenda buffer and in the remote buffer.
5852 @kindex t
5853 @item t
5854 Change the TODO state of the item, both in the agenda and in the
5855 original org file.
5857 @kindex C-k
5858 @item C-k
5859 Delete the current agenda item along with the entire subtree belonging
5860 to it in the original Org file.  If the text to be deleted remotely
5861 is longer than one line, the kill needs to be confirmed by the user.  See
5862 variable @code{org-agenda-confirm-kill}.
5864 @kindex a
5865 @item a
5866 Toggle the ARCHIVE tag for the current headline.
5868 @kindex A
5869 @item A
5870 Move the subtree corresponding to the current entry to its @emph{Archive
5871 Sibling}.
5873 @kindex $
5874 @item $
5875 Archive the subtree corresponding to the current headline.  This means the
5876 entry will be moved to the configured archive location, most likely a
5877 different file.
5879 @kindex T
5880 @item T
5881 Show all tags associated with the current item.  Because of
5882 inheritance, this may be more than the tags listed in the line itself.
5884 @kindex :
5885 @item :
5886 Set tags for the current headline.  If there is an active region in the
5887 agenda, change a tag for all headings in the region.
5889 @kindex ,
5890 @item ,
5891 Set the priority for the current item.  Org mode prompts for the
5892 priority character. If you reply with @key{SPC}, the priority cookie
5893 is removed from the entry.
5895 @kindex P
5896 @item P
5897 Display weighted priority of current item.
5899 @kindex +
5900 @kindex S-@key{up}
5901 @item +
5902 @itemx S-@key{up}
5903 Increase the priority of the current item.  The priority is changed in
5904 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
5905 key for this.
5907 @kindex -
5908 @kindex S-@key{down}
5909 @item -
5910 @itemx S-@key{down}
5911 Decrease the priority of the current item.
5913 @kindex C-c C-s
5914 @item C-c C-s
5915 Schedule this item
5917 @kindex C-c C-d
5918 @item C-c C-d
5919 Set a deadline for this item.
5921 @kindex k
5922 @item k
5923 Agenda actions, to set dates for selected items to the cursor date.
5924 This command also works in the calendar!  The command prompts for an
5925 additonal key:
5926 @example
5927 m   @r{Mark the entry at point for action.  You can also make entries}
5928     @r{in Org files with @kbd{C-c C-x C-k}.}
5929 d   @r{Set the deadline of the marked entry to the date at point.}
5930 s   @r{Schedule the marked entry at the date at point.}
5931 r   @r{Call @code{org-remember} with the cursor date as default date.}
5932 @end example
5933 Press @kbd{r} afterwards to refresh the agenda and see the effect of the
5934 command.
5936 @kindex S-@key{right}
5937 @item S-@key{right}
5938 Change the time stamp associated with the current line by one day into the
5939 future.  With a numeric prefix argument, change it by that many days.  For
5940 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The stamp is
5941 changed in the original org file, but the change is not directly reflected in
5942 the agenda buffer.  Use the @kbd{r} key to update the buffer.
5944 @kindex S-@key{left}
5945 @item S-@key{left}
5946 Change the time stamp associated with the current line by one day
5947 into the past.
5949 @kindex >
5950 @item >
5951 Change the time stamp associated with the current line to today.
5952 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
5953 on my keyboard.
5955 @kindex I
5956 @item I
5957 Start the clock on the current item.  If a clock is running already, it
5958 is stopped first.
5960 @kindex O
5961 @item O
5962 Stop the previously started clock.
5964 @kindex X
5965 @item X
5966 Cancel the currently running clock.
5968 @kindex J
5969 @item J
5970 Jump to the running clock in another window.
5972 @tsubheading{Calendar commands}
5973 @cindex calendar commands, from agenda
5974 @kindex c
5975 @item c
5976 Open the Emacs calendar and move to the date at the agenda cursor.
5978 @item c
5979 When in the calendar, compute and show the Org mode agenda for the
5980 date at the cursor.
5982 @cindex diary entries, creating from agenda
5983 @kindex i
5984 @item i
5985 Insert a new entry into the diary.  Prompts for the type of entry
5986 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
5987 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
5988 The date is taken from the cursor position.
5990 @kindex M
5991 @item M
5992 Show the phases of the moon for the three months around current date.
5994 @kindex S
5995 @item S
5996 Show sunrise and sunset times.  The geographical location must be set
5997 with calendar variables, see documentation of the Emacs calendar.
5999 @kindex C
6000 @item C
6001 Convert the date at cursor into many other cultural and historic
6002 calendars.
6004 @kindex H
6005 @item H
6006 Show holidays for three month around the cursor date.
6008 @item M-x org-export-icalendar-combine-agenda-files
6009 Export a single iCalendar file containing entries from all agenda files.
6010 This is a globally available command, and also available in the agenda menu.
6012 @tsubheading{Exporting to a file}
6013 @kindex C-x C-w
6014 @item C-x C-w
6015 @cindex exporting agenda views
6016 @cindex agenda views, exporting
6017 Write the agenda view to a file.  Depending on the extension of the
6018 selected file name, the view will be exported as HTML (extension
6019 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
6020 plain text (any other extension).  Use the variable
6021 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
6022 and for @file{htmlize} to be used during export.
6024 @tsubheading{Quit and Exit}
6025 @kindex q
6026 @item q
6027 Quit agenda, remove the agenda buffer.
6029 @kindex x
6030 @cindex agenda files, removing buffers
6031 @item x
6032 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
6033 for the compilation of the agenda.  Buffers created by the user to
6034 visit org files will not be removed.
6035 @end table
6038 @node Custom agenda views, Agenda column view, Agenda commands, Agenda Views
6039 @section Custom agenda views
6040 @cindex custom agenda views
6041 @cindex agenda views, custom
6043 Custom agenda commands serve two purposes: to store and quickly access
6044 frequently used TODO and tags searches, and to create special composite
6045 agenda buffers.  Custom agenda commands will be accessible through the
6046 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
6048 @menu
6049 * Storing searches::            Type once, use often
6050 * Block agenda::                All the stuff you need in a single buffer
6051 * Setting Options::             Changing the rules
6052 * Exporting Agenda Views::      Writing agendas to files
6053 * Using the agenda elsewhere::  Using agenda information in other programs
6054 @end menu
6056 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
6057 @subsection Storing searches
6059 The first application of custom searches is the definition of keyboard
6060 shortcuts for frequently used searches, either creating an agenda
6061 buffer, or a sparse tree (the latter covering of course only the current
6062 buffer).
6063 @kindex C-c a C
6064 Custom commands are configured in the variable
6065 @code{org-agenda-custom-commands}.  You can customize this variable, for
6066 example by pressing @kbd{C-c a C}.  You can also directly set it with
6067 Emacs Lisp in @file{.emacs}.  The following example contains all valid
6068 search types:
6070 @lisp
6071 @group
6072 (setq org-agenda-custom-commands
6073       '(("w" todo "WAITING")
6074         ("W" todo-tree "WAITING")
6075         ("u" tags "+boss-urgent")
6076         ("v" tags-todo "+boss-urgent")
6077         ("U" tags-tree "+boss-urgent")
6078         ("f" occur-tree "\\<FIXME\\>")
6079         ("h" . "HOME+Name tags searches") ; description for "h" prefix
6080         ("hl" tags "+home+Lisa")
6081         ("hp" tags "+home+Peter")
6082         ("hk" tags "+home+Kim")))
6083 @end group
6084 @end lisp
6086 @noindent
6087 The initial string in each entry defines the keys you have to press
6088 after the dispatcher command @kbd{C-c a} in order to access the command.
6089 Usually this will be just a single character, but if you have many
6090 similar commands, you can also define two-letter combinations where the
6091 first character is the same in several combinations and serves as a
6092 prefix key@footnote{You can provide a description for a prefix key by
6093 inserting a cons cell with the prefix and the description.}.  The second
6094 parameter is the search type, followed by the string or regular
6095 expression to be used for the matching.  The example above will
6096 therefore define:
6098 @table @kbd
6099 @item C-c a w
6100 as a global search for TODO entries with @samp{WAITING} as the TODO
6101 keyword
6102 @item C-c a W
6103 as the same search, but only in the current buffer and displaying the
6104 results as a sparse tree
6105 @item C-c a u
6106 as a global tags search for headlines marked @samp{:boss:} but not
6107 @samp{:urgent:}
6108 @item C-c a v
6109 as the same search as @kbd{C-c a u}, but limiting the search to
6110 headlines that are also TODO items
6111 @item C-c a U
6112 as the same search as @kbd{C-c a u}, but only in the current buffer and
6113 displaying the result as a sparse tree
6114 @item C-c a f
6115 to create a sparse tree (again: current buffer only) with all entries
6116 containing the word @samp{FIXME}
6117 @item C-c a h
6118 as a prefix command for a HOME tags search where you have to press an
6119 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
6120 Peter, or Kim) as additional tag to match.
6121 @end table
6123 @node Block agenda, Setting Options, Storing searches, Custom agenda views
6124 @subsection Block agenda
6125 @cindex block agenda
6126 @cindex agenda, with block views
6128 Another possibility is the construction of agenda views that comprise
6129 the results of @emph{several} commands, each of which creates a block in
6130 the agenda buffer.  The available commands include @code{agenda} for the
6131 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
6132 for the global TODO list (as constructed with @kbd{C-c a t}), and the
6133 matching commands discussed above: @code{todo}, @code{tags}, and
6134 @code{tags-todo}.  Here are two examples:
6136 @lisp
6137 @group
6138 (setq org-agenda-custom-commands
6139       '(("h" "Agenda and Home-related tasks"
6140          ((agenda "")
6141           (tags-todo "home")
6142           (tags "garden")))
6143         ("o" "Agenda and Office-related tasks"
6144          ((agenda "")
6145           (tags-todo "work")
6146           (tags "office")))))
6147 @end group
6148 @end lisp
6150 @noindent
6151 This will define @kbd{C-c a h} to create a multi-block view for stuff
6152 you need to attend to at home.  The resulting agenda buffer will contain
6153 your agenda for the current week, all TODO items that carry the tag
6154 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
6155 command @kbd{C-c a o} provides a similar view for office tasks.
6157 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
6158 @subsection Setting options for custom commands
6159 @cindex options, for custom agenda views
6161 Org mode contains a number of variables regulating agenda construction
6162 and display.  The global variables define the behavior for all agenda
6163 commands, including the custom commands.  However, if you want to change
6164 some settings just for a single custom view, you can do so.  Setting
6165 options requires inserting a list of variable names and values at the
6166 right spot in @code{org-agenda-custom-commands}.  For example:
6168 @lisp
6169 @group
6170 (setq org-agenda-custom-commands
6171       '(("w" todo "WAITING"
6172          ((org-agenda-sorting-strategy '(priority-down))
6173           (org-agenda-prefix-format "  Mixed: ")))
6174         ("U" tags-tree "+boss-urgent"
6175          ((org-show-following-heading nil)
6176           (org-show-hierarchy-above nil)))
6177         ("N" search ""
6178          ((org-agenda-files '("~org/notes.org"))
6179           (org-agenda-text-search-extra-files nil)))))
6180 @end group
6181 @end lisp
6183 @noindent
6184 Now the @kbd{C-c a w} command will sort the collected entries only by
6185 priority, and the prefix format is modified to just say @samp{  Mixed: }
6186 instead of giving the category of the entry.  The sparse tags tree of
6187 @kbd{C-c a U} will now turn out ultra-compact, because neither the
6188 headline hierarchy above the match, nor the headline following the match
6189 will be shown.  The command @kbd{C-c a N} will do a text search limited
6190 to only a single file.
6192 For command sets creating a block agenda,
6193 @code{org-agenda-custom-commands} has two separate spots for setting
6194 options.  You can add options that should be valid for just a single
6195 command in the set, and options that should be valid for all commands in
6196 the set.  The former are just added to the command entry, the latter
6197 must come after the list of command entries.  Going back to the block
6198 agenda example (@pxref{Block agenda}), let's change the sorting strategy
6199 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
6200 the results for GARDEN tags query in the opposite order,
6201 @code{priority-up}.  This would look like this:
6203 @lisp
6204 @group
6205 (setq org-agenda-custom-commands
6206       '(("h" "Agenda and Home-related tasks"
6207          ((agenda)
6208           (tags-todo "home")
6209           (tags "garden"
6210                 ((org-agenda-sorting-strategy '(priority-up)))))
6211          ((org-agenda-sorting-strategy '(priority-down))))
6212         ("o" "Agenda and Office-related tasks"
6213          ((agenda)
6214           (tags-todo "work")
6215           (tags "office")))))
6216 @end group
6217 @end lisp
6219 As you see, the values and parenthesis setting is a little complex.
6220 When in doubt, use the customize interface to set this variable - it
6221 fully supports its structure.  Just one caveat: When setting options in
6222 this interface, the @emph{values} are just lisp expressions.  So if the
6223 value is a string, you need to add the double quotes around the value
6224 yourself.
6227 @node Exporting Agenda Views, Using the agenda elsewhere, Setting Options, Custom agenda views
6228 @subsection Exporting Agenda Views
6229 @cindex agenda views, exporting
6231 If you are away from your computer, it can be very useful to have a
6232 printed version of some agenda views to carry around.  Org mode can
6233 export custom agenda views as plain text, HTML@footnote{You need to
6234 install Hrvoje Niksic' @file{htmlize.el}.} postscript, and iCalendar
6235 files.  If you want to do this only occasionally, use the command
6237 @table @kbd
6238 @kindex C-x C-w
6239 @item C-x C-w
6240 @cindex exporting agenda views
6241 @cindex agenda views, exporting
6242 Write the agenda view to a file.  Depending on the extension of the
6243 selected file name, the view will be exported as HTML (extension
6244 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
6245 iCalendar (extension @file{.ics}), or plain text (any other extension).
6246 Use the variable @code{org-agenda-exporter-settings} to
6247 set options for @file{ps-print} and for @file{htmlize} to be used during
6248 export, for example
6250 @lisp
6251 (setq org-agenda-exporter-settings
6252       '((ps-number-of-columns 2)
6253         (ps-landscape-mode t)
6254         (htmlize-output-type 'css)))
6255 @end lisp
6256 @end table
6258 If you need to export certain agenda views frequently, you can associate
6259 any custom agenda command with a list of output file names
6260 @footnote{If you want to store standard views like the weekly agenda
6261 or the global TODO list as well, you need to define custom commands for
6262 them in order to be able to specify file names.}.  Here is an example
6263 that first does define custom commands for the agenda and the global
6264 todo list, together with a number of files to which to export them.
6265 Then we define two block agenda commands and specify file names for them
6266 as well.  File names can be relative to the current working directory,
6267 or absolute.
6269 @lisp
6270 @group
6271 (setq org-agenda-custom-commands
6272       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
6273         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
6274         ("h" "Agenda and Home-related tasks"
6275          ((agenda "")
6276           (tags-todo "home")
6277           (tags "garden"))
6278          nil
6279          ("~/views/home.html"))
6280         ("o" "Agenda and Office-related tasks"
6281          ((agenda)
6282           (tags-todo "work")
6283           (tags "office"))
6284          nil
6285          ("~/views/office.ps" "~/calendars/office.ics"))))
6286 @end group
6287 @end lisp
6289 The extension of the file name determines the type of export.  If it is
6290 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
6291 the buffer to HTML and save it to this file name.  If the extension is
6292 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
6293 postscript output.  If the extension is @file{.ics}, iCalendar export is
6294 run export over all files that were used to construct the agenda, and
6295 limit the export to entries listed in the agenda now.  Any other
6296 extension produces a plain ASCII file.
6298 The export files are @emph{not} created when you use one of those
6299 commands interactively because this might use too much overhead.
6300 Instead, there is a special command to produce @emph{all} specified
6301 files in one step:
6303 @table @kbd
6304 @kindex C-c a e
6305 @item C-c a e
6306 Export all agenda views that have export file names associated with
6307 them.
6308 @end table
6310 You can use the options section of the custom agenda commands to also
6311 set options for the export commands.  For example:
6313 @lisp
6314 (setq org-agenda-custom-commands
6315       '(("X" agenda ""
6316          ((ps-number-of-columns 2)
6317           (ps-landscape-mode t)
6318           (org-agenda-prefix-format " [ ] ")
6319           (org-agenda-with-colors nil)
6320           (org-agenda-remove-tags t))
6321          ("theagenda.ps"))))
6322 @end lisp
6324 @noindent
6325 This command sets two options for the postscript exporter, to make it
6326 print in two columns in landscape format - the resulting page can be cut
6327 in two and then used in a paper agenda.  The remaining settings modify
6328 the agenda prefix to omit category and scheduling information, and
6329 instead include a checkbox to check off items.  We also remove the tags
6330 to make the lines compact, and we don't want to use colors for the
6331 black-and-white printer.  Settings specified in
6332 @code{org-agenda-exporter-settings} will also apply, but the settings
6333 in @code{org-agenda-custom-commands} take precedence.
6335 @noindent
6336 From the command line you may also use
6337 @example
6338 emacs -f org-batch-store-agenda-views -kill
6339 @end example
6340 @noindent
6341 or, if you need to modify some parameters
6342 @example
6343 emacs -eval '(org-batch-store-agenda-views                      \
6344               org-agenda-ndays 30                               \
6345               org-agenda-start-day "2007-11-01"                 \
6346               org-agenda-include-diary nil                      \
6347               org-agenda-files (quote ("~/org/project.org")))'  \
6348       -kill
6349 @end example
6350 @noindent
6351 which will create the agenda views restricted to the file
6352 @file{~/org/project.org}, without diary entries and with 30 days
6353 extent.
6355 @node Using the agenda elsewhere,  , Exporting Agenda Views, Custom agenda views
6356 @subsection Using agenda information outside of Org
6357 @cindex agenda, pipe
6358 @cindex Scripts, for agenda processing
6360 Org provides commands to access agenda information for the command
6361 line in emacs batch mode.  This extracted information can be sent
6362 directly to a printer, or it can be read by a program that does further
6363 processing of the data.  The first of these commands is the function
6364 @code{org-batch-agenda}, that produces an agenda view and sends it as
6365 ASCII text to STDOUT.  The command takes a single string as parameter.
6366 If the string has length 1, it is used as a key to one of the commands
6367 you have configured in @code{org-agenda-custom-commands}, basically any
6368 key you can use after @kbd{C-c a}.  For example, to directly print the
6369 current TODO list, you could use
6371 @example
6372 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
6373 @end example
6375 If the parameter is a string with 2 or more characters, it is used as a
6376 tags/todo match string.  For example, to print your local shopping list
6377 (all items with the tag @samp{shop}, but excluding the tag
6378 @samp{NewYork}), you could use
6380 @example
6381 emacs -batch -l ~/.emacs                                      \
6382       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
6383 @end example
6385 @noindent
6386 You may also modify parameters on the fly like this:
6388 @example
6389 emacs -batch -l ~/.emacs                                      \
6390    -eval '(org-batch-agenda "a"                               \
6391             org-agenda-ndays 30                               \
6392             org-agenda-include-diary nil                      \
6393             org-agenda-files (quote ("~/org/project.org")))'  \
6394    | lpr
6395 @end example
6397 @noindent
6398 which will produce a 30 day agenda, fully restricted to the Org file
6399 @file{~/org/projects.org}, not even including the diary.
6401 If you want to process the agenda data in more sophisticated ways, you
6402 can use the command @code{org-batch-agenda-csv} to get a comma-separated
6403 list of values for each agenda item.  Each line in the output will
6404 contain a number of fields separated by commas.  The fields in a line
6405 are:
6407 @example
6408 category     @r{The category of the item}
6409 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
6410 type         @r{The type of the agenda entry, can be}
6411                 todo               @r{selected in TODO match}
6412                 tagsmatch          @r{selected in tags match}
6413                 diary              @r{imported from diary}
6414                 deadline           @r{a deadline}
6415                 scheduled          @r{scheduled}
6416                 timestamp          @r{appointment, selected by timestamp}
6417                 closed             @r{entry was closed on date}
6418                 upcoming-deadline  @r{warning about nearing deadline}
6419                 past-scheduled     @r{forwarded scheduled item}
6420                 block              @r{entry has date block including date}
6421 todo         @r{The TODO keyword, if any}
6422 tags         @r{All tags including inherited ones, separated by colons}
6423 date         @r{The relevant date, like 2007-2-14}
6424 time         @r{The time, like 15:00-16:50}
6425 extra        @r{String with extra planning info}
6426 priority-l   @r{The priority letter if any was given}
6427 priority-n   @r{The computed numerical priority}
6428 @end example
6430 @noindent
6431 Time and date will only be given if a timestamp (or deadline/scheduled)
6432 lead to the selection of the item.
6434 A CSV list like this is very easy to use in a post processing script.
6435 For example, here is a Perl program that gets the TODO list from
6436 Emacs/Org and prints all the items, preceded by a checkbox:
6438 @example
6439 @group
6440 #!/usr/bin/perl
6442 # define the Emacs command to run
6443 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
6445 # run it and capture the output
6446 $agenda = qx@{$cmd 2>/dev/null@};
6448 # loop over all lines
6449 foreach $line (split(/\n/,$agenda)) @{
6451   # get the individual values
6452   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
6453    $priority_l,$priority_n) = split(/,/,$line);
6455   # proccess and print
6456   print "[ ] $head\n";
6458 @end group
6459 @end example
6461 @node Agenda column view,  , Custom agenda views, Agenda Views
6462 @section Using column view in the agenda
6463 @cindex column view, in agenda
6464 @cindex agenda, column view
6466 Column view (@pxref{Column view}) is normally used to view and edit
6467 properties embedded in the hierarchical structure of an Org file.  It can be
6468 quite useful to use column view also from the agenda, where entries are
6469 collected by certain criteria.
6471 @table @kbd
6472 @kindex C-c C-x C-c
6473 @item C-c C-x C-c
6474 Turn on column view in the agenda.
6475 @end table
6477 To understand how to use this properly, it is important to realize that the
6478 entries in the agenda are no longer in their proper outline environment.
6479 This causes the following issues:
6481 @enumerate
6482 @item
6483 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
6484 entries in the agenda are collected from different files, and different files
6485 may have different @code{COLUMNS} formats, this is a non-trivial problem.
6486 Org first checks if the variable @code{org-overriding-columns-format} is
6487 currently set, and if yes takes the format from there.  Otherwise it takes
6488 the format associated with the first item in the agenda, or, if that item
6489 does not have a specific format (defined in a property, or in it's file), it
6490 uses @code{org-columns-default-format}.
6491 @item
6492 If any of the columns has a summary type defined (@pxref{Column attributes}),
6493 turning on column view in the agenda will visit all relevant agenda files and
6494 make sure that the computations of this property are up to date.  This is
6495 also true for the special @code{CLOCKSUM} property.  Org will then sum the
6496 values displayed in the agenda.  In the daily/weekly agenda, the sums will
6497 cover a single day, in all other views they cover the entire block.  It is
6498 vital to realize that the agenda may show the same entry @emph{twice} (for
6499 example as scheduled and as a deadline), and it may show two entries from the
6500 same hierarchy (for example a @emph{parent} and it's @emph{child}).  In these
6501 cases, the summation in the agenda will lead to incorrect results because
6502 some values will count double.
6503 @item
6504 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
6505 the entire clocked time for this item.  So even in the daily/weekly agenda,
6506 the clocksum listed in column view may originate from times outside the
6507 current view.  This has the advantage that you can compare these values with
6508 a column listing the planned total effort for a task - one of the major
6509 applications for column view in the agenda.  If you want information about
6510 clocked time in the displayed period use clock table mode (press @kbd{R} in
6511 the agenda).
6512 @end enumerate
6515 @node Embedded LaTeX, Exporting, Agenda Views, Top
6516 @chapter Embedded LaTeX
6517 @cindex @TeX{} interpretation
6518 @cindex La@TeX{} interpretation
6520 Plain ASCII is normally sufficient for almost all note taking.  One
6521 exception, however, are scientific notes which need to be able to contain
6522 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
6523 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
6524 features described here as ``La@TeX{}'' are really from @TeX{}, but for
6525 simplicity I am blurring this distinction.}  is widely used to typeset
6526 scientific documents. Org mode supports embedding La@TeX{} code into its
6527 files, because many academics are used to reading La@TeX{} source code, and
6528 because it can be readily processed into images for HTML production.
6530 It is not necessary to mark La@TeX{} macros and code in any special way.
6531 If you observe a few conventions, Org mode knows how to find it and what
6532 to do with it.
6534 @menu
6535 * Math symbols::                TeX macros for symbols and Greek letters
6536 * Subscripts and superscripts::  Simple syntax for raising/lowering text
6537 * LaTeX fragments::             Complex formulas made easy
6538 * Processing LaTeX fragments::  Previewing LaTeX processing
6539 * CDLaTeX mode::                Speed up entering of formulas
6540 @end menu
6542 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
6543 @section Math symbols
6544 @cindex math symbols
6545 @cindex TeX macros
6547 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
6548 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
6549 Completion for these macros is available, just type @samp{\} and maybe a
6550 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
6551 Unlike La@TeX{} code, Org mode allows these macros to be present
6552 without surrounding math delimiters, for example:
6554 @example
6555 Angles are written as Greek letters \alpha, \beta and \gamma.
6556 @end example
6558 During HTML export (@pxref{HTML export}), these symbols are translated
6559 into the proper syntax for HTML, for the above examples this is
6560 @samp{&alpha;} and @samp{&rarr;}, respectively.  If you need such a symbol
6561 inside a word, terminate it like this: @samp{\Aacute@{@}stor}.
6563 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
6564 @section Subscripts and superscripts
6565 @cindex subscript
6566 @cindex superscript
6568 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
6569 and subscripts.  Again, these can be used without embedding them in
6570 math-mode delimiters.  To increase the readability of ASCII text, it is
6571 not necessary (but OK) to surround multi-character sub- and superscripts
6572 with curly braces.  For example
6574 @example
6575 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
6576 the sun is R_@{sun@} = 6.96 x 10^8 m.
6577 @end example
6579 To avoid interpretation as raised or lowered text, you can quote
6580 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
6582 During HTML export (@pxref{HTML export}), subscript and superscripts
6583 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
6585 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
6586 @section LaTeX fragments
6587 @cindex LaTeX fragments
6589 With symbols, sub- and superscripts, HTML is pretty much at its end when
6590 it comes to representing mathematical formulas@footnote{Yes, there is
6591 MathML, but that is not yet fully supported by many browsers, and there
6592 is no decent converter for turning La@TeX{} or ASCII representations of
6593 formulas into MathML. So for the time being, converting formulas into
6594 images seems the way to go.}. More complex expressions need a dedicated
6595 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
6596 fragments. It provides commands to preview the typeset result of these
6597 fragments, and upon export to HTML, all fragments will be converted to
6598 images and inlined into the HTML document@footnote{The La@TeX{} export
6599 will not use images for displaying La@TeX{} fragments but include these
6600 fragments directly into the La@TeX{} code.}. For this to work you
6601 need to be on a system with a working La@TeX{} installation. You also
6602 need the @file{dvipng} program, available at
6603 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
6604 will be used when processing a fragment can be configured with the
6605 variable @code{org-format-latex-header}.
6607 La@TeX{} fragments don't need any special marking at all.  The following
6608 snippets will be identified as La@TeX{} source code:
6609 @itemize @bullet
6610 @item
6611 Environments of any kind.  The only requirement is that the
6612 @code{\begin} statement appears on a new line, preceded by only
6613 whitespace.
6614 @item
6615 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
6616 currency specifications, single @samp{$} characters are only recognized
6617 as math delimiters if the enclosed text contains at most two line breaks,
6618 is directly attached to the @samp{$} characters with no whitespace in
6619 between, and if the closing @samp{$} is followed by whitespace or
6620 punctuation.  For the other delimiters, there is no such restriction, so
6621 when in doubt, use @samp{\(...\)} as inline math delimiters.
6622 @end itemize
6624 @noindent For example:
6626 @example
6627 \begin@{equation@}                          % arbitrary environments,
6628 x=\sqrt@{b@}                                % even tables, figures
6629 \end@{equation@}                            % etc
6631 If $a^2=b$ and \( b=2 \), then the solution must be
6632 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
6633 @end example
6635 @noindent
6636 If you need any of the delimiter ASCII sequences for other purposes, you
6637 can configure the option @code{org-format-latex-options} to deselect the
6638 ones you do not wish to have interpreted by the La@TeX{} converter.
6640 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
6641 @section Processing LaTeX fragments
6642 @cindex LaTeX fragments, preview
6644 La@TeX{} fragments can be processed to produce a preview images of the
6645 typeset expressions:
6647 @table @kbd
6648 @kindex C-c C-x C-l
6649 @item C-c C-x C-l
6650 Produce a preview image of the La@TeX{} fragment at point and overlay it
6651 over the source code.  If there is no fragment at point, process all
6652 fragments in the current entry (between two headlines).  When called
6653 with a prefix argument, process the entire subtree.  When called with
6654 two prefix arguments, or when the cursor is before the first headline,
6655 process the entire buffer.
6656 @kindex C-c C-c
6657 @item C-c C-c
6658 Remove the overlay preview images.
6659 @end table
6661 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
6662 converted into images and inlined into the document if the following
6663 setting is active:
6665 @lisp
6666 (setq org-export-with-LaTeX-fragments t)
6667 @end lisp
6669 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
6670 @section Using CDLaTeX to enter math
6671 @cindex CDLaTeX
6673 CDLaTeX mode is a minor mode that is normally used in combination with a
6674 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
6675 environments and math templates.  Inside Org mode, you can make use of
6676 some of the features of CDLaTeX mode.  You need to install
6677 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
6678 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
6679 Don't use CDLaTeX mode itself under Org mode, but use the light
6680 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
6681 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
6682 Org files with
6684 @lisp
6685 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
6686 @end lisp
6688 When this mode is enabled, the following features are present (for more
6689 details see the documentation of CDLaTeX mode):
6690 @itemize @bullet
6691 @kindex C-c @{
6692 @item
6693 Environment templates can be inserted with @kbd{C-c @{}.
6694 @item
6695 @kindex @key{TAB}
6696 The @key{TAB} key will do template expansion if the cursor is inside a
6697 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
6698 inside such a fragment, see the documentation of the function
6699 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
6700 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
6701 correctly inside the first brace.  Another @key{TAB} will get you into
6702 the second brace.  Even outside fragments, @key{TAB} will expand
6703 environment abbreviations at the beginning of a line.  For example, if
6704 you write @samp{equ} at the beginning of a line and press @key{TAB},
6705 this abbreviation will be expanded to an @code{equation} environment.
6706 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
6707 @item
6708 @kindex _
6709 @kindex ^
6710 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
6711 characters together with a pair of braces.  If you use @key{TAB} to move
6712 out of the braces, and if the braces surround only a single character or
6713 macro, they are removed again (depending on the variable
6714 @code{cdlatex-simplify-sub-super-scripts}).
6715 @item
6716 @kindex `
6717 Pressing the backquote @kbd{`} followed by a character inserts math
6718 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
6719 after the backquote, a help window will pop up.
6720 @item
6721 @kindex '
6722 Pressing the normal quote @kbd{'} followed by another character modifies
6723 the symbol before point with an accent or a font.  If you wait more than
6724 1.5 seconds after the backquote, a help window will pop up.  Character
6725 modification will work only inside La@TeX{} fragments, outside the quote
6726 is normal.
6727 @end itemize
6729 @node Exporting, Publishing, Embedded LaTeX, Top
6730 @chapter Exporting
6731 @cindex exporting
6733 Org mode documents can be exported into a variety of other formats.  For
6734 printing and sharing of notes, ASCII export produces a readable and
6735 simple version of an Org file.  HTML export allows you to publish a
6736 notes file on the web, while the XOXO format provides a solid base for
6737 exchange with a broad range of other applications. La@TeX{} export lets
6738 you use Org mode and its structured editing functions to easily create
6739 La@TeX{} files.  To incorporate entries with associated times like
6740 deadlines or appointments into a desktop calendar program like iCal,
6741 Org mode can also produce extracts in the iCalendar format.  Currently
6742 Org mode only supports export, not import of these different formats.
6744 @menu
6745 * Markup rules::                Which structures are recognized?
6746 * Export options::              Per-file export settings
6747 * The export dispatcher::       How to access exporter commands
6748 * ASCII export::                Exporting to plain ASCII
6749 * HTML export::                 Exporting to HTML
6750 * LaTeX export::                Exporting to LaTeX
6751 * XOXO export::                 Exporting to XOXO
6752 * iCalendar export::            Exporting in iCalendar format
6753 @end menu
6755 @node Markup rules, Export options, Exporting, Exporting
6756 @section Markup rules
6758 When exporting Org mode documents,  the exporter tries to reflect the
6759 structure of the document as accurately as possible in the back-end.  Since
6760 export targets like HTML or La@TeX{} allow much richer formatting, Org mode
6761 has rules how to prepare text for rich export.  This section summarizes the
6762 markup rule used in an Org mode buffer.
6764 @menu
6765 * Document title::              How the document title is determined
6766 * Headings and sections::       The main structure of the exported document
6767 * Table of contents::           If, where, how to create a table of contents
6768 * Initial text::                Text before the first headline
6769 * Lists::                       Plain lists are exported
6770 * Paragraphs::                  What determines beginning and ending
6771 * Literal examples::            Source code and other examples
6772 * Include files::               Include the contents of a file during export
6773 * Tables exported::             Tables are exported richly
6774 * Footnotes::                   Numbers like [1]
6775 * Emphasis and monospace::      To bold or not to bold
6776 * TeX macros and LaTeX fragments::  Create special, rich export.
6777 * Horizontal rules::            A line across the page
6778 * Comment lines::               Some lines will not be exported
6779 @end menu
6781 @node Document title, Headings and sections, Markup rules, Markup rules
6782 @subheading Document title
6783 @cindex document title, markup rules
6785 @noindent
6786 The title of the exported document is taken from the special line
6788 @example
6789 #+TITLE: This is the title of the document
6790 @end example
6792 @noindent
6793 If this line does not exist, the title is derived from the first non-empty,
6794 non-comment line in the buffer.  If no such line exists, or if you have
6795 turned off exporting of the text before the first headline (see below), the
6796 title will be the file name without extension.
6798 If you are exporting only a subtree by marking is as the region, the heading
6799 of the subtree will become the title of the document.  If the subtree has a
6800 property @code{EXPORT_TITLE}, that will take precedence.
6802 @node Headings and sections, Table of contents, Document title, Markup rules
6803 @subheading Headings and sections
6804 @cindex headings and sections, markup rules
6806 The outline structure of the document as described in @ref{Document
6807 Structure} forms the basis for defining sections of the exported document.
6808 However, since the outline structure is also used for (for example) lists of
6809 tasks, only the first three outline levels will be used as headings.  Deeper
6810 levels will become itemized lists.  You can change the location of this
6811 switch, globally by setting the variable @code{org-headline-levels}, or on a
6812 per file basis with a line
6814 @example
6815 #+OPTIONS: H:4
6816 @end example
6818 @node Table of contents, Initial text, Headings and sections, Markup rules
6819 @subheading Table of contents
6820 @cindex table of contents, markup rules
6822 The table of contents is normally inserted directly before the first headline
6823 of the file.  If you would like to get it to a different location, insert the
6824 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
6825 location.  The depth of the table of contents is by default the same as the
6826 number of headline levels, but you can choose a smaller number or turn off
6827 the table of contents entirely by configuring the variable
6828 @code{org-export-with-toc}, or on a per-file basis with a line like
6830 @example
6831 #+OPTIONS: toc:2          (only to two levels in TOC)
6832 #+OPTIONS: toc:nil        (no TOC at all)
6833 @end example
6835 @node Initial text, Lists, Table of contents, Markup rules
6836 @subheading Text before the first headline
6837 @cindex text before first headline, markup rules
6838 @cindex #+TEXT
6840 Org mode normally exports the text before the first headline, and even uses
6841 the first line as the document title.  The text will be fully marked up.  If
6842 you need to include literal HTML or La@TeX{} code, use the special constructs
6843 described below in the sections for the individual exporters.
6845 Some people like to use the space before the first headline for setup and
6846 internal links and therefore would like to control the exported text before
6847 the first headline in a different way.  You can do so by setting the variable
6848 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
6849 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
6851 @noindent
6852 If you still want to have some text before the first headline, use the
6853 @code{#+TEXT} construct:
6855 @example
6856 #+OPTIONS: skip:t
6857 #+TEXT: This text will go before the *first* headline.
6858 #+TEXT: [TABLE-OF-CONTENTS]
6859 #+TEXT: This goes between the table of contents and the first headline
6860 @end example
6862 @node Lists, Paragraphs, Initial text, Markup rules
6863 @subheading Lists
6864 @cindex lists, markup rules
6866 Plain lists as described in @ref{Plain lists} are translated to the back-ends
6867 syntax for such lists.  Most back-ends support unordered, ordered, and
6868 description lists.
6870 @node Paragraphs, Literal examples, Lists, Markup rules
6871 @subheading Paragraphs, line breaks, and quoting
6872 @cindex paragraphs, markup rules
6874 Paragraphs are separated by at least one empty line.  If you need to enforce
6875 a line break within a paragraph, use @samp{\\} at the end of a line.
6877 To keep the line breaks in a region, but otherwise use normal formatting, you
6878 can use this construct, which can also be used to format poetry.
6880 @example
6881 #+BEGIN_VERSE
6882  Great clouds overhead
6883  Tiny black birds rise and fall
6884  Snow covers Emacs
6886      -- AlexSchroeder
6887 #+END_VERSE
6888 @end example
6890 When quoting a passage from another document, it is customary to format this
6891 as a paragraph that is indented on both the left and the right margin.  You
6892 can include quotations in Org mode documents like this:
6894 @example
6895 #+BEGIN_QUOTE
6896 Everything should be made as simple as possible,
6897 but not any simpler -- Albert Einstein
6898 #+END_QUOTE
6899 @end example
6902 @node Literal examples, Include files, Paragraphs, Markup rules
6903 @subheading Literal examples
6904 @cindex literal examples, markup rules
6906 You can include literal examples that should not be subjected to
6907 markup.  Such examples will be typeset in monospace, so this is well suited
6908 for source code and similar examples.
6909 @cindex #+BEGIN_EXAMPLE
6911 @example
6912 #+BEGIN_EXAMPLE
6913 Some example from a text file.
6914 #+END_EXAMPLE
6915 @end example
6917 For simplicity when using small examples, you can also start the example
6918 lines with a colon:
6920 @example
6921 : Some example from a text file.
6922 @end example
6924 @cindex formatting source code, markup rules
6925 If the example is source code from a programming language, or any other text
6926 that can be marked up by font-lock in Emacs, you can ask for the example to
6927 look like the fontified Emacs buffer@footnote{Currently this works only for
6928 the HTML back-end, and requires the @file{htmlize.el} package version 1.34 or
6929 later.}.  This is done with the @samp{src} block, where you also need to
6930 specify the name of the major mode that should be used to fontify the
6931 example:
6932 @cindex #+BEGIN_SRC
6934 @example
6935 #+BEGIN_SRC emacs-lisp
6936 (defun org-xor (a b)
6937    "Exclusive or."
6938    (if a (not b) b))
6939 #+END_SRC
6940 @end example
6942 @table @kbd
6943 @kindex C-c '
6944 @item C-c '
6945 Edit the source code example at point in its native mode.  This works by
6946 switching to an indirect buffer, narrowing the buffer and switching to the
6947 other mode.  You need to exit by pressing @kbd{C-c '} again.  Fixed-width
6948 regions (where each line starts with a colon followed by a space) will be
6949 edited using @code{artist-mode}@footnote{You may select a different-mode with
6950 the variable @code{org-edit-fixed-width-region-mode}.} to allow creating
6951 ASCII drawings easily.  Using this command in an empty line will create a new
6952 fixed-width region.
6953 @end table
6956 @node Include files, Tables exported, Literal examples, Markup rules
6957 @subheading Include files
6958 @cindex include files, markup rules
6960 During export, you can include the content of another file.  For example, to
6961 include your .emacs file, you could use:
6962 @cindex #+INCLUDE
6964 @example
6965 #+INCLUDE: "~/.emacs" src emacs-lisp
6966 @end example
6968 The optional second and third parameter are the markup (@samp{quote},
6969 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
6970 language for formatting the contents.  The markup is optional, if it is not
6971 given, the text will be assumed to be in Org mode format and will be
6972 processed normally.  The include line will also allow additional keyword
6973 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
6974 first line and for each following line.  For example, to include a file as an
6975 item, use
6977 @example
6978 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
6979 @end example
6981 @table @kbd
6982 @kindex C-c '
6983 @item C-c '
6984 Visit the include file at point.
6985 @end table
6987 @node Tables exported, Footnotes, Include files, Markup rules
6988 @subheading Tables
6989 @cindex tables, markup rules
6991 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
6992 the @file{table.el} package will be exported properly.  For Org mode tables,
6993 the lines before the first horizontal separator line will become table header
6994 lines.
6996 @node Footnotes, Emphasis and monospace, Tables exported, Markup rules
6997 @subheading Footnotes
6998 @cindex footnotes, markup rules
6999 @cindex @file{footnote.el}
7001 @kindex C-c !
7002 Numbers in square brackets are treated as footnote markers, and lines
7003 starting with such a marker are interpreted as the footnote itself.  You can
7004 use the Emacs package @file{footnote.el} to create footnotes@footnote{The
7005 @file{footnote} package uses @kbd{C-c !} to invoke its commands.  This
7006 binding conflicts with the Org mode command for inserting inactive time
7007 stamps.  You could use the variable @code{footnote-prefix} to switch
7008 footnotes commands to another key.  Or, if you are too used to this binding,
7009 you could use @code{org-replace-disputed-keys} and @code{org-disputed-keys}
7010 to change the settings in Org.}.  For example:
7012 @example
7013 The Org homepage[1] now looks a lot better than it used to.
7015 [1] The link is: http://orgmode.org
7016 @end example
7018 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnotes, Markup rules
7019 @subheading Emphasis and monospace
7021 @cindex underlined text, markup rules
7022 @cindex bold text, markup rules
7023 @cindex italic text, markup rules
7024 @cindex verbatim text, markup rules
7025 @cindex code text, markup rules
7026 @cindex strike-through text, markup rules
7027 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
7028 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
7029 in the code and verbatim string is not processed for Org mode specific
7030 syntax, it is exported verbatim.
7032 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
7033 @subheading @TeX{} macros and La@TeX{} fragments
7034 @cindex LaTeX fragments, markup rules
7035 @cindex TeX macros, markup rules
7036 @cindex HTML entities
7037 @cindex LaTeX entities
7039 A @TeX{}-like syntax is used to specify special characters.  Where possible,
7040 these will be transformed into the native format of the exporter back-end.
7041 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
7042 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
7043 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
7044 This applies for a large number of entities, with names taken from both HTML
7045 and La@TeX{}, see the variable @code{org-html-entities} for the complete
7046 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
7047 after having types the backslash and maybe a few characters
7048 (@pxref{Completion}).
7050 La@TeX{} fragments are converted into images for HTML export, and they are
7051 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
7053 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
7054 @samp{...} are all converted into special commands creating hyphens of
7055 different lengths or a compact set of dots.
7057 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
7058 @subheading  Horizontal rules
7059 @cindex horizontal rules, markup rules
7060 A line consisting of only dashes, and at least 5 of them, will be
7061 exported as a horizontal line (@samp{<hr/>} in HTML).
7063 @node Comment lines,  , Horizontal rules, Markup rules
7064 @subheading Comment lines
7065 @cindex comment lines
7066 @cindex exporting, not
7068 Lines starting with @samp{#} in column zero are treated as comments and will
7069 never be exported.  Also entire subtrees starting with the word
7070 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
7071 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
7073 @table @kbd
7074 @kindex C-c ;
7075 @item C-c ;
7076 Toggle the COMMENT keyword at the beginning of an entry.
7077 @end table
7079 @node Export options, The export dispatcher, Markup rules, Exporting
7080 @section Export options
7081 @cindex options, for export
7083 @cindex completion, of option keywords
7084 The exporter recognizes special lines in the buffer which provide
7085 additional information.  These lines may be put anywhere in the file.
7086 The whole set of lines can be inserted into the buffer with @kbd{C-c
7087 C-e t}.  For individual lines, a good way to make sure the keyword is
7088 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
7089 (@pxref{Completion}).
7091 @table @kbd
7092 @kindex C-c C-e t
7093 @item C-c C-e t
7094 Insert template with export options, see example below.
7095 @end table
7097 @cindex #+TITLE:
7098 @cindex #+AUTHOR:
7099 @cindex #+DATE:
7100 @cindex #+EMAIL:
7101 @cindex #+LANGUAGE:
7102 @cindex #+TEXT:
7103 @cindex #+OPTIONS:
7104 @cindex #+LINK_UP:
7105 @cindex #+LINK_HOME:
7106 @example
7107 #+TITLE:     the title to be shown (default is the buffer name)
7108 #+AUTHOR:    the author (default taken from @code{user-full-name})
7109 #+DATE:      A date, fixed, of a format string for @code{format-time-string}
7110 #+EMAIL:     his/her email address (default from @code{user-mail-address})
7111 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
7112 #+TEXT:      Some descriptive text to be inserted at the beginning.
7113 #+TEXT:      Several lines may be given.
7114 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
7115 #+LINK_UP:   the ``up'' link of an exported page
7116 #+LINK_HOME: the ``home'' link of an exported page
7117 @end example
7119 @noindent
7120 The OPTIONS line is a compact@footnote{If you want to configure many options
7121 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
7122 you can:
7123 @cindex headline levels
7124 @cindex section-numbers
7125 @cindex table of contents
7126 @cindex line-break preservation
7127 @cindex quoted HTML tags
7128 @cindex fixed-width sections
7129 @cindex tables
7130 @cindex @TeX{}-like syntax for sub- and superscripts
7131 @cindex footnotes
7132 @cindex special strings
7133 @cindex emphasized text
7134 @cindex @TeX{} macros
7135 @cindex La@TeX{} fragments
7136 @cindex author info, in export
7137 @cindex time info, in export
7138 @example
7139 H:         @r{set the number of headline levels for export}
7140 num:       @r{turn on/off section-numbers}
7141 toc:       @r{turn on/off table of contents, or set level limit (integer)}
7142 \n:        @r{turn on/off line-break-preservation}
7143 @@:         @r{turn on/off quoted HTML tags}
7144 ::         @r{turn on/off fixed-width sections}
7145 |:         @r{turn on/off tables}
7146 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
7147            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
7148            @r{the simple @code{a_b} will be left as it is.}
7149 -:         @r{turn on/off conversion of special strings.}
7150 f:         @r{turn on/off footnotes like this[1].}
7151 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
7152 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
7153 LaTeX:     @r{turn on/off La@TeX{} fragments}
7154 skip:      @r{turn on/off skipping the text before the first heading}
7155 author:    @r{turn on/off inclusion of author name/email into exported file}
7156 creator:   @r{turn on/off inclusion of creator info into exported file}
7157 timestamp: @r{turn on/off inclusion creation time into exported file}
7158 d:         @r{turn on/off inclusion of drawers}
7159 @end example
7161 These options take effect in both the HTML and La@TeX{} export, except
7162 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
7163 @code{nil} for the La@TeX{} export.
7165 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
7166 calling an export command, the subtree can overrule some of the file's export
7167 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
7168 @code{EXPORT_TEXT}, and @code{EXPORT_OPTIONS}.
7170 @node The export dispatcher, ASCII export, Export options, Exporting
7171 @section The export dispatcher
7172 @cindex dispatcher, for export commands
7174 All export commands can be reached using the export dispatcher, which is a
7175 prefix key that prompts for an additional key specifying the command.
7176 Normally the entire file is exported, but if there is an active region that
7177 contains one outline tree, the first heading is used as document title and
7178 the subtrees are exported.
7180 @table @kbd
7181 @kindex C-c C-e
7182 @item C-c C-e
7183 Dispatcher for export and publishing commands.  Displays a help-window
7184 listing the additional key(s) needed to launch an export or publishing
7185 command.  The prefix arg is passed through to the exporter.  If the option
7186 @code{org-export-run-in-background} is set, Org will run the command in the
7187 background if that seems useful for the specific command (i.e. commands that
7188 write to a file).
7189 @kindex C-c C-e v
7190 @item C-c C-e v
7191 Like @kbd{C-c C-e}, but only export the text that is currently visible
7192 (i.e. not hidden by outline visibility).
7193 @kindex C-u C-u C-c C-e
7194 @item C-u C-u C-c C-e
7195 Call an the exporter, but reverse the setting of
7196 @code{org-export-run-in-background}, i.e. request background processing if
7197 not set, or force processing in the current Emacs process if st.
7198 @end table
7200 @node ASCII export, HTML export, The export dispatcher, Exporting
7201 @section ASCII export
7202 @cindex ASCII export
7204 ASCII export produces a simple and very readable version of an Org mode
7205 file.
7207 @cindex region, active
7208 @cindex active region
7209 @cindex Transient mark mode
7210 @table @kbd
7211 @kindex C-c C-e a
7212 @item C-c C-e a
7213 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
7214 will be @file{myfile.txt}.  The file will be overwritten without
7215 warning.  If there is an active region, only the region will be
7216 exported. If the selected region is a single tree@footnote{To select the
7217 current subtree, use @kbd{C-c @@}.}, the tree head will
7218 become the document title.  If the tree head entry has or inherits an
7219 @code{EXPORT_FILE_NAME} property, that name will be used for the
7220 export.
7221 @kindex C-c C-e v a
7222 @item C-c C-e v a
7223 Export only the visible part of the document.
7224 @end table
7226 @cindex headline levels, for exporting
7227 In the exported version, the first 3 outline levels will become
7228 headlines, defining a general document structure.  Additional levels
7229 will be exported as itemized lists.  If you want that transition to occur
7230 at a different level, specify it with a prefix argument.  For example,
7232 @example
7233 @kbd{C-1 C-c C-e a}
7234 @end example
7236 @noindent
7237 creates only top level headlines and does the rest as items.  When
7238 headlines are converted to items, the indentation of the text following
7239 the headline is changed to fit nicely under the item.  This is done with
7240 the assumption that the first body line indicates the base indentation of
7241 the body text.  Any indentation larger than this is adjusted to preserve
7242 the layout relative to the first line.  Should there be lines with less
7243 indentation than the first, these are left alone.
7245 @node HTML export, LaTeX export, ASCII export, Exporting
7246 @section HTML export
7247 @cindex HTML export
7249 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
7250 HTML formatting, in ways similar to John Grubers @emph{markdown}
7251 language, but with additional support for tables.
7253 @menu
7254 * HTML Export commands::        How to invoke HTML export
7255 * Quoting HTML tags::           Using direct HTML in Org mode
7256 * Links::                       Transformation of links for HTML
7257 * Images::                      How to include images
7258 * CSS support::                 Changing the appearance of the output
7259 * Javascript support::          Info and Folding in a web browser
7260 @end menu
7262 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
7263 @subsection HTML export commands
7265 @cindex region, active
7266 @cindex active region
7267 @cindex Transient mark mode
7268 @table @kbd
7269 @kindex C-c C-e h
7270 @item C-c C-e h
7271 Export as HTML file @file{myfile.html}.  For an org file @file{myfile.org},
7272 the ASCII file will be @file{myfile.html}.  The file will be overwritten
7273 without warning.  If there is an active region, only the region will be
7274 exported. If the selected region is a single tree@footnote{To select the
7275 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
7276 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
7277 property, that name will be used for the export.
7278 @kindex C-c C-e b
7279 @item C-c C-e b
7280 Export as HTML file and immediately open it with a browser.
7281 @kindex C-c C-e H
7282 @item C-c C-e H
7283 Export to a temporary buffer, do not create a file.
7284 @kindex C-c C-e R
7285 @item C-c C-e R
7286 Export the active region to a temporary buffer.  With a prefix argument, do
7287 not produce the file header and footer, but just the plain HTML section for
7288 the region.  This is good for cut-and-paste operations.
7289 @kindex C-c C-e v h
7290 @kindex C-c C-e v b
7291 @kindex C-c C-e v H
7292 @kindex C-c C-e v R
7293 @item C-c C-e v h
7294 @item C-c C-e v b
7295 @item C-c C-e v H
7296 @item C-c C-e v R
7297 Export only the visible part of the document.
7298 @item M-x org-export-region-as-html
7299 Convert the region to HTML under the assumption that it was Org mode
7300 syntax before.  This is a global command that can be invoked in any
7301 buffer.
7302 @item M-x org-replace-region-by-HTML
7303 Replace the active region (assumed to be in Org mode syntax) by HTML
7304 code.
7305 @end table
7307 @cindex headline levels, for exporting
7308 In the exported version, the first 3 outline levels will become headlines,
7309 defining a general document structure.  Additional levels will be exported as
7310 itemized lists.  If you want that transition to occur at a different level,
7311 specify it with a numeric prefix argument.  For example,
7313 @example
7314 @kbd{C-2 C-c C-e b}
7315 @end example
7317 @noindent
7318 creates two levels of headings and does the rest as items.
7320 @node Quoting HTML tags, Links, HTML Export commands, HTML export
7321 @subsection Quoting HTML tags
7323 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
7324 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
7325 which should be interpreted as such, mark them with @samp{@@} as in
7326 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
7327 simple tags.  For more extensive HTML that should be copied verbatim to
7328 the exported file use either
7330 @example
7331 #+HTML: Literal HTML code for export
7332 @end example
7334 @noindent or
7335 @cindex #+BEGIN_HTML
7337 @example
7338 #+BEGIN_HTML
7339 All lines between these markers are exported literally
7340 #+END_HTML
7341 @end example
7344 @node Links, Images, Quoting HTML tags, HTML export
7345 @subsection Links
7347 @cindex links, in HTML export
7348 @cindex internal links, in HTML export
7349 @cindex external links, in HTML export
7350 Internal links (@pxref{Internal links}) will continue to work in HTML
7351 files only if they match a dedicated @samp{<<target>>}.  Automatic links
7352 created by radio targets (@pxref{Radio targets}) will also work in the
7353 HTML file.  Links to external files will still work if the HTML file is
7354 in the same directory as the Org file.  Links to other @file{.org}
7355 files will be translated into HTML links under the assumption that an
7356 HTML version also exists of the linked file.  For information related to
7357 linking files while publishing them to a publishing directory see
7358 @ref{Publishing links}.
7360 If you want to specify attributes for links, you can do so using a special
7361 syntax.  Here is an example that sets @code{alt} and @code{title} attributes
7362 for an inlined image:
7364 @example
7365 [[./img/a.jpg@{@{alt="This is image A" title="Image with no action"@}@}]]
7366 @end example
7368 @node Images, CSS support, Links, HTML export
7369 @subsection Images
7371 @cindex images, inline in HTML
7372 @cindex inlining images in HTML
7373 HTML export can inline images given as links in the Org file, and
7374 it can make an image the clickable part of a link.  By
7375 default@footnote{but see the variable
7376 @code{org-export-html-inline-images}}, images are inlined if a link does
7377 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
7378 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
7379 @samp{the image} that points to the image.  If the description part
7380 itself is a @code{file:} link or a @code{http:} URL pointing to an
7381 image, this image will be inlined and activated so that clicking on the
7382 image will activate the link.  For example, to include a thumbnail that
7383 will link to a high resolution version of the image, you could use:
7385 @example
7386 [[file:highres.jpg][file:thumb.jpg]]
7387 @end example
7389 @noindent
7390 and you could use @code{http} addresses just as well.
7392 @node CSS support, Javascript support, Images, HTML export
7393 @subsection CSS support
7394 @cindex CSS, for HTML export
7395 @cindex HTML export, CSS
7397 You can also give style information for the exported file.  The HTML
7398 exporter assigns the following CSS classes to appropriate parts of the
7399 document - your style specifications may change these:
7400 @example
7401 .todo           @r{TODO keywords}
7402 .done           @r{the DONE keyword}
7403 .timestamp      @r{time stamp}
7404 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
7405 .tag            @r{tag in a headline}
7406 .target         @r{target for links}
7407 @end example
7409 Each exported files contains a compact default style that defines these
7410 classes in a basic way.  You may overwrite these settings, or add to them by
7411 using the variables @code{org-export-html-style} (for Org-wide settings) and
7412 @code{org-export-html-style-extra} (for more granular settings, like
7413 file-local settings).  If you want to use a file-local style, you may use
7414 file variables, best wrapped into a COMMENT section at the end of the outline
7415 tree.  For example@footnote{Under Emacs 21, the continuation lines for a
7416 variable value should have no @samp{#} at the start of the line.}:
7418 @example
7419 * COMMENT html style specifications
7421 # Local Variables:
7422 # org-export-html-style-extra: 
7423 #  "<style>
7424 #   p  @{font-weight: normal; color: gray; @}
7425 #   h1 @{color: black; @}
7426 #   </style>"
7427 # End:
7428 @end example
7430 Remember to execute @kbd{M-x normal-mode} after changing this to make the new
7431 style immediately visible to Emacs.  This command restarts Org mode for the
7432 current buffer and forces Emacs to re-evaluate the local variables section in
7433 the buffer.
7435 @c FIXME: More about header and footer styles
7436 @c FIXME: Talk about links and targets.
7438 @node Javascript support,  , CSS support, HTML export
7439 @subsection Javascript supported display of web pages
7441 @emph{Sebastian Rose} has written a JavaScript program especially designed to
7442 enhance the web viewing experience of HTML files created with Org.  This
7443 program allows to view large files in two different ways.  The first one is
7444 an @emph{Info}-like mode where each section is displayed separately and
7445 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
7446 as well, press @kbd{?} for an overview of the available keys).  The second
7447 view type is a @emph{folding} view much like Org provides it inside Emacs.
7448 The script is available at @url{http://orgmode.org/org-info.js} and you can
7449 find the documentation for it at
7450 @url{http://orgmode.org/worg/code/org-info-js/org-info.js.html}.  We are
7451 serving the script from our site, but if you use it a lot, you might not want
7452 to be dependent on @url{orgmode.org} and prefer to install a local copy on
7453 your own web server.
7455 To use the script, you need to make sure that the @file{org-jsinfo.el} module
7456 gets loaded.  It should be loaded by default, try @kbd{M-x customize-variable
7457 @key{RET} org-modules @key{RET}} to convince yourself that this is indeed the
7458 case.  All it then takes to make use of the program is adding a single line
7459 to the Org file:
7461 @example
7462 #+INFOJS_OPT: view:info toc:nil
7463 @end example
7465 @noindent
7466 If this line is found, the HTML header will automatically contain the code
7467 needed to invoke the script.  Using the line above, you can set the following
7468 viewing options:
7470 @example
7471 path:    @r{The path to the script.  The default is to grab the script from}
7472          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
7473          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
7474 view:    @r{Initial view when website is first shown.  Possible values are:}
7475          info      @r{Info-like interface with one section per page.}
7476          overview  @r{Folding interface, initially showing only top-level.}
7477          content   @r{Folding interface, starting with all headlines visible.}
7478          showall   @r{Folding interface, all headlines and text visible.}
7479 sdepth:  @r{Maximum headline level that will still become an independent}
7480          @r{section for info and folding modes.  The default is taken from}
7481          @r{@code{org-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
7482          @r{If this is smaller than in @code{org-headline-levels}, each}
7483          @r{info/folding section can still contain children headlines.}
7484 toc:     @r{Should the table of content @emph{initially} be visible?}
7485          @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
7486 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
7487          @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
7488 ftoc:    @r{Does the css of the page specify a fixed position for the toc?}
7489          @r{If yes, the toc will never be displayed as a section.}
7490 ltoc:    @r{Should there be short contents (children) in each section?}
7491 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
7492          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
7493 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
7494          @r{default), only one such button will be present.}
7495 @end example
7497 You can choose default values for these options by customizing the variable
7498 @code{org-infojs-options}.  If you always want to apply the script to your
7499 pages, configure the variable @code{org-export-html-use-infojs}.
7501 @node LaTeX export, XOXO export, HTML export, Exporting
7502 @section LaTeX export
7503 @cindex LaTeX export
7505 Org mode contains a La@TeX{} exporter written by Bastien Guerry.
7507 @menu
7508 * LaTeX export commands::       How to invoke LaTeX export
7509 * Quoting LaTeX code::          Incorporating literal LaTeX code
7510 * Sectioning structure::        Changing sectioning in LaTeX output
7511 @end menu
7513 @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
7514 @subsection LaTeX export commands
7516 @table @kbd
7517 @kindex C-c C-e l
7518 @item C-c C-e l
7519 Export as La@TeX{} file @file{myfile.tex}.  For an org file
7520 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
7521 be overwritten without warning.  If there is an active region, only the
7522 region will be exported. If the selected region is a single tree@footnote{To
7523 select the current subtree, use @kbd{C-c @@}.}, the tree head will become the
7524 document title.  If the tree head entry has or inherits an
7525 @code{EXPORT_FILE_NAME} property, that name will be used for the export.
7526 @kindex C-c C-e L
7527 @item C-c C-e L
7528 Export to a temporary buffer, do not create a file.
7529 @kindex C-c C-e v l
7530 @kindex C-c C-e v L
7531 @item C-c C-e v l
7532 @item C-c C-e v L
7533 Export only the visible part of the document.
7534 @item M-x org-export-region-as-latex
7535 Convert the region to La@TeX{} under the assumption that it was Org mode
7536 syntax before.  This is a global command that can be invoked in any
7537 buffer.
7538 @item M-x org-replace-region-by-latex
7539 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
7540 code.
7541 @end table
7543 @cindex headline levels, for exporting
7544 In the exported version, the first 3 outline levels will become
7545 headlines, defining a general document structure.  Additional levels
7546 will be exported as description lists.  The exporter can ignore them or
7547 convert them to a custom string depending on
7548 @code{org-latex-low-levels}.
7550 If you want that transition to occur at a different level, specify it
7551 with a numeric prefix argument. For example,
7553 @example
7554 @kbd{C-2 C-c C-e l}
7555 @end example
7557 @noindent
7558 creates two levels of headings and does the rest as items.
7560 @node Quoting LaTeX code, Sectioning structure, LaTeX export commands, LaTeX export
7561 @subsection Quoting LaTeX code
7563 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
7564 inserted into the La@TeX{} file.  Furthermore, you can add special code
7565 that should only be present in La@TeX{} export with the following
7566 constructs:
7568 @example
7569 #+LaTeX: Literal LaTeX code for export
7570 @end example
7572 @noindent or
7573 @cindex #+BEGIN_LaTeX
7575 @example
7576 #+BEGIN_LaTeX
7577 All lines between these markers are exported literally
7578 #+END_LaTeX
7579 @end example
7581 @node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
7582 @subsection Sectioning structure
7583 @cindex LaTeX class
7584 @cindex LaTeX sectioning structure
7586 By default, the La@TeX{} output uses the class @code{article}.
7588 You can change this globally by setting a different value for
7589 @code{org-export-latex-default-class} or locally by adding an option
7590 like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
7591 listed in @code{org-export-latex-classes}, where you can also define the
7592 sectioning structure for each class.
7595 @node XOXO export, iCalendar export, LaTeX export, Exporting
7596 @section XOXO export
7597 @cindex XOXO export
7599 Org mode contains an exporter that produces XOXO-style output.
7600 Currently, this exporter only handles the general outline structure and
7601 does not interpret any additional Org mode features.
7603 @table @kbd
7604 @kindex C-c C-e x
7605 @item C-c C-e x
7606 Export as XOXO file @file{myfile.html}.
7607 @kindex C-c C-e v
7608 @item C-c C-e v x
7609 Export only the visible part of the document.
7610 @end table
7612 @node iCalendar export,  , XOXO export, Exporting
7613 @section iCalendar export
7614 @cindex iCalendar export
7616 Some people like to use Org mode for keeping track of projects, but still
7617 prefer a standard calendar application for anniversaries and appointments.
7618 In this case it can be useful to have deadlines and other time-stamped items
7619 in Org files show up in the calendar application.  Org mode can export
7620 calendar information in the standard iCalendar format.  If you also want to
7621 have TODO entries included in the export, configure the variable
7622 @code{org-icalendar-include-todo}.  iCalendar export will export plain time
7623 stamps as VEVENT, and TODO items as VTODO.  It will also create events from
7624 deadlines that are in non-TODO items.  Deadlines and scheduling dates in TODO
7625 items will be used to set the start and due dates for the todo
7626 entry@footnote{See the variables @code{org-icalendar-use-deadline} and
7627 @code{org-icalendar-use-scheduled}.}.
7629 The iCalendar standard requires each entry to have a globally unique
7630 identifier (UID).  Org creates these identifiers during export.  If you set
7631 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
7632 @code{:ID:} property of the entry and re-used next time you report this
7633 entry.  Since a single entry can give rise to multiple iCalendar entries (as
7634 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
7635 prefixes to the UID, depending on what triggered the inclusion of the entry.
7636 In this way the UID remains unique, but a synchronization program can still
7637 figure out from which entry all the different instances originate.
7639 @table @kbd
7640 @kindex C-c C-e i
7641 @item C-c C-e i
7642 Create iCalendar entries for the current file and store them in the same
7643 directory, using a file extension @file{.ics}.
7644 @kindex C-c C-e I
7645 @item C-c C-e I
7646 Like @kbd{C-c C-e i}, but do this for all files in
7647 @code{org-agenda-files}.  For each of these files, a separate iCalendar
7648 file will be written.
7649 @kindex C-c C-e c
7650 @item C-c C-e c
7651 Create a single large iCalendar file from all files in
7652 @code{org-agenda-files} and write it to the file given by
7653 @code{org-combined-agenda-icalendar-file}.
7654 @end table
7656 The export will honor SUMMARY, DESCRIPTION and LOCATION properties if
7657 the selected entries have them.  If not, the summary will be derived
7658 from the headline, and the description from the body (limited to
7659 @code{org-icalendar-include-body} characters).
7661 How this calendar is best read and updated, that depends on the application
7662 you are using.  The FAQ covers this issue.
7664 @node Publishing, Miscellaneous, Exporting, Top
7665 @chapter Publishing
7666 @cindex publishing
7668 Org includes@footnote{@file{org-publish.el} is not distributed with
7669 Emacs 21, if you are still using Emacs 21, you need you need to download
7670 this file separately.} a publishing management system that allows you to
7671 configure automatic HTML conversion of @emph{projects} composed of
7672 interlinked org files.  This system is called @emph{org-publish}.  You can
7673 also configure org-publish to automatically upload your exported HTML
7674 pages and related attachments, such as images and source code files, to
7675 a web server. Org-publish turns Org into a web-site authoring tool.
7677 You can also use Org-publish to convert files into La@TeX{}, or even
7678 combine HTML and La@TeX{} conversion so that files are available in both
7679 formats on the server@footnote{Since La@TeX{} files on a server are not
7680 that helpful, you surely want to perform further conversion on them --
7681 e.g. convert them to @code{PDF} format.}.
7683 Org-publish has been contributed to Org by David O'Toole.
7685 @menu
7686 * Configuration::               Defining projects
7687 * Sample configuration::        Example projects
7688 * Triggering publication::      Publication commands
7689 @end menu
7691 @node Configuration, Sample configuration, Publishing, Publishing
7692 @section Configuration
7694 Publishing needs significant configuration to specify files, destination
7695 and many other properties of a project.
7697 @menu
7698 * Project alist::               The central configuration variable
7699 * Sources and destinations::    From here to there
7700 * Selecting files::             What files are part of the project?
7701 * Publishing action::           Setting the function doing the publishing
7702 * Publishing options::          Tweaking HTML export
7703 * Publishing links::            Which links keep working after publishing?
7704 * Project page index::          Publishing a list of project files
7705 @end menu
7707 @node Project alist, Sources and destinations, Configuration, Configuration
7708 @subsection The variable @code{org-publish-project-alist}
7709 @cindex org-publish-project-alist
7710 @cindex projects, for publishing
7712 Org-publish is configured almost entirely through setting the value of
7713 one variable, called @code{org-publish-project-alist}.
7714 Each element of the list configures one project, and may be in one of
7715 the two following forms:
7717 @lisp
7718 ("project-name" :property value :property value ...)
7720 @r{or}
7722 ("project-name" :components ("project-name" "project-name" ...))
7724 @end lisp
7726 In both cases, projects are configured by specifying property values.
7727 A project defines the set of files that will be published, as well as
7728 the publishing configuration to use when publishing those files.  When
7729 a project takes the second form listed above, the individual members
7730 of the ``components'' property are taken to be components of the
7731 project, which group together files requiring different publishing
7732 options. When you publish such a ``meta-project'' all the components
7733 will also publish.
7735 @node Sources and destinations, Selecting files, Project alist, Configuration
7736 @subsection Sources and destinations for files
7737 @cindex directories, for publishing
7739 Most properties are optional, but some should always be set. In
7740 particular, org-publish needs to know where to look for source files,
7741 and where to put published files.
7743 @multitable @columnfractions 0.3 0.7
7744 @item @code{:base-directory}
7745 @tab Directory containing publishing source files
7746 @item @code{:publishing-directory}
7747 @tab Directory (possibly remote) where output files will be published.
7748 @item @code{:preparation-function}
7749 @tab Function called before starting the publishing process, for example to
7750 run @code{make} for updating files to be published.
7751 @item @code{:completion-function}
7752 @tab Function called after finishing the publishing process, for example to
7753 change permissions of the resulting files.
7754 @end multitable
7755 @noindent
7757 @node Selecting files, Publishing action, Sources and destinations, Configuration
7758 @subsection Selecting files
7759 @cindex files, selecting for publishing
7761 By default, all files with extension @file{.org} in the base directory
7762 are considered part of the project.  This can be modified by setting the
7763 properties
7764 @multitable @columnfractions 0.25 0.75
7765 @item @code{:base-extension}
7766 @tab Extension (without the dot!) of source files.  This actually is a
7767 regular expression.
7769 @item @code{:exclude}
7770 @tab Regular expression to match file names that should not be
7771 published, even though they have been selected on the basis of their
7772 extension.
7774 @item @code{:include}
7775 @tab List of files to be included regardless of @code{:base-extension}
7776 and @code{:exclude}.
7777 @end multitable
7779 @node Publishing action, Publishing options, Selecting files, Configuration
7780 @subsection Publishing action
7781 @cindex action, for publishing
7783 Publishing means that a file is copied to the destination directory and
7784 possibly transformed in the process.  The default transformation is to
7785 export Org files as HTML files, and this is done by the function
7786 @code{org-publish-org-to-html} which calls the HTML exporter
7787 (@pxref{HTML export}). But you also can publish your files in La@TeX{} by
7788 using the function @code{org-publish-org-to-latex} instead. Other files
7789 like images only need to be copied to the publishing destination. For
7790 non-Org files, you need to specify the publishing function.
7793 @multitable @columnfractions 0.3 0.7
7794 @item @code{:publishing-function}
7795 @tab Function executing the publication of a file.  This may also be a
7796 list of functions, which will all be called in turn.
7797 @end multitable
7799 The function must accept two arguments: a property list containing at
7800 least a @code{:publishing-directory} property, and the name of the file
7801 to be published.  It should take the specified file, make the necessary
7802 transformation (if any) and place the result into the destination folder.
7803 You can write your own publishing function, but @code{org-publish}
7804 provides one for attachments (files that only need to be copied):
7805 @code{org-publish-attachment}.
7807 @node Publishing options, Publishing links, Publishing action, Configuration
7808 @subsection Options for the HTML/LaTeX exporters
7809 @cindex options, for publishing
7811 The property list can be used to set many export options for the HTML
7812 and La@TeX{} exporters.  In most cases, these properties correspond to user
7813 variables in Org.  The table below lists these properties along
7814 with the variable they belong to.  See the documentation string for the
7815 respective variable for details.
7817 @multitable @columnfractions 0.3 0.7
7818 @item @code{:language}              @tab @code{org-export-default-language}
7819 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
7820 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
7821 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
7822 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
7823 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
7824 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
7825 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
7826 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
7827 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
7828 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
7829 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
7830 @item @code{:author-info}           @tab @code{org-export-author-info}
7831 @item @code{:creator-info}          @tab @code{org-export-creator-info}
7832 @item @code{:tags}                  @tab @code{org-export-with-tags}
7833 @item @code{:tables}                @tab @code{org-export-with-tables}
7834 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
7835 @item @code{:style}                 @tab @code{org-export-html-style}
7836 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
7837 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
7838 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
7839 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
7840 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
7841 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
7842 @item @code{:preamble}              @tab @code{org-export-html-preamble}
7843 @item @code{:postamble}             @tab @code{org-export-html-postamble}
7844 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
7845 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
7846 @item @code{:author}                @tab @code{user-full-name}
7847 @item @code{:email}                 @tab @code{user-mail-address}
7848 @end multitable
7850 If you use several email addresses, separate them by a semi-column.
7852 Most of the @code{org-export-with-*} variables have the same effect in
7853 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
7854 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
7855 La@TeX{} export.
7857 When a property is given a value in @code{org-publish-project-alist},
7858 its setting overrides the value of the corresponding user variable (if
7859 any) during publishing.  Options set within a file (@pxref{Export
7860 options}), however, override everything.
7862 @node Publishing links, Project page index, Publishing options, Configuration
7863 @subsection Links between published files
7864 @cindex links, publishing
7866 To create a link from one Org file to another, you would use
7867 something like @samp{[[file:foo.org][The foo]]} or simply
7868 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
7869 becomes a link to @file{foo.html}.  In this way, you can interlink the
7870 pages of your "org web" project and the links will work as expected when
7871 you publish them to HTML.
7873 You may also link to related files, such as images. Provided you are
7874 careful with relative pathnames, and provided you have also configured
7875 @code{org-publish} to upload the related files, these links will work
7876 too. @ref{Complex example} for an example of this usage.
7878 Sometime an Org file to be published may contain links that are
7879 only valid in your production environment, but not in the publishing
7880 location.  In this case, use the property
7882 @multitable @columnfractions 0.4 0.6
7883 @item @code{:link-validation-function}
7884 @tab Function to validate links
7885 @end multitable
7887 @noindent
7888 to define a function for checking link validity.  This function must
7889 accept two arguments, the file name and a directory relative to which
7890 the file name is interpreted in the production environment.  If this
7891 function returns @code{nil}, then the HTML generator will only insert a
7892 description into the HTML file, but no link.  One option for this
7893 function is @code{org-publish-validate-link} which checks if the given
7894 file is part of any project in @code{org-publish-project-alist}.
7896 @node Project page index,  , Publishing links, Configuration
7897 @subsection Project page index
7898 @cindex index, of published pages
7900 The following properties may be used to control publishing of an
7901 index of files or summary page for a given project.
7903 @multitable @columnfractions 0.25 0.75
7904 @item @code{:auto-index}
7905 @tab When non-nil, publish an index during org-publish-current-project or
7906 org-publish-all.
7908 @item @code{:index-filename}
7909 @tab Filename for output of index. Defaults to @file{index.org} (which
7910 becomes @file{index.html}).
7912 @item @code{:index-title}
7913 @tab Title of index page. Defaults to name of file.
7915 @item @code{:index-function}
7916 @tab Plug-in function to use for generation of index.
7917 Defaults to @code{org-publish-org-index}, which generates a plain list
7918 of links to all files in the project.
7919 @end multitable
7921 @node Sample configuration, Triggering publication, Configuration, Publishing
7922 @section Sample configuration
7924 Below we provide two example configurations.  The first one is a simple
7925 project publishing only a set of Org files.  The second example is
7926 more complex, with a multi-component project.
7928 @menu
7929 * Simple example::              One-component publishing
7930 * Complex example::             A multi-component publishing example
7931 @end menu
7933 @node Simple example, Complex example, Sample configuration, Sample configuration
7934 @subsection Example: simple publishing configuration
7936 This example publishes a set of Org files to the @file{public_html}
7937 directory on the local machine.
7939 @lisp
7940 (setq org-publish-project-alist
7941       '(("org"
7942          :base-directory "~/org/"
7943          :publishing-directory "~/public_html"
7944          :section-numbers nil
7945          :table-of-contents nil
7946          :style "<link rel=stylesheet
7947                 href=\"../other/mystyle.css\"
7948                 type=\"text/css\">")))
7949 @end lisp
7951 @node Complex example,  , Simple example, Sample configuration
7952 @subsection Example: complex publishing configuration
7954 This more complicated example publishes an entire website, including
7955 org files converted to HTML, image files, emacs lisp source code, and
7956 style sheets. The publishing-directory is remote and private files are
7957 excluded.
7959 To ensure that links are preserved, care should be taken to replicate
7960 your directory structure on the web server, and to use relative file
7961 paths. For example, if your org files are kept in @file{~/org} and your
7962 publishable images in @file{~/images}, you'd link to an image with
7964 @example
7965 file:../images/myimage.png
7966 @end example
7968 On the web server, the relative path to the image should be the
7969 same. You can accomplish this by setting up an "images" folder in the
7970 right place on the web server, and publishing images to it.
7972 @lisp
7973 (setq org-publish-project-alist
7974       '(("orgfiles"
7975           :base-directory "~/org/"
7976           :base-extension "org"
7977           :publishing-directory "/ssh:user@@host:~/html/notebook/"
7978           :publishing-function org-publish-org-to-html
7979           :exclude "PrivatePage.org"   ;; regexp
7980           :headline-levels 3
7981           :section-numbers nil
7982           :table-of-contents nil
7983           :style "<link rel=stylesheet
7984                   href=\"../other/mystyle.css\" type=\"text/css\">"
7985           :auto-preamble t
7986           :auto-postamble nil)
7988          ("images"
7989           :base-directory "~/images/"
7990           :base-extension "jpg\\|gif\\|png"
7991           :publishing-directory "/ssh:user@@host:~/html/images/"
7992           :publishing-function org-publish-attachment)
7994          ("other"
7995           :base-directory "~/other/"
7996           :base-extension "css\\|el"
7997           :publishing-directory "/ssh:user@@host:~/html/other/"
7998           :publishing-function org-publish-attachment)
7999          ("website" :components ("orgfiles" "images" "other"))))
8000 @end lisp
8002 @node Triggering publication,  , Sample configuration, Publishing
8003 @section Triggering publication
8005 Once org-publish is properly configured, you can publish with the
8006 following functions:
8008 @table @kbd
8009 @item C-c C-e C
8010 Prompt for a specific project and publish all files that belong to it.
8011 @item C-c C-e P
8012 Publish the project containing the current file.
8013 @item C-c C-e F
8014 Publish only the current file.
8015 @item C-c C-e A
8016 Publish all projects.
8017 @end table
8019 Org uses timestamps to track when a file has changed. The above
8020 functions normally only publish changed files. You can override this and
8021 force publishing of all files by giving a prefix argument.
8023 @node Miscellaneous, Extensions, Publishing, Top
8024 @chapter Miscellaneous
8026 @menu
8027 * Completion::                  M-TAB knows what you need
8028 * Customization::               Adapting Org to your taste
8029 * In-buffer settings::          Overview of the #+KEYWORDS
8030 * The very busy C-c C-c key::   When in doubt, press C-c C-c
8031 * Clean view::                  Getting rid of leading stars in the outline
8032 * TTY keys::                    Using Org on a tty
8033 * Interaction::                 Other Emacs packages
8034 * Bugs::                        Things which do not work perfectly
8035 @end menu
8037 @node Completion, Customization, Miscellaneous, Miscellaneous
8038 @section Completion
8039 @cindex completion, of @TeX{} symbols
8040 @cindex completion, of TODO keywords
8041 @cindex completion, of dictionary words
8042 @cindex completion, of option keywords
8043 @cindex completion, of tags
8044 @cindex completion, of property keys
8045 @cindex completion, of link abbreviations
8046 @cindex @TeX{} symbol completion
8047 @cindex TODO keywords completion
8048 @cindex dictionary word completion
8049 @cindex option keyword completion
8050 @cindex tag completion
8051 @cindex link abbreviations, completion of
8053 Org supports in-buffer completion.  This type of completion does
8054 not make use of the minibuffer.  You simply type a few letters into
8055 the buffer and use the key to complete text right there.
8057 @table @kbd
8058 @kindex M-@key{TAB}
8059 @item M-@key{TAB}
8060 Complete word at point
8061 @itemize @bullet
8062 @item
8063 At the beginning of a headline, complete TODO keywords.
8064 @item
8065 After @samp{\}, complete @TeX{} symbols supported by the exporter.
8066 @item
8067 After @samp{*}, complete headlines in the current buffer so that they
8068 can be used in search links like @samp{[[*find this headline]]}.
8069 @item
8070 After @samp{:} in a headline, complete tags.  The list of tags is taken
8071 from the variable @code{org-tag-alist} (possibly set through the
8072 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
8073 dynamically from all tags used in the current buffer.
8074 @item
8075 After @samp{:} and not in a headline, complete property keys.  The list
8076 of keys is constructed dynamically from all keys used in the current
8077 buffer.
8078 @item
8079 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
8080 @item
8081 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
8082 @samp{OPTIONS} which set file-specific options for Org mode.  When the
8083 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
8084 will insert example settings for this keyword.
8085 @item
8086 In the line after @samp{#+STARTUP: }, complete startup keywords,
8087 i.e. valid keys for this line.
8088 @item
8089 Elsewhere, complete dictionary words using Ispell.
8090 @end itemize
8091 @end table
8093 @node Customization, In-buffer settings, Completion, Miscellaneous
8094 @section Customization
8095 @cindex customization
8096 @cindex options, for customization
8097 @cindex variables, for customization
8099 There are more than 180 variables that can be used to customize
8100 Org.  For the sake of compactness of the manual, I am not
8101 describing the variables here.  A structured overview of customization
8102 variables is available with @kbd{M-x org-customize}.  Or select
8103 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
8104 settings can also be activated on a per-file basis, by putting special
8105 lines into the buffer (@pxref{In-buffer settings}).
8107 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
8108 @section Summary of in-buffer settings
8109 @cindex in-buffer settings
8110 @cindex special keywords
8112 Org mode uses special lines in the buffer to define settings on a
8113 per-file basis.  These lines start with a @samp{#+} followed by a
8114 keyword, a colon, and then individual words defining a setting.  Several
8115 setting words can be in the same line, but you can also have multiple
8116 lines for the keyword.  While these settings are described throughout
8117 the manual, here is a summary.  After changing any of those lines in the
8118 buffer, press @kbd{C-c C-c} with the cursor still in the line to
8119 activate the changes immediately.  Otherwise they become effective only
8120 when the file is visited again in a new Emacs session.
8122 @table @kbd
8123 @item #+ARCHIVE: %s_done::
8124 This line sets the archive location for the agenda file.  It applies for
8125 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
8126 of the file.  The first such line also applies to any entries before it.
8127 The corresponding variable is @code{org-archive-location}.
8128 @item #+CATEGORY:
8129 This line sets the category for the agenda file.  The category applies
8130 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
8131 end of the file.  The first such line also applies to any entries before it.
8132 @item #+COLUMNS: %25ITEM .....
8133 Set the default format for columns view.  This format applies when
8134 columns view is invoked in location where no @code{COLUMNS} property
8135 applies.
8136 @item #+CONSTANTS: name1=value1 ...
8137 Set file-local values for constants to be used in table formulas.  This
8138 line set the local variable @code{org-table-formula-constants-local}.
8139 The global version of this variable is
8140 @code{org-table-formula-constants}.
8141 @item #+FILETAGS: :tag1:tag2:tag3:
8142 Set tags that can be inherited by any entry in the file, including the
8143 top-level entries.
8144 @item #+DRAWERS: NAME1 .....
8145 Set the file-local set of drawers.  The corresponding global variable is
8146 @code{org-drawers}.
8147 @item #+LINK:  linkword replace
8148 These lines (several are allowed) specify link abbreviations.
8149 @xref{Link abbreviations}.  The corresponding variable is
8150 @code{org-link-abbrev-alist}.
8151 @item #+PRIORITIES: highest lowest default
8152 This line sets the limits and the default for the priorities.  All three
8153 must be either letters A-Z or numbers 0-9.  The highest priority must
8154 have a lower ASCII number that the lowest priority.
8155 @item #+PROPERTY: Property_Name Value
8156 This line sets a default inheritance value for entries in the current
8157 buffer, most useful for specifying the allowed values of a property.
8158 @item #+SETUPFILE: file
8159 This line defines a file that holds more in-buffer setup.  Normally this is
8160 entirely ignored.  Only when the buffer is parsed for option-setting lines
8161 (i.e. when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
8162 settings line, or when exporting), then the contents of this file are parsed
8163 as if they had been included in the buffer.  In particlar, the file can be
8164 any other Org mode file with internal setup.  You can visit the file the
8165 cursor is in the line with @kbd{C-c '}.
8166 @item #+STARTUP:
8167 This line sets options to be used at startup of Org mode, when an
8168 Org file is being visited.  The first set of options deals with the
8169 initial visibility of the outline tree.  The corresponding variable for
8170 global default settings is @code{org-startup-folded}, with a default
8171 value @code{t}, which means @code{overview}.
8172 @cindex @code{overview}, STARTUP keyword
8173 @cindex @code{content}, STARTUP keyword
8174 @cindex @code{showall}, STARTUP keyword
8175 @example
8176 overview   @r{top-level headlines only}
8177 content    @r{all headlines}
8178 showall    @r{no folding at all, show everything}
8179 @end example
8180 Then there are options for aligning tables upon visiting a file.  This
8181 is useful in files containing narrowed table columns.  The corresponding
8182 variable is @code{org-startup-align-all-tables}, with a default value
8183 @code{nil}.
8184 @cindex @code{align}, STARTUP keyword
8185 @cindex @code{noalign}, STARTUP keyword
8186 @example
8187 align      @r{align all tables}
8188 noalign    @r{don't align tables on startup}
8189 @end example
8190 Logging closing and reinstating TODO items, and clock intervals
8191 (variables @code{org-log-done}, @code{org-log-note-clock-out}, and
8192 @code{org-log-repeat}) can be configured using these options.
8193 @cindex @code{logdone}, STARTUP keyword
8194 @cindex @code{lognotedone}, STARTUP keyword
8195 @cindex @code{nologdone}, STARTUP keyword
8196 @cindex @code{lognoteclock-out}, STARTUP keyword
8197 @cindex @code{nolognoteclock-out}, STARTUP keyword
8198 @cindex @code{logrepeat}, STARTUP keyword
8199 @cindex @code{lognoterepeat}, STARTUP keyword
8200 @cindex @code{nologrepeat}, STARTUP keyword
8201 @example
8202 logdone            @r{record a timestamp when an item is marked DONE}
8203 lognotedone        @r{record timestamp and a note when DONE}
8204 nologdone          @r{don't record when items are marked DONE}
8205 logrepeat          @r{record a time when reinstating a repeating item}
8206 lognoterepeat      @r{record a note when reinstating a repeating item}
8207 nologrepeat        @r{do not record when reinstating repeating item}
8208 lognoteclock-out   @r{record a note when clocking out}
8209 nolognoteclock-out @r{don't record a note when clocking out}
8210 @end example
8211 Here are the options for hiding leading stars in outline headings, and for
8212 indenting outlines.  The corresponding variables are
8213 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
8214 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
8215 @cindex @code{hidestars}, STARTUP keyword
8216 @cindex @code{showstars}, STARTUP keyword
8217 @cindex @code{odd}, STARTUP keyword
8218 @cindex @code{even}, STARTUP keyword
8219 @example
8220 hidestars  @r{make all but one of the stars starting a headline invisible.}
8221 showstars  @r{show all stars starting a headline}
8222 indent     @r{virtual indentation according to outline level}
8223 noindent   @r{no virtual indentation according to outline level}
8224 odd        @r{allow only odd outline levels (1,3,...)}
8225 oddeven    @r{allow all outline levels}
8226 @end example
8227 To turn on custom format overlays over time stamps (variables
8228 @code{org-put-time-stamp-overlays} and
8229 @code{org-time-stamp-overlay-formats}), use
8230 @cindex @code{customtime}, STARTUP keyword
8231 @example
8232 customtime @r{overlay custom time format}
8233 @end example
8234 The following options influence the table spreadsheet (variable
8235 @code{constants-unit-system}).
8236 @cindex @code{constcgs}, STARTUP keyword
8237 @cindex @code{constSI}, STARTUP keyword
8238 @example
8239 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
8240 constSI    @r{@file{constants.el} should use the SI unit system}
8241 @end example
8242 @item #+TAGS:  TAG1(c1) TAG2(c2)
8243 These lines (several such lines are allowed) specify the valid tags in
8244 this file, and (potentially) the corresponding @emph{fast tag selection}
8245 keys.  The corresponding variable is @code{org-tag-alist}.
8246 @item #+TBLFM:
8247 This line contains the formulas for the table directly above the line.
8248 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
8249 These lines provide settings for exporting files.  For more details see
8250 @ref{Export options}.
8251 @item #+SEQ_TODO:   #+TYP_TODO:
8252 These lines set the TODO keywords and their interpretation in the
8253 current file.  The corresponding variables are @code{org-todo-keywords}
8254 and @code{org-todo-interpretation}.
8255 @end table
8257 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
8258 @section The very busy C-c C-c key
8259 @kindex C-c C-c
8260 @cindex C-c C-c, overview
8262 The key @kbd{C-c C-c} has many purposes in Org, which are all
8263 mentioned scattered throughout this manual.  One specific function of
8264 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
8265 other circumstances it means something like @emph{Hey Org, look
8266 here and update according to what you see here}.  Here is a summary of
8267 what this means in different contexts.
8269 @itemize @minus
8270 @item
8271 If there are highlights in the buffer from the creation of a sparse
8272 tree, or from clock display, remove these highlights.
8273 @item
8274 If the cursor is in one of the special @code{#+KEYWORD} lines, this
8275 triggers scanning the buffer for these lines and updating the
8276 information.
8277 @item
8278 If the cursor is inside a table, realign the table.  This command
8279 works even if the automatic table editor has been turned off.
8280 @item
8281 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
8282 the entire table.
8283 @item
8284 If the cursor is inside a table created by the @file{table.el} package,
8285 activate that table.
8286 @item
8287 If the current buffer is a remember buffer, close the note and file it.
8288 With a prefix argument, file it, without further interaction, to the
8289 default location.
8290 @item
8291 If the cursor is on a @code{<<<target>>>}, update radio targets and
8292 corresponding links in this buffer.
8293 @item
8294 If the cursor is in a property line or at the start or end of a property
8295 drawer, offer property commands.
8296 @item
8297 If the cursor is in a plain list item with a checkbox, toggle the status
8298 of the checkbox.
8299 @item
8300 If the cursor is on a numbered item in a plain list, renumber the
8301 ordered list.
8302 @item
8303 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
8304 block is updated.
8305 @end itemize
8307 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
8308 @section A cleaner outline view
8309 @cindex hiding leading stars
8310 @cindex dynamic indentation
8311 @cindex odd-levels-only outlines
8312 @cindex clean outline view
8314 Some people find it noisy and distracting that the Org headlines are starting
8315 with a potentially large number of stars, and that text below the headlines
8316 is not indented.  This is not really a problem when you are writing a book
8317 where the outline headings are really section headlines.  However, in a more
8318 list-oriented outline, it is clear that an indented structure is a lot
8319 cleaner, as can be seen by comparing the two columns in the following
8320 example: 
8322 @example
8323 @group
8324 * Top level headline             |    * Top level headline
8325 ** Second level                  |      * Second level
8326 *** 3rd level                    |        * 3rd level
8327 some text                        |          some text
8328 *** 3rd level                    |        * 3rd level
8329 more text                        |          more text
8330 * Another top level headline     |    * Another top level headline
8331 @end group
8332 @end example
8334 @noindent
8335 It is non-trivial to make such a look work in Emacs, but Org contains three
8336 separate features that, combined, achieve just that.
8338 @enumerate
8339 @item 
8340 @emph{Indentation of text below headlines}@*
8341 You may indent text below each headline to make the left boundary line up
8342 with the headline, like
8344 @example
8345 *** 3rd level
8346     more text, now indented
8347 @end example
8349 A good way to get this indentation is by hand, and Org supports this with
8350 paragraph filling, line wrapping, and structure editing@footnote{See also the
8351 variable @code{org-adapt-indentation}.} preserving or adapting the
8352 indentation appropriate.  A different approach would be to have a way to
8353 automatically indent lines according to outline structure by adding overlays
8354 or text properties.  But I have not yet found a robust and efficient way to
8355 do this in large files.
8357 @item
8358 @emph{Hiding leading stars}@* You can modify the display in such a way that
8359 all leading stars become invisible.  To do this in a global way, configure
8360 the variable @code{org-hide-leading-stars} or change this on a per-file basis
8361 with
8363 @example
8364 #+STARTUP: hidestars
8365 @end example
8367 @noindent
8368 Note that the opposite behavior is selected with @code{showstars}.
8370 With hidden stars, the tree becomes:
8372 @example
8373 @group
8374 * Top level headline
8375  * Second level
8376   * 3rd level
8377   ...
8378 @end group
8379 @end example
8381 @noindent
8382 Note that the leading stars are not truly replaced by whitespace, they
8383 are only fontified with the face @code{org-hide} that uses the
8384 background color as font color.  If you are not using either white or
8385 black background, you may have to customize this face to get the wanted
8386 effect.  Another possibility is to set this font such that the extra
8387 stars are @i{almost} invisible, for example using the color
8388 @code{grey90} on a white background.
8390 @item
8391 Things become cleaner still if you skip all the even levels and use only odd
8392 levels 1, 3, 5..., effectively adding two stars to go from one outline level
8393 to the next.  In this way we get the outline view shown at the beginning of
8394 this section.  In order to make the structure editing and export commands
8395 handle this convention correctly, configure the variable
8396 @code{org-odd-levels-only}, or set this on a per-file basis with one of the
8397 following lines:
8399 @example
8400 #+STARTUP: odd
8401 #+STARTUP: oddeven
8402 @end example
8404 You can convert an Org file from single-star-per-level to the
8405 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
8406 RET} in that file.  The reverse operation is @kbd{M-x
8407 org-convert-to-oddeven-levels}.
8408 @end enumerate
8410 @node TTY keys, Interaction, Clean view, Miscellaneous
8411 @section Using Org on a tty
8412 @cindex tty key bindings
8414 Because Org contains a large number of commands, by default much of
8415 Org's core commands are bound to keys that are generally not
8416 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
8417 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
8418 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
8419 these commands on a tty when special keys are unavailable, the following
8420 alternative bindings can be used.  The tty bindings below will likely be
8421 more cumbersome; you may find for some of the bindings below that a
8422 customized work-around suits you better.  For example, changing a time
8423 stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
8424 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
8426 @multitable @columnfractions 0.15 0.2 0.2
8427 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
8428 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
8429 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
8430 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
8431 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
8432 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
8433 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
8434 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
8435 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
8436 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
8437 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
8438 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
8439 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
8440 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
8441 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
8442 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
8443 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
8444 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
8445 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
8446 @end multitable
8448 @node Interaction, Bugs, TTY keys, Miscellaneous
8449 @section Interaction with other packages
8450 @cindex packages, interaction with other
8451 Org lives in the world of GNU Emacs and interacts in various ways
8452 with other code out there.
8454 @menu
8455 * Cooperation::                 Packages Org cooperates with
8456 * Conflicts::                   Packages that lead to conflicts
8457 @end menu
8459 @node Cooperation, Conflicts, Interaction, Interaction
8460 @subsection Packages that Org cooperates with
8462 @table @asis
8463 @cindex @file{calc.el}
8464 @item @file{calc.el} by Dave Gillespie
8465 Org uses the Calc package for implementing spreadsheet
8466 functionality in its tables (@pxref{The spreadsheet}).  Org
8467 checks for the availability of Calc by looking for the function
8468 @code{calc-eval} which should be autoloaded in your setup if Calc has
8469 been installed properly.  As of Emacs 22, Calc is part of the Emacs
8470 distribution.  Another possibility for interaction between the two
8471 packages is using Calc for embedded calculations. @xref{Embedded Mode,
8472 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
8473 @cindex @file{constants.el}
8474 @item @file{constants.el} by Carsten Dominik
8475 In a table formula (@pxref{The spreadsheet}), it is possible to use
8476 names for natural constants or units.  Instead of defining your own
8477 constants in the variable @code{org-table-formula-constants}, install
8478 the @file{constants} package which defines a large number of constants
8479 and units, and lets you use unit prefixes like @samp{M} for
8480 @samp{Mega} etc.  You will need version 2.0 of this package, available
8481 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
8482 the function @code{constants-get}, which has to be autoloaded in your
8483 setup.  See the installation instructions in the file
8484 @file{constants.el}.
8485 @item @file{cdlatex.el} by Carsten Dominik
8486 @cindex @file{cdlatex.el}
8487 Org mode can make use of the CDLaTeX package to efficiently enter
8488 La@TeX{} fragments into Org files. See @ref{CDLaTeX mode}.
8489 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
8490 @cindex @file{imenu.el}
8491 Imenu allows menu access to an index of items in a file.  Org mode
8492 supports Imenu - all you need to do to get the index is the following:
8493 @lisp
8494 (add-hook 'org-mode-hook
8495           (lambda () (imenu-add-to-menubar "Imenu")))
8496 @end lisp
8497 By default the index is two levels deep - you can modify the depth using
8498 the option @code{org-imenu-depth}.
8499 @item @file{remember.el} by John Wiegley
8500 @cindex @file{remember.el}
8501 Org cooperates with remember, see @ref{Remember}.
8502 @file{Remember.el} is not part of Emacs, find it on the web.
8503 @item @file{speedbar.el} by Eric M. Ludlam
8504 @cindex @file{speedbar.el}
8505 Speedbar is a package that creates a special frame displaying files and
8506 index items in files.  Org mode supports Speedbar and allows you to
8507 drill into Org files directly from the Speedbar.  It also allows to
8508 restrict the scope of agenda commands to a file or a subtree by using
8509 the command @kbd{<} in the Speedbar frame.
8510 @cindex @file{table.el}
8511 @item @file{table.el} by Takaaki Ota
8512 @kindex C-c C-c
8513 @cindex table editor, @file{table.el}
8514 @cindex @file{table.el}
8516 Complex ASCII tables with automatic line wrapping, column- and
8517 row-spanning, and alignment can be created using the Emacs table
8518 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
8519 and also part of Emacs 22).
8520 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
8521 will call @command{table-recognize-table} and move the cursor into the
8522 table.  Inside a table, the keymap of Org mode is inactive.  In order
8523 to execute Org mode-related commands, leave the table.
8525 @table @kbd
8526 @kindex C-c C-c
8527 @item C-c C-c
8528 Recognize @file{table.el} table.  Works when the cursor is in a
8529 table.el table.
8531 @kindex C-c ~
8532 @item C-c ~
8533 Insert a table.el table.  If there is already a table at point, this
8534 command converts it between the table.el format and the Org mode
8535 format.  See the documentation string of the command
8536 @code{org-convert-table} for the restrictions under which this is
8537 possible.
8538 @end table
8539 @file{table.el} is part of Emacs 22.
8540 @cindex @file{footnote.el}
8541 @item @file{footnote.el} by Steven L. Baur
8542 Org mode recognizes numerical footnotes as provided by this package
8543 (@pxref{Footnotes}).
8544 @end table
8546 @node Conflicts,  , Cooperation, Interaction
8547 @subsection Packages that lead to conflicts with Org mode
8549 @table @asis
8551 @cindex @file{allout.el}
8552 @item @file{allout.el} by Ken Manheimer
8553 Startup of Org may fail with the error message
8554 @code{(wrong-type-argument keymapp nil)} when there is an outdated
8555 version @file{allout.el} on the load path, for example the version
8556 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
8557 disappear.  If for some reason you cannot do this, make sure that org.el
8558 is loaded @emph{before} @file{allout.el}, for example by putting
8559 @code{(require 'org)} early enough into your @file{.emacs} file.
8561 @cindex @file{CUA.el}
8562 @item @file{CUA.el} by Kim. F. Storm
8563 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by
8564 CUA mode (as well as pc-select-mode and s-region-mode) to select and
8565 extend the region.  If you want to use one of these packages along with
8566 Org, configure the variable @code{org-replace-disputed-keys}.  When
8567 set, Org will move the following key bindings in Org files, and
8568 in the agenda buffer (but not during date selection).
8570 @example
8571 S-UP    -> M-p             S-DOWN  -> M-n
8572 S-LEFT  -> M--             S-RIGHT -> M-+
8573 @end example
8575 Yes, these are unfortunately more difficult to remember.  If you want
8576 to have other replacement keys, look at the variable
8577 @code{org-disputed-keys}.
8578 @item @file{windmove.el} by Hovav Shacham
8579 @cindex @file{windmove.el}
8580 Also this package uses the @kbd{S-<cursor>} keys, so everything written
8581 in the paragraph above about CUA mode also applies here.
8583 @cindex @file{footnote.el}
8584 @item @file{footnote.el} by Steven L. Baur
8585 Org supports the syntax of the footnote package, but only the
8586 numerical footnote markers.  Also, the default key for footnote
8587 commands, @kbd{C-c !} is already used by Org.  You could use the
8588 variable @code{footnote-prefix} to switch footnotes commands to another
8589 key.  Or, you could use @code{org-replace-disputed-keys} and
8590 @code{org-disputed-keys} to change the settings in Org.
8592 @end table
8595 @node Bugs,  , Interaction, Miscellaneous
8596 @section Bugs
8597 @cindex bugs
8599 Here is a list of things that should work differently, but which I
8600 have found too hard to fix.
8602 @itemize @bullet
8603 @item
8604 If a table field starts with a link, and if the corresponding table
8605 column is narrowed (@pxref{Narrow columns}) to a width too small to
8606 display the link, the field would look entirely empty even though it is
8607 not.  To prevent this, Org throws an error.  The work-around is to
8608 make the column wide enough to fit the link, or to add some text (at
8609 least 2 characters) before the link in the same field.
8610 @item
8611 Narrowing table columns does not work on XEmacs, because the
8612 @code{format} function does not transport text properties.
8613 @item
8614 Text in an entry protected with the @samp{QUOTE} keyword should not
8615 autowrap.
8616 @item
8617 When the application called by @kbd{C-c C-o} to open a file link fails
8618 (for example because the application does not exist or refuses to open
8619 the file), it does so silently.  No error message is displayed.
8620 @item
8621 Recalculating a table line applies the formulas from left to right.
8622 If a formula uses @emph{calculated} fields further down the row,
8623 multiple recalculation may be needed to get all fields consistent.  You
8624 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
8625 recalculate until convergence.
8626 @item
8627 The exporters work well, but could be made more efficient.
8628 @end itemize
8631 @node Extensions, Hacking, Miscellaneous, Top
8632 @appendix Extensions
8634 This appendix lists the extension modules that have been written for Org.
8635 Many of these extensions live in the @file{contrib} directory of the Org
8636 distribution, others are available somewhere on the web.
8638 @menu
8639 * Extensions in the contrib directory::  These come with the Org distro
8640 * Other extensions::            These you have to find on the web.
8641 @end menu
8643 @node Extensions in the contrib directory, Other extensions, Extensions, Extensions
8644 @section Extensions in the @file{contrib} directory
8646 @table @asis
8647 @item @file{org-annotate-file.el} by @i{Philip Jackson}
8648       Annotate a file with org syntax, in a separate file, with links back to
8649       the annotated file.
8650 @item @file{org-annotation-helper.el} by @i{Bastien Guerry and Daniel E. German} 
8651       Call @i{remember} directly from Firefox/Opera, or from Adobe Reader.
8652       When activating a special link or bookmark, Emacs receives a trigger to
8653       create a note with a link back to the website.  Requires some setup, a
8654       detailes description is in
8655       @file{contrib/packages/org-annotation-helper}.
8656 @item @file{org-bookmark.el} by @i{Tokuya Kameshima}
8657       Support for links to Emacs bookmarks.
8658 @item @file{org-depend.el} by @i{Carsten Dominik}
8659       TODO dependencies for Org-mode.  Make TODO state changes in one entry
8660       trigger changes in another, or be blocked by the state of another
8661       entry.  Also, easily create chains of TODO items with exactly one
8662       active item at any time.
8663 @item @file{org-elisp-symbol.el} by @i{Bastien Guerry}
8664       Org links to emacs-lisp symbols.  This can create annotated links that
8665       exactly point to the definition location of a variable of function.
8666 @item @file{org-eval.el} by @i{Carsten Dominik}
8667       The @code{<lisp>} tag, adapted from Emacs Wiki and Emacs Muse, allows
8668       to include text in a document that is the result of evaluating some
8669       code.  Other scripting languages like @code{perl} can be supported with
8670       this package as well.
8671 @item @file{org-expiry.el} by @i{Bastien Guerry}
8672       Expiry mechanism for Org entries.
8673 @item @file{org-indent.el} by @i{Carsten Dominik}
8674       Dynamic indentation of Org outlines.  The plan is to indent an outline
8675       according to level, but so far this is too hard for a proper and stable
8676       implementation.  Still, it works somewhat.
8677 @item @file{org-interactive-query.el} by @i{Christopher League}
8678       Interactive modification of tags queries.  After running a general
8679       query in Org, this package allows to narrow down the results by adding
8680       more tags or keywords.
8681 @item @file{org-mairix.el} by @i{Georg C. F. Greve}
8682       Hook mairix search into Org for different MUAs.
8683 @item @file{org-man.el} by @i{Carsten Dominik}
8684       Support for links to manpages in Org-mode.
8685 @item @file{org-mtags.el} by @i{Carsten Dominik}
8686       Support for some Muse-like tags in Org-mode.  This package allows you
8687       to write @code{<example>} and @code{<src>} and other syntax copied from
8688       Emacs Muse, right inside an Org file.  The goal here is to make it easy
8689       to publish the same file using either org-publish or Muse.
8690 @item @file{org-panel.el} by @i{Lennard Borgman}
8691       Simplified and display-aided access to some Org commands.
8692 @item @file{org-registry.el} by @i{Bastien Guerry}
8693       A registry for Org links, to find out from where links point to a given
8694       file or location.
8695 @item @file{org2rem.el} by @i{Bastien Guerry}
8696       Convert org appointments into reminders for the @file{remind} program.
8697 @item @file{org-screen.el} by @i{Andrew Hyatt}
8698       Visit screen sessions through Org-mode links.
8699 @item @file{org-toc.el} by @i{Bastien Guerry}
8700       Table of contents in a separate buffer, with fast access to sections
8701       and easy visibility cycling.
8702 @item @file{orgtbl-sqlinsert.el} by @i{Jason Riedy}
8703       Convert Org-mode tables to SQL insertions.  Documentation for this can
8704       be found on the Worg pages.
8705 @end table
8708 @node Other extensions,  , Extensions in the contrib directory, Extensions
8709 @section Other extensions
8711 @i{TO BE DONE}
8713 @node Hacking, History and Acknowledgments, Extensions, Top
8714 @appendix Hacking
8716 This appendix covers some aspects where users can extend the functionality of
8717 Org.
8719 @menu
8720 * Adding hyperlink types::      New custom link types
8721 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
8722 * Dynamic blocks::              Automatically filled blocks
8723 * Special agenda views::        Customized views
8724 * Using the property API::      Writing programs that use entry properties
8725 * Using the mapping API::       Mapping over all or selected entries
8726 @end menu
8728 @node Adding hyperlink types, Tables in arbitrary syntax, Hacking, Hacking
8729 @section Adding hyperlink types
8730 @cindex hyperlinks, adding new types
8732 Org has a large number of hyperlink types built-in
8733 (@pxref{Hyperlinks}).  If you would like to add new link types, it
8734 provides an interface for doing so.  Lets look at an example file
8735 @file{org-man.el} that will add support for creating links like
8736 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
8737 emacs:
8739 @lisp
8740 ;;; org-man.el - Support for links to manpages in Org
8742 (require 'org)
8744 (org-add-link-type "man" 'org-man-open)
8745 (add-hook 'org-store-link-functions 'org-man-store-link)
8747 (defcustom org-man-command 'man
8748   "The Emacs command to be used to display a man page."
8749   :group 'org-link
8750   :type '(choice (const man) (const woman)))
8752 (defun org-man-open (path)
8753   "Visit the manpage on PATH.
8754 PATH should be a topic that can be thrown at the man command."
8755   (funcall org-man-command path))
8757 (defun org-man-store-link ()
8758   "Store a link to a manpage."
8759   (when (memq major-mode '(Man-mode woman-mode))
8760     ;; This is a man page, we do make this link
8761     (let* ((page (org-man-get-page-name))
8762            (link (concat "man:" page))
8763            (description (format "Manpage for %s" page)))
8764       (org-store-link-props
8765        :type "man"
8766        :link link
8767        :description description))))
8769 (defun org-man-get-page-name ()
8770   "Extract the page name from the buffer name."
8771   ;; This works for both `Man-mode' and `woman-mode'.
8772   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
8773       (match-string 1 (buffer-name))
8774     (error "Cannot create link to this man page")))
8776 (provide 'org-man)
8778 ;;; org-man.el ends here
8779 @end lisp
8781 @noindent
8782 You would activate this new link type in @file{.emacs} with
8784 @lisp
8785 (require 'org-man)
8786 @end lisp
8788 @noindent
8789 Lets go through the file and see what it does.
8790 @enumerate
8791 @item
8792 It does @code{(require 'org)} to make sure that @file{org.el} has been
8793 loaded.
8794 @item
8795 The next line calls @code{org-add-link-type} to define a new link type
8796 with prefix @samp{man}.  The call also contains the name of a function
8797 that will be called to follow such a link.
8798 @item
8799 The next line adds a function to @code{org-store-link-functions}, in
8800 order to allow the command @kbd{C-c l} to record a useful link in a
8801 buffer displaying a man page.
8802 @end enumerate
8804 The rest of the file defines the necessary variables and functions.
8805 First there is a customization variable that determines which emacs
8806 command should be used to display man pages.  There are two options,
8807 @code{man} and @code{woman}.  Then the function to follow a link is
8808 defined.  It gets the link path as an argument - in this case the link
8809 path is just a topic for the manual command.  The function calls the
8810 value of @code{org-man-command} to display the man page.
8812 Finally the function @code{org-man-store-link} is defined.  When you try
8813 to store a link with @kbd{C-c l}, also this function will be called to
8814 try to make a link.  The function must first decide if it is supposed to
8815 create the link for this buffer type, we do this by checking the value
8816 of the variable @code{major-mode}.  If not, the function must exit and
8817 return the value @code{nil}.  If yes, the link is created by getting the
8818 manual topic from the buffer name and prefixing it with the string
8819 @samp{man:}.  Then it must call the command @code{org-store-link-props}
8820 and set the @code{:type} and @code{:link} properties.  Optionally you
8821 can also set the @code{:description} property to provide a default for
8822 the link description when the link is later inserted into an Org
8823 buffer with @kbd{C-c C-l}.
8825 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Hacking
8826 @section Tables and lists in arbitrary syntax
8827 @cindex tables, in other modes
8828 @cindex lists, in other modes
8829 @cindex Orgtbl mode
8831 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
8832 frequent feature request has been to make it work with native tables in
8833 specific languages, for example La@TeX{}.  However, this is extremely
8834 hard to do in a general way, would lead to a customization nightmare,
8835 and would take away much of the simplicity of the Orgtbl mode table
8836 editor.
8839 This appendix describes a different approach.  We keep the Orgtbl mode
8840 table in its native format (the @i{source table}), and use a custom
8841 function to @i{translate} the table to the correct syntax, and to
8842 @i{install} it in the right location (the @i{target table}).  This puts
8843 the burden of writing conversion functions on the user, but it allows
8844 for a very flexible system.
8846 Bastien added the ability to do the same with lists.  You can use Org's
8847 facilities to edit and structure lists by turning @code{orgstruct-mode}
8848 on, then locally exporting such lists in another format (HTML, La@TeX{}
8849 or Texinfo.)
8852 @menu
8853 * Radio tables::                Sending and receiving
8854 * A LaTeX example::             Step by step, almost a tutorial
8855 * Translator functions::        Copy and modify
8856 * Radio lists::                 Doing the same for lists
8857 @end menu
8859 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
8860 @subsection Radio tables
8861 @cindex radio tables
8863 To define the location of the target table, you first need to create two
8864 lines that are comments in the current mode, but contain magic words for
8865 Orgtbl mode to find.  Orgtbl mode will insert the translated table
8866 between these lines, replacing whatever was there before.  For example:
8868 @example
8869 /* BEGIN RECEIVE ORGTBL table_name */
8870 /* END RECEIVE ORGTBL table_name */
8871 @end example
8873 @noindent
8874 Just above the source table, we put a special line that tells
8875 Orgtbl mode how to translate this table and where to install it.  For
8876 example:
8877 @example
8878 #+ORGTBL: SEND table_name translation_function arguments....
8879 @end example
8881 @noindent
8882 @code{table_name} is the reference name for the table that is also used
8883 in the receiver lines. @code{translation_function} is the Lisp function
8884 that does the translation.  Furthermore, the line can contain a list of
8885 arguments (alternating key and value) at the end.  The arguments will be
8886 passed as a property list to the translation function for
8887 interpretation.  A few standard parameters are already recognized and
8888 acted upon before the translation function is called:
8890 @table @code
8891 @item :skip N
8892 Skip the first N lines of the table.  Hlines do count as separate lines for
8893 this parameter!
8895 @item :skipcols (n1 n2 ...)
8896 List of columns that should be skipped.  If the table has a column with
8897 calculation marks, that column is automatically discarded as well.
8898 Please note that the translator function sees the table @emph{after} the
8899 removal of these columns, the function never knows that there have been
8900 additional columns.
8901 @end table
8903 @noindent
8904 The one problem remaining is how to keep the source table in the buffer
8905 without disturbing the normal workings of the file, for example during
8906 compilation of a C file or processing of a La@TeX{} file.  There are a
8907 number of different solutions:
8909 @itemize @bullet
8910 @item
8911 The table could be placed in a block comment if that is supported by the
8912 language.  For example, in C mode you could wrap the table between
8913 @samp{/*} and @samp{*/} lines.
8914 @item
8915 Sometimes it is possible to put the table after some kind of @i{END}
8916 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
8917 in La@TeX{}.
8918 @item
8919 You can just comment the table line by line whenever you want to process
8920 the file, and uncomment it whenever you need to edit the table.  This
8921 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
8922 make this comment-toggling very easy, in particular if you bind it to a
8923 key.
8924 @end itemize
8926 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
8927 @subsection A LaTeX example of radio tables
8928 @cindex LaTeX, and Orgtbl mode
8930 The best way to wrap the source table in La@TeX{} is to use the
8931 @code{comment} environment provided by @file{comment.sty}.  It has to be
8932 activated by placing @code{\usepackage@{comment@}} into the document
8933 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
8934 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
8935 variable @code{orgtbl-radio-tables} to install templates for other
8936 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
8937 be prompted for a table name, lets say we use @samp{salesfigures}.  You
8938 will then get the following template:
8940 @cindex #+ORGTBL: SEND
8941 @example
8942 % BEGIN RECEIVE ORGTBL salesfigures
8943 % END RECEIVE ORGTBL salesfigures
8944 \begin@{comment@}
8945 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8946 | | |
8947 \end@{comment@}
8948 @end example
8950 @noindent
8951 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
8952 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
8953 into the receiver location with name @code{salesfigures}.  You may now
8954 fill in the table, feel free to use the spreadsheet features@footnote{If
8955 the @samp{#+TBLFM} line contains an odd number of dollar characters,
8956 this may cause problems with font-lock in LaTeX mode.  As shown in the
8957 example you can fix this by adding an extra line inside the
8958 @code{comment} environment that is used to balance the dollar
8959 expressions.  If you are using AUCTeX with the font-latex library, a
8960 much better solution is to add the @code{comment} environment to the
8961 variable @code{LaTeX-verbatim-environments}.}:
8963 @example
8964 % BEGIN RECEIVE ORGTBL salesfigures
8965 % END RECEIVE ORGTBL salesfigures
8966 \begin@{comment@}
8967 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8968 | Month | Days | Nr sold | per day |
8969 |-------+------+---------+---------|
8970 | Jan   |   23 |      55 |     2.4 |
8971 | Feb   |   21 |      16 |     0.8 |
8972 | March |   22 |     278 |    12.6 |
8973 #+TBLFM: $4=$3/$2;%.1f
8974 % $ (optional extra dollar to keep font-lock happy, see footnote)
8975 \end@{comment@}
8976 @end example
8978 @noindent
8979 When you are done, press @kbd{C-c C-c} in the table to get the converted
8980 table inserted between the two marker lines.
8982 Now lets assume you want to make the table header by hand, because you
8983 want to control how columns are aligned etc.  In this case we make sure
8984 that the table translator does skip the first 2 lines of the source
8985 table, and tell the command to work as a @i{splice}, i.e. to not produce
8986 header and footer commands of the target table:
8988 @example
8989 \begin@{tabular@}@{lrrr@}
8990 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
8991 % BEGIN RECEIVE ORGTBL salesfigures
8992 % END RECEIVE ORGTBL salesfigures
8993 \end@{tabular@}
8995 \begin@{comment@}
8996 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
8997 | Month | Days | Nr sold | per day |
8998 |-------+------+---------+---------|
8999 | Jan   |   23 |      55 |     2.4 |
9000 | Feb   |   21 |      16 |     0.8 |
9001 | March |   22 |     278 |    12.6 |
9002 #+TBLFM: $4=$3/$2;%.1f
9003 \end@{comment@}
9004 @end example
9006 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
9007 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
9008 and marks horizontal lines with @code{\hline}.  Furthermore, it
9009 interprets the following parameters (see also @ref{Translator functions}):
9011 @table @code
9012 @item :splice nil/t
9013 When set to t, return only table body lines, don't wrap them into a
9014 tabular environment.  Default is nil.
9016 @item :fmt fmt
9017 A format to be used to wrap each field, should contain @code{%s} for the
9018 original field value.  For example, to wrap each field value in dollars,
9019 you could use @code{:fmt "$%s$"}.  This may also be a property list with
9020 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
9021 A function of one argument can be used in place of the strings; the
9022 function must return a formatted string.
9024 @item :efmt efmt
9025 Use this format to print numbers with exponentials.  The format should
9026 have @code{%s} twice for inserting mantissa and exponent, for example
9027 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
9028 may also be a property list with column numbers and formats, for example
9029 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
9030 @code{efmt} has been applied to a value, @code{fmt} will also be
9031 applied.  Similar to @code{fmt}, functions of two arguments can be
9032 supplied instead of strings.
9033 @end table
9035 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
9036 @subsection Translator functions
9037 @cindex HTML, and Orgtbl mode
9038 @cindex translator function
9040 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
9041 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
9042 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
9043 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
9044 code that produces tables during HTML export.}, these all use a generic
9045 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
9046 itself is a very short function that computes the column definitions for the
9047 @code{tabular} environment, defines a few field and line separators and then
9048 hands over to the generic translator.  Here is the entire code:
9050 @lisp
9051 @group
9052 (defun orgtbl-to-latex (table params)
9053   "Convert the Orgtbl mode TABLE to LaTeX."
9054   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
9055                                org-table-last-alignment ""))
9056          (params2
9057           (list
9058            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
9059            :tend "\\end@{tabular@}"
9060            :lstart "" :lend " \\\\" :sep " & "
9061            :efmt "%s\\,(%s)" :hline "\\hline")))
9062     (orgtbl-to-generic table (org-combine-plists params2 params))))
9063 @end group
9064 @end lisp
9066 As you can see, the properties passed into the function (variable
9067 @var{PARAMS}) are combined with the ones newly defined in the function
9068 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
9069 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
9070 would like to use the La@TeX{} translator, but wanted the line endings to
9071 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
9072 overrule the default with
9074 @example
9075 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
9076 @end example
9078 For a new language, you can either write your own converter function in
9079 analogy with the La@TeX{} translator, or you can use the generic function
9080 directly.  For example, if you have a language where a table is started
9081 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
9082 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
9083 separator is a TAB, you could call the generic translator like this (on
9084 a single line!):
9086 @example
9087 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
9088                               :lstart "!BL! " :lend " !EL!" :sep "\t"
9089 @end example
9091 @noindent
9092 Please check the documentation string of the function
9093 @code{orgtbl-to-generic} for a full list of parameters understood by
9094 that function and remember that you can pass each of them into
9095 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
9096 using the generic function.
9098 Of course you can also write a completely new function doing complicated
9099 things the generic translator cannot do.  A translator function takes
9100 two arguments.  The first argument is the table, a list of lines, each
9101 line either the symbol @code{hline} or a list of fields.  The second
9102 argument is the property list containing all parameters specified in the
9103 @samp{#+ORGTBL: SEND} line.  The function must return a single string
9104 containing the formatted table.  If you write a generally useful
9105 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
9106 others can benefit from your work.
9108 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
9109 @subsection Radio lists
9110 @cindex radio lists
9111 @cindex org-list-insert-radio-list
9113 Sending and receiving radio lists works exactly the same way than
9114 sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
9115 need to load the @code{org-export-latex.el} package to use radio lists
9116 since the relevant code is there for now.}.  As for radio tables, you
9117 can insert radio lists templates in HTML, La@TeX{} and Texinfo modes by
9118 calling @code{org-list-insert-radio-list}.
9120 Here are the differences with radio tables:
9122 @itemize @minus
9123 @item
9124 Use @code{ORGLST} instead of @code{ORGTBL}.
9125 @item
9126 The available translation functions for radio lists don't take
9127 parameters.
9128 @item
9129 `C-c C-c' will work when pressed on the first item of the list.
9130 @end itemize
9132 Here is a La@TeX{} example.  Let's say that you have this in your
9133 La@TeX{} file:
9135 @example
9136 % BEGIN RECEIVE ORGLST to-buy
9137 % END RECEIVE ORGLST to-buy
9138 \begin@{comment@}
9139 #+ORGLIST: SEND to-buy orgtbl-to-latex
9140 - a new house
9141 - a new computer
9142   + a new keyboard
9143   + a new mouse
9144 - a new life
9145 \end@{comment@}
9146 @end example
9148 Pressing `C-c C-c' on @code{a new house} and will insert the converted
9149 La@TeX{} list between the two marker lines.
9151 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
9152 @section Dynamic blocks
9153 @cindex dynamic blocks
9155 Org documents can contain @emph{dynamic blocks}.  These are
9156 specially marked regions that are updated by some user-written function.
9157 A good example for such a block is the clock table inserted by the
9158 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
9160 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
9161 to the block and can also specify parameters for the function producing
9162 the content of the block.
9164 #+BEGIN:dynamic block
9165 @example
9166 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
9168 #+END:
9169 @end example
9171 Dynamic blocks are updated with the following commands
9173 @table @kbd
9174 @kindex C-c C-x C-u
9175 @item C-c C-x C-u
9176 Update dynamic block at point.
9177 @kindex C-u C-c C-x C-u
9178 @item C-u C-c C-x C-u
9179 Update all dynamic blocks in the current file.
9180 @end table
9182 Updating a dynamic block means to remove all the text between BEGIN and
9183 END, parse the BEGIN line for parameters and then call the specific
9184 writer function for this block to insert the new content.  If you want
9185 to use the original content in the writer function, you can use the
9186 extra parameter @code{:content}.
9188 For a block with name @code{myblock}, the writer function is
9189 @code{org-dblock-write:myblock} with as only parameter a property list
9190 with the parameters given in the begin line.  Here is a trivial example
9191 of a block that keeps track of when the block update function was last
9192 run:
9194 @example
9195 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
9197 #+END:
9198 @end example
9200 @noindent
9201 The corresponding block writer function could look like this:
9203 @lisp
9204 (defun org-dblock-write:block-update-time (params)
9205    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
9206      (insert "Last block update at: "
9207              (format-time-string fmt (current-time)))))
9208 @end lisp
9210 If you want to make sure that all dynamic blocks are always up-to-date,
9211 you could add the function @code{org-update-all-dblocks} to a hook, for
9212 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
9213 written in a way that is does nothing in buffers that are not in
9214 @code{org-mode}.
9216 @node Special agenda views, Using the property API, Dynamic blocks, Hacking
9217 @section Special agenda views
9218 @cindex agenda views, user-defined
9220 Org provides a special hook that can be used to narrow down the
9221 selection made by any of the agenda views.  You may specify a function
9222 that is used at each match to verify if the match should indeed be part
9223 of the agenda view, and if not, how much should be skipped.
9225 Let's say you want to produce a list of projects that contain a WAITING
9226 tag anywhere in the project tree.  Let's further assume that you have
9227 marked all tree headings that define a project with the TODO keyword
9228 PROJECT.  In this case you would run a TODO search for the keyword
9229 PROJECT, but skip the match unless there is a WAITING tag anywhere in
9230 the subtree belonging to the project line.
9232 To achieve this, you must write a function that searches the subtree for
9233 the tag.  If the tag is found, the function must return @code{nil} to
9234 indicate that this match should not be skipped.  If there is no such
9235 tag, return the location of the end of the subtree, to indicate that
9236 search should continue from there.
9238 @lisp
9239 (defun my-skip-unless-waiting ()
9240   "Skip trees that are not waiting"
9241   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
9242     (if (re-search-forward ":waiting:" subtree-end t)
9243         nil          ; tag found, do not skip
9244       subtree-end))) ; tag not found, continue after end of subtree
9245 @end lisp
9247 Now you may use this function in an agenda custom command, for example
9248 like this:
9250 @lisp
9251 (org-add-agenda-custom-command
9252  '("b" todo "PROJECT"
9253    ((org-agenda-skip-function 'my-org-waiting-projects)
9254     (org-agenda-overriding-header "Projects waiting for something: "))))
9255 @end lisp
9257 Note that this also binds @code{org-agenda-overriding-header} to get a
9258 meaningful header in the agenda view.
9260 A general way to create custom searches is to base them on a search for
9261 entries with a certain level limit.  If you want to study all entries with
9262 your custom search function, simply do a search for @samp{LEVEL>0}, and then
9263 use @code{org-agenda-skip-function} to select the entries you really want to
9264 have.
9266 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
9267 particular, you may use the functions @code{org-agenda-skip-entry-if}
9268 and @code{org-agenda-skip-subtree-if} in this form, for example:
9270 @table @code
9271 @item '(org-agenda-skip-entry-if 'scheduled)
9272 Skip current entry if it has been scheduled.
9273 @item '(org-agenda-skip-entry-if 'notscheduled)
9274 Skip current entry if it has not been scheduled.
9275 @item '(org-agenda-skip-entry-if 'deadline)
9276 Skip current entry if it has a deadline.
9277 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
9278 Skip current entry if it has a deadline, or if it is scheduled.
9279 @item '(org-agenda-skip-entry 'regexp "regular expression")
9280 Skip current entry if the regular expression matches in the entry.
9281 @item '(org-agenda-skip-entry 'notregexp "regular expression")
9282 Skip current entry unless the regular expression matches.
9283 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
9284 Same as above, but check and skip the entire subtree.
9285 @end table
9287 Therefore we could also have written the search for WAITING projects
9288 like this, even without defining a special function:
9290 @lisp
9291 (org-add-agenda-custom-command
9292  '("b" todo "PROJECT"
9293    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
9294                                 'regexp ":waiting:"))
9295     (org-agenda-overriding-header "Projects waiting for something: "))))
9296 @end lisp
9298 @node Using the property API, Using the mapping API, Special agenda views, Hacking
9299 @section Using the property API
9300 @cindex API, for properties
9301 @cindex properties, API
9303 Here is a description of the functions that can be used to work with
9304 properties.
9306 @defun org-entry-properties &optional pom which
9307 Get all properties of the entry at point-or-marker POM.
9308 This includes the TODO keyword, the tags, time strings for deadline,
9309 scheduled, and clocking, and any additional properties defined in the
9310 entry.  The return value is an alist, keys may occur multiple times
9311 if the property key was used several times.
9312 POM may also be nil, in which case the current entry is used.
9313 If WHICH is nil or `all', get all properties.  If WHICH is
9314 `special' or `standard', only get that subclass.
9315 @end defun
9316 @defun org-entry-get pom property &optional inherit
9317 Get value of PROPERTY for entry at point-or-marker POM.  By default,
9318 this only looks at properties defined locally in the entry.  If INHERIT
9319 is non-nil and the entry does not have the property, then also check
9320 higher levels of the hierarchy.  If INHERIT is the symbol
9321 @code{selective}, use inheritance if and only if the setting of
9322 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
9323 @end defun
9325 @defun org-entry-delete pom property
9326 Delete the property PROPERTY from entry at point-or-marker POM.
9327 @end defun
9329 @defun org-entry-put pom property value
9330 Set PROPERTY to VALUE for entry at point-or-marker POM.
9331 @end defun
9333 @defun org-buffer-property-keys &optional include-specials
9334 Get all property keys in the current buffer.
9335 @end defun
9337 @defun org-insert-property-drawer
9338 Insert a property drawer at point.
9339 @end defun
9341 @defun org-entry-add-to-multivalued-property pom property value
9342 Treat the value of the property PROPERTY as a whitespace-separated list of
9343 values and make sure that VALUE is in this list.
9344 @end defun
9346 @defun org-entry-remove-from-multivalued-property pom property value
9347 Treat the value of the property PROPERTY as a whitespace-separated list of
9348 values and make sure that VALUE is @emph{not} in this list.
9349 @end defun
9351 @defun org-entry-member-in-multivalued-property pom property value
9352 Treat the value of the property PROPERTY as a whitespace-separated list of
9353 values and check if VALUE is in this list.
9354 @end defun
9356 @node Using the mapping API,  , Using the property API, Hacking
9357 @section Using the mapping API
9358 @cindex API, for mapping
9359 @cindex mapping entries, API
9361 Org has sophisticated mapping capabilities to find all entries satisfying
9362 certain criteria.  Internally, this functionality is used to produce agenda
9363 views, but there is also an API that can be used to execute arbitrary
9364 functions for each or selected entries.  The main entry point for this API
9365 is: 
9367 @defun org-map-entries func &optional match scope &rest skip
9368 Call FUNC at each headline selected by MATCH in SCOPE.
9370 FUNC is a function or a lisp form.  The function will be called without
9371 arguments, with the cursor positioned at the beginning of the headline.
9372 The return values of all calls to the function will be collected and
9373 returned as a list.
9375 MATCH is a tags/property/todo match as it is used in the agenda tags view.
9376 Only headlines that are matched by this query will be considered during
9377 the iteration.  When MATCH is nil or t, all headlines will be
9378 visited by the iteration.
9380 SCOPE determines the scope of this command.  It can be any of:
9382 @example
9383 nil     @r{the current buffer, respecting the restriction if any}
9384 tree    @r{the subtree started with the entry at point}
9385 file    @r{the current buffer, without restriction}
9386 file-with-archives
9387         @r{the current buffer, and any archives associated with it}
9388 agenda  @r{all agenda files}
9389 agenda-with-archives
9390         @r{all agenda files with any archive files associated with them}
9391 (file1 file2 ...)
9392         @r{if this is a list, all files in the list will be scanned}
9393 @end example
9395 The remaining args are treated as settings for the skipping facilities of
9396 the scanner.  The following items can be given here:
9398 @example
9399 archive   @r{skip trees with the archive tag}
9400 comment   @r{skip trees with the COMMENT keyword}
9401 function or Lisp form
9402           @r{will be used as value for @code{org-agenda-skip-function},}
9403           @r{so whenever the the function returns t, FUNC}
9404           @r{will not be called for that entry and search will}
9405           @r{continue from the point where the function leaves it}
9406 @end example
9407 @end defun
9409 The function given to that mapping routine can really do anything you like.
9410 It can uce the property API (@pxref{Using the property API}) to gather more
9411 information about the entry, or in order to change metadate in the entry.
9412 Here are a couple of functions that might be handy:
9414 @defun org-todo &optional arg
9415 Change the TODO state of the entry, see the docstring of the functions for
9416 the many possible values for the argument ARG.
9417 @end defun
9419 @defun org-priority &optional action
9420 Change the priority of the entry, see the docstring of this function for the
9421 possible values for ACTION.
9422 @end defun
9424 @defun org-toggle-tag tag &optional onoff
9425 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
9426 or @code{off} will not toggle tag, but ensure that it is either on or off.
9427 @end defun
9429 @defun org-promote
9430 Promote the current entry.
9431 @end defun
9433 @defun org-demote
9434 Demote the current entry.
9435 @end defun
9437 Here is a simple example that will turn all entries in the current file with
9438 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
9439 Entries in comment trees and in archive trees will be ignored.
9441 @lisp
9442 (org-map-entries
9443    '(org-todo "UPCOMING")
9444    "+TOMORROW" 'file 'archive 'comment)
9445 @end lisp
9447 The following example counts the number of entries with TODO keyword
9448 @code{WAITING}, in all agenda files.
9450 @lisp
9451 (length (org-map-entries t "/+WAITING" nil 'agenda))
9452 @end lisp
9454 @node History and Acknowledgments, Main Index, Hacking, Top
9455 @appendix History and Acknowledgments
9456 @cindex acknowledgments
9457 @cindex history
9458 @cindex thanks
9460 Org was borne in 2003, out of frustration over the user interface
9461 of the Emacs Outline mode.  I was trying to organize my notes and
9462 projects, and using Emacs seemed to be the natural way to go.  However,
9463 having to remember eleven different commands with two or three keys per
9464 command, only to hide and show parts of the outline tree, that seemed
9465 entirely unacceptable to me.  Also, when using outlines to take notes, I
9466 constantly want to restructure the tree, organizing it parallel to my
9467 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
9468 editing} were originally implemented in the package
9469 @file{outline-magic.el}, but quickly moved to the more general
9470 @file{org.el}.  As this environment became comfortable for project
9471 planning, the next step was adding @emph{TODO entries}, basic @emph{time
9472 stamps}, and @emph{table support}.  These areas highlight the two main
9473 goals that Org still has today: To create a new, outline-based,
9474 plain text mode with innovative and intuitive editing features, and to
9475 incorporate project planning functionality directly into a notes file.
9477 A special thanks goes to @i{Bastien Guerry} who has not only writen a large
9478 number of extensions to Org (most of them integrated into the core by now),
9479 but has also helped the development and maintenance of Org so much that he
9480 should be considered co-author of this package.
9482 Since the first release, literally thousands of emails to me or on
9483 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
9484 reports, feedback, new ideas, and sometimes patches and add-on code.
9485 Many thanks to everyone who has helped to improve this package.  I am
9486 trying to keep here a list of the people who had significant influence
9487 in shaping one or more aspects of Org.  The list may not be
9488 complete, if I have forgotten someone, please accept my apologies and
9489 let me know.
9491 @itemize @bullet
9493 @item
9494 @i{Russel Adams} came up with the idea for drawers.
9495 @item
9496 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
9497 @item
9498 @i{Christophe Bataillon} created the great unicorn logo that we use on the
9499 Org-mode website.
9500 @item
9501 @i{Alex Bochannek} provided a patch for rounding time stamps.
9502 @item
9503 @i{Charles Cave}'s suggestion sparked the implementation of templates
9504 for Remember.
9505 @item
9506 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
9507 specified time.
9508 @item
9509 @i{Gregory Chernov} patched support for lisp forms into table
9510 calculations and improved XEmacs compatibility, in particular by porting
9511 @file{nouline.el} to XEmacs.
9512 @item
9513 @i{Sacha Chua} suggested to copy some linking code from Planner.
9514 @item
9515 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
9516 came up with the idea of properties, and that there should be an API for
9517 them.
9518 @item
9519 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
9520 inspired some of the early development, including HTML export.  He also
9521 asked for a way to narrow wide table columns.
9522 @item
9523 @i{Christian Egli} converted the documentation into Texinfo format,
9524 patched CSS formatting into the HTML exporter, and inspired the agenda.
9525 @item
9526 @i{David Emery} provided a patch for custom CSS support in exported
9527 HTML agendas.
9528 @item
9529 @i{Nic Ferrier} contributed mailcap and XOXO support.
9530 @item
9531 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
9532 @item
9533 @i{John Foerch} figured out how to make incremental search show context
9534 around a match in a hidden outline tree.
9535 @item
9536 @i{Niels Giesen} had the idea to automatically archive DONE trees.
9537 @item
9538 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
9539 has been prolific with patches, ideas, and bug reports.
9540 @item
9541 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
9542 @item
9543 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
9544 task state change logging, and the clocktable.  His clear explanations have
9545 been critical when we started to adopt the GIT version control system.
9546 @item
9547 @i{Manuel Hermenegildo} has contributed various ideas, small fixed and
9548 patches.
9549 @item
9550 @i{Phil Jackson} wrote @file{org-irc.el}.
9551 @item
9552 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
9553 folded entries, and column view for properties.
9554 @item
9555 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
9556 @item
9557 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
9558 provided frequent feedback and some patches.
9559 @item
9560 @i{Jason F. McBrayer} suggested agenda export to CSV format.
9561 @item
9562 @i{Max Mikhanosha} came up with the idea of refiling.
9563 @item
9564 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
9565 basis.
9566 @item
9567 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
9568 happy.
9569 @item
9570 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
9571 and to be able to quickly restrict the agenda to a subtree.
9572 @item
9573 @i{Todd Neal} provided patches for links to Info files and elisp forms.
9574 @item
9575 @i{Tim O'Callaghan} suggested in-file links, search options for general
9576 file links, and TAGS.
9577 @item
9578 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
9579 into Japanese.
9580 @item
9581 @i{Oliver Oppitz} suggested multi-state TODO items.
9582 @item
9583 @i{Scott Otterson} sparked the introduction of descriptive text for
9584 links, among other things.
9585 @item
9586 @i{Pete Phillips} helped during the development of the TAGS feature, and
9587 provided frequent feedback.
9588 @item
9589 @i{T.V. Raman} reported bugs and suggested improvements.
9590 @item
9591 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
9592 control.
9593 @item
9594 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
9595 @item
9596 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
9597 webpages derived from Org using an Info-like, or a folding interface with
9598 single key navigation.
9599 @item
9600 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
9601 conflict with @file{allout.el}.
9602 @item
9603 @i{Jason Riedy} generalized the send-receive mechanism for orgtbl tables with
9604 extensive patches.
9605 @item
9606 @i{Philip Rooke} created the Org reference card, provided lots
9607 of feedback, developed and applied standards to the Org documentation.
9608 @item
9609 @i{Christian Schlauer} proposed angular brackets around links, among
9610 other things.
9611 @item
9612 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
9613 @file{organizer-mode.el}.
9614 @item
9615 @i{Ilya Shlyakhter} proposed the Archive Sibling.
9616 @item
9617 @i{Daniel Sinder} came up with the idea of internal archiving by locking
9618 subtrees.
9619 @item
9620 @i{Dale Smith} proposed link abbreviations.
9621 @item
9622 @i{James TD Smith} has contributed a large number of patches for useful
9623 tweaks and features.
9624 @item
9625 @i{Adam Spiers} asked for global linking commands, inspired the link
9626 extension system, added support for mairix, and proposed the mapping API.
9627 @item
9628 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
9629 chapter about publishing.
9630 @item
9631 @i{J@"urgen Vollmer} contributed code generating the table of contents
9632 in HTML output.
9633 @item
9634 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
9635 keyword.
9636 @item
9637 @i{David Wainberg} suggested archiving, and improvements to the linking
9638 system.
9639 @item
9640 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
9641 @file{muse.el}, which have similar goals as Org.  Initially the
9642 development of Org was fully independent because I was not aware of the
9643 existence of these packages.  But with time I have accasionally looked
9644 at John's code and learned a lot from it.  John has also contributed a
9645 number of great ideas and patches directly to Org, including the file
9646 @code{org-mac-message.el}'
9647 @item
9648 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
9649 linking to Gnus.
9650 @item
9651 @i{Roland Winkler} requested additional key bindings to make Org
9652 work on a tty.
9653 @item
9654 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
9655 and contributed various ideas and code snippets.
9656 @end itemize
9659 @node Main Index, Key Index, History and Acknowledgments, Top
9660 @unnumbered The Main Index
9662 @printindex cp
9664 @node Key Index,  , Main Index, Top
9665 @unnumbered Key Index
9667 @printindex ky
9669 @bye
9671 @ignore
9672         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
9673 @end ignore
9675 @c Local variables:
9676 @c ispell-local-dictionary: "en_US-w_accents"
9677 @c ispell-local-pdict: "./.aspell.org.pws"
9678 @c fill-column: 77
9679 @c End: