Release 6.24a
[org-mode.git] / doc / org.texi
blobe4eadded4523beddfde9214fcbb8aae6c39dcc0f
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.24a
7 @set DATE March 2009
9 @c Version and Contact Info
10 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
11 @set AUTHOR Carsten Dominik
12 @set MAINTAINER Carsten Dominik
13 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
14 @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
15 @c %**end of header
16 @finalout
18 @c Macro definitions
20 @c Subheadings inside a table.
21 @macro tsubheading{text}
22 @ifinfo
23 @subsubheading \text\
24 @end ifinfo
25 @ifnotinfo
26 @item @b{\text\}
27 @end ifnotinfo
28 @end macro
30 @copying
31 This manual is for Org version @value{VERSION}.
33 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
35 @quotation
36 Permission is granted to copy, distribute and/or modify this document
37 under the terms of the GNU Free Documentation License, Version 1.3 or
38 any later version published by the Free Software Foundation; with no
39 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
40 and with the Back-Cover Texts as in (a) below.  A copy of the license
41 is included in the section entitled ``GNU Free Documentation License.''
43 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
44 modify this GNU manual.  Buying copies from the FSF supports it in
45 developing GNU and promoting software freedom.''
47 This document is part of a collection distributed under the GNU Free
48 Documentation License.  If you want to distribute this document
49 separately from the collection, you can do so by adding a copy of the
50 license to the document, as described in section 6 of the license.
51 @end quotation
52 @end copying
54 @dircategory Emacs
55 @direntry
56 * Org Mode: (org).      Outline-based notes management and organizer
57 @end direntry
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 * Capture::                     Creating tasks and attaching files
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 * Hacking::                     How to hack your way around
97 * History and Acknowledgments::  How Org came into being
98 * Main Index::                  An index of Org's concepts and features
99 * Key Index::                   Key bindings and where they are described
100 * Variable and Faces Index::    Index for variables and faces discussed
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 * Footnotes::                   How footnotes are defined in Org's syntax
125 * Orgstruct mode::              Structure editing outside Org
127 Archiving
129 * ARCHIVE tag::                 Marking a tree as inactive
130 * Moving subtrees::             Moving a tree to an archive file
132 Tables
134 * Built-in table editor::       Simple tables
135 * Narrow columns::              Stop wasting space in tables
136 * Column groups::               Grouping to trigger vertical lines
137 * Orgtbl mode::                 The table editor as minor mode
138 * The spreadsheet::             The table editor has spreadsheet capabilities
139 * Org Plot::                    Plotting from org tables
141 The spreadsheet
143 * References::                  How to refer to another field or range
144 * Formula syntax for Calc::     Using Calc to compute stuff
145 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
146 * Field formulas::              Formulas valid for a single field
147 * Column formulas::             Formulas valid for an entire column
148 * Editing and debugging formulas::  Fixing formulas
149 * Updating the table::          Recomputing all dependent fields
150 * Advanced features::           Field names, parameters and automatic recalc
152 Hyperlinks
154 * Link format::                 How links in Org are formatted
155 * Internal links::              Links to other places in the current file
156 * External links::              URL-like links to the world
157 * Handling links::              Creating, inserting and following
158 * Using links outside Org::     Linking from my C source code?
159 * Link abbreviations::          Shortcuts for writing complex links
160 * Search options::              Linking to a specific location
161 * Custom searches::             When the default search is not enough
163 Internal links
165 * Radio targets::               Make targets trigger links in plain text
167 TODO Items
169 * TODO basics::                 Marking and displaying TODO entries
170 * TODO extensions::             Workflow and assignments
171 * Progress logging::            Dates and notes for progress
172 * Priorities::                  Some things are more important than others
173 * Breaking down tasks::         Splitting a task into manageable pieces
174 * Checkboxes::                  Tick-off lists
176 Extended use of TODO keywords
178 * Workflow states::             From TODO to DONE in steps
179 * TODO types::                  I do this, Fred does the rest
180 * Multiple sets in one file::   Mixing it all, and still finding your way
181 * Fast access to TODO states::  Single letter selection of a state
182 * Per-file keywords::           Different files, different requirements
183 * Faces for TODO keywords::     Highlighting states
184 * TODO dependencies::           When one task needs to wait for others
186 Progress logging
188 * Closing items::               When was this entry marked DONE?
189 * Tracking TODO state changes::  When did the status change?
191 Tags
193 * Tag inheritance::             Tags use the tree structure of the outline
194 * Setting tags::                How to assign tags to a headline
195 * Tag searches::                Searching for combinations of tags
197 Properties and Columns
199 * Property syntax::             How properties are spelled out
200 * Special properties::          Access to other Org mode features
201 * Property searches::           Matching property values
202 * Property inheritance::        Passing values down the tree
203 * Column view::                 Tabular viewing and editing
204 * Property API::                Properties for Lisp programmers
206 Column view
208 * Defining columns::            The COLUMNS format property
209 * Using column view::           How to create and use column view
210 * Capturing column view::       A dynamic block for column view
212 Defining columns
214 * Scope of column definitions::  Where defined, where valid?
215 * Column attributes::           Appearance and content of a column
217 Dates and Times
219 * Timestamps::                  Assigning a time to a tree entry
220 * Creating timestamps::         Commands which insert timestamps
221 * Deadlines and scheduling::    Planning your work
222 * Clocking work time::          Tracking how long you spend on a task
223 * Effort estimates::            Planning work effort in advance
224 * Relative timer::              Notes with a running timer
226 Creating timestamps
228 * The date/time prompt::        How Org mode helps you entering date and time
229 * Custom time format::          Making dates look different
231 Deadlines and scheduling
233 * Inserting deadline/schedule::  Planning items
234 * Repeated tasks::              Items that show up again and again
236 Capture
238 * Remember::                    Capture new tasks/ideas with little interruption
239 * Attachments::                 Add files to tasks.
241 Remember
243 * Setting up Remember::         Some code for .emacs to get things going
244 * Remember templates::          Define the outline of different note types
245 * Storing notes::               Directly get the note to where it belongs
246 * Refiling notes::              Moving a note or task to a project
248 Agenda Views
250 * Agenda files::                Files being searched for agenda information
251 * Agenda dispatcher::           Keyboard access to agenda views
252 * Built-in agenda views::       What is available out of the box?
253 * Presentation and sorting::    How agenda items are prepared for display
254 * Agenda commands::             Remote editing of Org trees
255 * Custom agenda views::         Defining special searches and views
256 * Agenda column view::          Using column view for collected entries
258 The built-in agenda views
260 * Weekly/daily agenda::         The calendar page with current tasks
261 * Global TODO list::            All unfinished action items
262 * Matching tags and properties::  Structured information with fine-tuned search
263 * Timeline::                    Time-sorted view for single file
264 * Keyword search::              Finding entries by keyword
265 * Stuck projects::              Find projects you need to review
267 Presentation and sorting
269 * Categories::                  Not all tasks are equal
270 * Time-of-day specifications::  How the agenda knows the time
271 * Sorting of agenda items::     The order of things
273 Custom agenda views
275 * Storing searches::            Type once, use often
276 * Block agenda::                All the stuff you need in a single buffer
277 * Setting Options::             Changing the rules
278 * Exporting Agenda Views::      Writing agendas to files
279 * Using the agenda elsewhere::  Using agenda information in other programs
281 Embedded LaTeX
283 * Math symbols::                TeX macros for symbols and Greek letters
284 * Subscripts and superscripts::  Simple syntax for raising/lowering text
285 * LaTeX fragments::             Complex formulas made easy
286 * Processing LaTeX fragments::  Previewing LaTeX processing
287 * CDLaTeX mode::                Speed up entering of formulas
289 Exporting
291 * Markup rules::                Which structures are recognized?
292 * Selective export::            Using tags to select and exclude trees
293 * Export options::              Per-file export settings
294 * The export dispatcher::       How to access exporter commands
295 * ASCII export::                Exporting to plain ASCII
296 * HTML export::                 Exporting to HTML
297 * LaTeX and PDF export::        Exporting to LaTeX, and processing to PDF
298 * XOXO export::                 Exporting to XOXO
299 * iCalendar export::            Exporting in iCalendar format
301 Markup rules
303 * Document title::              How the document title is determined
304 * Headings and sections::       The main structure of the exported document
305 * Table of contents::           If, where, how to create a table of contents
306 * Initial text::                Text before the first headline
307 * Lists::                       Plain lists are exported
308 * Paragraphs::                  What determines beginning and ending
309 * Literal examples::            Source code and other examples
310 * Include files::               Include the contents of a file during export
311 * Tables exported::             Tables are exported richly
312 * Inlined images::              How to inline images during export
313 * Footnote markup::             ASCII representation of footnotes
314 * Emphasis and monospace::      To bold or not to bold
315 * TeX macros and LaTeX fragments::  Create special, rich export.
316 * Horizontal rules::            A line across the page
317 * Comment lines::               Some lines will not be exported
318 * Macro replacement::           Global replacement of place holdes
320 HTML export
322 * HTML Export commands::        How to invoke HTML export
323 * Quoting HTML tags::           Using direct HTML in Org mode
324 * Links::                       Transformation of links for HTML
325 * Images in HTML export::       How to insert figures into HTML output
326 * Text areas in HTML export::   An alternative way to show an example
327 * CSS support::                 Changing the appearance of the output
328 * Javascript support::          Info and Folding in a web browser
330 LaTeX and PDF export
332 * LaTeX/PDF export commands::   Which key invokes which commands
333 * Quoting LaTeX code::          Incorporating literal LaTeX code
334 * Sectioning structure::        Changing sectioning in LaTeX output
335 * Tables in LaTeX export::      Options for exporting tables to LaTeX
336 * Images in LaTeX export::      How to insert figures into LaTeX output
338 Publishing
340 * Configuration::               Defining projects
341 * Sample configuration::        Example projects
342 * Triggering publication::      Publication commands
344 Configuration
346 * Project alist::               The central configuration variable
347 * Sources and destinations::    From here to there
348 * Selecting files::             What files are part of the project?
349 * Publishing action::           Setting the function doing the publishing
350 * Publishing options::          Tweaking HTML export
351 * Publishing links::            Which links keep working after publishing?
352 * Project page index::          Publishing a list of project files
354 Sample configuration
356 * Simple example::              One-component publishing
357 * Complex example::             A multi-component publishing example
359 Miscellaneous
361 * Completion::                  M-TAB knows what you need
362 * Customization::               Adapting Org to your taste
363 * In-buffer settings::          Overview of the #+KEYWORDS
364 * The very busy C-c C-c key::   When in doubt, press C-c C-c
365 * Clean view::                  Getting rid of leading stars in the outline
366 * TTY keys::                    Using Org on a tty
367 * Interaction::                 Other Emacs packages
369 Interaction with other packages
371 * Cooperation::                 Packages Org cooperates with
372 * Conflicts::                   Packages that lead to conflicts
374 Hacking
376 * Hooks::                       Who to reach into Org's internals
377 * Add-on packages::             Available extensions
378 * Adding hyperlink types::      New custom link types
379 * Context-sensitive commands::  How to add functioality to such commands
380 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
381 * Dynamic blocks::              Automatically filled blocks
382 * Special agenda views::        Customized views
383 * Using the property API::      Writing programs that use entry properties
384 * Using the mapping API::       Mapping over all or selected entries
386 Tables and lists in arbitrary syntax
388 * Radio tables::                Sending and receiving
389 * A LaTeX example::             Step by step, almost a tutorial
390 * Translator functions::        Copy and modify
391 * Radio lists::                 Doing the same for lists
393 @end detailmenu
394 @end menu
396 @node Introduction, Document Structure, Top, Top
397 @chapter Introduction
398 @cindex introduction
400 @menu
401 * Summary::                     Brief summary of what Org does
402 * Installation::                How to install a downloaded version of Org
403 * Activation::                  How to activate Org for certain buffers
404 * Feedback::                    Bug reports, ideas, patches etc.
405 * Conventions::                 Type-setting conventions in the manual
406 @end menu
408 @node Summary, Installation, Introduction, Introduction
409 @section Summary
410 @cindex summary
412 Org is a mode for keeping notes, maintaining TODO lists, and doing
413 project planning with a fast and effective plain-text system.
415 Org develops organizational tasks around NOTES files that contain
416 lists or information about projects as plain text.  Org is
417 implemented on top of Outline mode, which makes it possible to keep the
418 content of large files well structured.  Visibility cycling and
419 structure editing help to work with the tree.  Tables are easily created
420 with a built-in table editor.  Org supports TODO items, deadlines,
421 time stamps, and scheduling.  It dynamically compiles entries into an
422 agenda that utilizes and smoothly integrates much of the Emacs calendar
423 and diary.  Plain text URL-like links connect to websites, emails,
424 Usenet messages, BBDB entries, and any files related to the projects.
425 For printing and sharing of notes, an Org file can be exported as a
426 structured ASCII file, as HTML, or (TODO and agenda items only) as an
427 iCalendar file.  It can also serve as a publishing tool for a set of
428 linked web pages.
430 An important design aspect that distinguishes Org from for example
431 Planner/Muse is that it encourages to store every piece of information
432 only once.  In Planner, you have project pages, day pages and possibly
433 other files, duplicating some information such as tasks.  In Org,
434 you only have notes files.  In your notes you mark entries as tasks,
435 label them with tags and timestamps.  All necessary lists like a
436 schedule for the day, the agenda for a meeting, tasks lists selected by
437 tags etc are created dynamically when you need them.
439 Org keeps simple things simple.  When first fired up, it should
440 feel like a straightforward, easy to use outliner.  Complexity is not
441 imposed, but a large amount of functionality is available when you need
442 it.  Org is a toolbox and can be used in different ways, for
443 example as:
445 @example
446 @r{@bullet{} outline extension with visibility cycling and structure editing}
447 @r{@bullet{} ASCII system and table editor for taking structured notes}
448 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
449 @r{@bullet{} TODO list editor}
450 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
451 @r{@bullet{} environment to implement David Allen's GTD system}
452 @r{@bullet{} a basic database application}
453 @r{@bullet{} simple hypertext system, with HTML and LaTeX export}
454 @r{@bullet{} publishing tool to create a set of interlinked webpages}
455 @end example
457 Org's automatic, context sensitive table editor with spreadsheet
458 capabilities can be integrated into any major mode by activating the
459 minor Orgtbl mode.  Using a translation step, it can be used to maintain
460 tables in arbitrary file types, for example in La@TeX{}.  The structure
461 editing and list creation capabilities can be used outside Org with
462 the minor Orgstruct mode.
464 @cindex FAQ
465 There is a website for Org which provides links to the newest
466 version of Org, as well as additional information, frequently asked
467 questions (FAQ), links to tutorials etc.  This page is located at
468 @uref{http://orgmode.org}.
470 @page
473 @node Installation, Activation, Summary, Introduction
474 @section Installation
475 @cindex installation
476 @cindex XEmacs
478 @b{Important:} @i{If Org is part of the Emacs distribution or an
479 XEmacs package, please skip this section and go directly to
480 @ref{Activation}.}
482 If you have downloaded Org from the Web, either as a distribution @file{.zip}
483 or @file{.tar} file, or as a GIT archive, you must take the following steps
484 to install it: Go into the unpacked Org distribution directory and edit the
485 top section of the file @file{Makefile}.  You must set the name of the Emacs
486 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
487 directories where local Lisp and Info files are kept.  If you don't have
488 access to the system-wide directories, you can simply run Org directly from
489 the distribution directory by adding the @file{lisp} subdirectory to the
490 Emacs load path.  To do this, add the following line to @file{.emacs}:
492 @example
493 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
494 @end example
496 @noindent
497 If you plan to use code from the @file{contrib} subdirectory, do a similar
498 step for this directory:
500 @example
501 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
502 @end example
504 @b{XEmacs users now need to install the file @file{noutline.el} from
505 the @file{xemacs} sub-directory of the Org distribution.  Use the
506 command:}
508 @example
509 @b{make install-noutline}
510 @end example
512 @noindent Now byte-compile the Lisp files with the shell command:
514 @example
515 make
516 @end example
518 @noindent If you are running Org from the distribution directory, this is
519 all.  If you want to install into the system directories, use
521 @example
522 make install
523 make install-info
524 @end example
526 @noindent Then add to @file{.emacs}:
528 @lisp
529 ;; This line only if Org is not part of the X/Emacs distribution.
530 (require 'org-install)
531 @end lisp
533 Do not forget to activate Org as described in the following section.
535 @node Activation, Feedback, Installation, Introduction
536 @section Activation
537 @cindex activation
538 @cindex autoload
539 @cindex global key bindings
540 @cindex key bindings, global
542 @iftex
543 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
544 PDF documentation as viewed by some PDF viewers to your .emacs file, the
545 single quote character comes out incorrectly and the code will not work.
546 You need to fix the single quotes by hand, or copy from Info
547 documentation.}
548 @end iftex
550 Add the following lines to your @file{.emacs} file.  The last three lines
551 define @emph{global} keys for the commands @command{org-store-link},
552 @command{org-agenda}, and @command{org-iswitchb} - please choose suitable
553 keys yourself.
555 @lisp
556 ;; The following lines are always needed.  Choose your own keys.
557 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
558 (global-set-key "\C-cl" 'org-store-link)
559 (global-set-key "\C-ca" 'org-agenda)
560 (global-set-key "\C-cb" 'org-iswitchb)
561 @end lisp
563 Furthermore, you must activate @code{font-lock-mode} in Org
564 buffers, because significant functionality depends on font-locking being
565 active.  You can do this with either one of the following two lines
566 (XEmacs user must use the second option):
567 @lisp
568 (global-font-lock-mode 1)                     ; for all buffers
569 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
570 @end lisp
572 @cindex Org mode, turning on
573 With this setup, all files with extension @samp{.org} will be put
574 into Org mode.  As an alternative, make the first line of a file look
575 like this:
577 @example
578 MY PROJECTS    -*- mode: org; -*-
579 @end example
581 @vindex org-insert-mode-line-in-empty-file
582 @noindent which will select Org mode for this buffer no matter what
583 the file's name is.  See also the variable
584 @code{org-insert-mode-line-in-empty-file}.
586 Many commands in Org work on the region if the region is @i{active}.  To make
587 use of this, you need to have @code{transient-mark-mode}
588 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
589 in Emacs 22 you need to do this yourself with
590 @lisp
591 (transient-mark-mode 1)
592 @end lisp
593 @noindent If you do not like @code{transient-make-mode}, you can create an
594 active region by using the mouse to select a region, or pressing
595 @kbd{C-@key{SPC}} twice before moving the cursor.
597 @node Feedback, Conventions, Activation, Introduction
598 @section Feedback
599 @cindex feedback
600 @cindex bug reports
601 @cindex maintainer
602 @cindex author
604 If you find problems with Org, or if you have questions, remarks, or ideas
605 about it, please mail to the Org mailing list @code{emacs-orgmode@@gnu.org}.
606 If you are not a member of the mailing list, your mail will be reviewed by a
607 moderator and then passed through to the list.
609 For bug reports, please provide as much information as possible,
610 including the version information of Emacs (@kbd{C-h v emacs-version
611 @key{RET}}) and Org (@kbd{C-h v org-version @key{RET}}), as well as
612 the Org related setup in @file{.emacs}.  If an error occurs, a
613 backtrace can be very useful (see below on how to create one).  Often a
614 small example file helps, along with clear information about:
616 @enumerate
617 @item What exactly did you do?
618 @item What did you expect to happen?
619 @item What happened instead?
620 @end enumerate
621 @noindent Thank you for helping to improve this mode.
623 @subsubheading How to create a useful backtrace
625 @cindex backtrace of an error
626 If working with Org produces an error with a message you don't
627 understand, you may have hit a bug.  The best way to report this is by
628 providing, in addition to what was mentioned above, a @emph{Backtrace}.
629 This is information from the built-in debugger about where and how the
630 error occurred.  Here is how to produce a useful backtrace:
632 @enumerate
633 @item
634 Reload uncompiled versions of all Org-mode lisp files.  The backtrace
635 contains much more information if it is produced with uncompiled code.
636 To do this, use
637 @example
638 C-u M-x org-reload RET
639 @end example
640 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
641 menu.
642 @item
643 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
644 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
645 @item
646 Do whatever you have to do to hit the error.  Don't forget to
647 document the steps you take.
648 @item
649 When you hit the error, a @file{*Backtrace*} buffer will appear on the
650 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
651 attach it to your bug report.
652 @end enumerate
654 @node Conventions,  , Feedback, Introduction
655 @section Typesetting conventions used in this manual
657 Org uses three types of keywords: TODO keywords, tags, and property
658 names.  In this manual we use the following conventions:
660 @table @code
661 @item TODO
662 @itemx WAITING
663 TODO keywords are written with all capitals, even if they are
664 user-defined.
665 @item boss
666 @itemx ARCHIVE
667 User-defined tags are written in lowercase; built-in tags with special
668 meaning are written with all capitals.
669 @item Release
670 @itemx PRIORITY
671 User-defined properties are capitalized; built-in properties with
672 special meaning are written with all capitals.
673 @end table
675 @node Document Structure, Tables, Introduction, Top
676 @chapter Document Structure
677 @cindex document structure
678 @cindex structure of document
680 Org is based on outline mode and provides flexible commands to
681 edit the structure of the document.
683 @menu
684 * Outlines::                    Org is based on Outline mode
685 * Headlines::                   How to typeset Org tree headlines
686 * Visibility cycling::          Show and hide, much simplified
687 * Motion::                      Jumping to other headlines
688 * Structure editing::           Changing sequence and level of headlines
689 * Archiving::                   Move done task trees to a different place
690 * Sparse trees::                Matches embedded in context
691 * Plain lists::                 Additional structure within an entry
692 * Drawers::                     Tucking stuff away
693 * Footnotes::                   How footnotes are defined in Org's syntax
694 * Orgstruct mode::              Structure editing outside Org
695 @end menu
697 @node Outlines, Headlines, Document Structure, Document Structure
698 @section Outlines
699 @cindex outlines
700 @cindex Outline mode
702 Org is implemented on top of Outline mode.  Outlines allow a
703 document to be organized in a hierarchical structure, which (at least
704 for me) is the best representation of notes and thoughts.  An overview
705 of this structure is achieved by folding (hiding) large parts of the
706 document to show only the general document structure and the parts
707 currently being worked on.  Org greatly simplifies the use of
708 outlines by compressing the entire show/hide functionality into a single
709 command @command{org-cycle}, which is bound to the @key{TAB} key.
711 @node Headlines, Visibility cycling, Outlines, Document Structure
712 @section Headlines
713 @cindex headlines
714 @cindex outline tree
715 @vindex org-special-ctrl-a/e
717 Headlines define the structure of an outline tree.  The headlines in
718 Org start with one or more stars, on the left margin@footnote{See
719 the variable @code{org-special-ctrl-a/e} to configure special behavior
720 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
722 @example
723 * Top level headline
724 ** Second level
725 *** 3rd level
726     some text
727 *** 3rd level
728     more text
730 * Another top level headline
731 @end example
733 @noindent Some people find the many stars too noisy and would prefer an
734 outline that has whitespace followed by a single star as headline
735 starters.  @ref{Clean view} describes a setup to realize this.
737 @vindex org-cycle-separator-lines
738 An empty line after the end of a subtree is considered part of it and
739 will be hidden when the subtree is folded.  However, if you leave at
740 least two empty lines, one empty line will remain visible after folding
741 the subtree, in order to structure the collapsed view.  See the
742 variable @code{org-cycle-separator-lines} to modify this behavior.
744 @node Visibility cycling, Motion, Headlines, Document Structure
745 @section Visibility cycling
746 @cindex cycling, visibility
747 @cindex visibility cycling
748 @cindex trees, visibility
749 @cindex show hidden text
750 @cindex hide text
752 Outlines make it possible to hide parts of the text in the buffer.
753 Org uses just two commands, bound to @key{TAB} and
754 @kbd{S-@key{TAB}} to change the visibility in the buffer.
756 @cindex subtree visibility states
757 @cindex subtree cycling
758 @cindex folded, subtree visibility state
759 @cindex children, subtree visibility state
760 @cindex subtree, subtree visibility state
761 @table @kbd
762 @kindex @key{TAB}
763 @item @key{TAB}
764 @emph{Subtree cycling}: Rotate current subtree among the states
766 @example
767 ,-> FOLDED -> CHILDREN -> SUBTREE --.
768 '-----------------------------------'
769 @end example
771 @vindex org-cycle-emulate-tab
772 @vindex org-cycle-global-at-bob
773 The cursor must be on a headline for this to work@footnote{see, however,
774 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
775 beginning of the buffer and the first line is not a headline, then
776 @key{TAB} actually runs global cycling (see below)@footnote{see the
777 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
778 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
780 @cindex global visibility states
781 @cindex global cycling
782 @cindex overview, global visibility state
783 @cindex contents, global visibility state
784 @cindex show all, global visibility state
785 @kindex S-@key{TAB}
786 @item S-@key{TAB}
787 @itemx C-u @key{TAB}
788 @emph{Global cycling}: Rotate the entire buffer among the states
790 @example
791 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
792 '--------------------------------------'
793 @end example
795 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
796 CONTENTS view up to headlines of level N will be shown.  Note that inside
797 tables, @kbd{S-@key{TAB}} jumps to the previous field.
799 @cindex show all, command
800 @kindex C-u C-u C-u @key{TAB}
801 @item C-u C-u C-u @key{TAB}
802 Show all, including drawers.
803 @kindex C-c C-r
804 @item C-c C-r
805 Reveal context around point, showing the current entry, the following heading
806 and the hierarchy above.  Useful for working near a location that has been
807 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
808 (@pxref{Agenda commands}).  With a prefix argument show, on each
809 level, all sibling headings.
810 @kindex C-c C-x b
811 @item C-c C-x b
812 Show the current subtree in an indirect buffer@footnote{The indirect
813 buffer
814 @ifinfo
815 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
816 @end ifinfo
817 @ifnotinfo
818 (see the Emacs manual for more information about indirect buffers)
819 @end ifnotinfo
820 will contain the entire buffer, but will be narrowed to the current
821 tree.  Editing the indirect buffer will also change the original buffer,
822 but without affecting visibility in that buffer.}.  With a numeric
823 prefix argument N, go up to level N and then take that tree.  If N is
824 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
825 the previously used indirect buffer.
826 @end table
828 @vindex org-startup-folded
829 When Emacs first visits an Org file, the global state is set to
830 OVERVIEW, i.e. only the top level headlines are visible.  This can be
831 configured through the variable @code{org-startup-folded}, or on a
832 per-file basis by adding one of the following lines anywhere in the
833 buffer:
835 @example
836 #+STARTUP: overview
837 #+STARTUP: content
838 #+STARTUP: showall
839 @end example
841 @noindent
842 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
843 and Columns}) will get their visibility adapted accordingly.  Allowed values
844 for this property are @code{folded}, @code{children}, @code{content}, and
845 @code{all}.
846 @table @kbd
847 @kindex C-u C-u @key{TAB}
848 @item C-u C-u @key{TAB}
849 Switch back to the startup visibility of the buffer, i.e. whatever is
850 requested by startup options and @samp{VISIBILITY} properties in individual
851 entries.
852 @end table
854 @node Motion, Structure editing, Visibility cycling, Document Structure
855 @section Motion
856 @cindex motion, between headlines
857 @cindex jumping, to headlines
858 @cindex headline navigation
859 The following commands jump to other headlines in the buffer.
861 @table @kbd
862 @kindex C-c C-n
863 @item C-c C-n
864 Next heading.
865 @kindex C-c C-p
866 @item C-c C-p
867 Previous heading.
868 @kindex C-c C-f
869 @item C-c C-f
870 Next heading same level.
871 @kindex C-c C-b
872 @item C-c C-b
873 Previous heading same level.
874 @kindex C-c C-u
875 @item C-c C-u
876 Backward to higher level heading.
877 @kindex C-c C-j
878 @item C-c C-j
879 Jump to a different place without changing the current outline
880 visibility.  Shows the document structure in a temporary buffer, where
881 you can use the following keys to find your destination:
882 @vindex org-goto-auto-isearch
883 @example
884 @key{TAB}         @r{Cycle visibility.}
885 @key{down} / @key{up}   @r{Next/previous visible headline.}
886 @key{RET}         @r{Select this location.}
887 @kbd{/}           @r{Do a Sparse-tree search}
888 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
889 n / p        @r{Next/previous visible headline.}
890 f / b        @r{Next/previous headline same level.}
891 u            @r{One level up.}
892 0-9          @r{Digit argument.}
893 q            @r{Quit}
894 @end example
895 @vindex org-goto-interface
896 See also the variable @code{org-goto-interface}.
897 @end table
899 @node Structure editing, Archiving, Motion, Document Structure
900 @section Structure editing
901 @cindex structure editing
902 @cindex headline, promotion and demotion
903 @cindex promotion, of subtrees
904 @cindex demotion, of subtrees
905 @cindex subtree, cut and paste
906 @cindex pasting, of subtrees
907 @cindex cutting, of subtrees
908 @cindex copying, of subtrees
909 @cindex subtrees, cut and paste
911 @table @kbd
912 @kindex M-@key{RET}
913 @item M-@key{RET}
914 @vindex org-M-RET-may-split-line
915 Insert new heading with same level as current.  If the cursor is in a
916 plain list item, a new item is created (@pxref{Plain lists}).  To force
917 creation of a new headline, use a prefix argument, or first press @key{RET}
918 to get to the beginning of the next line.  When this command is used in
919 the middle of a line, the line is split and the rest of the line becomes
920 the new headline@footnote{If you do not want the line to be split,
921 customize the variable @code{org-M-RET-may-split-line}.}.  If the
922 command is used at the beginning of a headline, the new headline is
923 created before the current line.  If at the beginning of any other line,
924 the content of that line is made the new heading.  If the command is
925 used at the end of a folded subtree (i.e. behind the ellipses at the end
926 of a headline), then a headline like the current one will be inserted
927 after the end of the subtree.
928 @kindex C-@key{RET}
929 @item C-@key{RET}
930 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
931 current heading, the new heading is placed after the body instead of before
932 it.  This command works from anywhere in the entry.
933 @kindex M-S-@key{RET}
934 @item M-S-@key{RET}
935 Insert new TODO entry with same level as current heading.
936 @kindex C-S-@key{RET}
937 @item C-S-@key{RET}
938 Insert new TODO entry with same level as current heading.  Like
939 @kbd{C-@key{RET}}, the new headline will be inserted after the current
940 subtree.
941 @kindex M-@key{left}
942 @item M-@key{left}
943 Promote current heading by one level.
944 @kindex M-@key{right}
945 @item M-@key{right}
946 Demote current heading by one level.
947 @kindex M-S-@key{left}
948 @item M-S-@key{left}
949 Promote the current subtree by one level.
950 @kindex M-S-@key{right}
951 @item M-S-@key{right}
952 Demote the current subtree by one level.
953 @kindex M-S-@key{up}
954 @item M-S-@key{up}
955 Move subtree up (swap with previous subtree of same
956 level).
957 @kindex M-S-@key{down}
958 @item M-S-@key{down}
959 Move subtree down (swap with next subtree of same level).
960 @kindex C-c C-x C-w
961 @item C-c C-x C-w
962 Kill subtree, i.e. remove it from buffer but save in kill ring.
963 With a numeric prefix argument N, kill N sequential subtrees.
964 @kindex C-c C-x M-w
965 @item C-c C-x M-w
966 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
967 sequential subtrees.
968 @kindex C-c C-x C-y
969 @item C-c C-x C-y
970 Yank subtree from kill ring.  This does modify the level of the subtree to
971 make sure the tree fits in nicely at the yank position.  The yank level can
972 also be specified with a numeric prefix argument, or by yanking after a
973 headline marker like @samp{****}.
974 @kindex C-y
975 @item C-y
976 @vindex org-yank-adjusted-subtrees
977 @vindex org-yank-folded-subtrees
978 Depending on the variables @code{org-yank-adjusted-subtrees} and
979 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
980 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
981 C-x C-y}.  With the default settings, no level adjustment will take place,
982 but the yanked tree will be folded unless doing so would swallow text
983 previously visible.  Any prefix argument to this command will force a normal
984 @code{yank} to be executed, with the prefix passed along.  A good way to
985 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
986 yank, it will yank previous kill items plainly, without adjustment and
987 folding.
988 @kindex C-c C-w
989 @item C-c C-w
990 Refile entry or region to a different location.  @xref{Refiling notes}.
991 @kindex C-c ^
992 @item C-c ^
993 Sort same-level entries.  When there is an active region, all entries in the
994 region will be sorted.  Otherwise the children of the current headline are
995 sorted.  The command prompts for the sorting method, which can be
996 alphabetically, numerically, by time (using the first time stamp in each
997 entry), by priority, or by TODO keyword (in the sequence the keywords have
998 been defined in the setup).  Reverse sorting is possible as well.  You can
999 also supply your own function to extract the sorting key.  With a @kbd{C-u}
1000 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes,
1001 duplicate entries will also be removed.
1002 @kindex C-x n s
1003 @item C-x n s
1004 Narrow buffer to current subtree.
1005 @kindex C-x n w
1006 @item C-x n w
1007 Widen buffer to remove a narrowing.
1008 @kindex C-c *
1009 @item C-c *
1010 Turn a normal line or plain list item into a headline (so that it becomes a
1011 subheading at its location).  Also turn a headline into a normal line by
1012 removing the stars.  If there is an active region, turn all lines in the
1013 region into headlines.  If the first line in the region was an item, turn
1014 only the item lines into headlines.  Finally, if the first line is a
1015 headline, remove the stars from all headlines in the region.
1016 @end table
1018 @cindex region, active
1019 @cindex active region
1020 @cindex Transient mark mode
1021 When there is an active region (Transient mark mode), promotion and
1022 demotion work on all headlines in the region.  To select a region of
1023 headlines, it is best to place both point and mark at the beginning of a
1024 line, mark at the beginning of the first headline, and point at the line
1025 just after the last headline to change.  Note that when the cursor is
1026 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1027 functionality.
1029 @node Archiving, Sparse trees, Structure editing, Document Structure
1030 @section Archiving
1031 @cindex archiving
1033 When a project represented by a (sub)tree is finished, you may want
1034 to move the tree out of the way and to stop it from contributing to the
1035 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
1036 the ARCHIVE tag, or you can move an entire (sub)tree to a different
1037 location.
1039 @menu
1040 * ARCHIVE tag::                 Marking a tree as inactive
1041 * Moving subtrees::             Moving a tree to an archive file
1042 @end menu
1044 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
1045 @subsection The ARCHIVE tag
1046 @cindex internal archiving
1048 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
1049 its location in the outline tree, but behaves in the following way:
1050 @itemize @minus
1051 @item
1052 @vindex org-cycle-open-archived-trees
1053 It does not open when you attempt to do so with a visibility cycling
1054 command (@pxref{Visibility cycling}).  You can force cycling archived
1055 subtrees with @kbd{C-@key{TAB}}, or by setting the option
1056 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
1057 @code{show-all} will open archived subtrees.
1058 @item
1059 @vindex org-sparse-tree-open-archived-trees
1060 During sparse tree construction (@pxref{Sparse trees}), matches in
1061 archived subtrees are not exposed, unless you configure the option
1062 @code{org-sparse-tree-open-archived-trees}.
1063 @item
1064 @vindex org-agenda-skip-archived-trees
1065 During agenda view construction (@pxref{Agenda Views}), the content of
1066 archived trees is ignored unless you configure the option
1067 @code{org-agenda-skip-archived-trees}, in which case these trees will always
1068 be included.  In the agenda you can press the @kbd{v} key to get archives
1069 temporarily included.
1070 @item
1071 @vindex org-export-with-archived-trees
1072 Archived trees are not exported (@pxref{Exporting}), only the headline
1073 is.  Configure the details using the variable
1074 @code{org-export-with-archived-trees}.
1075 @end itemize
1077 The following commands help managing the ARCHIVE tag:
1079 @table @kbd
1080 @kindex C-c C-x a
1081 @item C-c C-x a
1082 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
1083 the headline changes to a shadowed face, and the subtree below it is
1084 hidden.
1085 @kindex C-u C-c C-x a
1086 @item C-u C-c C-x a
1087 Check if any direct children of the current headline should be archived.
1088 To do this, each subtree is checked for open TODO entries.  If none are
1089 found, the command offers to set the ARCHIVE tag for the child.  If the
1090 cursor is @emph{not} on a headline when this command is invoked, the
1091 level 1 trees will be checked.
1092 @kindex C-@kbd{TAB}
1093 @item C-@kbd{TAB}
1094 Cycle a tree even if it is tagged with ARCHIVE.
1095 @end table
1097 @node Moving subtrees,  , ARCHIVE tag, Archiving
1098 @subsection Moving subtrees
1099 @cindex external archiving
1101 Once an entire project is finished, you may want to move it to a different
1102 location.  Org can move it to an @emph{Archive Sibling} in the same tree, to a
1103 different tree in the current file, or to a different file, the archive file.
1105 @table @kbd
1106 @kindex C-c C-x A
1107 @item C-c C-x A
1108 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
1109 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}
1110 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1111 way retains a lot of its original context, including inherited tags and
1112 approximate position in the outline.
1113 @kindex C-c $
1114 @kindex C-c C-x C-s
1115 @itemx C-c $
1116 @item C-c C-x C-s
1117 @vindex org-archive-location
1118 Archive the subtree starting at the cursor position to the location
1119 given by @code{org-archive-location}.  Context information that could be
1120 lost like the file name, the category, inherited tags, and the TODO
1121 state will be store as properties in the entry.
1122 @kindex C-u C-c C-x C-s
1123 @item C-u C-c C-x C-s
1124 Check if any direct children of the current headline could be moved to
1125 the archive.  To do this, each subtree is checked for open TODO entries.
1126 If none are found, the command offers to move it to the archive
1127 location.  If the cursor is @emph{not} on a headline when this command
1128 is invoked, the level 1 trees will be checked.
1129 @end table
1131 @cindex archive locations
1132 The default archive location is a file in the same directory as the
1133 current file, with the name derived by appending @file{_archive} to the
1134 current file name.  For information and examples on how to change this,
1135 see the documentation string of the variable
1136 @code{org-archive-location}.  There is also an in-buffer option for
1137 setting this variable, for example@footnote{For backward compatibility,
1138 the following also works: If there are several such lines in a file,
1139 each specifies the archive location for the text below it.  The first
1140 such line also applies to any text before its definition.  However,
1141 using this method is @emph{strongly} deprecated as it is incompatible
1142 with the outline structure of the document.  The correct method for
1143 setting multiple archive locations in a buffer is using properties.}:
1145 @example
1146 #+ARCHIVE: %s_done::
1147 @end example
1149 @noindent
1150 If you would like to have a special ARCHIVE location for a single entry
1151 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1152 location as the value (@pxref{Properties and Columns}).
1154 @vindex org-archive-save-context-info
1155 When a subtree is moved, it receives a number of special properties that
1156 record context information like the file from where the entry came, it's
1157 outline path the archiving time etc.  Configure the variable
1158 @code{org-archive-save-context-info} to adjust the amount of information
1159 added.
1161 @node Sparse trees, Plain lists, Archiving, Document Structure
1162 @section Sparse trees
1163 @cindex sparse trees
1164 @cindex trees, sparse
1165 @cindex folding, sparse trees
1166 @cindex occur, command
1168 @vindex org-show-hierarchy-above
1169 @vindex org-show-following-heading
1170 @vindex org-show-siblings
1171 @vindex org-show-entry-below
1172 An important feature of Org mode is the ability to construct @emph{sparse
1173 trees} for selected information in an outline tree, so that the entire
1174 document is folded as much as possible, but the selected information is made
1175 visible along with the headline structure above it@footnote{See also the
1176 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1177 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1178 control on how much context is shown around each match.}.  Just try it out
1179 and you will see immediately how it works.
1181 Org mode contains several commands creating such trees, all these
1182 commands can be accessed through a dispatcher:
1184 @table @kbd
1185 @kindex C-c /
1186 @item C-c /
1187 This prompts for an extra key to select a sparse-tree creating command.
1188 @kindex C-c / r
1189 @item C-c / r
1190 @vindex org-remove-highlights-with-change
1191 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
1192 the match is in a headline, the headline is made visible.  If the match is in
1193 the body of an entry, headline and body are made visible.  In order to
1194 provide minimal context, also the full hierarchy of headlines above the match
1195 is shown, as well as the headline following the match.  Each match is also
1196 highlighted; the highlights disappear when the buffer is changed by an
1197 editing command@footnote{depending on the option
1198 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1199 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1200 so several calls to this command can be stacked.
1201 @end table
1203 @noindent
1204 @vindex org-agenda-custom-commands
1205 For frequently used sparse trees of specific search strings, you can
1206 use the variable @code{org-agenda-custom-commands} to define fast
1207 keyboard access to specific sparse trees.  These commands will then be
1208 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1209 For example:
1211 @lisp
1212 (setq org-agenda-custom-commands
1213       '(("f" occur-tree "FIXME")))
1214 @end lisp
1216 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1217 a sparse tree matching the string @samp{FIXME}.
1219 The other sparse tree commands select headings based on TODO keywords,
1220 tags, or properties and will be discussed later in this manual.
1222 @kindex C-c C-e v
1223 @cindex printing sparse trees
1224 @cindex visible text, printing
1225 To print a sparse tree, you can use the Emacs command
1226 @code{ps-print-buffer-with-faces} which does not print invisible parts
1227 of the document @footnote{This does not work under XEmacs, because
1228 XEmacs uses selective display for outlining, not text properties.}.
1229 Or you can use the command @kbd{C-c C-e v} to export only the visible
1230 part of the document and print the resulting file.
1232 @node Plain lists, Drawers, Sparse trees, Document Structure
1233 @section Plain lists
1234 @cindex plain lists
1235 @cindex lists, plain
1236 @cindex lists, ordered
1237 @cindex ordered lists
1239 Within an entry of the outline tree, hand-formatted lists can provide
1240 additional structure.  They also provide a way to create lists of
1241 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1242 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1244 Org knows ordered lists, unordered lists, and description lists.
1245 @itemize @bullet
1246 @item
1247 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1248 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1249 they will be seen as top-level headlines.  Also, when you are hiding leading
1250 stars to get a clean outline view, plain list items starting with a star are
1251 visually indistinguishable from true headlines.  In short: even though
1252 @samp{*} is supported, it may be better to not use it for plain list items.}
1253 as bullets.
1254 @item
1255 @emph{Ordered} list items start with a numeral followed by either a period or
1256 a right parenthesis, such as @samp{1.} or @samp{1)}.
1257 @item
1258 @emph{Description} list items are like unordered list items, but contain the
1259 separator @samp{ :: } to separate the description @emph{term} from the
1260 description.
1261 @end itemize
1263 @vindex org-empty-line-terminates-plain-lists
1264 Items belonging to the same list must have the same indentation on the first
1265 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1266 2--digit numbers must be written left-aligned with the other numbers in the
1267 list.  Indentation also determines the end of a list item.  It ends before
1268 the next line that is indented like the bullet/number, or less.  Empty lines
1269 are part of the previous item, so you can have several paragraphs in one
1270 item.  If you would like an empty line to terminate all currently open plain
1271 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1272 Here is an example:
1274 @example
1275 @group
1276 ** Lord of the Rings
1277    My favorite scenes are (in this order)
1278    1. The attack of the Rohirrim
1279    2. Eowyn's fight with the witch king
1280       + this was already my favorite scene in the book
1281       + I really like Miranda Otto.
1282    3. Peter Jackson being shot by Legolas
1283        - on DVD only
1284       He makes a really funny face when it happens.
1285    But in the end, no individual scenes matter but the film as a whole.
1286    Important actors in this film are:
1287    - @b{Elijah Wood} :: He plays Frodo
1288    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1289      him very well from his role as Mikey Walsh in the Goonies.
1290 @end group
1291 @end example
1293 Org supports these lists by tuning filling and wrapping commands to
1294 deal with them correctly@footnote{Org only changes the filling
1295 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1296 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1297 @code{(require 'filladapt)}}, and by exporting them properly
1298 (@pxref{Exporting}).
1300 The following commands act on items when the cursor is in the first line
1301 of an item (the line with the bullet or number).
1303 @table @kbd
1304 @kindex @key{TAB}
1305 @item @key{TAB}
1306 @vindex org-cycle-include-plain-lists
1307 Items can be folded just like headline levels if you set the variable
1308 @code{org-cycle-include-plain-lists}.  The level of an item is then
1309 given by the indentation of the bullet/number.  Items are always
1310 subordinate to real headlines, however; the hierarchies remain
1311 completely separated.
1313 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1314 fixes the indentation of the current line in a heuristic way.
1315 @kindex M-@key{RET}
1316 @item M-@key{RET}
1317 @vindex org-M-RET-may-split-line
1318 Insert new item at current level.  With a prefix argument, force a new
1319 heading (@pxref{Structure editing}).  If this command is used in the middle
1320 of a line, the line is @emph{split} and the rest of the line becomes the new
1321 item@footnote{If you do not want the line to be split, customize the variable
1322 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1323 @emph{whitespace before a bullet or number}, the new item is created
1324 @emph{before} the current item.  If the command is executed in the white
1325 space before the text that is part of an item but does not contain the
1326 bullet, a bullet is added to the current line.
1327 @kindex M-S-@key{RET}
1328 @item M-S-@key{RET}
1329 Insert a new item with a checkbox (@pxref{Checkboxes}).
1330 @kindex S-@key{up}
1331 @kindex S-@key{down}
1332 @item S-@key{up}
1333 @itemx S-@key{down}
1334 @cindex shift-selection-mode
1335 @vindex org-support-shift-select
1336 Jump to the previous/next item in the current list, but only if
1337 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1338 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1339 similar effect.
1340 @kindex M-S-@key{up}
1341 @kindex M-S-@key{down}
1342 @item M-S-@key{up}
1343 @itemx M-S-@key{down}
1344 Move the item including subitems up/down (swap with previous/next item
1345 of same indentation).  If the list is ordered, renumbering is
1346 automatic.
1347 @kindex M-S-@key{left}
1348 @kindex M-S-@key{right}
1349 @item M-S-@key{left}
1350 @itemx M-S-@key{right}
1351 Decrease/increase the indentation of the item, including subitems.
1352 Initially, the item tree is selected based on current indentation.
1353 When these commands are executed several times in direct succession,
1354 the initially selected region is used, even if the new indentation
1355 would imply a different hierarchy.  To use the new hierarchy, break
1356 the command chain with a cursor motion or so.
1357 @kindex C-c C-c
1358 @item C-c C-c
1359 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1360 state of the checkbox.  If not, this command makes sure that all the
1361 items on this list level use the same bullet.  Furthermore, if this is
1362 an ordered list, make sure the numbering is OK.
1363 @kindex C-c -
1364 @item C-c -
1365 Cycle the entire list level through the different itemize/enumerate bullets
1366 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1367 argument N, select the Nth bullet from this list.  If there is an active
1368 region when calling this, all lines will be converted to list items.  If the
1369 first line already was a list item, any item markers will be removed from the
1370 list.  Finally, even without an active region, a normal line will be
1371 converted into a list item.
1372 @kindex S-@key{left}
1373 @kindex S-@key{right}
1374 @item S-@key{left}/@key{right}
1375 @vindex org-support-shift-select
1376 This command also cycles bullet styles when the cursor in on the bullet or
1377 anywhere in an item line, details depending on
1378 @code{org-support-shift-select}.
1379 @end table
1381 @node Drawers, Footnotes, Plain lists, Document Structure
1382 @section Drawers
1383 @cindex drawers
1384 @cindex visibility cycling, drawers
1386 @vindex org-drawers
1387 Sometimes you want to keep information associated with an entry, but you
1388 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1389 Drawers need to be configured with the variable
1390 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1391 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1392 look like this:
1394 @example
1395 ** This is a headline
1396    Still outside the drawer
1397    :DRAWERNAME:
1398       This is inside the drawer.
1399    :END:
1400    After the drawer.
1401 @end example
1403 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1404 show the entry, but keep the drawer collapsed to a single line.  In order to
1405 look inside the drawer, you need to move the cursor to the drawer line and
1406 press @key{TAB} there.  Org mode uses the @code{PROPERTIES} drawer for
1407 storing properties (@pxref{Properties and Columns}), and you can also arrange
1408 for state change notes @pxref{Tracking TODO state changes} and clock times
1409 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.
1411 @node Footnotes, Orgstruct mode, Drawers, Document Structure
1412 @section Footnotes
1413 @cindex footnotes
1415 Org-mode supports the creation of footnotes.  In contrast to the
1416 @file{footnote.el} package, Org-mode's footnotes are designed for work on a
1417 larger document, not only for one-off documents like emails.  The basic
1418 syntax is similar to the one used by @file{footnote.el}, i.e. a footnote is
1419 defined in a paragraph that is started by a footnote marker in square
1420 brackets in column 0, no indentation allowed.  If you need a paragraph break
1421 inside a footnote, use the LaTeX idiom @samp{\par}.  The footnote reference
1422 is simply the marker in square brackets, inside text.  For example:
1424 @example
1425 The Org homepage[fn:1] now looks a lot better than it used to.
1427 [fn:1] The link is: http://orgmode.org
1428 @end example
1430 Org-mode extends the number-based syntax to @emph{named} footnotes and
1431 optional inline definition.  Using plain numbers as markers (as
1432 @file{footnote.el} does) is supported for backward compatibility, but not
1433 encouraged because of possible conflicts with LaTeX snippets @pxref{Embedded
1434 LaTeX}.  Here are the valid references:
1436 @table @code
1437 @item [1]
1438 A plain numeric footnote marker.
1439 @item [fn:name]
1440 A named footnote reference, where @code{name} is a unique label word, or, for
1441 simplicity of automatic creation, a number.
1442 @item [fn:: This is the inline definition of this footnote]
1443 A LaTeX-like anonymous footnote where the definition is given directly at the
1444 reference point.
1445 @item [fn:name: a definition]
1446 An inline definition of a footnote, which also specifies a name for the note.
1447 Since Org allows multiple references to the same note, you can then use
1448 @code{[fn:name]} to create additional references.
1449 @end table
1451 @vindex org-footnote-auto-label
1452 Footnote labels can be created automatically, or you create names yourself.
1453 This is handled by the variable @code{org-footnote-auto-label} and its
1454 corresponding @code{#+STARTUP} keywords, see the docstring of that variable
1455 for details.
1457 @noindent The following command handles footnotes:
1459 @table @kbd
1460 @kindex C-c C-x f
1461 @item C-c C-x f
1462 The footnote action command.
1464 When the cursor is on a footnote reference, jump to the definition.  When it
1465 is at a definition, jump to the (first) reference.
1467 @vindex org-footnote-define-inline
1468 @vindex org-footnote-section
1469 Otherwise, create a new footnote.  Depending on the variable
1470 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1471 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1472 definition will be placed right into the text as part of the reference, or
1473 separately into the location determined by the variable
1474 @code{org-footnote-section}.
1476 When this command is called with a prefix argument, a menu of additional
1477 options is offered:
1478 @example
1479 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1480     @r{Org makes no effort to sort footnote definitions into a particular}
1481     @r{sequence.  If you want them sorted, use this command, which will}
1482     @r{also move entries according to @code{org-footnote-section}.}
1483 n   @r{Normalize the footnotes by collecting all definitions (including}
1484     @r{inline definitions) into a special section, and then numbering them}
1485     @r{in sequence.  The references will then also be numbers.  This is}
1486     @r{meant to be the final step before finishing a document (e.g. sending}
1487     @r{off an email).  The exporters do this automatically, and so could}
1488     @r{something like @code{message-send-hook}.}
1489 d   @r{Delete the footnote at point, and all definitions of and references}
1490     @r{to it.}
1491 @end example
1492 @kindex C-c C-c
1493 @item C-c C-c
1494 If the cursor is on a footnote reference, jump to the definition.  If it is a
1495 the definition, jump back to the reference.  When called at a footnote
1496 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1497 @kindex C-c C-o
1498 @kindex mouse-1
1499 @kindex mouse-2
1500 @item C-c C-c  @r{or} mouse-1/2
1501 Footnote labels are also links to the corresponding definition/reference, and
1502 you can use the usual commands to follow these links.
1503 @end table
1505 @node Orgstruct mode,  , Footnotes, Document Structure
1506 @section The Orgstruct minor mode
1507 @cindex Orgstruct mode
1508 @cindex minor mode for structure editing
1510 If you like the intuitive way the Org mode structure editing and list
1511 formatting works, you might want to use these commands in other modes like
1512 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
1513 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
1514 turn it on by default, for example in Mail mode, with one of:
1516 @lisp
1517 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1518 (add-hook 'mail-mode-hook 'turn-on-orgstruct++)
1519 @end lisp
1521 When this mode is active and the cursor is on a line that looks to Org like a
1522 headline or the first line of a list item, most structure editing commands
1523 will work, even if the same keys normally have different functionality in the
1524 major mode you are using.  If the cursor is not in one of those special
1525 lines, Orgstruct mode lurks silently in the shadow.  When you use
1526 @code{orgstruct++-mode}, Org will also export indentation and autofill
1527 settings into that mode, and detect item context after the first line of an
1528 item.
1530 @node Tables, Hyperlinks, Document Structure, Top
1531 @chapter Tables
1532 @cindex tables
1533 @cindex editing tables
1535 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1536 calculations are supported in connection with the Emacs @file{calc}
1537 package
1538 @ifinfo
1539 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1540 @end ifinfo
1541 @ifnotinfo
1542 (see the Emacs Calculator manual for more information about the Emacs
1543 calculator).
1544 @end ifnotinfo
1546 @menu
1547 * Built-in table editor::       Simple tables
1548 * Narrow columns::              Stop wasting space in tables
1549 * Column groups::               Grouping to trigger vertical lines
1550 * Orgtbl mode::                 The table editor as minor mode
1551 * The spreadsheet::             The table editor has spreadsheet capabilities
1552 * Org Plot::                    Plotting from org tables
1553 @end menu
1555 @node Built-in table editor, Narrow columns, Tables, Tables
1556 @section The built-in table editor
1557 @cindex table editor, built-in
1559 Org makes it easy to format tables in plain ASCII.  Any line with
1560 @samp{|} as the first non-whitespace character is considered part of a
1561 table.  @samp{|} is also the column separator.  A table might look like
1562 this:
1564 @example
1565 | Name  | Phone | Age |
1566 |-------+-------+-----|
1567 | Peter |  1234 |  17 |
1568 | Anna  |  4321 |  25 |
1569 @end example
1571 A table is re-aligned automatically each time you press @key{TAB} or
1572 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1573 the next field (@key{RET} to the next row) and creates new table rows
1574 at the end of the table or before horizontal lines.  The indentation
1575 of the table is set by the first line.  Any line starting with
1576 @samp{|-} is considered as a horizontal separator line and will be
1577 expanded on the next re-align to span the whole table width.  So, to
1578 create the above table, you would only type
1580 @example
1581 |Name|Phone|Age|
1583 @end example
1585 @noindent and then press @key{TAB} to align the table and start filling in
1586 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
1587 @kbd{C-c @key{RET}}.
1589 @vindex org-enable-table-editor
1590 @vindex org-table-auto-blank-field
1591 When typing text into a field, Org treats @key{DEL},
1592 @key{Backspace}, and all character keys in a special way, so that
1593 inserting and deleting avoids shifting other fields.  Also, when
1594 typing @emph{immediately after the cursor was moved into a new field
1595 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1596 field is automatically made blank.  If this behavior is too
1597 unpredictable for you, configure the variables
1598 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1600 @table @kbd
1601 @tsubheading{Creation and conversion}
1602 @kindex C-c |
1603 @item C-c |
1604 Convert the active region to table. If every line contains at least one
1605 TAB character, the function assumes that the material is tab separated.
1606 If every line contains a comma, comma-separated values (CSV) are assumed.
1607 If not, lines are split at whitespace into fields.  You can use a prefix
1608 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1609 C-u} forces TAB, and a numeric argument N indicates that at least N
1610 consecutive spaces, or alternatively a TAB will be the separator.
1612 If there is no active region, this command creates an empty Org
1613 table.  But it's easier just to start typing, like
1614 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1616 @tsubheading{Re-aligning and field motion}
1617 @kindex C-c C-c
1618 @item C-c C-c
1619 Re-align the table without moving the cursor.
1621 @kindex @key{TAB}
1622 @item @key{TAB}
1623 Re-align the table, move to the next field.  Creates a new row if
1624 necessary.
1626 @kindex S-@key{TAB}
1627 @item S-@key{TAB}
1628 Re-align, move to previous field.
1630 @kindex @key{RET}
1631 @item @key{RET}
1632 Re-align the table and move down to next row.  Creates a new row if
1633 necessary.  At the beginning or end of a line, @key{RET} still does
1634 NEWLINE, so it can be used to split a table.
1636 @tsubheading{Column and row editing}
1637 @kindex M-@key{left}
1638 @kindex M-@key{right}
1639 @item M-@key{left}
1640 @itemx M-@key{right}
1641 Move the current column left/right.
1643 @kindex M-S-@key{left}
1644 @item M-S-@key{left}
1645 Kill the current column.
1647 @kindex M-S-@key{right}
1648 @item M-S-@key{right}
1649 Insert a new column to the left of the cursor position.
1651 @kindex M-@key{up}
1652 @kindex M-@key{down}
1653 @item M-@key{up}
1654 @itemx M-@key{down}
1655 Move the current row up/down.
1657 @kindex M-S-@key{up}
1658 @item M-S-@key{up}
1659 Kill the current row or horizontal line.
1661 @kindex M-S-@key{down}
1662 @item M-S-@key{down}
1663 Insert a new row above the current row.  With a prefix argument, the line is
1664 created below the current one.
1666 @kindex C-c -
1667 @item C-c -
1668 Insert a horizontal line below current row.  With a prefix argument, the line
1669 is created above the current line.
1671 @kindex C-c @key{RET}
1672 @item C-c @key{RET}
1673 Insert a horizontal line below current row, and move the cursor into the row
1674 below that line.
1676 @kindex C-c ^
1677 @item C-c ^
1678 Sort the table lines in the region.  The position of point indicates the
1679 column to be used for sorting, and the range of lines is the range
1680 between the nearest horizontal separator lines, or the entire table.  If
1681 point is before the first column, you will be prompted for the sorting
1682 column.  If there is an active region, the mark specifies the first line
1683 and the sorting column, while point should be in the last line to be
1684 included into the sorting.  The command prompts for the sorting type
1685 (alphabetically, numerically, or by time).  When called with a prefix
1686 argument, alphabetic sorting will be case-sensitive.
1688 @tsubheading{Regions}
1689 @kindex C-c C-x M-w
1690 @item C-c C-x M-w
1691 Copy a rectangular region from a table to a special clipboard.  Point
1692 and mark determine edge fields of the rectangle.  The process ignores
1693 horizontal separator lines.
1695 @kindex C-c C-x C-w
1696 @item C-c C-x C-w
1697 Copy a rectangular region from a table to a special clipboard, and
1698 blank all fields in the rectangle.  So this is the ``cut'' operation.
1700 @kindex C-c C-x C-y
1701 @item C-c C-x C-y
1702 Paste a rectangular region into a table.
1703 The upper left corner ends up in the current field.  All involved fields
1704 will be overwritten.  If the rectangle does not fit into the present table,
1705 the table is enlarged as needed.  The process ignores horizontal separator
1706 lines.
1708 @kindex M-@key{RET}
1709 @itemx M-@kbd{RET}
1710 Wrap several fields in a column like a paragraph.  If there is an active
1711 region, and both point and mark are in the same column, the text in the
1712 column is wrapped to minimum width for the given number of lines.  A numeric
1713 prefix argument may be used to change the number of desired lines.  If there
1714 is no region, the current field is split at the cursor position and the text
1715 fragment to the right of the cursor is prepended to the field one line
1716 down. If there is no region, but you specify a prefix argument, the current
1717 field is made blank, and the content is appended to the field above.
1719 @tsubheading{Calculations}
1720 @cindex formula, in tables
1721 @cindex calculations, in tables
1722 @cindex region, active
1723 @cindex active region
1724 @cindex Transient mark mode
1725 @kindex C-c +
1726 @item C-c +
1727 Sum the numbers in the current column, or in the rectangle defined by
1728 the active region.  The result is shown in the echo area and can
1729 be inserted with @kbd{C-y}.
1731 @kindex S-@key{RET}
1732 @item S-@key{RET}
1733 @vindex org-table-copy-increment
1734 When current field is empty, copy from first non-empty field above.  When not
1735 empty, copy current field down to next row and move cursor along with it.
1736 Depending on the variable @code{org-table-copy-increment}, integer field
1737 values will be incremented during copy.  Integers that are too large will not
1738 be incremented.  Also, a @code{0} prefix argument temporarily disables the
1739 increment.  This key is also used by CUA mode (@pxref{Cooperation}).
1741 @tsubheading{Miscellaneous}
1742 @kindex C-c `
1743 @item C-c `
1744 Edit the current field in a separate window.  This is useful for fields
1745 that are not fully visible (@pxref{Narrow columns}).  When called with a
1746 @kbd{C-u} prefix, just make the full field visible, so that it can be
1747 edited in place.
1749 @item M-x org-table-import
1750 Import a file as a table.  The table should be TAB- or whitespace
1751 separated.  Useful, for example, to import a spreadsheet table or data
1752 from a database, because these programs generally can write
1753 TAB-separated text files.  This command works by inserting the file into
1754 the buffer and then converting the region to a table.  Any prefix
1755 argument is passed on to the converter, which uses it to determine the
1756 separator.
1757 @item C-c |
1758 Tables can also be imported by pasting tabular text into the Org
1759 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1760 @kbd{C-c |} command (see above under @i{Creation and conversion}).
1762 @item M-x org-table-export
1763 @vindex org-table-export-default-format
1764 Export the table, by default as a TAB-separated file.  Useful for data
1765 exchange with, for example, spreadsheet or database programs.  The format
1766 used to export the file can be configured in the variable
1767 @code{org-table-export-default-format}.  You may also use properties
1768 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1769 name and the format for table export in a subtree.  Org supports quite
1770 general formats for exported tables.  The exporter format is the same as the
1771 format used by Orgtbl radio tables, see @ref{Translator functions} for a
1772 detailed description.
1773 @end table
1775 If you don't like the automatic table editor because it gets in your
1776 way on lines which you would like to start with @samp{|}, you can turn
1777 it off with
1779 @lisp
1780 (setq org-enable-table-editor nil)
1781 @end lisp
1783 @noindent Then the only table command that still works is
1784 @kbd{C-c C-c} to do a manual re-align.
1786 @node Narrow columns, Column groups, Built-in table editor, Tables
1787 @section Narrow columns
1788 @cindex narrow columns in tables
1790 The width of columns is automatically determined by the table editor.
1791 Sometimes a single field or a few fields need to carry more text,
1792 leading to inconveniently wide columns.  To limit@footnote{This feature
1793 does not work on XEmacs.} the width of a column, one field anywhere in
1794 the column may contain just the string @samp{<N>} where @samp{N} is an
1795 integer specifying the width of the column in characters.  The next
1796 re-align will then set the width of this column to no more than this
1797 value.
1799 @example
1800 @group
1801 |---+------------------------------|               |---+--------|
1802 |   |                              |               |   | <6>    |
1803 | 1 | one                          |               | 1 | one    |
1804 | 2 | two                          |     ----\     | 2 | two    |
1805 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1806 | 4 | four                         |               | 4 | four   |
1807 |---+------------------------------|               |---+--------|
1808 @end group
1809 @end example
1811 @noindent
1812 Fields that are wider become clipped and end in the string @samp{=>}.
1813 Note that the full text is still in the buffer, it is only invisible.
1814 To see the full text, hold the mouse over the field - a tool-tip window
1815 will show the full content.  To edit such a field, use the command
1816 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1817 open a new window with the full field.  Edit it and finish with @kbd{C-c
1818 C-c}.
1820 @vindex org-startup-align-all-tables
1821 When visiting a file containing a table with narrowed columns, the
1822 necessary character hiding has not yet happened, and the table needs to
1823 be aligned before it looks nice.  Setting the option
1824 @code{org-startup-align-all-tables} will realign all tables in a file
1825 upon visiting, but also slow down startup.  You can also set this option
1826 on a per-file basis with:
1828 @example
1829 #+STARTUP: align
1830 #+STARTUP: noalign
1831 @end example
1833 @node Column groups, Orgtbl mode, Narrow columns, Tables
1834 @section Column groups
1835 @cindex grouping columns in tables
1837 When Org exports tables, it does so by default without vertical
1838 lines because that is visually more satisfying in general.  Occasionally
1839 however, vertical lines can be useful to structure a table into groups
1840 of columns, much like horizontal lines can do for groups of rows.  In
1841 order to specify column groups, you can use a special row where the
1842 first field contains only @samp{/}.  The further fields can either
1843 contain @samp{<} to indicate that this column should start a group,
1844 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1845 a group of its own.  Boundaries between column groups will upon export be
1846 marked with vertical lines.  Here is an example:
1848 @example
1849 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1850 |---+----+-----+-----+-----+---------+------------|
1851 | / | <> |   < |     |   > |       < |          > |
1852 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1853 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1854 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1855 |---+----+-----+-----+-----+---------+------------|
1856 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2)))
1857 @end example
1859 It is also sufficient to just insert the column group starters after
1860 every vertical line you'd like to have:
1862 @example
1863 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1864 |----+-----+-----+-----+---------+------------|
1865 | /  | <   |     |     | <       |            |
1866 @end example
1868 @node Orgtbl mode, The spreadsheet, Column groups, Tables
1869 @section The Orgtbl minor mode
1870 @cindex Orgtbl mode
1871 @cindex minor mode for tables
1873 If you like the intuitive way the Org table editor works, you
1874 might also want to use it in other modes like Text mode or Mail mode.
1875 The minor mode Orgtbl mode makes this possible.  You can always toggle
1876 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1877 example in mail mode, use
1879 @lisp
1880 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1881 @end lisp
1883 Furthermore, with some special setup, it is possible to maintain tables
1884 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
1885 construct La@TeX{} tables with the underlying ease and power of
1886 Orgtbl mode, including spreadsheet capabilities.  For details, see
1887 @ref{Tables in arbitrary syntax}.
1889 @node The spreadsheet, Org Plot, Orgtbl mode, Tables
1890 @section The spreadsheet
1891 @cindex calculations, in tables
1892 @cindex spreadsheet capabilities
1893 @cindex @file{calc} package
1895 The table editor makes use of the Emacs @file{calc} package to implement
1896 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1897 derive fields from other fields.  While fully featured, Org's
1898 implementation is not identical to other spreadsheets.  For example,
1899 Org knows the concept of a @emph{column formula} that will be
1900 applied to all non-header fields in a column without having to copy the
1901 formula to each relevant field.
1903 @menu
1904 * References::                  How to refer to another field or range
1905 * Formula syntax for Calc::     Using Calc to compute stuff
1906 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1907 * Field formulas::              Formulas valid for a single field
1908 * Column formulas::             Formulas valid for an entire column
1909 * Editing and debugging formulas::  Fixing formulas
1910 * Updating the table::          Recomputing all dependent fields
1911 * Advanced features::           Field names, parameters and automatic recalc
1912 @end menu
1914 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1915 @subsection References
1916 @cindex references
1918 To compute fields in the table from other fields, formulas must
1919 reference other fields or ranges.  In Org, fields can be referenced
1920 by name, by absolute coordinates, and by relative coordinates.  To find
1921 out what the coordinates of a field are, press @kbd{C-c ?} in that
1922 field, or press @kbd{C-c @}} to toggle the display of a grid.
1924 @subsubheading Field references
1925 @cindex field references
1926 @cindex references, to fields
1928 Formulas can reference the value of another field in two ways.  Like in
1929 any other spreadsheet, you may reference fields with a letter/number
1930 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1931 @c Such references are always fixed to that field, they don't change
1932 @c when you copy and paste a formula to a different field.  So
1933 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1935 @noindent
1936 Org also uses another, more general operator that looks like this:
1937 @example
1938 @@row$column
1939 @end example
1941 @noindent
1942 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1943 or relative to the current column like @samp{+1} or @samp{-2}.
1945 The row specification only counts data lines and ignores horizontal
1946 separator lines (hlines).  You can use absolute row numbers
1947 @samp{1}...@samp{N}, and row numbers relative to the current row like
1948 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1949 hlines: @samp{I} refers to the first hline@footnote{Note that only
1950 hlines are counted that @emph{separate} table lines.  If the table
1951 starts with a hline above the header, it does not count.}, @samp{II} to
1952 the second etc.  @samp{-I} refers to the first such line above the
1953 current line, @samp{+I} to the first such line below the current line.
1954 You can also write @samp{III+2} which is the second data line after the
1955 third hline in the table.  Relative row numbers like @samp{-3} will not
1956 cross hlines if the current line is too close to the hline.  Instead,
1957 the value directly at the hline is used.
1959 @samp{0} refers to the current row and column.  Also, if you omit
1960 either the column or the row part of the reference, the current
1961 row/column is implied.
1963 Org's references with @emph{unsigned} numbers are fixed references
1964 in the sense that if you use the same reference in the formula for two
1965 different fields, the same field will be referenced each time.
1966 Org's references with @emph{signed} numbers are floating
1967 references because the same reference operator can reference different
1968 fields depending on the field being calculated by the formula.
1970 As a special case references like @samp{$LR5} and @samp{$LR12} can be used to
1971 refer in a stable way to the 5th and 12th field in the last row of the
1972 table.
1974 Here are a few examples:
1976 @example
1977 @@2$3      @r{2nd row, 3rd column}
1978 C2        @r{same as previous}
1979 $5        @r{column 5 in the current row}
1980 E&        @r{same as previous}
1981 @@2        @r{current column, row 2}
1982 @@-1$-3    @r{the field one row up, three columns to the left}
1983 @@-I$2     @r{field just under hline above current row, column 2}
1984 @end example
1986 @subsubheading Range references
1987 @cindex range references
1988 @cindex references, to ranges
1990 You may reference a rectangular range of fields by specifying two field
1991 references connected by two dots @samp{..}.  If both fields are in the
1992 current row, you may simply use @samp{$2..$7}, but if at least one field
1993 is in a different row, you need to use the general @code{@@row$column}
1994 format at least for the first field (i.e the reference must start with
1995 @samp{@@} in order to be interpreted correctly).  Examples:
1997 @example
1998 $1..$3        @r{First three fields in the current row.}
1999 $P..$Q        @r{Range, using column names (see under Advanced)}
2000 @@2$1..@@4$3    @r{6 fields between these two fields.}
2001 A2..C4        @r{Same as above.}
2002 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
2003 @end example
2005 @noindent Range references return a vector of values that can be fed
2006 into Calc vector functions.  Empty fields in ranges are normally
2007 suppressed, so that the vector contains only the non-empty fields (but
2008 see the @samp{E} mode switch below).  If there are no non-empty fields,
2009 @samp{[0]} is returned to avoid syntax errors in formulas.
2011 @subsubheading Named references
2012 @cindex named references
2013 @cindex references, named
2014 @cindex name, of column or field
2015 @cindex constants, in calculations
2017 @vindex org-table-formula-constants
2018 @samp{$name} is interpreted as the name of a column, parameter or
2019 constant.  Constants are defined globally through the variable
2020 @code{org-table-formula-constants}, and locally (for the file) through a
2021 line like
2023 @example
2024 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2025 @end example
2027 @noindent
2028 @vindex constants-unit-system
2029 Also properties (@pxref{Properties and Columns}) can be used as
2030 constants in table formulas: For a property @samp{:Xyz:} use the name
2031 @samp{$PROP_Xyz}, and the property will be searched in the current
2032 outline entry and in the hierarchy above it.  If you have the
2033 @file{constants.el} package, it will also be used to resolve constants,
2034 including natural constants like @samp{$h} for Planck's constant, and
2035 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
2036 supply the values of constants in two different unit systems, @code{SI}
2037 and @code{cgs}.  Which one is used depends on the value of the variable
2038 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2039 @code{constSI} and @code{constcgs} to set this value for the current
2040 buffer.}.  Column names and parameters can be specified in special table
2041 lines.  These are described below, see @ref{Advanced features}.  All
2042 names must start with a letter, and further consist of letters and
2043 numbers.
2045 @subsubheading Remote references
2046 @cindex remote references
2047 @cindex references, remote
2048 @cindex references, to a different table
2049 @cindex name, of column or field
2050 @cindex constants, in calculations
2052 You may also reference constants, fields and ranges from a different table,
2053 either in the current file or even in a different file.  The syntax is
2055 @example
2056 remote(NAME-OR-ID,REF)
2057 @end example
2059 @noindent
2060 where NAME can be the name of a table in the current file as set by a
2061 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2062 entry, even in a different file, and the reference then refers to the first
2063 table in that entry.  REF is an absolute field or range reference as
2064 described above, valid in the referenced table.
2066 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2067 @subsection Formula syntax for Calc
2068 @cindex formula syntax, Calc
2069 @cindex syntax, of formulas
2071 A formula can be any algebraic expression understood by the Emacs
2072 @file{Calc} package.  @b{Note that @file{calc} has the
2073 non-standard convention that @samp{/} has lower precedence than
2074 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2075 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2076 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
2077 Emacs Calc Manual}),
2078 @c FIXME:  The link to the Calc manual in HTML does not work.
2079 variable substitution takes place according to the rules described above.
2080 @cindex vectors, in table calculations
2081 The range vectors can be directly fed into the Calc vector functions
2082 like @samp{vmean} and @samp{vsum}.
2084 @cindex format specifier
2085 @cindex mode, for @file{calc}
2086 @vindex org-calc-default-modes
2087 A formula can contain an optional mode string after a semicolon.  This
2088 string consists of flags to influence Calc and other modes during
2089 execution.  By default, Org uses the standard Calc modes (precision
2090 12, angular units degrees, fraction and symbolic modes off).  The display
2091 format, however, has been changed to @code{(float 5)} to keep tables
2092 compact.  The default settings can be configured using the variable
2093 @code{org-calc-default-modes}.
2095 @example
2096 p20           @r{switch the internal precision to 20 digits}
2097 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
2098 D R           @r{angle modes: degrees, radians}
2099 F S           @r{fraction and symbolic modes}
2100 N             @r{interpret all fields as numbers, use 0 for non-numbers}
2101 T             @r{force text interpretation}
2102 E             @r{keep empty fields in ranges}
2103 @end example
2105 @noindent
2106 In addition, you may provide a @code{printf} format specifier to
2107 reformat the final result.  A few examples:
2109 @example
2110 $1+$2                @r{Sum of first and second field}
2111 $1+$2;%.2f           @r{Same, format result to two decimals}
2112 exp($2)+exp($1)      @r{Math functions can be used}
2113 $0;%.1f              @r{Reformat current cell to 1 decimal}
2114 ($3-32)*5/9          @r{Degrees F -> C conversion}
2115 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2116 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2117 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2118 vmean($2..$7)        @r{Compute column range mean, using vector function}
2119 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2120 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
2121 @end example
2123 Calc also contains a complete set of logical operations.  For example
2125 @example
2126 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
2127 @end example
2129 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
2130 @subsection Emacs Lisp forms as formulas
2131 @cindex Lisp forms, as table formulas
2133 It is also possible to write a formula in Emacs Lisp; this can be useful
2134 for string manipulation and control structures, if Calc's
2135 functionality is not enough.  If a formula starts with a single quote
2136 followed by an opening parenthesis, then it is evaluated as a lisp form.
2137 The evaluation should return either a string or a number.  Just as with
2138 @file{calc} formulas, you can specify modes and a printf format after a
2139 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
2140 field references are interpolated into the form.  By default, a
2141 reference will be interpolated as a Lisp string (in double quotes)
2142 containing the field.  If you provide the @samp{N} mode switch, all
2143 referenced elements will be numbers (non-number fields will be zero) and
2144 interpolated as Lisp numbers, without quotes.  If you provide the
2145 @samp{L} flag, all fields will be interpolated literally, without quotes.
2146 I.e., if you want a reference to be interpreted as a string by the Lisp
2147 form, enclose the reference operator itself in double quotes, like
2148 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
2149 embed them in list or vector syntax.  A few examples, note how the
2150 @samp{N} mode is used when we do computations in lisp.
2152 @example
2153 @r{Swap the first two characters of the content of column 1}
2154   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2155 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2156   '(+ $1 $2);N
2157 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
2158   '(apply '+ '($1..$4));N
2159 @end example
2161 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
2162 @subsection Field formulas
2163 @cindex field formula
2164 @cindex formula, for individual table field
2166 To assign a formula to a particular field, type it directly into the
2167 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
2168 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
2169 the field, the formula will be stored as the formula for this field,
2170 evaluated, and the current field replaced with the result.
2172 Formulas are stored in a special line starting with @samp{#+TBLFM:}
2173 directly below the table.  If you typed the equation in the 4th field of
2174 the 3rd data line in the table, the formula will look like
2175 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
2176 with the appropriate commands, @i{absolute references} (but not relative
2177 ones) in stored formulas are modified in order to still reference the
2178 same field.  Of cause this is not true if you edit the table structure
2179 with normal editing commands - then you must fix the equations yourself.
2180 The left hand side of a formula may also be a named field (@pxref{Advanced
2181 features}), or a last-row reference like @samp{$LR3}.
2183 Instead of typing an equation into the field, you may also use the
2184 following command
2186 @table @kbd
2187 @kindex C-u C-c =
2188 @item C-u C-c =
2189 Install a new formula for the current field.  The command prompts for a
2190 formula, with default taken from the @samp{#+TBLFM:} line, applies
2191 it to the current field and stores it.
2192 @end table
2194 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
2195 @subsection Column formulas
2196 @cindex column formula
2197 @cindex formula, for table column
2199 Often in a table, the same formula should be used for all fields in a
2200 particular column.  Instead of having to copy the formula to all fields
2201 in that column, Org allows to assign a single formula to an entire
2202 column.  If the table contains horizontal separator hlines, everything
2203 before the first such line is considered part of the table @emph{header}
2204 and will not be modified by column formulas.
2206 To assign a formula to a column, type it directly into any field in the
2207 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2208 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2209 the formula will be stored as the formula for the current column, evaluated
2210 and the current field replaced with the result.  If the field contains only
2211 @samp{=}, the previously stored formula for this column is used.  For each
2212 column, Org will only remember the most recently used formula.  In the
2213 @samp{TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The left
2214 hand side of a column formula can currently not be the name of column, it
2215 must be the numeric column reference.
2217 Instead of typing an equation into the field, you may also use the
2218 following command:
2220 @table @kbd
2221 @kindex C-c =
2222 @item C-c =
2223 Install a new formula for the current column and replace current field with
2224 the result of the formula.  The command prompts for a formula, with default
2225 taken from the @samp{#+TBLFM} line, applies it to the current field and
2226 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
2227 will apply it to that many consecutive fields in the current column.
2228 @end table
2230 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2231 @subsection Editing and debugging formulas
2232 @cindex formula editing
2233 @cindex editing, of table formulas
2235 @vindex org-table-use-standard-references
2236 You can edit individual formulas in the minibuffer or directly in the
2237 field.  Org can also prepare a special buffer with all active
2238 formulas of a table.  When offering a formula for editing, Org
2239 converts references to the standard format (like @code{B3} or @code{D&})
2240 if possible.  If you prefer to only work with the internal format (like
2241 @code{@@3$2} or @code{$4}), configure the variable
2242 @code{org-table-use-standard-references}.
2244 @table @kbd
2245 @kindex C-c =
2246 @kindex C-u C-c =
2247 @item C-c =
2248 @itemx C-u C-c =
2249 Edit the formula associated with the current column/field in the
2250 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
2251 @kindex C-u C-u C-c =
2252 @item C-u C-u C-c =
2253 Re-insert the active formula (either a
2254 field formula, or a column formula) into the current field, so that you
2255 can edit it directly in the field.  The advantage over editing in the
2256 minibuffer is that you can use the command @kbd{C-c ?}.
2257 @kindex C-c ?
2258 @item C-c ?
2259 While editing a formula in a table field, highlight the field(s)
2260 referenced by the reference at the cursor position in the formula.
2261 @kindex C-c @}
2262 @item C-c @}
2263 Toggle the display of row and column numbers for a table, using
2264 overlays.  These are updated each time the table is aligned, you can
2265 force it with @kbd{C-c C-c}.
2266 @kindex C-c @{
2267 @item C-c @{
2268 Toggle the formula debugger on and off.  See below.
2269 @kindex C-c '
2270 @item C-c '
2271 Edit all formulas for the current table in a special buffer, where the
2272 formulas will be displayed one per line.  If the current field has an
2273 active formula, the cursor in the formula editor will mark it.
2274 While inside the special buffer, Org will automatically highlight
2275 any field or range reference at the cursor position.  You may edit,
2276 remove and add formulas, and use the following commands:
2277 @table @kbd
2278 @kindex C-c C-c
2279 @kindex C-x C-s
2280 @item C-c C-c
2281 @itemx C-x C-s
2282 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2283 prefix, also apply the new formulas to the entire table.
2284 @kindex C-c C-q
2285 @item C-c C-q
2286 Exit the formula editor without installing changes.
2287 @kindex C-c C-r
2288 @item C-c C-r
2289 Toggle all references in the formula editor between standard (like
2290 @code{B3}) and internal (like @code{@@3$2}).
2291 @kindex @key{TAB}
2292 @item @key{TAB}
2293 Pretty-print or indent lisp formula at point.  When in a line containing
2294 a lisp formula, format the formula according to Emacs Lisp rules.
2295 Another @key{TAB} collapses the formula back again.  In the open
2296 formula, @key{TAB} re-indents just like in Emacs lisp mode.
2297 @kindex M-@key{TAB}
2298 @item M-@key{TAB}
2299 Complete Lisp symbols, just like in Emacs lisp mode.
2300 @kindex S-@key{up}
2301 @kindex S-@key{down}
2302 @kindex S-@key{left}
2303 @kindex S-@key{right}
2304 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2305 Shift the reference at point.  For example, if the reference is
2306 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2307 This also works for relative references, and for hline references.
2308 @kindex M-S-@key{up}
2309 @kindex M-S-@key{down}
2310 @item M-S-@key{up}/@key{down}
2311 Move the test line for column formulas in the Org buffer up and
2312 down.
2313 @kindex M-@key{up}
2314 @kindex M-@key{down}
2315 @item M-@key{up}/@key{down}
2316 Scroll the window displaying the table.
2317 @kindex C-c @}
2318 @item C-c @}
2319 Turn the coordinate grid in the table on and off.
2320 @end table
2321 @end table
2323 Making a table field blank does not remove the formula associated with
2324 the field, because that is stored in a different line (the @samp{TBLFM}
2325 line) - during the next recalculation the field will be filled again.
2326 To remove a formula from a field, you have to give an empty reply when
2327 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2329 @kindex C-c C-c
2330 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2331 equations with @kbd{C-c C-c} in that line, or with the normal
2332 recalculation commands in the table.
2334 @subsubheading Debugging formulas
2335 @cindex formula debugging
2336 @cindex debugging, of table formulas
2337 When the evaluation of a formula leads to an error, the field content
2338 becomes the string @samp{#ERROR}.  If you would like see what is going
2339 on during variable substitution and calculation in order to find a bug,
2340 turn on formula debugging in the @code{Tbl} menu and repeat the
2341 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2342 field.  Detailed information will be displayed.
2344 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2345 @subsection Updating the table
2346 @cindex recomputing table fields
2347 @cindex updating, table
2349 Recalculation of a table is normally not automatic, but needs to be
2350 triggered by a command.  See @ref{Advanced features} for a way to make
2351 recalculation at least semi-automatically.
2353 In order to recalculate a line of a table or the entire table, use the
2354 following commands:
2356 @table @kbd
2357 @kindex C-c *
2358 @item C-c *
2359 Recalculate the current row by first applying the stored column formulas
2360 from left to right, and all field formulas in the current row.
2362 @kindex C-u C-c *
2363 @item C-u C-c *
2364 @kindex C-u C-c C-c
2365 @itemx C-u C-c C-c
2366 Recompute the entire table, line by line.  Any lines before the first
2367 hline are left alone, assuming that these are part of the table header.
2369 @kindex C-u C-u C-c *
2370 @kindex C-u C-u C-c C-c
2371 @item C-u C-u C-c *
2372 @itemx C-u C-u C-c C-c
2373 Iterate the table by recomputing it until no further changes occur.
2374 This may be necessary if some computed fields use the value of other
2375 fields that are computed @i{later} in the calculation sequence.
2376 @end table
2378 @node Advanced features,  , Updating the table, The spreadsheet
2379 @subsection Advanced features
2381 If you want the recalculation of fields to happen automatically, or if
2382 you want to be able to assign @i{names} to fields and columns, you need
2383 to reserve the first column of the table for special marking characters.
2384 @table @kbd
2385 @kindex C-#
2386 @item C-#
2387 Rotate the calculation mark in first column through the states @samp{},
2388 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
2389 change all marks in the region.
2390 @end table
2392 Here is an example of a table that collects exam results of students and
2393 makes use of these features:
2395 @example
2396 @group
2397 |---+---------+--------+--------+--------+-------+------|
2398 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2399 |---+---------+--------+--------+--------+-------+------|
2400 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2401 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2402 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2403 |---+---------+--------+--------+--------+-------+------|
2404 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2405 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2406 |---+---------+--------+--------+--------+-------+------|
2407 |   | Average |        |        |        |  29.7 |      |
2408 | ^ |         |        |        |        |    at |      |
2409 | $ | max=50  |        |        |        |       |      |
2410 |---+---------+--------+--------+--------+-------+------|
2411 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2412 @end group
2413 @end example
2415 @noindent @b{Important}: Please note that for these special tables,
2416 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2417 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2418 to the field itself.  The column formulas are not applied in rows with
2419 empty first field.
2421 @cindex marking characters, tables
2422 The marking characters have the following meaning:
2423 @table @samp
2424 @item !
2425 The fields in this line define names for the columns, so that you may
2426 refer to a column as @samp{$Tot} instead of @samp{$6}.
2427 @item ^
2428 This row defines names for the fields @emph{above} the row.  With such
2429 a definition, any formula in the table may use @samp{$m1} to refer to
2430 the value @samp{10}.  Also, if you assign a formula to a names field, it
2431 will be stored as @samp{$name=...}.
2432 @item _
2433 Similar to @samp{^}, but defines names for the fields in the row
2434 @emph{below}.
2435 @item $
2436 Fields in this row can define @emph{parameters} for formulas.  For
2437 example, if a field in a @samp{$} row contains @samp{max=50}, then
2438 formulas in this table can refer to the value 50 using @samp{$max}.
2439 Parameters work exactly like constants, only that they can be defined on
2440 a per-table basis.
2441 @item #
2442 Fields in this row are automatically recalculated when pressing
2443 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2444 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2445 lines will be left alone by this command.
2446 @item *
2447 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2448 not for automatic recalculation.  Use this when automatic
2449 recalculation slows down editing too much.
2450 @item
2451 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2452 All lines that should be recalculated should be marked with @samp{#}
2453 or @samp{*}.
2454 @item /
2455 Do not export this line.  Useful for lines that contain the narrowing
2456 @samp{<N>} markers.
2457 @end table
2459 Finally, just to whet your appetite on what can be done with the
2460 fantastic @file{calc} package, here is a table that computes the Taylor
2461 series of degree @code{n} at location @code{x} for a couple of
2462 functions.
2464 @example
2465 @group
2466 |---+-------------+---+-----+--------------------------------------|
2467 |   | Func        | n | x   | Result                               |
2468 |---+-------------+---+-----+--------------------------------------|
2469 | # | exp(x)      | 1 | x   | 1 + x                                |
2470 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2471 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2472 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2473 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2474 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2475 |---+-------------+---+-----+--------------------------------------|
2476 #+TBLFM: $5=taylor($2,$4,$3);n3
2477 @end group
2478 @end example
2480 @page
2481 @node Org Plot,  , The spreadsheet, Tables
2482 @section Org Plot
2483 @cindex graph, in tables
2484 @cindex plot tables using gnuplot
2486 Org Plot can produce 2D and 3D graphs of information stored in org tables
2487 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
2488 @uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html}.  To see
2489 this in action ensure that you have both Gnuplot and Gnuplot-mode installed
2490 on your system, then call @code{org-plot/gnuplot} on the following table.
2492 @example
2493 @group
2494 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2495 | Sede      | Max cites | H-index |
2496 |-----------+-----------+---------|
2497 | Chile     |    257.72 |   21.39 |
2498 | Leeds     |    165.77 |   19.68 |
2499 | Sao Paolo |     71.00 |   11.50 |
2500 | Stockholm |    134.19 |   14.33 |
2501 | Morelia   |    257.56 |   17.67 |
2502 @end group
2503 @end example
2505 Notice that Org Plot is smart enough to apply the tables headers as labels.
2506 Further control over the labels, type, content, and appearance of plots can
2507 be exercised through the @code{#+Plot:} lines preceding a table.  See below
2508 for a complete list of Org plot options.  For more information and examples
2509 see the org-plot tutorial at
2510 @uref{http://orgmode.org/worg/org-tutorials/org-plot.php}.
2512 @subsubheading Plot Options
2514 @table @code
2515 @item set
2516 Specify any @file{gnuplot} option to be set when graphing.
2518 @item title
2519 Specify the title of the plot.
2521 @item ind
2522 Specify which column of the table to use as the @code{x} axis.
2524 @item deps
2525 Specify the columns to graph as a lisp style list, surrounded by parenthesis
2526 and separated by spaces for example @code{dep:(3 4)} to graph the third and
2527 fourth columns (defaults to graphing all other columns aside from the ind
2528 column).
2530 @item type
2531 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
2533 @item with
2534 Specify a @code{with} option to be inserted for every col being plotted
2535 (e.g. @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
2536 Defaults to 'lines'.
2538 @item file
2539 If you want to plot to a file specify the @code{"path/to/desired/output-file"}.
2541 @item labels
2542 List of labels to be used for the deps (defaults to column headers if they
2543 exist).
2545 @item line
2546 Specify an entire line to be inserted in the gnuplot script.
2548 @item map
2549 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
2550 flat mapping rather than a @code{3d} slope.
2552 @item timefmt
2553 Specify format of org-mode timestamps as they will be parsed by gnuplot.
2554 Defaults to '%Y-%m-%d-%H:%M:%S'.
2556 @item script
2557 If you want total control you can specify a script file (place the file name
2558 between double quotes) which will be used to plot.  Before plotting, every
2559 instance of @code{$datafile} in the specified script will be replaced with
2560 the path to the generated data file.  Note even if you set this option you
2561 may still want to specify the plot type, as that can impact the content of
2562 the data file.
2563 @end table
2565 @node Hyperlinks, TODO Items, Tables, Top
2566 @chapter Hyperlinks
2567 @cindex hyperlinks
2569 Like HTML, Org provides links inside a file, external links to
2570 other files, Usenet articles, emails, and much more.
2572 @menu
2573 * Link format::                 How links in Org are formatted
2574 * Internal links::              Links to other places in the current file
2575 * External links::              URL-like links to the world
2576 * Handling links::              Creating, inserting and following
2577 * Using links outside Org::     Linking from my C source code?
2578 * Link abbreviations::          Shortcuts for writing complex links
2579 * Search options::              Linking to a specific location
2580 * Custom searches::             When the default search is not enough
2581 @end menu
2583 @node Link format, Internal links, Hyperlinks, Hyperlinks
2584 @section Link format
2585 @cindex link format
2586 @cindex format, of links
2588 Org will recognize plain URL-like links and activate them as
2589 clickable links.  The general link format, however, looks like this:
2591 @example
2592 [[link][description]]       @r{or alternatively}           [[link]]
2593 @end example
2595 Once a link in the buffer is complete (all brackets present), Org
2596 will change the display so that @samp{description} is displayed instead
2597 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2598 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2599 which by default is an underlined face.  You can directly edit the
2600 visible part of a link.  Note that this can be either the @samp{link}
2601 part (if there is no description) or the @samp{description} part.  To
2602 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2603 cursor on the link.
2605 If you place the cursor at the beginning or just behind the end of the
2606 displayed text and press @key{BACKSPACE}, you will remove the
2607 (invisible) bracket at that location.  This makes the link incomplete
2608 and the internals are again displayed as plain text.  Inserting the
2609 missing bracket hides the link internals again.  To show the
2610 internal structure of all links, use the menu entry
2611 @code{Org->Hyperlinks->Literal links}.
2613 @node Internal links, External links, Link format, Hyperlinks
2614 @section Internal links
2615 @cindex internal links
2616 @cindex links, internal
2617 @cindex targets, for links
2619 If the link does not look like a URL, it is considered to be internal in
2620 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2621 Target][Find my target]]} lead to a text search in the current file.
2622 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2623 link, or with a mouse click (@pxref{Handling links}).  The preferred
2624 match for such a link is a dedicated target: the same string in double
2625 angular brackets.  Targets may be located anywhere; sometimes it is
2626 convenient to put them into a comment line. For example
2628 @example
2629 # <<My Target>>
2630 @end example
2632 @noindent In HTML export (@pxref{HTML export}), such targets will become
2633 named anchors for direct access through @samp{http} links@footnote{Note that
2634 text before the first headline is usually not exported, so the first such
2635 target should be after the first headline, or in the line directly before the
2636 first headline.}.
2638 If no dedicated target exists, Org will search for the words in the
2639 link.  In the above example the search would be for @samp{my target}.
2640 Links starting with a star like @samp{*My Target} restrict the search to
2641 headlines.  When searching, Org mode will first try an exact match, but
2642 then move on to more and more lenient searches.  For example, the link
2643 @samp{[[*My Targets]]} will find any of the following:
2645 @example
2646 ** My targets
2647 ** TODO my targets are bright
2648 ** my 20 targets are
2649 @end example
2651 To insert a link targeting a headline, in-buffer completion can be used.
2652 Just type a star followed by a few optional letters into the buffer and
2653 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2654 offered as completions.  @xref{Handling links}, for more commands
2655 creating links.
2657 Following a link pushes a mark onto Org's own mark ring.  You can
2658 return to the previous position with @kbd{C-c &}.  Using this command
2659 several times in direct succession goes back to positions recorded
2660 earlier.
2662 @menu
2663 * Radio targets::               Make targets trigger links in plain text
2664 @end menu
2666 @node Radio targets,  , Internal links, Internal links
2667 @subsection Radio targets
2668 @cindex radio targets
2669 @cindex targets, radio
2670 @cindex links, radio targets
2672 Org can automatically turn any occurrences of certain target names
2673 in normal text into a link.  So without explicitly creating a link, the
2674 text connects to the target radioing its position.  Radio targets are
2675 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2676 Target>>>} causes each occurrence of @samp{my target} in normal text to
2677 become activated as a link.  The Org file is scanned automatically
2678 for radio targets only when the file is first loaded into Emacs.  To
2679 update the target list during editing, press @kbd{C-c C-c} with the
2680 cursor on or at a target.
2682 @node External links, Handling links, Internal links, Hyperlinks
2683 @section External links
2684 @cindex links, external
2685 @cindex external links
2686 @cindex links, external
2687 @cindex Gnus links
2688 @cindex BBDB links
2689 @cindex IRC links
2690 @cindex URL links
2691 @cindex file links
2692 @cindex VM links
2693 @cindex RMAIL links
2694 @cindex WANDERLUST links
2695 @cindex MH-E links
2696 @cindex USENET links
2697 @cindex SHELL links
2698 @cindex Info links
2699 @cindex elisp links
2701 Org supports links to files, websites, Usenet and email messages,
2702 BBDB database entries and links to both IRC conversations and their
2703 logs.  External links are URL-like locators.  They start with a short
2704 identifying string followed by a colon.  There can be no space after
2705 the colon.  The following list shows examples for each link type.
2707 @example
2708 http://www.astro.uva.nl/~dominik          @r{on the web}
2709 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2710 /home/dominik/images/jupiter.jpg          @r{same as above}
2711 file:papers/last.pdf                      @r{file, relative path}
2712 ./papers/last.pdf                         @r{same as above}
2713 file:projects.org                         @r{another org file}
2714 file:projects.org::some words             @r{text search in org file}
2715 file:projects.org::*task title            @r{heading search in org file}
2716 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
2717 news:comp.emacs                           @r{Usenet link}
2718 mailto:adent@@galaxy.net                   @r{Mail link}
2719 vm:folder                                 @r{VM folder link}
2720 vm:folder#id                              @r{VM message link}
2721 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2722 wl:folder                                 @r{WANDERLUST folder link}
2723 wl:folder#id                              @r{WANDERLUST message link}
2724 mhe:folder                                @r{MH-E folder link}
2725 mhe:folder#id                             @r{MH-E message link}
2726 rmail:folder                              @r{RMAIL folder link}
2727 rmail:folder#id                           @r{RMAIL message link}
2728 gnus:group                                @r{Gnus group link}
2729 gnus:group#id                             @r{Gnus article link}
2730 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
2731 irc:/irc.com/#emacs/bob                   @r{IRC link}
2732 shell:ls *.org                            @r{A shell command}
2733 elisp:org-agenda                          @r{Interactive elisp command}
2734 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
2735 @end example
2737 A link should be enclosed in double brackets and may contain a
2738 descriptive text to be displayed instead of the URL (@pxref{Link
2739 format}), for example:
2741 @example
2742 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2743 @end example
2745 @noindent
2746 If the description is a file name or URL that points to an image, HTML
2747 export (@pxref{HTML export}) will inline the image as a clickable
2748 button.  If there is no description at all and the link points to an
2749 image,
2750 that image will be inlined into the exported HTML file.
2752 @cindex angular brackets, around links
2753 @cindex plain text external links
2754 Org also finds external links in the normal text and activates them
2755 as links.  If spaces must be part of the link (for example in
2756 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2757 about the end of the link, enclose them in angular brackets.
2759 @node Handling links, Using links outside Org, External links, Hyperlinks
2760 @section Handling links
2761 @cindex links, handling
2763 Org provides methods to create a link in the correct syntax, to
2764 insert it into an Org file, and to follow the link.
2766 @table @kbd
2767 @kindex C-c l
2768 @cindex storing links
2769 @item C-c l
2770 Store a link to the current location.  This is a @emph{global} command (you
2771 must create the key binding yourself) which can be used in any buffer to
2772 create a link.  The link will be stored for later insertion into an Org
2773 buffer (see below).
2775 @vindex org-link-to-org-use-id
2776 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
2777 to the target.  Otherwise it points to the current headline, either by text
2778 (unsafe), or, if @file{org-id.el} is loaded and @code{org-link-to-org-use-id}
2779 is set, by ID property.
2781 @vindex org-irc-link-to-logs
2782 For VM, Rmail, Wanderlust, MH-E, Gnus and BBDB buffers, the link will
2783 indicate the current article/entry.  For W3 and W3M buffers, the link goes to
2784 the current URL.  For IRC links, if you set the variable
2785 @code{org-irc-link-to-logs} to non-nil then @kbd{C-c l} will store a
2786 @samp{file:/} style link to the relevant point in the logs for the current
2787 conversation.  Otherwise an @samp{irc:/} style link to the user/channel/server
2788 under the point will be stored.
2790 For any other files, the link will point to the file, with a search string
2791 (@pxref{Search options}) pointing to the contents of the current line.  If
2792 there is an active region, the selected words will form the basis of the
2793 search string.  If the automatically created link is not working correctly or
2794 accurately enough, you can write custom functions to select the search string
2795 and to do the search for particular file types - see @ref{Custom searches}.
2796 The key binding @kbd{C-c l} is only a suggestion - see @ref{Installation}.
2798 @kindex C-c C-l
2799 @cindex link completion
2800 @cindex completion, of links
2801 @cindex inserting links
2802 @item C-c C-l
2803 @vindex org-keep-stored-link-after-insertion
2804 Insert a link.  This prompts for a link to be inserted into the buffer.  You
2805 can just type a link, using text for an internal link, or one of the link
2806 type prefixes mentioned in the examples above.  All links stored during the
2807 current session are part of the history for this prompt, so you can access
2808 them with @key{up} and @key{down} (or @kbd{M-p/n}).  Completion, on the other
2809 hand, will help you to insert valid link prefixes like @samp{http:} or
2810 @samp{ftp:}, including the prefixes defined through link abbreviations
2811 (@pxref{Link abbreviations}).  The link will be inserted into the
2812 buffer@footnote{After insertion of a stored link, the link will be removed
2813 from the list of stored links.  To keep it in the list later use, use a
2814 triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2815 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2816 If some text was selected when this command is called, the selected text
2817 becomes the default description.@* Note that you don't have to use this
2818 command to insert a link.  Links in Org are plain text, and you can type
2819 or paste them straight into the buffer.  By using this command, the links are
2820 automatically enclosed in double brackets, and you will be asked for the
2821 optional descriptive text.
2823 @c  If the link is a @samp{file:} link and
2824 @c the linked file is located in the same directory as the current file or
2825 @c a subdirectory of it, the path of the file will be inserted relative to
2826 @c the current directory.
2828 @kindex C-u C-c C-l
2829 @cindex file name completion
2830 @cindex completion, of file names
2831 @item C-u C-c C-l
2832 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2833 a file will be inserted and you may use file name completion to select
2834 the name of the file.  The path to the file is inserted relative to the
2835 directory of the current org file, if the linked file is in the current
2836 directory or in a sub-directory of it, or if the path is written relative
2837 to the current directory using @samp{../}.  Otherwise an absolute path
2838 is used, if possible with @samp{~/} for your home directory.  You can
2839 force an absolute path with two @kbd{C-u} prefixes.
2841 @item C-c C-l @r{(with cursor on existing link)}
2842 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2843 link and description parts of the link.
2845 @cindex following links
2846 @kindex C-c C-o
2847 @kindex RET
2848 @item C-c C-o @r{or} @key{RET}
2849 @vindex org-file-apps
2850 Open link at point.  This will launch a web browser for URLs (using
2851 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
2852 the corresponding links, and execute the command in a shell link.  When the
2853 cursor is on an internal link, this commands runs the corresponding search.
2854 When the cursor is on a TAG list in a headline, it creates the corresponding
2855 TAGS view.  If the cursor is on a time stamp, it compiles the agenda for that
2856 date.  Furthermore, it will visit text and remote files in @samp{file:} links
2857 with Emacs and select a suitable application for local non-text files.
2858 Classification of files is based on file extension only.  See option
2859 @code{org-file-apps}.  If you want to override the default application and
2860 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
2861 opening in Emacs, use a @kbd{C-u C-u} prefix.
2863 @kindex mouse-2
2864 @kindex mouse-1
2865 @item mouse-2
2866 @itemx mouse-1
2867 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2868 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2870 @kindex mouse-3
2871 @item mouse-3
2872 @vindex org-display-internal-link-with-indirect-buffer
2873 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2874 internal links to be displayed in another window@footnote{See the
2875 variable @code{org-display-internal-link-with-indirect-buffer}}.
2877 @cindex mark ring
2878 @kindex C-c %
2879 @item C-c %
2880 Push the current position onto the mark ring, to be able to return
2881 easily. Commands following an internal link do this automatically.
2883 @cindex links, returning to
2884 @kindex C-c &
2885 @item C-c &
2886 Jump back to a recorded position.  A position is recorded by the
2887 commands following internal links, and by @kbd{C-c %}.  Using this
2888 command several times in direct succession moves through a ring of
2889 previously recorded positions.
2891 @kindex C-c C-x C-n
2892 @kindex C-c C-x C-p
2893 @cindex links, finding next/previous
2894 @item C-c C-x C-n
2895 @itemx C-c C-x C-p
2896 Move forward/backward to the next link in the buffer.  At the limit of
2897 the buffer, the search fails once, and then wraps around.  The key
2898 bindings for this are really too long, you might want to bind this also
2899 to @kbd{C-n} and @kbd{C-p}
2900 @lisp
2901 (add-hook 'org-load-hook
2902   (lambda ()
2903     (define-key 'org-mode-map "\C-n" 'org-next-link)
2904     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2905 @end lisp
2906 @end table
2908 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
2909 @section Using links outside Org
2911 You can insert and follow links that have Org syntax not only in
2912 Org, but in any Emacs buffer.  For this, you should create two
2913 global commands, like this (please select suitable global keys
2914 yourself):
2916 @lisp
2917 (global-set-key "\C-c L" 'org-insert-link-global)
2918 (global-set-key "\C-c o" 'org-open-at-point-global)
2919 @end lisp
2921 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
2922 @section Link abbreviations
2923 @cindex link abbreviations
2924 @cindex abbreviation, links
2926 Long URLs can be cumbersome to type, and often many similar links are
2927 needed in a document.  For this you can use link abbreviations.  An
2928 abbreviated link looks like this
2930 @example
2931 [[linkword:tag][description]]
2932 @end example
2934 @noindent
2935 @vindex org-link-abbrev-alist
2936 where the tag is optional.  The @i{linkword} must be a word; letter, numbers,
2937 @samp{-}, and @samp{_} are allowed here.  Abbreviations are resolved
2938 according to the information in the variable @code{org-link-abbrev-alist}
2939 that relates the linkwords to replacement text.  Here is an example:
2941 @lisp
2942 @group
2943 (setq org-link-abbrev-alist
2944   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2945     ("google"   . "http://www.google.com/search?q=")
2946     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2947                    nph-abs_connect?author=%s&db_key=AST")))
2948 @end group
2949 @end lisp
2951 If the replacement text contains the string @samp{%s}, it will be
2952 replaced with the tag.  Otherwise the tag will be appended to the string
2953 in order to create the link.  You may also specify a function that will
2954 be called with the tag as the only argument to create the link.
2956 With the above setting, you could link to a specific bug with
2957 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2958 @code{[[google:OrgMode]]} and find out what the Org author is
2959 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2961 If you need special abbreviations just for a single Org buffer, you
2962 can define them in the file with
2964 @example
2965 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2966 #+LINK: google    http://www.google.com/search?q=%s
2967 @end example
2969 @noindent
2970 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2971 complete link abbreviations.
2973 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2974 @section Search options in file links
2975 @cindex search option in file links
2976 @cindex file links, searching
2978 File links can contain additional information to make Emacs jump to a
2979 particular location in the file when following a link.  This can be a
2980 line number or a search option after a double@footnote{For backward
2981 compatibility, line numbers can also follow a single colon.} colon. For
2982 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2983 links}) to a file, it encodes the words in the current line as a search
2984 string that can be used to find this line back later when following the
2985 link with @kbd{C-c C-o}.
2987 Here is the syntax of the different ways to attach a search to a file
2988 link, together with an explanation:
2990 @example
2991 [[file:~/code/main.c::255]]
2992 [[file:~/xx.org::My Target]]
2993 [[file:~/xx.org::*My Target]]
2994 [[file:~/xx.org::/regexp/]]
2995 @end example
2997 @table @code
2998 @item 255
2999 Jump to line 255.
3000 @item My Target
3001 Search for a link target @samp{<<My Target>>}, or do a text search for
3002 @samp{my target}, similar to the search in internal links, see
3003 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3004 link will become an HTML reference to the corresponding named anchor in
3005 the linked file.
3006 @item *My Target
3007 In an Org file, restrict search to headlines.
3008 @item /regexp/
3009 Do a regular expression search for @code{regexp}.  This uses the Emacs
3010 command @code{occur} to list all matches in a separate window.  If the
3011 target file is in Org mode, @code{org-occur} is used to create a
3012 sparse tree with the matches.
3013 @c If the target file is a directory,
3014 @c @code{grep} will be used to search all files in the directory.
3015 @end table
3017 As a degenerate case, a file link with an empty file name can be used
3018 to search the current file.  For example, @code{[[file:::find me]]} does
3019 a search for @samp{find me} in the current file, just as
3020 @samp{[[find me]]} would.
3022 @node Custom searches,  , Search options, Hyperlinks
3023 @section Custom Searches
3024 @cindex custom search strings
3025 @cindex search strings, custom
3027 The default mechanism for creating search strings and for doing the
3028 actual search related to a file link may not work correctly in all
3029 cases.  For example, BibTeX database files have many entries like
3030 @samp{year="1993"} which would not result in good search strings,
3031 because the only unique identification for a BibTeX entry is the
3032 citation key.
3034 @vindex org-create-file-search-functions
3035 @vindex org-execute-file-search-functions
3036 If you come across such a problem, you can write custom functions to set
3037 the right search string for a particular file type, and to do the search
3038 for the string in the file.  Using @code{add-hook}, these functions need
3039 to be added to the hook variables
3040 @code{org-create-file-search-functions} and
3041 @code{org-execute-file-search-functions}.  See the docstring for these
3042 variables for more information.  Org actually uses this mechanism
3043 for Bib@TeX{} database files, and you can use the corresponding code as
3044 an implementation example.  See the file @file{org-bibtex.el}.
3046 @node TODO Items, Tags, Hyperlinks, Top
3047 @chapter TODO Items
3048 @cindex TODO items
3050 Org mode does not maintain TODO lists as separate documents@footnote{Of
3051 course, you can make a document that contains only long lists of TODO items,
3052 but this is not required.}.  Instead, TODO items are an integral part of the
3053 notes file, because TODO items usually come up while taking notes!  With Org
3054 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3055 information is not duplicated, and the entire context from which the TODO
3056 item emerged is always present.
3058 Of course, this technique for managing TODO items scatters them
3059 throughout your notes file.  Org mode compensates for this by providing
3060 methods to give you an overview of all the things that you have to do.
3062 @menu
3063 * TODO basics::                 Marking and displaying TODO entries
3064 * TODO extensions::             Workflow and assignments
3065 * Progress logging::            Dates and notes for progress
3066 * Priorities::                  Some things are more important than others
3067 * Breaking down tasks::         Splitting a task into manageable pieces
3068 * Checkboxes::                  Tick-off lists
3069 @end menu
3071 @node TODO basics, TODO extensions, TODO Items, TODO Items
3072 @section Basic TODO functionality
3074 Any headline becomes a TODO item when it starts with the word
3075 @samp{TODO}, for example:
3077 @example
3078 *** TODO Write letter to Sam Fortune
3079 @end example
3081 @noindent
3082 The most important commands to work with TODO entries are:
3084 @table @kbd
3085 @kindex C-c C-t
3086 @cindex cycling, of TODO states
3087 @item C-c C-t
3088 Rotate the TODO state of the current item among
3090 @example
3091 ,-> (unmarked) -> TODO -> DONE --.
3092 '--------------------------------'
3093 @end example
3095 The same rotation can also be done ``remotely'' from the timeline and
3096 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3098 @kindex C-u C-c C-t
3099 @item C-u C-c C-t
3100 Select a specific keyword using completion or (if it has been set up)
3101 the fast selection interface.  For the latter, you need to assign keys
3102 to TODO states, see @ref{Per-file keywords} and @ref{Setting tags} for
3103 more information.
3105 @kindex S-@key{right}
3106 @kindex S-@key{left}
3107 @item S-@key{right}
3108 @itemx S-@key{left}
3109 Select the following/preceding TODO state, similar to cycling.  Useful
3110 mostly if more than two TODO states are possible (@pxref{TODO
3111 extensions}).  See also @ref{Conflicts} for a discussion of the interaction
3112 with @code{shift-selection-mode}.
3113 @kindex C-c C-v
3114 @kindex C-c / t
3115 @cindex sparse tree, for TODO
3116 @item C-c C-v
3117 @itemx C-c / t
3118 @vindex org-todo-keywords
3119 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3120 entire buffer, but shows all TODO items and the headings hierarchy above
3121 them.  With a prefix argument, search for a specific TODO.  You will be
3122 prompted for the keyword, and you can also give a list of keywords like
3123 @code{KWD1|KWD2|...} to list entries that match any one of these keywords.
3124 With numeric prefix argument N, show the tree for the Nth keyword in the
3125 variable @code{org-todo-keywords}.  With two prefix arguments, find all TODO
3126 and DONE entries.
3127 @kindex C-c a t
3128 @item C-c a t
3129 Show the global TODO list.  Collects the TODO items from all agenda
3130 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
3131 be in @code{agenda-mode}, which provides commands to examine and
3132 manipulate the TODO entries from the new buffer (@pxref{Agenda
3133 commands}).  @xref{Global TODO list}, for more information.
3134 @kindex S-M-@key{RET}
3135 @item S-M-@key{RET}
3136 Insert a new TODO entry below the current one.
3137 @end table
3139 @noindent
3140 @vindex org-todo-state-tags-triggers
3141 Changing a TODO state can also trigger tag changes.  See the docstring of the
3142 option @code{org-todo-state-tags-triggers} for details.
3144 @node TODO extensions, Progress logging, TODO basics, TODO Items
3145 @section Extended use of TODO keywords
3146 @cindex extended TODO keywords
3148 @vindex org-todo-keywords
3149 By default, marked TODO entries have one of only two states: TODO and
3150 DONE.  Org mode allows you to classify TODO items in more complex ways
3151 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3152 special setup, the TODO keyword system can work differently in different
3153 files.
3155 Note that @i{tags} are another way to classify headlines in general and
3156 TODO items in particular (@pxref{Tags}).
3158 @menu
3159 * Workflow states::             From TODO to DONE in steps
3160 * TODO types::                  I do this, Fred does the rest
3161 * Multiple sets in one file::   Mixing it all, and still finding your way
3162 * Fast access to TODO states::  Single letter selection of a state
3163 * Per-file keywords::           Different files, different requirements
3164 * Faces for TODO keywords::     Highlighting states
3165 * TODO dependencies::           When one task needs to wait for others
3166 @end menu
3168 @node Workflow states, TODO types, TODO extensions, TODO extensions
3169 @subsection TODO keywords as workflow states
3170 @cindex TODO workflow
3171 @cindex workflow states as TODO keywords
3173 You can use TODO keywords to indicate different @emph{sequential} states
3174 in the process of working on an item, for example@footnote{Changing
3175 this variable only becomes effective after restarting Org mode in a
3176 buffer.}:
3178 @lisp
3179 (setq org-todo-keywords
3180   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3181 @end lisp
3183 The vertical bar separates the TODO keywords (states that @emph{need
3184 action}) from the DONE states (which need @emph{no further action}).  If
3185 you don't provide the separator bar, the last state is used as the DONE
3186 state.
3187 @cindex completion, of TODO keywords
3188 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3189 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
3190 also use a numeric prefix argument to quickly select a specific state.  For
3191 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
3192 Or you can use @kbd{S-left} to go backward through the sequence.  If you
3193 define many keywords, you can use in-buffer completion
3194 (@pxref{Completion}) or even a special one-key selection scheme
3195 (@pxref{Fast access to TODO states}) to insert these words into the
3196 buffer.  Changing a TODO state can be logged with a timestamp, see
3197 @ref{Tracking TODO state changes} for more information.
3199 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3200 @subsection TODO keywords as types
3201 @cindex TODO types
3202 @cindex names as TODO keywords
3203 @cindex types as TODO keywords
3205 The second possibility is to use TODO keywords to indicate different
3206 @emph{types} of action items.  For example, you might want to indicate
3207 that items are for ``work'' or ``home''.  Or, when you work with several
3208 people on a single project, you might want to assign action items
3209 directly to persons, by using their names as TODO keywords.  This would
3210 be set up like this:
3212 @lisp
3213 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3214 @end lisp
3216 In this case, different keywords do not indicate a sequence, but rather
3217 different types.  So the normal work flow would be to assign a task to a
3218 person, and later to mark it DONE.  Org mode supports this style by adapting
3219 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3220 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3221 times in succession, it will still cycle through all names, in order to first
3222 select the right type for a task.  But when you return to the item after some
3223 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3224 to DONE.  Use prefix arguments or completion to quickly select a specific
3225 name.  You can also review the items of a specific TODO type in a sparse tree
3226 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
3227 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
3228 from all agenda files into a single buffer, you would use the numeric prefix
3229 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
3231 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3232 @subsection Multiple keyword sets in one file
3233 @cindex TODO keyword sets
3235 Sometimes you may want to use different sets of TODO keywords in
3236 parallel.  For example, you may want to have the basic
3237 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
3238 separate state indicating that an item has been canceled (so it is not
3239 DONE, but also does not require action).  Your setup would then look
3240 like this:
3242 @lisp
3243 (setq org-todo-keywords
3244       '((sequence "TODO" "|" "DONE")
3245         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3246         (sequence "|" "CANCELED")))
3247 @end lisp
3249 The keywords should all be different, this helps Org mode to keep track
3250 of which subsequence should be used for a given entry.  In this setup,
3251 @kbd{C-c C-t} only operates within a subsequence, so it switches from
3252 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
3253 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
3254 select the correct sequence.  Besides the obvious ways like typing a
3255 keyword or using completion, you may also apply the following commands:
3257 @table @kbd
3258 @kindex C-S-@key{right}
3259 @kindex C-S-@key{left}
3260 @kindex C-u C-u C-c C-t
3261 @item C-u C-u C-c C-t
3262 @itemx C-S-@key{right}
3263 @itemx C-S-@key{left}
3264 These keys jump from one TODO subset to the next.  In the above example,
3265 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
3266 @code{DONE} to @code{REPORT}, and any of the words in the second row to
3267 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
3268 @code{shift-selection-mode} (@pxref{Conflicts}).
3269 @kindex S-@key{right}
3270 @kindex S-@key{left}
3271 @item S-@key{right}
3272 @itemx S-@key{left}
3273 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
3274 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
3275 from @code{DONE} to @code{REPORT} in the example above.  See also
3276 @ref{Conflicts} for a discussion of the interaction with
3277 @code{shift-selection-mode}.
3278 @end table
3280 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
3281 @subsection Fast access to TODO states
3283 If you would like to quickly change an entry to an arbitrary TODO state
3284 instead of cycling through the states, you can set up keys for
3285 single-letter access to the states.  This is done by adding the section
3286 key after each keyword, in parenthesis.  For example:
3288 @lisp
3289 (setq org-todo-keywords
3290       '((sequence "TODO(t)" "|" "DONE(d)")
3291         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3292         (sequence "|" "CANCELED(c)")))
3293 @end lisp
3295 @vindex org-fast-tag-selection-include-todo
3296 If you then press @code{C-c C-t} followed by the selection key, the entry
3297 will be switched to this state.  @key{SPC} can be used to remove any TODO
3298 keyword from an entry.@footnote{Check also the variable
3299 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
3300 state through the tags interface (@pxref{Setting tags}), in case you like to
3301 mingle the two concepts.  Note that this means you need to come up with
3302 unique keys across both sets of keywords.}
3304 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
3305 @subsection Setting up keywords for individual files
3306 @cindex keyword options
3307 @cindex per-file keywords
3309 It can be very useful to use different aspects of the TODO mechanism in
3310 different files.  For file-local settings, you need to add special lines
3311 to the file which set the keywords and interpretation for that file
3312 only.  For example, to set one of the two examples discussed above, you
3313 need one of the following lines, starting in column zero anywhere in the
3314 file:
3316 @example
3317 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3318 @end example
3319 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
3320 interpretation, but it means the same as @code{#+TODO}), or
3321 @example
3322 #+TYP_TODO: Fred Sara Lucy Mike | DONE
3323 @end example
3325 A setup for using several sets in parallel would be:
3327 @example
3328 #+TODO: TODO | DONE
3329 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
3330 #+TODO: | CANCELED
3331 @end example
3333 @cindex completion, of option keywords
3334 @kindex M-@key{TAB}
3335 @noindent To make sure you are using the correct keyword, type
3336 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
3338 @cindex DONE, final TODO keyword
3339 Remember that the keywords after the vertical bar (or the last keyword
3340 if no bar is there) must always mean that the item is DONE (although you
3341 may use a different word).  After changing one of these lines, use
3342 @kbd{C-c C-c} with the cursor still in the line to make the changes
3343 known to Org mode@footnote{Org mode parses these lines only when
3344 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
3345 cursor in a line starting with @samp{#+} is simply restarting Org mode
3346 for the current buffer.}.
3348 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
3349 @subsection Faces for TODO keywords
3350 @cindex faces, for TODO keywords
3352 @vindex org-todo @r{(face)}
3353 @vindex org-done @r{(face)}
3354 @vindex org-todo-keyword-faces
3355 Org mode highlights TODO keywords with special faces: @code{org-todo}
3356 for keywords indicating that an item still has to be acted upon, and
3357 @code{org-done} for keywords indicating that an item is finished.  If
3358 you are using more than 2 different states, you might want to use
3359 special faces for some of them.  This can be done using the variable
3360 @code{org-todo-keyword-faces}.  For example:
3362 @lisp
3363 @group
3364 (setq org-todo-keyword-faces
3365       '(("TODO"      . org-warning)
3366         ("DEFERRED"  . shadow)
3367         ("CANCELED"  . (:foreground "blue" :weight bold))))
3368 @end group
3369 @end lisp
3371 While using a list with face properties as shown for CANCELED
3372 @emph{should} work, this does not aways seem to be the case.  If
3373 necessary, define a special face and use that.
3375 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
3376 @subsection TODO dependencies
3377 @cindex TODO dependencies
3378 @cindex dependencies, of TODO states
3380 @vindex org-enforce-todo-dependencies
3381 The structure of Org files (hierarchy and lists) makes it easy to define TODO
3382 dependencies.  Usually, a parent TODO task should not be marked DONE until
3383 all subtasks (defined as children tasks) are marked as DONE.  And sometimes
3384 there is a logical sequence to a number of (sub)tasks, so that one task
3385 cannot be acted upon before all siblings above it are done.  If you customize
3386 the variable @code{org-enforce-todo-dependencies}, Org will block entries
3387 from changing state to DONE while they have children that are not DONE.
3388 Furthermore, if an entry has a property @code{ORDERED}, each of its children
3389 will be blocked until all earlier siblings are marked DONE.  Here is an
3390 example:
3392 @example
3393 * TODO Blocked until (two) is done
3394 ** DONE one
3395 ** TODO two
3397 * Parent
3398   :PROPERTIES:
3399     :ORDERED: t
3400   :END:
3401 ** TODO a
3402 ** TODO b, needs to wait for (a)
3403 ** TODO c, needs to wait for (a) and (b)
3404 @end example
3406 @table @kbd
3407 @kindex C-c C-x o
3408 @item C-c C-x o
3409 @vindex org-track-ordered-property-with-tag
3410 Toggle the @code{ORDERED} property of the current entry.  A property is used
3411 for this behavior because this should be local to the current entry, not
3412 inherited like a tag.  However, if you would like to @i{track} the value of
3413 this property with a tag for better visibility, customize the variable
3414 @code{org-track-ordered-property-with-tag}.
3415 @kindex C-u C-u C-u C-c C-t
3416 @item C-u C-u C-u C-c C-t
3417 Change TODO state, circumventin any state blocking.
3418 @end table
3420 @vindex org-agenda-dim-blocked-tasks
3421 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
3422 that cannot be closed because of such dependencies will be shown in a dimmed
3423 font or even made invisible in agenda views (@pxref{Agenda Views}).
3425 @cindex checkboxes and TODO dependencies
3426 @vindex org-enforce-todo-dependencies
3427 You can also block changes of TODO states by looking at checkboxes
3428 (@pxref{Checkboxes}).  If you set the variable
3429 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
3430 checkboxes will be blocked from switching to DONE.
3432 If you need more complex dependency structures, for example dependencies
3433 between entries in different trees or files, check out the contributed
3434 module @file{org-depend.el}.
3436 @page
3437 @node Progress logging, Priorities, TODO extensions, TODO Items
3438 @section Progress logging
3439 @cindex progress logging
3440 @cindex logging, of progress
3442 Org mode can automatically record a time stamp and possibly a note when
3443 you mark a TODO item as DONE, or even each time you change the state of
3444 a TODO item.  This system is highly configurable, settings can be on a
3445 per-keyword basis and can be localized to a file or even a subtree.  For
3446 information on how to clock working time for a task, see @ref{Clocking
3447 work time}.
3449 @menu
3450 * Closing items::               When was this entry marked DONE?
3451 * Tracking TODO state changes::  When did the status change?
3452 @end menu
3454 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3455 @subsection Closing items
3457 The most basic logging is to keep track of @emph{when} a certain TODO
3458 item was finished.  This is achieved with@footnote{The corresponding
3459 in-buffer setting is: @code{#+STARTUP: logdone}}.
3461 @lisp
3462 (setq org-log-done 'time)
3463 @end lisp
3465 @noindent
3466 Then each time you turn an entry from a TODO (not-done) state into any
3467 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3468 just after the headline.  If you turn the entry back into a TODO item
3469 through further state cycling, that line will be removed again.  If you
3470 want to record a note along with the timestamp, use@footnote{The
3471 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3473 @lisp
3474 (setq org-log-done 'note)
3475 @end lisp
3477 @noindent
3478 You will then be prompted for a note, and that note will be stored below
3479 the entry with a @samp{Closing Note} heading.
3481 In the timeline (@pxref{Timeline}) and in the agenda
3482 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3483 display the TODO items with a @samp{CLOSED} timestamp on each day,
3484 giving you an overview of what has been done.
3486 @node Tracking TODO state changes,  , Closing items, Progress logging
3487 @subsection Tracking TODO state changes
3488 @cindex drawer, for state change recording
3490 @vindex org-log-states-order-reversed
3491 @vindex org-log-state-notes-into-drawer
3492 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
3493 might want to keep track of when a state change occurred and maybe take a
3494 note about this change.  You can either record just a timestamp, or a
3495 timestamped note for a change.  These records will be inserted after the
3496 headline as an itemized list, newest first@footnote{See the variable
3497 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
3498 want to get the notes out of a way into a drawer (@pxref{Drawers}).
3499 Customize the variable @code{org-log-state-notes-into-drawer} to get this
3500 behavior - the recommended drawer for this is called @code{LOGBOOK}.
3502 Since it is normally too much to record a note for every state, Org mode
3503 expects configuration on a per-keyword basis for this.  This is achieved by
3504 adding special markers @samp{!} (for a time stamp) and @samp{@@} (for a note)
3505 in parenthesis after each keyword.  For example, with the setting
3507 @lisp
3508 (setq org-todo-keywords
3509   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3510 @end lisp
3512 @noindent
3513 @vindex org-log-done
3514 you not only define global TODO keywords and fast access keys, but also
3515 request that a time is recorded when the entry is turned into
3516 DONE@footnote{It is possible that Org mode will record two time stamps
3517 when you are using both @code{org-log-done} and state change logging.
3518 However, it will never prompt for two notes - if you have configured
3519 both, the state change recording note will take precedence and cancel
3520 the @samp{Closing Note}.}, and that a note is recorded when switching to
3521 WAIT or CANCELED.  The setting for WAIT is even more special: The
3522 @samp{!} after the slash means that in addition to the note taken when
3523 entering the state, a time stamp should be recorded when @i{leaving} the
3524 WAIT state, if and only if the @i{target} state does not configure
3525 logging for entering it.  So it has no effect when switching from WAIT
3526 to DONE, because DONE is configured to record a timestamp only.  But
3527 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3528 setting now triggers a timestamp even though TODO has no logging
3529 configured.
3531 You can use the exact same syntax for setting logging preferences local
3532 to a buffer:
3533 @example
3534 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3535 @end example
3537 In order to define logging settings that are local to a subtree or a
3538 single item, define a LOGGING property in this entry.  Any non-empty
3539 LOGGING property resets all logging settings to nil.  You may then turn
3540 on logging for this specific tree using STARTUP keywords like
3541 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3542 settings like @code{TODO(!)}.  For example
3544 @example
3545 * TODO Log each state with only a time
3546   :PROPERTIES:
3547   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3548   :END:
3549 * TODO Only log when switching to WAIT, and when repeating
3550   :PROPERTIES:
3551   :LOGGING: WAIT(@@) logrepeat
3552   :END:
3553 * TODO No logging at all
3554   :PROPERTIES:
3555   :LOGGING: nil
3556   :END:
3557 @end example
3559 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3560 @section Priorities
3561 @cindex priorities
3563 If you use Org mode extensively, you may end up enough TODO items that
3564 it starts to make sense to prioritize them.  Prioritizing can be done by
3565 placing a @emph{priority cookie} into the headline of a TODO item, like
3566 this
3568 @example
3569 *** TODO [#A] Write letter to Sam Fortune
3570 @end example
3572 @noindent
3573 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3574 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3575 is treated as priority @samp{B}.  Priorities make a difference only in
3576 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3577 no inherent meaning to Org mode.
3579 Priorities can be attached to any outline tree entries; they do not need
3580 to be TODO items.
3582 @table @kbd
3583 @kindex @kbd{C-c ,}
3584 @item @kbd{C-c ,}
3585 Set the priority of the current headline.  The command prompts for a
3586 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3587 @key{SPC} instead, the priority cookie is removed from the headline.
3588 The priorities can also be changed ``remotely'' from the timeline and
3589 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3591 @kindex S-@key{up}
3592 @kindex S-@key{down}
3593 @item S-@key{up}
3594 @itemx S-@key{down}
3595 @vindex org-priority-start-cycle-with-default
3596 Increase/decrease priority of current headline@footnote{See also the option
3597 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
3598 also used to modify time stamps (@pxref{Creating timestamps}).  See also
3599 @ref{Conflicts} for a discussion of the interaction with
3600 @code{shift-selection-mode}.
3601 @end table
3603 @vindex org-highest-priority
3604 @vindex org-lowest-priority
3605 @vindex org-default-priority
3606 You can change the range of allowed priorities by setting the variables
3607 @code{org-highest-priority}, @code{org-lowest-priority}, and
3608 @code{org-default-priority}.  For an individual buffer, you may set
3609 these values (highest, lowest, default) like this (please make sure that
3610 the highest priority is earlier in the alphabet than the lowest
3611 priority):
3613 @example
3614 #+PRIORITIES: A C B
3615 @end example
3617 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3618 @section Breaking tasks down into subtasks
3619 @cindex tasks, breaking down
3621 @vindex org-agenda-todo-list-sublevels
3622 It is often advisable to break down large tasks into smaller, manageable
3623 subtasks.  You can do this by creating an outline tree below a TODO item,
3624 with detailed subtasks on the tree@footnote{To keep subtasks out of the
3625 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
3626 the overview over the fraction of subtasks that are already completed, insert
3627 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
3628 be updates each time the todo status of a child changes.  For example:
3630 @example
3631 * Organize Party [33%]
3632 ** TODO Call people [1/2]
3633 *** TODO Peter
3634 *** DONE Sarah
3635 ** TODO Buy food
3636 ** DONE Talk to neighbor
3637 @end example
3639 If you would like a TODO entry to automatically change to DONE when all
3640 children are done, you can use the following setup:
3642 @example
3643 (defun org-summary-todo (n-done n-not-done)
3644   "Switch entry to DONE when all subentries are done, to TODO otherwise."
3645   (let (org-log-done org-log-states)   ; turn off logging
3646     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3648 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3649 @end example
3652 Another possibility is the use of checkboxes to identify (a hierarchy of) a
3653 large number of subtasks (@pxref{Checkboxes}).
3656 @node Checkboxes,  , Breaking down tasks, TODO Items
3657 @section Checkboxes
3658 @cindex checkboxes
3660 Every item in a plain list (@pxref{Plain lists}) can be made into a
3661 checkbox by starting it with the string @samp{[ ]}.  This feature is
3662 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3663 Checkboxes are not included into the global TODO list, so they are often
3664 great to split a task into a number of simple steps.  Or you can use
3665 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3666 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3668 Here is an example of a checkbox list.
3670 @example
3671 * TODO Organize party [2/4]
3672   - [-] call people [1/3]
3673     - [ ] Peter
3674     - [X] Sarah
3675     - [ ] Sam
3676   - [X] order food
3677   - [ ] think about what music to play
3678   - [X] talk to the neighbors
3679 @end example
3681 Checkboxes work hierarchically, so if a checkbox item has children that
3682 are checkboxes, toggling one of the children checkboxes will make the
3683 parent checkbox reflect if none, some, or all of the children are
3684 checked.
3686 @cindex statistics, for checkboxes
3687 @cindex checkbox statistics
3688 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
3689 cookies indicating how many checkboxes present in this entry have been
3690 checked off, and the total number of checkboxes are present.  This can
3691 give you an idea on how many checkboxes remain, even without opening a
3692 folded entry.  The cookies can be placed into a headline or into (the
3693 first line of) a plain list item. Each cookie covers all checkboxes
3694 structurally below the headline/item on which the cookie appear.  You
3695 have to insert the cookie yourself by typing either @samp{[/]} or
3696 @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
3697 the examples above.  With @samp{[%]} you get information about the
3698 percentage of checkboxes checked (in the above example, this would be
3699 @samp{[50%]} and @samp{[33%]}, respectively).
3701 @cindex blocking, of checkboxes
3702 @cindex checkbox blocking
3703 If the current outline node has an @code{ORDERED} property, checkboxes must
3704 be checked off in sequence, and an error will be thrown if you try to check
3705 off a box while there are unchecked boxes bove it.
3707 @noindent The following commands work with checkboxes:
3709 @table @kbd
3710 @kindex C-c C-c
3711 @item C-c C-c
3712 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3713 double prefix argument, set it to @samp{[-]}, which is considered to be an
3714 intermediate state.
3715 @kindex C-c C-x C-b
3716 @item C-c C-x C-b
3717 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3718 double prefix argument, set it to @samp{[-]}, which is considered to be an
3719 intermediate state.
3720 @itemize @minus
3721 @item
3722 If there is an active region, toggle the first checkbox in the region
3723 and set all remaining boxes to the same status as the first.  With a prefix
3724 arg, add or remove the checkbox for all items in the region.
3725 @item
3726 If the cursor is in a headline, toggle checkboxes in the region between
3727 this headline and the next (so @emph{not} the entire subtree).
3728 @item
3729 If there is no active region, just toggle the checkbox at point.
3730 @end itemize
3731 @kindex M-S-@key{RET}
3732 @item M-S-@key{RET}
3733 Insert a new item with a checkbox.
3734 This works only if the cursor is already in a plain list item
3735 (@pxref{Plain lists}).
3736 @kindex C-c C-x o
3737 @item C-c C-x o
3738 @vindex org-track-ordered-property-with-tag
3739 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
3740 be checked off in sequence.  A property is used for this behavior because
3741 this should be local to the current entry, not inherited like a tag.
3742 However, if you would like to @i{track} the value of this property with a tag
3743 for better visibility, customize the variable
3744 @code{org-track-ordered-property-with-tag}.
3745 @kindex C-c #
3746 @item C-c #
3747 Update the checkbox statistics in the current outline entry.  When
3748 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3749 statistic cookies are updated automatically if you toggle checkboxes
3750 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3751 delete boxes or add/change them by hand, use this command to get things
3752 back into sync.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3753 @end table
3755 @node Tags, Properties and Columns, TODO Items, Top
3756 @chapter Tags
3757 @cindex tags
3758 @cindex headline tagging
3759 @cindex matching, tags
3760 @cindex sparse tree, tag based
3762 An excellent way to implement labels and contexts for cross-correlating
3763 information is to assign @i{tags} to headlines.  Org mode has extensive
3764 support for tags.
3766 @vindex org-tag-faces
3767 Every headline can contain a list of tags; they occur at the end of the
3768 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
3769 @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
3770 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
3771 Tags will by default get a bold face with the same color as the headline.
3772 You may specify special faces for specific tags using the variable
3773 @code{org-tag-faces}, much in the same way as you can do for TODO keywords
3774 (@pxref{Faces for TODO keywords}).
3776 @menu
3777 * Tag inheritance::             Tags use the tree structure of the outline
3778 * Setting tags::                How to assign tags to a headline
3779 * Tag searches::                Searching for combinations of tags
3780 @end menu
3782 @node Tag inheritance, Setting tags, Tags, Tags
3783 @section Tag inheritance
3784 @cindex tag inheritance
3785 @cindex inheritance, of tags
3786 @cindex sublevels, inclusion into tags match
3788 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3789 heading has a certain tag, all subheadings will inherit the tag as
3790 well.  For example, in the list
3792 @example
3793 * Meeting with the French group      :work:
3794 ** Summary by Frank                  :boss:notes:
3795 *** TODO Prepare slides for him      :action:
3796 @end example
3798 @noindent
3799 the final heading will have the tags @samp{:work:}, @samp{:boss:},
3800 @samp{:notes:}, and @samp{:action:} even though the final heading is not
3801 explicitly marked with those tags.  You can also set tags that all entries in
3802 a file should inherit as if these tags would be defined in a hypothetical
3803 level zero that surrounds the entire file.
3805 @example
3806 #+FILETAGS: :Peter:Boss:Secret:
3807 @end example
3809 @noindent
3810 @vindex org-use-tag-inheritance
3811 @vindex org-tags-exclude-from-inheritance
3812 To limit tag inheritance to specific tags, or to turn it off entirely, use
3813 the variables @code{org-use-tag-inheritance} and
3814 @code{org-tags-exclude-from-inheritance}.
3816 @vindex org-tags-match-list-sublevels
3817 When a headline matches during a tags search while tag inheritance is turned
3818 on, all the sublevels in the same tree will (for a simple match form) match
3819 as well@footnote{This is only true if the search does not involve more
3820 complex tests including properties (@pxref{Property searches}).}.  The list
3821 of matches may then become very long.  If you only want to see the first tags
3822 match in a subtree, configure the variable
3823 @code{org-tags-match-list-sublevels} (not recommended).
3825 @node Setting tags, Tag searches, Tag inheritance, Tags
3826 @section Setting tags
3827 @cindex setting tags
3828 @cindex tags, setting
3830 @kindex M-@key{TAB}
3831 Tags can simply be typed into the buffer at the end of a headline.
3832 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3833 also a special command for inserting tags:
3835 @table @kbd
3836 @kindex C-c C-q
3837 @item C-c C-q
3838 @cindex completion, of tags
3839 @vindex org-tags-column
3840 Enter new tags for the current headline.  Org mode will either offer
3841 completion or a special single-key interface for setting tags, see
3842 below.  After pressing @key{RET}, the tags will be inserted and aligned
3843 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3844 tags in the current buffer will be aligned to that column, just to make
3845 things look nice.  TAGS are automatically realigned after promotion,
3846 demotion, and TODO state changes (@pxref{TODO basics}).
3847 @kindex C-c C-c
3848 @item C-c C-c
3849 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
3850 @end table
3852 @vindex org-tag-alist
3853 Org will support tag insertion based on a @emph{list of tags}.  By
3854 default this list is constructed dynamically, containing all tags
3855 currently used in the buffer.  You may also globally specify a hard list
3856 of tags with the variable @code{org-tag-alist}.  Finally you can set
3857 the default tags for a given file with lines like
3859 @example
3860 #+TAGS: @@work @@home @@tennisclub
3861 #+TAGS: laptop car pc sailboat
3862 @end example
3864 If you have globally defined your preferred set of tags using the
3865 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3866 in a specific file, add an empty TAGS option line to that file:
3868 @example
3869 #+TAGS:
3870 @end example
3872 @vindex org-tag-persistent-alist
3873 If you have a preferred set of tags that you would like to use in every file,
3874 in addition to those defined on a per file basis by TAGS option lines, then
3875 you may specify a list of tags with the variable
3876 @code{org-tag-persistent-alist}.  You may turn this off on a per file basis
3877 by adding a STARTUP option line to that file:
3879 @example
3880 #+STARTUP: noptag
3881 @end example
3883 By default Org mode uses the standard minibuffer completion facilities for
3884 entering tags.  However, it also implements another, quicker, tag selection
3885 method called @emph{fast tag selection}.  This allows you to select and
3886 deselect tags with just a single key press.  For this to work well you should
3887 assign unique letters to most of your commonly used tags.  You can do this
3888 globally by configuring the variable @code{org-tag-alist} in your
3889 @file{.emacs} file.  For example, you may find the need to tag many items in
3890 different files with @samp{:@@home:}.  In this case you can set something
3891 like:
3893 @lisp
3894 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
3895 @end lisp
3897 @noindent If the tag is only relevant to the file you are working on then you
3898 can, instead, set the TAGS option line as:
3900 @example
3901 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
3902 @end example
3904 @noindent The tags interface will show the available tags in a splash
3905 window.  If you would to start a new line after a specific tag, insert
3906 @samp{\n} into the tag list
3908 @example
3909 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
3910 @end example
3912 @noindent or write them in two lines:
3914 @example
3915 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
3916 #+TAGS: laptop(l)  pc(p)
3917 @end example
3919 @noindent
3920 You can also group together tags that are mutually exclusive.  By using
3921 braces, as in:
3923 @example
3924 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
3925 @end example
3927 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
3928 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
3930 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3931 these lines to activate any changes.
3933 @noindent
3934 To set these mutually exclusive groups in the variable @code{org-tags-alist}
3935 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
3936 of the braces.  Similarly, you can use @code{:newline} to indicate a line
3937 break.  The previous example would be set globally by the following
3938 configuration:
3940 @lisp
3941 (setq org-tag-alist '((:startgroup . nil)
3942                       ("@@work" . ?w) ("@@home" . ?h)
3943                       ("@@tennisclub" . ?t)
3944                       (:endgroup . nil)
3945                       ("laptop" . ?l) ("pc" . ?p)))
3946 @end lisp
3948 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
3949 automatically present you with a special interface, listing inherited tags,
3950 the tags of the current headline, and a list of all valid tags with
3951 corresponding keys@footnote{Keys will automatically be assigned to tags which
3952 have no configured keys.}.  In this interface, you can use the following
3953 keys:
3955 @table @kbd
3956 @item a-z...
3957 Pressing keys assigned to tags will add or remove them from the list of
3958 tags in the current line.  Selecting a tag in a group of mutually
3959 exclusive tags will turn off any other tags from that group.
3960 @kindex @key{TAB}
3961 @item @key{TAB}
3962 Enter a tag in the minibuffer, even if the tag is not in the predefined
3963 list.  You will be able to complete on all tags present in the buffer.
3964 @kindex @key{SPC}
3965 @item @key{SPC}
3966 Clear all tags for this line.
3967 @kindex @key{RET}
3968 @item @key{RET}
3969 Accept the modified set.
3970 @item C-g
3971 Abort without installing changes.
3972 @item q
3973 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3974 @item !
3975 Turn off groups of mutually exclusive tags.  Use this to (as an
3976 exception) assign several tags from such a group.
3977 @item C-c
3978 Toggle auto-exit after the next change (see below).
3979 If you are using expert mode, the first @kbd{C-c} will display the
3980 selection window.
3981 @end table
3983 @noindent
3984 This method lets you assign tags to a headline with very few keys.  With
3985 the above setup, you could clear the current tags and set @samp{@@home},
3986 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
3987 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
3988 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
3989 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3990 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3991 @key{RET} @key{RET}}.
3993 @vindex org-fast-tag-selection-single-key
3994 If you find that most of the time, you need only a single key press to
3995 modify your list of tags, set the variable
3996 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3997 press @key{RET} to exit fast tag selection - it will immediately exit
3998 after the first change.  If you then occasionally need more keys, press
3999 @kbd{C-c} to turn off auto-exit for the current tag selection process
4000 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
4001 C-c}).  If you set the variable to the value @code{expert}, the special
4002 window is not even shown for single-key tag selection, it comes up only
4003 when you press an extra @kbd{C-c}.
4005 @node Tag searches,  , Setting tags, Tags
4006 @section Tag searches
4007 @cindex tag searches
4008 @cindex searching for tags
4010 Once a system of tags has been set up, it can be used to collect related
4011 information into special lists.
4013 @table @kbd
4014 @kindex C-c \
4015 @kindex C-c / m
4016 @item C-c \
4017 @itemx C-c / m
4018 Create a sparse tree with all headlines matching a tags search.  With a
4019 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4020 @kindex C-c a m
4021 @item C-c a m
4022 Create a global list of tag matches from all agenda files.
4023 @xref{Matching tags and properties}.
4024 @kindex C-c a M
4025 @item C-c a M
4026 @vindex org-tags-match-list-sublevels
4027 Create a global list of tag matches from all agenda files, but check
4028 only TODO items and force checking subitems (see variable
4029 @code{org-tags-match-list-sublevels}).
4030 @end table
4032 These commands all prompt for a match string which allows basic Boolean logic
4033 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
4034 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
4035 which are tagged @samp{Kathy} or @samp{Sally}.  The full syntax of the search
4036 string is rich and allows also matching against TODO keywords, entry levels
4037 and properties.  For a complete description with many examples, see
4038 @ref{Matching tags and properties}.
4041 @node Properties and Columns, Dates and Times, Tags, Top
4042 @chapter Properties and Columns
4043 @cindex properties
4045 Properties are a set of key-value pairs associated with an entry.  There
4046 are two main applications for properties in Org mode.  First, properties
4047 are like tags, but with a value.  Second, you can use properties to
4048 implement (very basic) database capabilities in an Org buffer.  For
4049 an example of the first application, imagine maintaining a file where
4050 you document bugs and plan releases of a piece of software.  Instead of
4051 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
4052 property, say @code{:Release:}, that in different subtrees has different
4053 values, such as @code{1.0} or @code{2.0}.  For an example of the second
4054 application of properties, imagine keeping track of your music CDs,
4055 where properties could be things such as the album artist, date of
4056 release, number of tracks, and so on.
4058 Properties can be conveniently edited and viewed in column view
4059 (@pxref{Column view}).
4061 @menu
4062 * Property syntax::             How properties are spelled out
4063 * Special properties::          Access to other Org mode features
4064 * Property searches::           Matching property values
4065 * Property inheritance::        Passing values down the tree
4066 * Column view::                 Tabular viewing and editing
4067 * Property API::                Properties for Lisp programmers
4068 @end menu
4070 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
4071 @section Property syntax
4072 @cindex property syntax
4073 @cindex drawer, for properties
4075 Properties are key-value pairs.  They need to be inserted into a special
4076 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
4077 is specified on a single line, with the key (surrounded by colons)
4078 first, and the value after it.  Here is an example:
4080 @example
4081 * CD collection
4082 ** Classic
4083 *** Goldberg Variations
4084     :PROPERTIES:
4085     :Title:     Goldberg Variations
4086     :Composer:  J.S. Bach
4087     :Artist:    Glen Gould
4088     :Publisher: Deutsche Grammophon
4089     :NDisks:    1
4090     :END:
4091 @end example
4093 You may define the allowed values for a particular property @samp{:Xyz:}
4094 by setting a property @samp{:Xyz_ALL:}.  This special property is
4095 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
4096 the entire tree.  When allowed values are defined, setting the
4097 corresponding property becomes easier and is less prone to typing
4098 errors.  For the example with the CD collection, we can predefine
4099 publishers and the number of disks in a box like this:
4101 @example
4102 * CD collection
4103   :PROPERTIES:
4104   :NDisks_ALL:  1 2 3 4
4105   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
4106   :END:
4107 @end example
4109 If you want to set properties that can be inherited by any entry in a
4110 file, use a line like
4112 @example
4113 #+PROPERTY: NDisks_ALL 1 2 3 4
4114 @end example
4116 @vindex org-global-properties
4117 Property values set with the global variable
4118 @code{org-global-properties} can be inherited by all entries in all
4119 Org files.
4121 @noindent
4122 The following commands help to work with properties:
4124 @table @kbd
4125 @kindex M-@key{TAB}
4126 @item M-@key{TAB}
4127 After an initial colon in a line, complete property keys.  All keys used
4128 in the current file will be offered as possible completions.
4129 @kindex C-c C-x p
4130 @item C-c C-x p
4131 Set a property.  This prompts for a property name and a value.  If
4132 necessary, the property drawer is created as well.
4133 @item M-x org-insert-property-drawer
4134 Insert a property drawer into the current entry.  The drawer will be
4135 inserted early in the entry, but after the lines with planning
4136 information like deadlines.
4137 @kindex C-c C-c
4138 @item C-c C-c
4139 With the cursor in a property drawer, this executes property commands.
4140 @item C-c C-c s
4141 Set a property in the current entry.  Both the property and the value
4142 can be inserted using completion.
4143 @kindex S-@key{right}
4144 @kindex S-@key{left}
4145 @item S-@key{left}/@key{right}
4146 Switch property at point to the next/previous allowed value.
4147 @item C-c C-c d
4148 Remove a property from the current entry.
4149 @item C-c C-c D
4150 Globally remove a property, from all entries in the current file.
4151 @item C-c C-c c
4152 Compute the property at point, using the operator and scope from the
4153 nearest column format definition.
4154 @end table
4156 @node Special properties, Property searches, Property syntax, Properties and Columns
4157 @section Special properties
4158 @cindex properties, special
4160 Special properties provide alternative access method to Org mode
4161 features discussed in the previous chapters, like the TODO state or the
4162 priority of an entry.  This interface exists so that you can include
4163 these states into columns view (@pxref{Column view}), or to use them in
4164 queries.  The following property names are special and should not be
4165 used as keys in the properties drawer:
4167 @example
4168 TODO         @r{The TODO keyword of the entry.}
4169 TAGS         @r{The tags defined directly in the headline.}
4170 ALLTAGS      @r{All tags, including inherited ones.}
4171 CATEGORY     @r{The category of an entry.}
4172 PRIORITY     @r{The priority of the entry, a string with a single letter.}
4173 DEADLINE     @r{The deadline time string, without the angular brackets.}
4174 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
4175 CLOSED       @r{When was this entry closed?}
4176 TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
4177 TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
4178 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
4179              @r{must be run first to compute the values.}
4180 @end example
4182 @node Property searches, Property inheritance, Special properties, Properties and Columns
4183 @section Property searches
4184 @cindex properties, searching
4185 @cindex searching, of properties
4187 To create sparse trees and special lists with selection based on properties,
4188 the same commands are used as for tag searches (@pxref{Tag searches}).
4189 @table @kbd
4190 @kindex C-c \
4191 @kindex C-c / m
4192 @item C-c \
4193 @itemx C-c / m
4194 Create a sparse tree with all matching entries.  With a
4195 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4196 @kindex C-c a m
4197 @item C-c a m
4198 Create a global list of tag/property  matches from all agenda files.
4199 @xref{Matching tags and properties}.
4200 @kindex C-c a M
4201 @item C-c a M
4202 @vindex org-tags-match-list-sublevels
4203 Create a global list of tag matches from all agenda files, but check
4204 only TODO items and force checking subitems (see variable
4205 @code{org-tags-match-list-sublevels}).
4206 @end table
4208 The syntax for the search string is described in @ref{Matching tags and
4209 properties}.
4211 There is also a special command for creating sparse trees based on a
4212 single property:
4214 @table @kbd
4215 @kindex C-c / p
4216 @item C-c / p
4217 Create a sparse tree based on the value of a property.  This first
4218 prompts for the name of a property, and then for a value.  A sparse tree
4219 is created with all entries that define this property with the given
4220 value.  If you enclose the value into curly braces, it is interpreted as
4221 a regular expression and matched against the property values.
4222 @end table
4224 @node Property inheritance, Column view, Property searches, Properties and Columns
4225 @section Property Inheritance
4226 @cindex properties, inheritance
4227 @cindex inheritance, of properties
4229 @vindex org-use-property-inheritance
4230 The outline structure of Org mode documents lends itself for an
4231 inheritance model of properties: If the parent in a tree has a certain
4232 property, the children can inherit this property.  Org mode does not
4233 turn this on by default, because it can slow down property searches
4234 significantly and is often not needed.  However, if you find inheritance
4235 useful, you can turn it on by setting the variable
4236 @code{org-use-property-inheritance}.  It may be set to @code{t}, to make
4237 all properties inherited from the parent, to a list of properties
4238 that should be inherited, or to a regular expression that matches
4239 inherited properties.
4241 Org mode has a few properties for which inheritance is hard-coded, at
4242 least for the special applications for which they are used:
4244 @table @code
4245 @item COLUMNS
4246 The @code{:COLUMNS:} property defines the format of column view
4247 (@pxref{Column view}).  It is inherited in the sense that the level
4248 where a @code{:COLUMNS:} property is defined is used as the starting
4249 point for a column view table, independently of the location in the
4250 subtree from where columns view is turned on.
4251 @item CATEGORY
4252 For agenda view, a category set through a @code{:CATEGORY:} property
4253 applies to the entire subtree.
4254 @item ARCHIVE
4255 For archiving, the @code{:ARCHIVE:} property may define the archive
4256 location for the entire subtree (@pxref{Moving subtrees}).
4257 @item LOGGING
4258 The LOGGING property may define logging settings for an entry or a
4259 subtree (@pxref{Tracking TODO state changes}).
4260 @end table
4262 @node Column view, Property API, Property inheritance, Properties and Columns
4263 @section Column view
4265 A great way to view and edit properties in an outline tree is
4266 @emph{column view}.  In column view, each outline item is turned into a
4267 table row.  Columns in this table provide access to properties of the
4268 entries.  Org mode implements columns by overlaying a tabular structure
4269 over the headline of each item.  While the headlines have been turned
4270 into a table row, you can still change the visibility of the outline
4271 tree.  For example, you get a compact table by switching to CONTENTS
4272 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
4273 is active), but you can still open, read, and edit the entry below each
4274 headline.  Or, you can switch to column view after executing a sparse
4275 tree command and in this way get a table only for the selected items.
4276 Column view also works in agenda buffers (@pxref{Agenda Views}) where
4277 queries have collected selected items, possibly from a number of files.
4279 @menu
4280 * Defining columns::            The COLUMNS format property
4281 * Using column view::           How to create and use column view
4282 * Capturing column view::       A dynamic block for column view
4283 @end menu
4285 @node Defining columns, Using column view, Column view, Column view
4286 @subsection Defining columns
4287 @cindex column view, for properties
4288 @cindex properties, column view
4290 Setting up a column view first requires defining the columns.  This is
4291 done by defining a column format line.
4293 @menu
4294 * Scope of column definitions::  Where defined, where valid?
4295 * Column attributes::           Appearance and content of a column
4296 @end menu
4298 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
4299 @subsubsection Scope of column definitions
4301 To define a column format for an entire file, use a line like
4303 @example
4304 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4305 @end example
4307 To specify a format that only applies to a specific tree, add a
4308 @code{:COLUMNS:} property to the top node of that tree, for example:
4310 @example
4311 ** Top node for columns view
4312    :PROPERTIES:
4313    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4314    :END:
4315 @end example
4317 If a @code{:COLUMNS:} property is present in an entry, it defines columns
4318 for the entry itself, and for the entire subtree below it.  Since the
4319 column definition is part of the hierarchical structure of the document,
4320 you can define columns on level 1 that are general enough for all
4321 sublevels, and more specific columns further down, when you edit a
4322 deeper part of the tree.
4324 @node Column attributes,  , Scope of column definitions, Defining columns
4325 @subsubsection Column attributes
4326 A column definition sets the attributes of a column.  The general
4327 definition looks like this:
4329 @example
4330  %[width]property[(title)][@{summary-type@}]
4331 @end example
4333 @noindent
4334 Except for the percent sign and the property name, all items are
4335 optional.  The individual parts have the following meaning:
4337 @example
4338 width           @r{An integer specifying the width of the column in characters.}
4339                 @r{If omitted, the width will be determined automatically.}
4340 property        @r{The property that should be edited in this column.}
4341 (title)         @r{The header text for the column. If omitted, the}
4342                 @r{property name is used.}
4343 @{summary-type@}  @r{The summary type.  If specified, the column values for}
4344                 @r{parent nodes are computed from the children.}
4345                 @r{Supported summary types are:}
4346                 @{+@}       @r{Sum numbers in this column.}
4347                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
4348                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
4349                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
4350                 @{X@}       @r{Checkbox status, [X] if all children are [X].}
4351                 @{X/@}      @r{Checkbox status, [n/m].}
4352                 @{X%@}      @r{Checkbox status, [n%].}
4353 @end example
4355 @noindent
4356 Here is an example for a complete columns definition, along with allowed
4357 values.
4359 @example
4360 :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.}
4361                    %10Time_Estimate@{:@} %CLOCKSUM
4362 :Owner_ALL:    Tammy Mark Karl Lisa Don
4363 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
4364 :Approved_ALL: "[ ]" "[X]"
4365 @end example
4367 The first column, @samp{%25ITEM}, means the first 25 characters of the
4368 item itself, i.e. of the headline.  You probably always should start the
4369 column definition with the @samp{ITEM} specifier.  The other specifiers
4370 create columns @samp{Owner} with a list of names as allowed values, for
4371 @samp{Status} with four different possible values, and for a checkbox
4372 field @samp{Approved}.  When no width is given after the @samp{%}
4373 character, the column will be exactly as wide as it needs to be in order
4374 to fully display all values.  The @samp{Approved} column does have a
4375 modified title (@samp{Approved?}, with a question mark).  Summaries will
4376 be created for the @samp{Time_Estimate} column by adding time duration
4377 expressions like HH:MM, and for the @samp{Approved} column, by providing
4378 an @samp{[X]} status if all children have been checked.  The
4379 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
4380 in the subtree.
4382 @node Using column view, Capturing column view, Defining columns, Column view
4383 @subsection Using column view
4385 @table @kbd
4386 @tsubheading{Turning column view on and off}
4387 @kindex C-c C-x C-c
4388 @item C-c C-x C-c
4389 @vindex org-columns-default-format
4390 Create the column view for the local environment.  This command searches
4391 the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
4392 a format.  When one is found, the column view table is established for
4393 the entire tree, starting from the entry that contains the @code{:COLUMNS:}
4394 property.  If none is found, the format is taken from the @code{#+COLUMNS}
4395 line or from the variable @code{org-columns-default-format}, and column
4396 view is established for the current entry and its subtree.
4397 @kindex r
4398 @item r
4399 Recreate the column view, to include recent changes made in the buffer.
4400 @kindex g
4401 @item g
4402 Same as @kbd{r}.
4403 @kindex q
4404 @item q
4405 Exit column view.
4406 @tsubheading{Editing values}
4407 @item @key{left} @key{right} @key{up} @key{down}
4408 Move through the column view from field to field.
4409 @kindex S-@key{left}
4410 @kindex S-@key{right}
4411 @item  S-@key{left}/@key{right}
4412 Switch to the next/previous allowed value of the field.  For this, you
4413 have to have specified allowed values for a property.
4414 @item 1..9,0
4415 Directly select the nth allowed value, @kbd{0} selects the 10th value.
4416 @kindex n
4417 @kindex p
4418 @itemx  n / p
4419 Same as @kbd{S-@key{left}/@key{right}}
4420 @kindex e
4421 @item e
4422 Edit the property at point.  For the special properties, this will
4423 invoke the same interface that you normally use to change that
4424 property.  For example, when editing a TAGS property, the tag completion
4425 or fast selection interface will pop up.
4426 @kindex C-c C-c
4427 @item C-c C-c
4428 When there is a checkbox at point, toggle it.
4429 @kindex v
4430 @item v
4431 View the full value of this property.  This is useful if the width of
4432 the column is smaller than that of the value.
4433 @kindex a
4434 @item a
4435 Edit the list of allowed values for this property.  If the list is found
4436 in the hierarchy, the modified values is stored there.  If no list is
4437 found, the new value is stored in the first entry that is part of the
4438 current column view.
4439 @tsubheading{Modifying the table structure}
4440 @kindex <
4441 @kindex >
4442 @item < / >
4443 Make the column narrower/wider by one character.
4444 @kindex S-M-@key{right}
4445 @item S-M-@key{right}
4446 Insert a new column, to the left of the current column.
4447 @kindex S-M-@key{left}
4448 @item S-M-@key{left}
4449 Delete the current column.
4450 @end table
4452 @node Capturing column view,  , Using column view, Column view
4453 @subsection Capturing column view
4455 Since column view is just an overlay over a buffer, it cannot be
4456 exported or printed directly.  If you want to capture a column view, use
4457 this @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
4458 of this block looks like this:
4460 @cindex #+BEGIN: columnview
4461 @example
4462 * The column view
4463 #+BEGIN: columnview :hlines 1 :id "label"
4465 #+END:
4466 @end example
4468 @noindent This dynamic block has the following parameters:
4470 @table @code
4471 @item :id
4472 This is most important parameter.  Column view is a feature that is
4473 often localized to a certain (sub)tree, and the capture block might be
4474 in a different location in the file.  To identify the tree whose view to
4475 capture, you can use 3 values:
4476 @example
4477 local     @r{use the tree in which the capture block is located}
4478 global    @r{make a global view, including all headings in the file}
4479 "file:path-to-file"
4480           @r{run column view at the top of this file}
4481 "ID"      @r{call column view in the tree that has an @code{:ID:}}
4482           @r{property with the value @i{label}.  You can use}
4483           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4484           @r{the current entry and copy it to the kill-ring.}
4485 @end example
4486 @item :hlines
4487 When @code{t}, insert a hline after every line.  When a number N, insert
4488 a hline before each headline with level @code{<= N}.
4489 @item :vlines
4490 When set to @code{t}, enforce column groups to get vertical lines.
4491 @item :maxlevel
4492 When set to a number, don't capture entries below this level.
4493 @item :skip-empty-rows
4494 When set to @code{t}, skip row where the only non-empty specifier of the
4495 column view is @code{ITEM}.
4497 @end table
4499 @noindent
4500 The following commands insert or update the dynamic block:
4502 @table @kbd
4503 @kindex C-c C-x i
4504 @item C-c C-x i
4505 Insert a dynamic block capturing a column view.  You will be prompted
4506 for the scope or id of the view.
4507 @kindex C-c C-c
4508 @item C-c C-c
4509 @kindex C-c C-x C-u
4510 @itemx C-c C-x C-u
4511 Update dynamical block at point.  The cursor needs to be in the
4512 @code{#+BEGIN} line of the dynamic block.
4513 @kindex C-u C-c C-x C-u
4514 @item C-u C-c C-x C-u
4515 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4516 you have several clock table blocks in a buffer.
4517 @end table
4519 You can add formulas to the column view table and you may add plotting
4520 instructions in front of the table - these will survive an update of the
4521 block.  If there is a @code{#+TBLFM:} after the table, the table will
4522 actually be recalculated automatically after an update.
4524 An alternative way to capture and process property values into a table is
4525 provided by Eric Schulte's @file{org-collector.el} which is a contributed
4526 package@footnote{Contributed packages are not part of Emacs, but are
4527 distributed with the main distribution of Org (see
4528 @uref{http://orgmode.org}).}.  It provides a general API to collect
4529 properties from entries in a certain scope, and arbitrary Lisp expressions to
4530 process these values before inserting them into a table or a dynamic block.
4532 @node Property API,  , Column view, Properties and Columns
4533 @section The Property API
4534 @cindex properties, API
4535 @cindex API, for properties
4537 There is a full API for accessing and changing properties.  This API can
4538 be used by Emacs Lisp programs to work with properties and to implement
4539 features based on them.  For more information see @ref{Using the
4540 property API}.
4542 @node Dates and Times, Capture, Properties and Columns, Top
4543 @chapter Dates and Times
4544 @cindex dates
4545 @cindex times
4546 @cindex time stamps
4547 @cindex date stamps
4549 To assist project planning, TODO items can be labeled with a date and/or
4550 a time.  The specially formatted string carrying the date and time
4551 information is called a @emph{timestamp} in Org mode.  This may be a
4552 little confusing because timestamp is often used as indicating when
4553 something was created or last changed.  However, in Org mode this term
4554 is used in a much wider sense.
4556 @menu
4557 * Timestamps::                  Assigning a time to a tree entry
4558 * Creating timestamps::         Commands which insert timestamps
4559 * Deadlines and scheduling::    Planning your work
4560 * Clocking work time::          Tracking how long you spend on a task
4561 * Effort estimates::            Planning work effort in advance
4562 * Relative timer::              Notes with a running timer
4563 @end menu
4566 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4567 @section Timestamps, deadlines and scheduling
4568 @cindex time stamps
4569 @cindex ranges, time
4570 @cindex date stamps
4571 @cindex deadlines
4572 @cindex scheduling
4574 A time stamp is a specification of a date (possibly with time or a range
4575 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4576 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4577 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4578 use an alternative format, see @ref{Custom time format}.}.  A time stamp
4579 can appear anywhere in the headline or body of an Org tree entry.  Its
4580 presence causes entries to be shown on specific dates in the agenda
4581 (@pxref{Weekly/daily agenda}).  We distinguish:
4583 @table @var
4584 @item Plain time stamp; Event; Appointment
4585 @cindex timestamp
4586 A simple time stamp just assigns a date/time to an item.  This is just
4587 like writing down an appointment or event in a paper agenda.  In the
4588 timeline and agenda displays, the headline of an entry associated with a
4589 plain time stamp will be shown exactly on that date.
4591 @example
4592 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4593 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4594 @end example
4596 @item Time stamp with repeater interval
4597 @cindex timestamp, with repeater interval
4598 A time stamp may contain a @emph{repeater interval}, indicating that it
4599 applies not only on the given date, but again and again after a certain
4600 interval of N days (d), weeks (w), months(m), or years(y).  The
4601 following will show up in the agenda every Wednesday:
4603 @example
4604 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4605 @end example
4607 @item Diary-style sexp entries
4608 For more complex date specifications, Org mode supports using the
4609 special sexp diary entries implemented in the Emacs calendar/diary
4610 package.  For example
4612 @example
4613 * The nerd meeting on every 2nd Thursday of the month
4614   <%%(diary-float t 4 2)>
4615 @end example
4617 @item Time/Date range
4618 @cindex timerange
4619 @cindex date range
4620 Two time stamps connected by @samp{--} denote a range.  The headline
4621 will be shown on the first and last day of the range, and on any dates
4622 that are displayed and fall in the range.  Here is an example:
4624 @example
4625 ** Meeting in Amsterdam
4626    <2004-08-23 Mon>--<2004-08-26 Thu>
4627 @end example
4629 @item Inactive time stamp
4630 @cindex timestamp, inactive
4631 @cindex inactive timestamp
4632 Just like a plain time stamp, but with square brackets instead of
4633 angular ones.  These time stamps are inactive in the sense that they do
4634 @emph{not} trigger an entry to show up in the agenda.
4636 @example
4637 * Gillian comes late for the fifth time [2006-11-01 Wed]
4638 @end example
4640 @end table
4642 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4643 @section Creating timestamps
4644 @cindex creating timestamps
4645 @cindex timestamps, creating
4647 For Org mode to recognize time stamps, they need to be in the specific
4648 format.  All commands listed below produce time stamps in the correct
4649 format.
4651 @table @kbd
4652 @kindex C-c .
4653 @item C-c .
4654 Prompt for a date and insert a corresponding time stamp.  When the cursor is
4655 at an existing time stamp in the buffer, the command is used to modify this
4656 timestamp instead of inserting a new one.  When this command is used twice in
4657 succession, a time range is inserted.
4659 @kindex C-c !
4660 @item C-c !
4661 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
4662 an agenda entry.
4664 @kindex C-u C-c .
4665 @kindex C-u C-c !
4666 @item C-u C-c .
4667 @itemx C-u C-c !
4668 @vindex org-time-stamp-rounding-minutes
4669 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
4670 contains date and time.  The default time can be rounded to multiples of 5
4671 minutes, see the option @code{org-time-stamp-rounding-minutes}.
4673 @kindex C-c <
4674 @item C-c <
4675 Insert a time stamp corresponding to the cursor date in the Calendar.
4677 @kindex C-c >
4678 @item C-c >
4679 Access the Emacs calendar for the current date.  If there is a
4680 timestamp in the current line, go to the corresponding date
4681 instead.
4683 @kindex C-c C-o
4684 @item C-c C-o
4685 Access the agenda for the date given by the time stamp or -range at
4686 point (@pxref{Weekly/daily agenda}).
4688 @kindex S-@key{left}
4689 @kindex S-@key{right}
4690 @item S-@key{left}
4691 @itemx S-@key{right}
4692 Change date at cursor by one day.  These key bindings conflict with
4693 CUA mode (@pxref{Conflicts}).
4695 @kindex S-@key{up}
4696 @kindex S-@key{down}
4697 @item S-@key{up}
4698 @itemx S-@key{down}
4699 Change the item under the cursor in a timestamp.  The cursor can be on a
4700 year, month, day, hour or minute.  Note that if the cursor is in a
4701 headline and not at a time stamp, these same keys modify the priority of
4702 an item.  (@pxref{Priorities}). The key bindings also conflict with
4703 CUA mode (@pxref{Conflicts}).
4705 @kindex C-c C-y
4706 @cindex evaluate time range
4707 @item C-c C-y
4708 Evaluate a time range by computing the difference between start and end.
4709 With a prefix argument, insert result after the time range (in a table: into
4710 the following column).
4711 @end table
4714 @menu
4715 * The date/time prompt::        How Org mode helps you entering date and time
4716 * Custom time format::          Making dates look different
4717 @end menu
4719 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4720 @subsection The date/time prompt
4721 @cindex date, reading in minibuffer
4722 @cindex time, reading in minibuffer
4724 @vindex org-read-date-prefer-future
4725 When Org mode prompts for a date/time, the default is shown as an ISO
4726 date, and the prompt therefore seems to ask for an ISO date.  But it
4727 will in fact accept any string containing some date and/or time
4728 information, and it is really smart about interpreting your input.  You
4729 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4730 copied from an email message.  Org mode will find whatever information
4731 is in there and derive anything you have not specified from the
4732 @emph{default date and time}.  The default is usually the current date
4733 and time, but when modifying an existing time stamp, or when entering
4734 the second stamp of a range, it is taken from the stamp in the buffer.
4735 When filling in information, Org mode assumes that most of the time you
4736 will want to enter a date in the future: If you omit the month/year and
4737 the given day/month is @i{before} today, it will assume that you mean a
4738 future date@footnote{See the variable
4739 @code{org-read-date-prefer-future}.}.
4741 For example, let's assume that today is @b{June 13, 2006}.  Here is how
4742 various inputs will be interpreted, the items filled in by Org mode are
4743 in @b{bold}.
4745 @example
4746 3-2-5         --> 2003-02-05
4747 14            --> @b{2006}-@b{06}-14
4748 12            --> @b{2006}-@b{07}-12
4749 Fri           --> nearest Friday (defaultdate or later)
4750 sep 15        --> @b{2006}-09-15
4751 feb 15        --> @b{2007}-02-15
4752 sep 12 9      --> 2009-09-12
4753 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
4754 22 sept 0:34  --> @b{2006}-09-22 0:34
4755 w4            --> ISO week for of the current year @b{2006}
4756 2012 w4 fri   --> Friday of ISO week 4 in 2012
4757 2012-w04-5    --> Same as above
4758 @end example
4760 Furthermore you can specify a relative date by giving, as the
4761 @emph{first} thing in the input: a plus/minus sign, a number and a
4762 letter [dwmy] to indicate change in days weeks, months, years.  With a
4763 single plus or minus, the date is always relative to today.  With a
4764 double plus or minus, it is relative to the default date.  If instead of
4765 a single letter, you use the abbreviation of day name, the date will be
4766 the nth such day.  E.g.
4768 @example
4769 +0            --> today
4770 .             --> today
4771 +4d           --> four days from today
4772 +4            --> same as above
4773 +2w           --> two weeks from today
4774 ++5           --> five days from default date
4775 +2tue         --> second tuesday from now.
4776 @end example
4778 @vindex parse-time-months
4779 @vindex parse-time-weekdays
4780 The function understands English month and weekday abbreviations.  If
4781 you want to use unabbreviated names and/or other languages, configure
4782 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
4784 @cindex calendar, for selecting date
4785 @vindex org-popup-calendar-for-date-prompt
4786 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
4787 you don't need/want the calendar, configure the variable
4788 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
4789 prompt, either by clicking on a date in the calendar, or by pressing
4790 @key{RET}, the date selected in the calendar will be combined with the
4791 information entered at the prompt.  You can control the calendar fully
4792 from the minibuffer:
4794 @kindex <
4795 @kindex >
4796 @kindex mouse-1
4797 @kindex S-@key{right}
4798 @kindex S-@key{left}
4799 @kindex S-@key{down}
4800 @kindex S-@key{up}
4801 @kindex M-S-@key{right}
4802 @kindex M-S-@key{left}
4803 @kindex @key{RET}
4804 @example
4805 > / <          @r{Scroll calendar forward/backward by one month.}
4806 mouse-1        @r{Select date by clicking on it.}
4807 S-@key{right}/@key{left}     @r{One day forward/backward.}
4808 S-@key{down}/@key{up}     @r{One week forward/backward.}
4809 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
4810 @key{RET}           @r{Choose date in calendar.}
4811 @end example
4813 @vindex org-read-date-display-live
4814 The actions of the date/time prompt may seem complex, but I assure you they
4815 will grow on you, and you will start getting annoyed by pretty much any other
4816 way of entering a date/time out there.  To help you understand what is going
4817 on, the current interpretation of your input will be displayed live in the
4818 minibuffer@footnote{If you find this distracting, turn the display of with
4819 @code{org-read-date-display-live}.}.
4821 @node Custom time format,  , The date/time prompt, Creating timestamps
4822 @subsection Custom time format
4823 @cindex custom date/time format
4824 @cindex time format, custom
4825 @cindex date format, custom
4827 @vindex org-display-custom-times
4828 @vindex org-time-stamp-custom-formats
4829 Org mode uses the standard ISO notation for dates and times as it is
4830 defined in ISO 8601.  If you cannot get used to this and require another
4831 representation of date and time to keep you happy, you can get it by
4832 customizing the variables @code{org-display-custom-times} and
4833 @code{org-time-stamp-custom-formats}.
4835 @table @kbd
4836 @kindex C-c C-x C-t
4837 @item C-c C-x C-t
4838 Toggle the display of custom formats for dates and times.
4839 @end table
4841 @noindent
4842 Org mode needs the default format for scanning, so the custom date/time
4843 format does not @emph{replace} the default format - instead it is put
4844 @emph{over} the default format using text properties.  This has the
4845 following consequences:
4846 @itemize @bullet
4847 @item
4848 You cannot place the cursor onto a time stamp anymore, only before or
4849 after.
4850 @item
4851 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4852 each component of a time stamp.  If the cursor is at the beginning of
4853 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4854 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4855 time will be changed by one minute.
4856 @item
4857 If the time stamp contains a range of clock times or a repeater, these
4858 will not be overlayed, but remain in the buffer as they were.
4859 @item
4860 When you delete a time stamp character-by-character, it will only
4861 disappear from the buffer after @emph{all} (invisible) characters
4862 belonging to the ISO timestamp have been removed.
4863 @item
4864 If the custom time stamp format is longer than the default and you are
4865 using dates in tables, table alignment will be messed up.  If the custom
4866 format is shorter, things do work as expected.
4867 @end itemize
4870 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
4871 @section Deadlines and scheduling
4873 A time stamp may be preceded by special keywords to facilitate planning:
4875 @table @var
4876 @item DEADLINE
4877 @cindex DEADLINE keyword
4879 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
4880 to be finished on that date.
4882 @vindex org-deadline-warning-days
4883 On the deadline date, the task will be listed in the agenda.  In
4884 addition, the agenda for @emph{today} will carry a warning about the
4885 approaching or missed deadline, starting
4886 @code{org-deadline-warning-days} before the due date, and continuing
4887 until the entry is marked DONE.  An example:
4889 @example
4890 *** TODO write article about the Earth for the Guide
4891     The editor in charge is [[bbdb:Ford Prefect]]
4892     DEADLINE: <2004-02-29 Sun>
4893 @end example
4895 You can specify a different lead time for warnings for a specific
4896 deadlines using the following syntax.  Here is an example with a warning
4897 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4899 @item SCHEDULED
4900 @cindex SCHEDULED keyword
4902 Meaning: you are planning to start working on that task on the given
4903 date.
4905 @vindex org-agenda-skip-scheduled-if-done
4906 The headline will be listed under the given date@footnote{It will still
4907 be listed on that date after it has been marked DONE.  If you don't like
4908 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4909 addition, a reminder that the scheduled date has passed will be present
4910 in the compilation for @emph{today}, until the entry is marked DONE.
4911 I.e., the task will automatically be forwarded until completed.
4913 @example
4914 *** TODO Call Trillian for a date on New Years Eve.
4915     SCHEDULED: <2004-12-25 Sat>
4916 @end example
4918 @noindent
4919 @b{Important:} Scheduling an item in Org mode should @i{not} be
4920 understood in the same way that we understand @i{scheduling a meeting}.
4921 Setting a date for a meeting is just a simple appointment, you should
4922 mark this entry with a simple plain time stamp, to get this item shown
4923 on the date where it applies.  This is a frequent mis-understanding from
4924 Org-users.  In Org mode, @i{scheduling} means setting a date when you
4925 want to start working on an action item.
4926 @end table
4928 You may use time stamps with repeaters in scheduling and deadline
4929 entries.  Org mode will issue early and late warnings based on the
4930 assumption that the time stamp represents the @i{nearest instance} of
4931 the repeater.  However, the use of diary sexp entries like
4933 @code{<%%(diary-float t 42)>}
4935 in scheduling and deadline timestamps is limited.  Org mode does not
4936 know enough about the internals of each sexp function to issue early and
4937 late warnings.  However, it will show the item on each day where the
4938 sexp entry matches.
4940 @menu
4941 * Inserting deadline/schedule::  Planning items
4942 * Repeated tasks::              Items that show up again and again
4943 @end menu
4945 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4946 @subsection Inserting deadlines or schedules
4948 The following commands allow to quickly insert a deadline or to schedule
4949 an item:
4951 @table @kbd
4953 @kindex C-c C-d
4954 @item C-c C-d
4955 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4956 happen in the line directly following the headline.  When called with a
4957 prefix arg, an existing deadline will be removed from the entry.
4958 @c FIXME Any CLOSED timestamp will be removed.????????
4960 @kindex C-c / d
4961 @cindex sparse tree, for deadlines
4962 @item C-c / d
4963 @vindex org-deadline-warning-days
4964 Create a sparse tree with all deadlines that are either past-due, or
4965 which will become due within @code{org-deadline-warning-days}.
4966 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4967 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
4968 all deadlines due tomorrow.
4970 @kindex C-c C-s
4971 @item C-c C-s
4972 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4973 happen in the line directly following the headline.  Any CLOSED
4974 timestamp will be removed.  When called with a prefix argument, remove
4975 the scheduling date from the entry.
4977 @kindex C-c C-x C-k
4978 @kindex k a
4979 @kindex k s
4980 @item C-c C-x C-k
4981 Mark the current entry for agenda action.  After you have marked the entry
4982 like this, you can open the agenda or the calendar to find an appropriate
4983 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
4984 schedule the marked item.
4985 @end table
4987 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4988 @subsection Repeated tasks
4990 Some tasks need to be repeated again and again.  Org mode helps to
4991 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
4992 or plain time stamp.  In the following example
4993 @example
4994 ** TODO Pay the rent
4995    DEADLINE: <2005-10-01 Sat +1m>
4996 @end example
4997 the @code{+1m} is a repeater; the intended interpretation is that the task
4998 has a deadline on <2005-10-01> and repeats itself every (one) month starting
4999 from that time.  If you need both a repeater and a special warning period in
5000 a deadline entry, the repeater should come first and the warning period last:
5001 @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
5003 Deadlines and scheduled items produce entries in the agenda when they
5004 are over-due, so it is important to be able to mark such an entry as
5005 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
5006 with the TODO keyword DONE, it will no longer produce entries in the
5007 agenda.  The problem with this is, however, that then also the
5008 @emph{next} instance of the repeated entry will not be active.  Org mode
5009 deals with this in the following way: When you try to mark such an entry
5010 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
5011 time stamp by the repeater interval, and immediately set the entry state
5012 back to TODO.  In the example above, setting the state to DONE would
5013 actually switch the date like this:
5015 @example
5016 ** TODO Pay the rent
5017    DEADLINE: <2005-11-01 Tue +1m>
5018 @end example
5020 @vindex org-log-repeat
5021 A timestamp@footnote{You can change this using the option
5022 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
5023 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
5024 will also be prompted for a note.} will be added under the deadline, to keep
5025 a record that you actually acted on the previous instance of this deadline.
5027 As a consequence of shifting the base date, this entry will no longer be
5028 visible in the agenda when checking past dates, but all future instances
5029 will be visible.
5031 With the @samp{+1m} cookie, the date shift will always be exactly one
5032 month.  So if you have not payed the rent for three months, marking this
5033 entry DONE will still keep it as an overdue deadline.  Depending on the
5034 task, this may not be the best way to handle it.  For example, if you
5035 forgot to call you father for 3 weeks, it does not make sense to call
5036 him 3 times in a single day to make up for it.  Finally, there are tasks
5037 like changing batteries which should always repeat a certain time
5038 @i{after} the last time you did it.  For these tasks, Org mode has
5039 special repeaters markers with @samp{++} and @samp{.+}.  For example:
5041 @example
5042 ** TODO Call Father
5043    DEADLINE: <2008-02-10 Sun ++1w>
5044    Marking this DONE will shift the date by at least one week,
5045    but also by as many weeks as it takes to get this date into
5046    the future.  However, it stays on a Sunday, even if you called
5047    and marked it done on Saturday.
5048 ** TODO Check the batteries in the smoke detectors
5049    DEADLINE: <2005-11-01 Tue .+1m>
5050    Marking this DONE will shift the date to one month after
5051    today.
5052 @end example
5054 You may have both scheduling and deadline information for a specific
5055 task - just make sure that the repeater intervals on both are the same.
5057 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
5058 @section Clocking work time
5060 Org mode allows you to clock the time you spent on specific tasks in a
5061 project.  When you start working on an item, you can start the clock.
5062 When you stop working on that task, or when you mark the task done, the
5063 clock is stopped and the corresponding time interval is recorded.  It
5064 also computes the total time spent on each subtree of a project.
5066 Normally, the clock does not survive xiting and re-entereing Emacs, but you
5067 can arrange for the clock information to persisst accress Emacs sessions with
5069 @lisp
5070 (setq org-clock-persist t)
5071 (org-clock-persistence-insinuate)
5072 @end lisp
5074 @table @kbd
5075 @kindex C-c C-x C-i
5076 @item C-c C-x C-i
5077 @vindex org-clock-into-drawer
5078 Start the clock on the current item (clock-in).  This inserts the CLOCK
5079 keyword together with a timestamp.  If this is not the first clocking of
5080 this item, the multiple CLOCK lines will be wrapped into a
5081 @code{:CLOCK:} drawer (see also the variable
5082 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
5083 select the task from a list of recently clocked tasks.  With two @kbd{C-u
5084 C-u} prefixes, clock into the task at point and mark it as the default task.
5085 The default task will always be available when selecting a clocking task,
5086 with letter @kbd{d}.
5087 @kindex C-c C-x C-o
5088 @item C-c C-x C-o
5089 @vindex org-log-note-clock-out
5090 Stop the clock (clock-out).  This inserts another timestamp at the same
5091 location where the clock was last started.  It also directly computes
5092 the resulting time in inserts it after the time range as @samp{=>
5093 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
5094 possibility to record an additional note together with the clock-out
5095 time stamp@footnote{The corresponding in-buffer setting is:
5096 @code{#+STARTUP: lognoteclock-out}}.
5097 @kindex C-c C-y
5098 @item C-c C-y
5099 Recompute the time interval after changing one of the time stamps.  This
5100 is only necessary if you edit the time stamps directly.  If you change
5101 them with @kbd{S-@key{cursor}} keys, the update is automatic.
5102 @kindex C-c C-t
5103 @item C-c C-t
5104 Changing the TODO state of an item to DONE automatically stops the clock
5105 if it is running in this same item.
5106 @kindex C-c C-x C-x
5107 @item C-c C-x C-x
5108 Cancel the current clock.  This is useful if a clock was started by
5109 mistake, or if you ended up working on something else.
5110 @kindex C-c C-x C-j
5111 @item C-c C-x C-j
5112 Jump to the entry that contains the currently running clock.  With a
5113 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
5114 tasks.
5115 @kindex C-c C-x C-d
5116 @item C-c C-x C-d
5117 @vindex org-remove-highlights-with-change
5118 Display time summaries for each subtree in the current buffer.  This
5119 puts overlays at the end of each headline, showing the total time
5120 recorded under that heading, including the time of any subheadings. You
5121 can use visibility cycling to study the tree, but the overlays disappear
5122 when you change the buffer (see variable
5123 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
5124 @kindex C-c C-x C-r
5125 @item C-c C-x C-r
5126 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
5127 report as an Org mode table into the current file.  When the cursor is
5128 at an existing clock table, just update it.  When called with a prefix
5129 argument, jump to the first clock report in the current document and
5130 update it.
5131 @cindex #+BEGIN: clocktable
5132 @example
5133 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
5134 #+END: clocktable
5135 @end example
5136 @noindent
5137 If such a block already exists at point, its content is replaced by the
5138 new table.  The @samp{BEGIN} line can specify options:
5139 @example
5140 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
5141 :emphasize   @r{When @code{t}, emphasize level one and level two items}
5142 :scope       @r{The scope to consider.  This can be any of the following:}
5143              nil        @r{the current buffer or narrowed region}
5144              file       @r{the full current buffer}
5145              subtree    @r{the subtree where the clocktable is located}
5146              treeN      @r{the surrounding level N tree, for example @code{tree3}}
5147              tree       @r{the surrounding level 1 tree}
5148              agenda     @r{all agenda files}
5149              ("file"..) @r{scan these files}
5150              file-with-archives    @r{current file and its archives}
5151              agenda-with-archives  @r{all agenda files, including archives}
5152 :block       @r{The time block to consider.  This block is specified either}
5153              @r{absolute, or relative to the current time and may be any of}
5154              @r{these formats:}
5155              2007-12-31    @r{New year eve 2007}
5156              2007-12       @r{December 2007}
5157              2007-W50      @r{ISO-week 50 in 2007}
5158              2007          @r{the year 2007}
5159              today, yesterday, today-N          @r{a relative day}
5160              thisweek, lastweek, thisweek-N     @r{a relative week}
5161              thismonth, lastmonth, thismonth-N  @r{a relative month}
5162              thisyear, lastyear, thisyear-N     @r{a relative year}
5163              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
5164 :tstart      @r{A time string specifying when to start considering times}
5165 :tend        @r{A time string specifying when to stop considering times}
5166 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
5167              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
5168 :link        @r{Link the item headlines in the table to their origins}
5169 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
5170              @r{As a special case, @samp{:formula %} adds column with % time.}
5171              @r{If you do not specify a formula here, any existing formula}
5172              @r{below the clock table will survive updates and be evaluated.}
5173 @end example
5174 So to get a clock summary of the current level 1 tree, for the current
5175 day, you could write
5176 @example
5177 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
5178 #+END: clocktable
5179 @end example
5180 and to use a specific time range you could write@footnote{Note that all
5181 parameters must be specified in a single line - the line is broken here
5182 only to fit it onto the manual.}
5183 @example
5184 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
5185                     :tend "<2006-08-10 Thu 12:00>"
5186 #+END: clocktable
5187 @end example
5188 A summary of the current subtree with % times would be
5189 @example
5190 #+BEGIN: clocktable :scope subtree :link t :formula %
5191 #+END: clocktable
5192 @end example
5193 @kindex C-c C-c
5194 @item C-c C-c
5195 @kindex C-c C-x C-u
5196 @itemx C-c C-x C-u
5197 Update dynamical block at point.  The cursor needs to be in the
5198 @code{#+BEGIN} line of the dynamic block.
5199 @kindex C-u C-c C-x C-u
5200 @item C-u C-c C-x C-u
5201 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5202 you have several clock table blocks in a buffer.
5203 @kindex S-@key{left}
5204 @kindex S-@key{right}
5205 @item S-@key{left}
5206 @itemx S-@key{right}
5207 Shift the current @code{:block} interval and update the table.  The cursor
5208 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
5209 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
5210 @end table
5212 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
5213 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
5214 worked on or closed during a day.
5216 @node Effort estimates, Relative timer, Clocking work time, Dates and Times
5217 @section Effort estimates
5218 @cindex effort estimates
5220 @vindex org-effort-property
5221 If you want to plan your work in a very detailed way, or if you need to
5222 produce offers with quotations of the estimated work effort, you may want to
5223 assign effort estimates to entries.  If you are also clocking your work, you
5224 may later want to compare the planned effort with the actual working time, a
5225 great way to improve planning estimates.  Effort estimates are stored in a
5226 special property @samp{Effort}@footnote{You may change the property being
5227 used with the variable @code{org-effort-property}.}.  Clearly the best way to
5228 work with effort estimates is through column view (@pxref{Column view}).  You
5229 should start by setting up discrete values for effort estimates, and a
5230 @code{COLUMNS} format that displays these values together with clock sums (if
5231 you want to clock your time).  For a specific buffer you can use
5233 @example
5234 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
5235 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
5236 @end example
5238 @noindent
5239 @vindex org-global-properties
5240 @vindex org-columns-default-format
5241 or, even better, you can set up these values globally by customizing the
5242 variables @code{org-global-properties} and @code{org-columns-default-format}.
5243 In particular if you want to use this setup also in the agenda, a global
5244 setup may be advised.
5246 The way to assign estimates to individual items is then to switch to column
5247 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
5248 value.  The values you enter will immediately be summed up in the hierarchy.
5249 In the column next to it, any clocked time will be displayed.
5251 @vindex org-agenda-columns-add-appointments-to-effort-sum
5252 If you switch to column view in the daily/weekly agenda, the effort column
5253 will summarize the estimated work effort for each day@footnote{Please note
5254 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
5255 column view}).}, and you can use this to find space in your schedule.  To get
5256 an overview of the entire part of the day that is committed, you can set the
5257 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
5258 appointments on a day that take place over a specified time interval will
5259 then also be added to the load estimate of the day.
5261 Effort estimates can be used in secondary agenda filtering that is triggered
5262 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
5263 these estimates defined consistently, two or three key presses will narrow
5264 down the list to stuff that fits into an available time slot.
5266 @node Relative timer,  , Effort estimates, Dates and Times
5267 @section Taking notes with a relative timer
5268 @cindex relative timer
5270 When taking notes during, for example, a meeting or a video viewing, it can
5271 be useful to have access to times relative to a starting time.  Org provides
5272 such a relative timer and make it easy to create timed notes.
5274 @table @kbd
5275 @kindex C-c C-x .
5276 @item C-c C-x .
5277 Insert a relative time into the buffer.  The first time you use this, the
5278 timer will be started.  When called with a prefix argument, the timer is
5279 restarted.
5280 @kindex C-c C-x -
5281 @item C-c C-x -
5282 Insert a description list item with the current relative time.  With a prefix
5283 argument, first reset the timer to 0.
5284 @kindex M-@key{RET}
5285 @item M-@key{RET}
5286 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
5287 new timer items.
5288 @kindex C-c C-x ,
5289 @item C-c C-x ,
5290 Pause the timer, or continue it if it is already paused.  With prefix
5291 argument, stop it entirely.
5292 @kindex C-u C-c C-x ,
5293 @item C-u C-c C-x ,
5294 Stop the timer.  After this, you can only start a new timer, not continue the
5295 old one.  This command also removes the timer from the mode line.
5296 @kindex C-c C-x 0
5297 @item C-c C-x 0
5298 Reset the timer without inserting anything into the buffer.  By default, the
5299 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
5300 specific starting offset.  The user is prompted for the offset, with a
5301 default taken from a timer string at point, if any, So this can be used to
5302 restart taking notes after a break in the process.  When called with a double
5303 prefix argument @kbd{C-c C-u}, change all timer strings in the active region
5304 by a certain amount.  This can be used to fix timer strings if the timer was
5305 not started at exactly the right moment.
5306 @end table
5308 @node Capture, Agenda Views, Dates and Times, Top
5309 @chapter Capture
5310 @cindex capture
5312 An important part of any organization system is the ability to quickly
5313 capture new ideas and tasks, and to associate reference material with them.
5314 Org uses the @file{remember} package to create tasks, and stores files
5315 related to a task (@i{attachments}) in a special directory.
5317 @menu
5318 * Remember::                    Capture new tasks/ideas with little interruption
5319 * Attachments::                 Add files to tasks.
5320 @end menu
5322 @node Remember, Attachments, Capture, Capture
5323 @section Remember
5324 @cindex @file{remember.el}
5326 The @i{Remember} package by John Wiegley lets you store quick notes with
5327 little interruption of your work flow.  See
5328 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
5329 information.  It is an excellent way to add new notes and tasks to
5330 Org files.  Org significantly expands the possibilities of
5331 @i{remember}: You may define templates for different note types, and
5332 associate target files and headlines with specific templates.  It also
5333 allows you to select the location where a note should be stored
5334 interactively, on the fly.
5336 @menu
5337 * Setting up Remember::         Some code for .emacs to get things going
5338 * Remember templates::          Define the outline of different note types
5339 * Storing notes::               Directly get the note to where it belongs
5340 * Refiling notes::              Moving a note or task to a project
5341 @end menu
5343 @node Setting up Remember, Remember templates, Remember, Remember
5344 @subsection Setting up Remember
5346 The following customization will tell @i{remember} to use org files as
5347 target, and to create annotations compatible with Org links.
5349 @example
5350 (org-remember-insinuate)
5351 (setq org-directory "~/path/to/my/orgfiles/")
5352 (setq org-default-notes-file (concat org-directory "/notes.org"))
5353 (define-key global-map "\C-cr" 'org-remember)
5354 @end example
5356 The last line binds the command @code{org-remember} to a global
5357 key@footnote{Please select your own key, @kbd{C-c r} is only a
5358 suggestion.}.  @code{org-remember} basically just calls @code{remember},
5359 but it makes a few things easier: If there is an active region, it will
5360 automatically copy the region into the remember buffer.  It also allows
5361 to jump to the buffer and location where remember notes are being
5362 stored: Just call @code{org-remember} with a prefix argument.  If you
5363 use two prefix arguments, Org jumps to the location where the last
5364 remember note was stored.
5366 The remember buffer will actually use @code{org-mode} as its major mode, so
5367 that all editing features of Org-mode are available.  In addition to this, a
5368 minor mode @code{org-remember-mode} is turned on, for the single purpose that
5369 you can use its keymap @code{org-remember-mode-map} to overwrite some of
5370 Org-mode's key bindings.
5372 You can also call @code{org-remember} in a special way from the agenda,
5373 using the @kbd{k r} key combination.  With this access, any time stamps
5374 inserted by the selected remember template (see below) will default to
5375 the cursor date in the agenda, rather than to the current date.
5377 @node Remember templates, Storing notes, Setting up Remember, Remember
5378 @subsection Remember templates
5379 @cindex templates, for remember
5381 In combination with Org, you can use templates to generate
5382 different types of @i{remember} notes.  For example, if you would like
5383 to use one template to create general TODO entries, another one for
5384 journal entries, and a third one for collecting random ideas, you could
5385 use:
5387 @example
5388 (setq org-remember-templates
5389  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
5390    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
5391    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5392 @end example
5394 @vindex org-remember-default-headline
5395 @vindex org-directory
5396 @noindent In these entries, the first string is just a name, and the
5397 character specifies how to select the template.  It is useful if the
5398 character is also the first letter of the name.  The next string specifies
5399 the template.  Two more (optional) strings give the file in which, and the
5400 headline under which the new note should be stored.  The file (if not present
5401 or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
5402 @code{org-remember-default-headline}.  If the file name is not an absolute
5403 path, it will be interpreted relative to @code{org-directory}.  The heading
5404 can also be the symbols @code{top} or @code{bottom} to send note as level 1
5405 entries to the beginning or end of the file, respectively.
5407 An optional sixth element specifies the contexts in which the user can select
5408 the template.  This element can be a list of major modes or a function.
5409 @code{org-remember} will first check whether the function returns @code{t} or
5410 if we are in any of the listed major mode, and exclude templates for which
5411 this condition is not fulfilled.  Templates that do not specify this element
5412 at all, or that use @code{nil} or @code{t} as a value will always be
5413 selectable.
5415 So for example:
5417 @example
5418 (setq org-remember-templates
5419  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
5420    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
5421    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5422 @end example
5424 The first template will only be available when invoking @code{org-remember}
5425 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
5426 available when the function @code{my-check} returns @code{t}.  The third
5427 template will be proposed in any context.
5429 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
5430 something, Org will prompt for a key to select the template (if you have
5431 more than one template) and then prepare the buffer like
5432 @example
5433 * TODO
5434   [[file:link to where you called remember]]
5435 @end example
5437 @noindent
5438 During expansion of the template, special @kbd{%}-escapes allow dynamic
5439 insertion of content:
5440 @example
5441 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
5442             @r{You may specify a default value and a completion table with}
5443             @r{%^@{prompt|default|completion2|completion3...@}}
5444             @r{The arrow keys access a prompt-specific history.}
5445 %a          @r{annotation, normally the link created with @code{org-store-link}}
5446 %A          @r{like @code{%a}, but prompt for the description part}
5447 %i          @r{initial content, the region when remember is called with C-u.}
5448             @r{The entire text will be indented like @code{%i} itself.}
5449 %t          @r{time stamp, date only}
5450 %T          @r{time stamp with date and time}
5451 %u, %U      @r{like the above, but inactive time stamps}
5452 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
5453             @r{You may define a prompt like @code{%^@{Birthday@}t}}
5454 %n          @r{user name (taken from @code{user-full-name})}
5455 %c          @r{Current kill ring head.}
5456 %x          @r{Content of the X clipboard.}
5457 %^C         @r{Interactive selection of which kill or clip to use.}
5458 %^L         @r{Like @code{%^C}, but insert as link.}
5459 %^g         @r{prompt for tags, with completion on tags in target file.}
5460 %k          @r{title of currently clocked task}
5461 %K          @r{link to currently clocked task}
5462 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
5463 %^@{prop@}p   @r{Prompt the user for a value for property @code{prop}}
5464 %:keyword   @r{specific information for certain link types, see below}
5465 %[pathname] @r{insert the contents of the file given by @code{pathname}}
5466 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
5467 %!          @r{immediately store note after completing the template}
5468             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
5469 %&          @r{jump to target location immediately after storing note}
5470 @end example
5472 @noindent
5473 For specific link types, the following keywords will be
5474 defined@footnote{If you define your own link types (@pxref{Adding
5475 hyperlink types}), any property you store with
5476 @code{org-store-link-props} can be accessed in remember templates in a
5477 similar way.}:
5479 @vindex org-from-is-user-regexp
5480 @example
5481 Link type          |  Available keywords
5482 -------------------+----------------------------------------------
5483 bbdb               |  %:name %:company
5484 bbdb               |  %::server %:port %:nick
5485 vm, wl, mh, rmail  |  %:type %:subject %:message-id
5486                    |  %:from %:fromname %:fromaddress
5487                    |  %:to   %:toname   %:toaddress
5488                    |  %: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}.}}
5489 gnus               |  %:group, @r{for messages also all email fields}
5490 w3, w3m            |  %:url
5491 info               |  %:file %:node
5492 calendar           |  %:date"
5493 @end example
5495 @noindent
5496 To place the cursor after template expansion use:
5498 @example
5499 %?          @r{After completing the template, position cursor here.}
5500 @end example
5502 @noindent
5503 If you change your mind about which template to use, call
5504 @code{org-remember} in the remember buffer.  You may then select a new
5505 template that will be filled with the previous context information.
5507 @node Storing notes, Refiling notes, Remember templates, Remember
5508 @subsection Storing notes
5510 @vindex org-remember-clock-out-on-exit
5511 When you are finished preparing a note with @i{remember}, you have to press
5512 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
5513 remember buffer, you will first be asked if you want to clock out
5514 now@footnote{To avoid this query, configure the variable
5515 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
5516 will continue to run after the note was filed away.
5518 The handler will then store the note in the file and under the headline
5519 specified in the template, or it will use the default file and headlines.
5520 The window configuration will be restored, sending you back to the working
5521 context before the call to @code{remember}.  To re-use the location found
5522 during the last call to @code{remember}, exit the remember buffer with
5523 @kbd{C-0 C-c C-c}, i.e. specify a zero prefix argument to @kbd{C-c C-c}.
5524 Another special case is @kbd{C-2 C-c C-c} which files the note as a child of
5525 the currently clocked item.
5527 @vindex org-remember-store-without-prompt
5528 If you want to store the note directly to a different place, use
5529 @kbd{C-1 C-c C-c} instead to exit remember@footnote{Configure the
5530 variable @code{org-remember-store-without-prompt} to make this behavior
5531 the default.}.  The handler will then first prompt for a target file -
5532 if you press @key{RET}, the value specified for the template is used.
5533 Then the command offers the headings tree of the selected file, with the
5534 cursor position at the default headline (if you had specified one in the
5535 template).  You can either immediately press @key{RET} to get the note
5536 placed there.  Or you can use the following keys to find a different
5537 location:
5538 @example
5539 @key{TAB}         @r{Cycle visibility.}
5540 @key{down} / @key{up}   @r{Next/previous visible headline.}
5541 n / p        @r{Next/previous visible headline.}
5542 f / b        @r{Next/previous headline same level.}
5543 u            @r{One level up.}
5544 @c 0-9          @r{Digit argument.}
5545 @end example
5546 @noindent
5547 Pressing @key{RET} or @key{left} or @key{right}
5548 then leads to the following result.
5550 @vindex org-reverse-note-order
5551 @multitable @columnfractions 0.2 0.15 0.65
5552 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
5553 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
5554 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
5555 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
5556 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
5557 @item                 @tab @tab depending on @code{org-reverse-note-order}.
5558 @item not on headline @tab @key{RET}
5559       @tab at cursor position, level taken from context.
5560 @end multitable
5562 Before inserting the text into a tree, the function ensures that the text has
5563 a headline, i.e. a first line that starts with a @samp{*}.  If not, a
5564 headline is constructed from the current date.  If you have indented the text
5565 of the note below the headline, the indentation will be adapted if inserting
5566 the note into the tree requires demotion from level 1.
5568 @node Refiling notes,  , Storing notes, Remember
5569 @subsection Refiling notes
5570 @cindex refiling notes
5572 Remember is usually used to quickly capture notes and tasks into one or
5573 a few capture lists.  When reviewing the captured data, you may want to
5574 refile some of the entries into a different list, for example into a
5575 project.  Cutting, finding the right location and then pasting the note
5576 is cumbersome.  To simplify this process, you can use the following
5577 special command:
5579 @table @kbd
5580 @kindex C-c C-w
5581 @item C-c C-w
5582 @vindex org-reverse-note-order
5583 @vindex org-refile-targets
5584 @vindex org-refile-use-outline-path
5585 @vindex org-outline-path-complete-in-steps
5586 Refile the entry or region at point.  This command offers possible locations
5587 for refiling the entry and lets you select one with completion.  The item (or
5588 all items in the region) is filed below the target heading as a subitem.
5589 Depending on @code{org-reverse-note-order}, it will be either the first or
5590 last subitem.@*
5591 By default, all level 1 headlines in the current buffer are considered to be
5592 targets, but you can have more complex definitions across a number of files.
5593 See the variable @code{org-refile-targets} for details.  If you would like to
5594 select a location via a file-path-like completion along the outline path, see
5595 the variables @code{org-refile-use-outline-path} and
5596 @code{org-outline-path-complete-in-steps}.
5597 @kindex C-u C-c C-w
5598 @item C-u C-c C-w
5599 Use the refile interface to jump to a heading.
5600 @kindex C-u C-u C-c C-w
5601 @item C-u C-u C-c C-w
5602 Jump to the location where @code{org-refile} last moved a tree to.
5603 @end table
5605 @node Attachments,  , Remember, Capture
5606 @section Attachments
5607 @cindex attachments
5609 @vindex org-attach-directory
5610 It is often useful to associate reference material with an outline node/task.
5611 Small chunks of plain text can simply be stored in the subtree of a project.
5612 Hyperlinks (@pxref{Hyperlinks}) can be used to establish associations with
5613 files that live elsewhere on your computer or in the cloud, like emails or
5614 source code files belonging to a project.  Another method is @i{attachments},
5615 which are files located in a directory belonging to an outline node.  Org
5616 uses directories named by the unique ID of each entry.  These directories are
5617 located in the @file{data} directory which lives in the same directory where
5618 your org-file lives@footnote{If you move entries or Org-files from one
5619 directory to the next, you may want to configure @code{org-attach-directory}
5620 to contain an absolute path.}.  If you initialize this directory with
5621 @code{git init}, Org will automatically commit changes when it sees them.
5622 The attachment system has been contributed to Org by John Wiegley.
5624 In cases where this seems better, you can also attach a directory of your
5625 choice to an entry.  You can also make children inherit the attachment
5626 directory from a parent, so that an entire subtree uses the same attached
5627 directory.
5629 @noindent The following commands deal with attachments.
5631 @table @kbd
5633 @kindex C-c C-a
5634 @item C-c C-a
5635 The dispatcher for commands related to the attachment system.  After these
5636 keys, a list of commands is displayed and you need to press an additional key
5637 to select a command:
5639 @table @kbd
5640 @kindex C-c C-a a
5641 @item a
5642 @vindex org-attach-method
5643 Select a file and move it into the task's attachment directory.  The file
5644 will be copied, moved, or linked, depending on @code{org-attach-method}.
5645 Note that hard links are not supported on all systems.
5647 @kindex C-c C-a c
5648 @kindex C-c C-a m
5649 @kindex C-c C-a l
5650 @item c/m/l
5651 Attach a file using the copy/move/link method.
5652 Note that hard links are not supported on all systems.
5654 @kindex C-c C-a n
5655 @item n
5656 Create a new attachment as an Emacs buffer.
5658 @kindex C-c C-a z
5659 @item z
5660 Synchronize the current task with its attachment directory, in case you added
5661 attachments yourself.
5663 @kindex C-c C-a o
5664 @item o
5665 @vindex org-file-apps
5666 Open current task's attachment.  If there are more than one, prompt for a
5667 file name first.  Opening will follow the rules set by @code{org-file-apps}.
5668 For more details, see the information on following hyperlinks
5669 (@pxref{Handling links}).
5671 @kindex C-c C-a O
5672 @item O
5673 Also open the attachment, but force opening the file in Emacs.
5675 @kindex C-c C-a f
5676 @item f
5677 Open the current task's attachment directory.
5679 @kindex C-c C-a F
5680 @item F
5681 Also open the directory, but force using @code{dired} in Emacs.
5683 @kindex C-c C-a d
5684 @item d
5685 Select and delete a single attachment.
5687 @kindex C-c C-a D
5688 @item D
5689 Delete all of a task's attachments.  A safer way is to open the directory in
5690 dired and delete from there.
5692 @kindex C-c C-a s
5693 @item C-c C-a s
5694 Set a specific directory as the entry's attachment directory.  This works by
5695 putting the directory path into the @code{ATTACH_DIR} property.
5697 @kindex C-c C-a i
5698 @item C-c C-a i
5699 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
5700 same directory for attachments as the parent.
5701 @end table
5702 @end table
5704 @node Agenda Views, Embedded LaTeX, Capture, Top
5705 @chapter Agenda Views
5706 @cindex agenda views
5708 Due to the way Org works, TODO items, time-stamped items, and
5709 tagged headlines can be scattered throughout a file or even a number of
5710 files.  To get an overview of open action items, or of events that are
5711 important for a particular date, this information must be collected,
5712 sorted and displayed in an organized way.
5714 Org can select items based on various criteria, and display them
5715 in a separate buffer.  Seven different view types are provided:
5717 @itemize @bullet
5718 @item
5719 an @emph{agenda} that is like a calendar and shows information
5720 for specific dates,
5721 @item
5722 a @emph{TODO list} that covers all unfinished
5723 action items,
5724 @item
5725 a @emph{match view}, showings headlines based on the tags, properties and
5726 TODO state associated with them,
5727 @item
5728 a @emph{timeline view} that shows all events in a single Org file,
5729 in time-sorted view,
5730 @item
5731 a @emph{keyword search view} that shows all entries from multiple files
5732 that contain specified keywords.
5733 @item
5734 a @emph{stuck projects view} showing projects that currently don't move
5735 along, and
5736 @item
5737 @emph{custom views} that are special tag/keyword searches and
5738 combinations of different views.
5739 @end itemize
5741 @noindent
5742 The extracted information is displayed in a special @emph{agenda
5743 buffer}.  This buffer is read-only, but provides commands to visit the
5744 corresponding locations in the original Org files, and even to
5745 edit these files remotely.
5747 @vindex org-agenda-window-setup
5748 @vindex org-agenda-restore-windows-after-quit
5749 Two variables control how the agenda buffer is displayed and whether the
5750 window configuration is restored when the agenda exits:
5751 @code{org-agenda-window-setup} and
5752 @code{org-agenda-restore-windows-after-quit}.
5754 @menu
5755 * Agenda files::                Files being searched for agenda information
5756 * Agenda dispatcher::           Keyboard access to agenda views
5757 * Built-in agenda views::       What is available out of the box?
5758 * Presentation and sorting::    How agenda items are prepared for display
5759 * Agenda commands::             Remote editing of Org trees
5760 * Custom agenda views::         Defining special searches and views
5761 * Agenda column view::          Using column view for collected entries
5762 @end menu
5764 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
5765 @section Agenda files
5766 @cindex agenda files
5767 @cindex files for agenda
5769 @vindex org-agenda-files
5770 The information to be shown is normally collected from all @emph{agenda
5771 files}, the files listed in the variable
5772 @code{org-agenda-files}@footnote{If the value of that variable is not a
5773 list, but a single file name, then the list of agenda files will be
5774 maintained in that external file.}. If a directory is part of this list,
5775 all files with the extension @file{.org} in this directory will be part
5776 of the list.
5778 Thus even if you only work with a single Org file, this file should
5779 be put into that list@footnote{When using the dispatcher, pressing
5780 @kbd{<} before selecting a command will actually limit the command to
5781 the current file, and ignore @code{org-agenda-files} until the next
5782 dispatcher command.}.  You can customize @code{org-agenda-files}, but
5783 the easiest way to maintain it is through the following commands
5785 @cindex files, adding to agenda list
5786 @table @kbd
5787 @kindex C-c [
5788 @item C-c [
5789 Add current file to the list of agenda files.  The file is added to
5790 the front of the list.  If it was already in the list, it is moved to
5791 the front.  With a prefix argument, file is added/moved to the end.
5792 @kindex C-c ]
5793 @item C-c ]
5794 Remove current file from the list of agenda files.
5795 @kindex C-,
5796 @kindex C-'
5797 @item C-,
5798 @itemx C-'
5799 Cycle through agenda file list, visiting one file after the other.
5800 @kindex M-x org-iswitchb
5801 @item M-x org-iswitchb
5802 Command to use an @code{iswitchb}-like interface to switch to and between Org
5803 buffers.
5804 @end table
5806 @noindent
5807 The Org menu contains the current list of files and can be used
5808 to visit any of them.
5810 If you would like to focus the agenda temporarily onto a file not in
5811 this list, or onto just one file in the list or even only a subtree in a
5812 file, this can be done in different ways.  For a single agenda command,
5813 you may press @kbd{<} once or several times in the dispatcher
5814 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
5815 extended period, use the following commands:
5817 @table @kbd
5818 @kindex C-c C-x <
5819 @item C-c C-x <
5820 Permanently restrict the agenda to the current subtree.  When with a
5821 prefix argument, or with the cursor before the first headline in a file,
5822 the agenda scope is set to the entire file.  This restriction remains in
5823 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
5824 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
5825 agenda view, the new restriction takes effect immediately.
5826 @kindex C-c C-x >
5827 @item C-c C-x >
5828 Remove the permanent restriction created by @kbd{C-c C-x <}.
5829 @end table
5831 @noindent
5832 When working with @file{Speedbar}, you can use the following commands in
5833 the Speedbar frame:
5834 @table @kbd
5835 @kindex <
5836 @item < @r{in the speedbar frame}
5837 Permanently restrict the agenda to the item at the cursor in the
5838 Speedbar frame, either an Org file or a subtree in such a file.
5839 If there is a window displaying an agenda view, the new restriction takes
5840 effect immediately.
5841 @kindex >
5842 @item > @r{in the speedbar frame}
5843 Lift the restriction again.
5844 @end table
5846 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
5847 @section The agenda dispatcher
5848 @cindex agenda dispatcher
5849 @cindex dispatching agenda commands
5850 The views are created through a dispatcher that should be bound to a
5851 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
5852 following we will assume that @kbd{C-c a} is indeed how the dispatcher
5853 is accessed and list keyboard access to commands accordingly.  After
5854 pressing @kbd{C-c a}, an additional letter is required to execute a
5855 command.  The dispatcher offers the following default commands:
5856 @table @kbd
5857 @item a
5858 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
5859 @item t @r{/} T
5860 Create a list of all TODO items (@pxref{Global TODO list}).
5861 @item m @r{/} M
5862 Create a list of headlines matching a TAGS expression (@pxref{Matching
5863 tags and properties}).
5864 @item L
5865 Create the timeline view for the current buffer (@pxref{Timeline}).
5866 @item s
5867 Create a list of entries selected by a boolean expression of keywords
5868 and/or regular expressions that must or must not occur in the entry.
5869 @item /
5870 @vindex org-agenda-text-search-extra-files
5871 Search for a regular expression in all agenda files and additionally in
5872 the files listed in @code{org-agenda-text-search-extra-files}.  This
5873 uses the Emacs command @code{multi-occur}.  A prefix argument can be
5874 used to specify the number of context lines for each match, default is
5876 @item # @r{/} !
5877 Create a list of stuck projects (@pxref{Stuck projects}).
5878 @item <
5879 Restrict an agenda command to the current buffer@footnote{For backward
5880 compatibility, you can also press @kbd{1} to restrict to the current
5881 buffer.}.  After pressing @kbd{<}, you still need to press the character
5882 selecting the command.
5883 @item < <
5884 If there is an active region, restrict the following agenda command to
5885 the region.  Otherwise, restrict it to the current subtree@footnote{For
5886 backward compatibility, you can also press @kbd{0} to restrict to the
5887 current buffer.}.  After pressing @kbd{< <}, you still need to press the
5888 character selecting the command.
5889 @end table
5891 You can also define custom commands that will be accessible through the
5892 dispatcher, just like the default commands.  This includes the
5893 possibility to create extended agenda buffers that contain several
5894 blocks together, for example the weekly agenda, the global TODO list and
5895 a number of special tags matches.  @xref{Custom agenda views}.
5897 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
5898 @section The built-in agenda views
5900 In this section we describe the built-in views.
5902 @menu
5903 * Weekly/daily agenda::         The calendar page with current tasks
5904 * Global TODO list::            All unfinished action items
5905 * Matching tags and properties::  Structured information with fine-tuned search
5906 * Timeline::                    Time-sorted view for single file
5907 * Keyword search::              Finding entries by keyword
5908 * Stuck projects::              Find projects you need to review
5909 @end menu
5911 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
5912 @subsection The weekly/daily agenda
5913 @cindex agenda
5914 @cindex weekly agenda
5915 @cindex daily agenda
5917 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
5918 paper agenda, showing all the tasks for the current week or day.
5920 @table @kbd
5921 @cindex org-agenda, command
5922 @kindex C-c a a
5923 @item C-c a a
5924 @vindex org-agenda-ndays
5925 Compile an agenda for the current week from a list of org files.  The agenda
5926 shows the entries for each day.  With a numeric prefix@footnote{For backward
5927 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
5928 listed before the agenda.  This feature is deprecated, use the dedicated TODO
5929 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
5930 C-c a a}) you may set the number of days to be displayed (see also the
5931 variable @code{org-agenda-ndays})
5932 @end table
5934 Remote editing from the agenda buffer means, for example, that you can
5935 change the dates of deadlines and appointments from the agenda buffer.
5936 The commands available in the Agenda buffer are listed in @ref{Agenda
5937 commands}.
5939 @subsubheading Calendar/Diary integration
5940 @cindex calendar integration
5941 @cindex diary integration
5943 Emacs contains the calendar and diary by Edward M. Reingold.  The
5944 calendar displays a three-month calendar with holidays from different
5945 countries and cultures.  The diary allows you to keep track of
5946 anniversaries, lunar phases, sunrise/set, recurrent appointments
5947 (weekly, monthly) and more.  In this way, it is quite complementary to
5948 Org.  It can be very useful to combine output from Org with
5949 the diary.
5951 In order to include entries from the Emacs diary into Org mode's
5952 agenda, you only need to customize the variable
5954 @lisp
5955 (setq org-agenda-include-diary t)
5956 @end lisp
5958 @noindent After that, everything will happen automatically.  All diary
5959 entries including holidays, anniversaries etc will be included in the
5960 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
5961 @key{RET} can be used from the agenda buffer to jump to the diary
5962 file in order to edit existing diary entries.  The @kbd{i} command to
5963 insert new entries for the current date works in the agenda buffer, as
5964 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
5965 Sunrise/Sunset times, show lunar phases and to convert to other
5966 calendars, respectively.  @kbd{c} can be used to switch back and forth
5967 between calendar and agenda.
5969 If you are using the diary only for sexp entries and holidays, it is
5970 faster to not use the above setting, but instead to copy or even move
5971 the entries into an Org file. Org mode evaluates diary-style sexp
5972 entries, and does it faster because there is no overhead for first
5973 creating the diary display.  Note that the sexp entries must start at
5974 the left margin, no white space is allowed before them.  For example,
5975 the following segment of an Org file will be processed and entries
5976 will be made in the agenda:
5978 @example
5979 * Birthdays and similar stuff
5980 #+CATEGORY: Holiday
5981 %%(org-calendar-holiday)   ; special function for holiday names
5982 #+CATEGORY: Ann
5983 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
5984 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
5985 @end example
5987 @subsubheading Anniversaries from BBDB
5988 @cindex BBDB, anniversaries
5989 @cindex anniversaries, from BBDB
5991 If you are using the Big Brothers Database to store your contacts, you will
5992 very likely prefer to store anniversaries in BBDB rather than in a
5993 separate Org or diary file.  Org supports this and will show BBDB
5994 anniversaries as part of the agenda.  All you need to do is to add the
5995 following to one your your agenda files:
5997 @example
5998 * Anniversaries
5999   :PROPERTIES:
6000   :CATEGORY: Anniv
6001   :END
6002 %%(org-bbdb-anniversaries)
6003 @end example
6005 You can then go ahead and define anniversaries for a BBDB record.  Basically,
6006 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
6007 record and then add the date in the format @code{YYYY-MM-DD}, followed by a
6008 space and the class of the anniversary (@samp{birthday} or @samp{wedding}, or
6009 a format string).  If you omit the class, it will default to @samp{birthday}.
6010 Here are a few examples, the header for the file @file{org-bbdb.el} contains
6011 more detailed information.
6013 @example
6014 1973-06-22
6015 1955-08-02 wedding
6016 2008-04-14 %s released version 6.01 of Org-mode, %d years ago
6017 @end example
6019 After a change to BBDB, or for the first agenda display during an Emacs
6020 session, the agenda display will suffer a short delay as Org updates it's
6021 hash with anniversaries.  However, from then on things will be very fast -
6022 much faster in fact than a long list of @samp{%%(diary-anniversary)} entries
6023 in an Org or Diary file.
6025 @subsubheading Appointment reminders
6026 @cindex @file{appt.el}
6027 @cindex appointment reminders
6029 Org can interact with Emacs appointments notification facility.  To add all
6030 the appointments of your agenda files, use the command
6031 @code{org-agenda-to-appt}.  This commands also lets you filter through the
6032 list of your appointments and add only those belonging to a specific category
6033 or matching a regular expression. See the docstring for details.
6035 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
6036 @subsection The global TODO list
6037 @cindex global TODO list
6038 @cindex TODO list, global
6040 The global TODO list contains all unfinished TODO items, formatted and
6041 collected into a single place.
6043 @table @kbd
6044 @kindex C-c a t
6045 @item C-c a t
6046 Show the global TODO list.  This collects the TODO items from all
6047 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
6048 @code{agenda-mode}, so there are commands to examine and manipulate
6049 the TODO entries directly from that buffer (@pxref{Agenda commands}).
6050 @kindex C-c a T
6051 @item C-c a T
6052 @cindex TODO keyword matching
6053 @vindex org-todo-keywords
6054 Like the above, but allows selection of a specific TODO keyword.  You
6055 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
6056 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
6057 specify several keywords by separating them with @samp{|} as boolean OR
6058 operator.  With a numeric prefix, the Nth keyword in
6059 @code{org-todo-keywords} is selected.
6060 @kindex r
6061 The @kbd{r} key in the agenda buffer regenerates it, and you can give
6062 a prefix argument to this command to change the selected TODO keyword,
6063 for example @kbd{3 r}.  If you often need a search for a specific
6064 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
6065 Matching specific TODO keywords can also be done as part of a tags
6066 search (@pxref{Tag searches}).
6067 @end table
6069 Remote editing of TODO items means that you can change the state of a
6070 TODO entry with a single key press.  The commands available in the
6071 TODO list are described in @ref{Agenda commands}.
6073 @cindex sublevels, inclusion into TODO list
6074 Normally the global TODO list simply shows all headlines with TODO
6075 keywords.  This list can become very long.  There are two ways to keep
6076 it more compact:
6077 @itemize @minus
6078 @item
6079 @vindex org-agenda-todo-ignore-scheduled
6080 @vindex org-agenda-todo-ignore-deadlines
6081 @vindex org-agenda-todo-ignore-with-date
6082 Some people view a TODO item that has been @emph{scheduled} for execution or
6083 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}
6084 Configure the variables @code{org-agenda-todo-ignore-scheduled},
6085 @code{org-agenda-todo-ignore-deadlines}, and/or
6086 @code{org-agenda-todo-ignore-with-date} to exclude such items from the
6087 global TODO list.
6088 @item
6089 @vindex org-agenda-todo-list-sublevels
6090 TODO items may have sublevels to break up the task into subtasks.  In
6091 such cases it may be enough to list only the highest level TODO headline
6092 and omit the sublevels from the global list.  Configure the variable
6093 @code{org-agenda-todo-list-sublevels} to get this behavior.
6094 @end itemize
6096 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
6097 @subsection Matching tags and properties
6098 @cindex matching, of tags
6099 @cindex matching, of properties
6100 @cindex tags view
6101 @cindex match view
6103 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
6104 or have properties @pxref{Properties and Columns}, you can select headlines
6105 based on this meta data and collect them into an agenda buffer.  The match
6106 syntax described here also applies when creating sparse trees with @kbd{C-c /
6109 @table @kbd
6110 @kindex C-c a m
6111 @item C-c a m
6112 Produce a list of all headlines that match a given set of tags.  The
6113 command prompts for a selection criterion, which is a boolean logic
6114 expression with tags, like @samp{+work+urgent-withboss} or
6115 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
6116 define a custom command for it (@pxref{Agenda dispatcher}).
6117 @kindex C-c a M
6118 @item C-c a M
6119 @vindex org-tags-match-list-sublevels
6120 @vindex org-agenda-tags-todo-honor-ignore-options
6121 Like @kbd{C-c a m}, but only select headlines that are also TODO items and
6122 force checking subitems (see variable @code{org-tags-match-list-sublevels}).
6123 To exclude scheduled/deadline items, see the variable
6124 @code{org-agenda-tags-todo-honor-ignore-options}.  Matching specific TODO
6125 keywords together with a tags match is also possible, see @ref{Tag searches}.
6126 @end table
6128 The commands available in the tags list are described in @ref{Agenda
6129 commands}.
6131 @subsubheading Match syntax
6133 @cindex Boolean logic, for tag/property searches
6134 A search string can use Boolean operators @samp{&} for AND and @samp{|} for
6135 OR.  @samp{&} binds more strongly than @samp{|}.  Parenthesis are currently
6136 not implemented.  Each element in the search is either a tag, a regular
6137 rexpression matching tags, or an expression like @code{PROPERTY OPERATOR
6138 VALUE} with a comparison operator, accessing a property value.  Each element
6139 may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
6140 sugar for positive selection.  The AND operator @samp{&} is optional when
6141 @samp{+} or @samp{-} is present.  Here are some examples, using only tags.
6143 @table @samp
6144 @item +work-boss
6145 Select headlines tagged @samp{:work:}, but discard those also tagged
6146 @samp{:boss:}.
6147 @item work|laptop
6148 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
6149 @item work|laptop+night
6150 Like before, but require the @samp{:laptop:} lines to be tagged also
6151 @samp{:night:}.
6152 @end table
6154 @cindex regular expressions, with tags search
6155 Instead of a tag, you may also specify a regular expression enclosed in curly
6156 braces.  For example,
6157 @samp{work+@{^boss.*@}} matches headlines that contain the tag
6158 @samp{:work:} and any tag @i{starting} with @samp{boss}.
6160 @cindex TODO keyword matching, with tags search
6161 @cindex level, require for tags/property match
6162 @cindex category, require for tags/property match
6163 @vindex org-odd-levels-only
6164 You may also test for properties (@pxref{Properties and Columns}) at the same
6165 time as matching tags.  The properties may be real properties, or special
6166 properties that represent other meta data (@pxref{Special properties}).  For
6167 example, the ``property'' @code{TODO} represents the TODO keyword of the
6168 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
6169 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
6170 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
6171 DONE.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
6172 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
6174 Here are more examples:
6175 @table @samp
6176 @item work+TODO="WAITING"
6177 Select @samp{:work:}-tagged TODO lines with the specific TODO
6178 keyword @samp{WAITING}.
6179 @item work+TODO="WAITING"|home+TODO="WAITING"
6180 Waiting tasks both at work and at home.
6181 @end table
6183 When matching properties, a number of different operaors can be used to test
6184 the value of a property.  Here is a complex example:
6186 @example
6187 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
6188          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
6189 @end example
6191 @noindent
6192 The type of comparison will depend on how the comparison value is written:
6193 @itemize @minus
6194 @item
6195 If the comparison value is a plain number, a numerical comparison is done,
6196 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
6197 @samp{>=}, and @samp{<>}.
6198 @item
6199 If the comparison value is enclosed in double
6200 quotes, a string comparison is done, and the same operators are allowed.
6201 @item
6202 If the comparison value is enclosed in double quotes @emph{and} angular
6203 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
6204 assumed to be date/time specifications in the standard Org way, and the
6205 comparison will be done accordingly.  Special values that will be recognized
6206 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
6207 @code{"<tomorrow>"} for these days at 0:00 hours, i.e. without a time
6208 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
6209 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
6210 respectively, can be used.
6211 @item
6212 If the comparison value is enclosed
6213 in curly braces, a regexp match is performed, with @samp{=} meaning that the
6214 regexp matches the property value, and @samp{<>} meaning that it does not
6215 match.
6216 @end itemize
6218 So the search string in the example finds entries tagged @samp{:work:} but
6219 not @samp{:boss:}, which also have a priority value @samp{A}, a
6220 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
6221 property that is numerically smaller than 2, a @samp{:With:} property that is
6222 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
6223 on or after October 11, 2008.
6225 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
6226 other properties will slow down the search.  However, once you have payed the
6227 price by accessig one property, testing additional properties is cheap
6228 again.
6230 You can configure Org mode to use property inheritance during a search, but
6231 beware that this can slow down searches considerably.  See @ref{Property
6232 inheritance} for details.
6234 For backward compatibility, and also for typing speed, there is also a
6235 different way to test TODO states in a search.  For this, terminalte the
6236 tags/property part of the search string (which may include several terms
6237 connected with @samp{|}) with a @samp{/} and then specify a Boolean
6238 expression just for TODO keywords.  The syntax is then similar to that for
6239 tags, but should be applied with consideration: For example, a positive
6240 selection on several TODO keywords can not meaningfully be combined with
6241 boolean AND.  However, @emph{negative selection} combined with AND can be
6242 meaningful.  To make sure that only lines are checked that actually have any
6243 TODO keyword (resulting in a speed-up), use @kbd{C-c a M}, or equivalently
6244 start the TODO part after the slash with @samp{!}.  Examples:
6246 @table @samp
6247 @item work/WAITING
6248 Same as @samp{work+TODO="WAITING"}
6249 @item work/!-WAITING-NEXT
6250 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
6251 nor @samp{NEXT}
6252 @item work/!+WAITING|+NEXT
6253 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
6254 @samp{NEXT}.
6255 @end table
6257 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
6258 @subsection Timeline for a single file
6259 @cindex timeline, single file
6260 @cindex time-sorted view
6262 The timeline summarizes all time-stamped items from a single Org mode
6263 file in a @emph{time-sorted view}.  The main purpose of this command is
6264 to give an overview over events in a project.
6266 @table @kbd
6267 @kindex C-c a L
6268 @item C-c a L
6269 Show a time-sorted view of the org file, with all time-stamped items.
6270 When called with a @kbd{C-u} prefix, all unfinished TODO entries
6271 (scheduled or not) are also listed under the current date.
6272 @end table
6274 @noindent
6275 The commands available in the timeline buffer are listed in
6276 @ref{Agenda commands}.
6278 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
6279 @subsection Keyword search
6280 @cindex keyword search
6281 @cindex searching, for keywords
6283 This agenda view is a general text search facility for Org mode entries.
6284 It is particularly useful to find notes.
6286 @table @kbd
6287 @kindex C-c a s
6288 @item C-c a s
6289 This is a special search that lets you select entries by keywords or
6290 regular expression, using a boolean logic.  For example, the search
6291 string
6293 @example
6294 +computer +wifi -ethernet -@{8\.11[bg]@}
6295 @end example
6297 @noindent
6298 will search for note entries that contain the keywords @code{computer}
6299 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
6300 not matched by the regular expression @code{8\.11[bg]}, meaning to
6301 exclude both 8.11b and 8.11g.
6303 @vindex org-agenda-text-search-extra-files
6304 Note that in addition to the agenda files, this command will also search
6305 the files listed in @code{org-agenda-text-search-extra-files}.
6306 @end table
6308 @node Stuck projects,  , Keyword search, Built-in agenda views
6309 @subsection Stuck projects
6311 If you are following a system like David Allen's GTD to organize your
6312 work, one of the ``duties'' you have is a regular review to make sure
6313 that all projects move along.  A @emph{stuck} project is a project that
6314 has no defined next actions, so it will never show up in the TODO lists
6315 Org mode produces.  During the review, you need to identify such
6316 projects and define next actions for them.
6318 @table @kbd
6319 @kindex C-c a #
6320 @item C-c a #
6321 List projects that are stuck.
6322 @kindex C-c a !
6323 @item C-c a !
6324 @vindex org-stuck-projects
6325 Customize the variable @code{org-stuck-projects} to define what a stuck
6326 project is and how to find it.
6327 @end table
6329 You almost certainly will have to configure this view before it will
6330 work for you.  The built-in default assumes that all your projects are
6331 level-2 headlines, and that a project is not stuck if it has at least
6332 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
6334 Let's assume that you, in your own way of using Org mode, identify
6335 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
6336 indicate a project that should not be considered yet.  Let's further
6337 assume that the TODO keyword DONE marks finished projects, and that NEXT
6338 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
6339 is a next action even without the NEXT tag.  Finally, if the project
6340 contains the special word IGNORE anywhere, it should not be listed
6341 either.  In this case you would start by identifying eligible projects
6342 with a tags/todo match@footnote{@ref{Tag searches}}
6343 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
6344 IGNORE in the subtree to identify projects that are not stuck.  The
6345 correct customization for this is
6347 @lisp
6348 (setq org-stuck-projects
6349       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
6350                                "\\<IGNORE\\>"))
6351 @end lisp
6354 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
6355 @section Presentation and sorting
6356 @cindex presentation, of agenda items
6358 @vindex org-agenda-prefix-format
6359 Before displaying items in an agenda view, Org mode visually prepares
6360 the items and sorts them.  Each item occupies a single line.  The line
6361 starts with a @emph{prefix} that contains the @emph{category}
6362 (@pxref{Categories}) of the item and other important information.  You can
6363 customize the prefix using the option @code{org-agenda-prefix-format}.
6364 The prefix is followed by a cleaned-up version of the outline headline
6365 associated with the item.
6367 @menu
6368 * Categories::                  Not all tasks are equal
6369 * Time-of-day specifications::  How the agenda knows the time
6370 * Sorting of agenda items::     The order of things
6371 @end menu
6373 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
6374 @subsection Categories
6376 @cindex category
6377 The category is a broad label assigned to each agenda item.  By default,
6378 the category is simply derived from the file name, but you can also
6379 specify it with a special line in the buffer, like this@footnote{For
6380 backward compatibility, the following also works: If there are several
6381 such lines in a file, each specifies the category for the text below it.
6382 The first category also applies to any text before the first CATEGORY
6383 line.  However, using this method is @emph{strongly} deprecated as it is
6384 incompatible with the outline structure of the document.  The correct
6385 method for setting multiple categories in a buffer is using a
6386 property.}:
6388 @example
6389 #+CATEGORY: Thesis
6390 @end example
6392 @noindent
6393 If you would like to have a special CATEGORY for a single entry or a
6394 (sub)tree, give the entry a @code{:CATEGORY:} property with the
6395 special category you want to apply as the value.
6397 @noindent
6398 The display in the agenda buffer looks best if the category is not
6399 longer than 10 characters.
6401 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
6402 @subsection Time-of-day specifications
6403 @cindex time-of-day specification
6405 Org mode checks each agenda item for a time-of-day specification.  The
6406 time can be part of the time stamp that triggered inclusion into the
6407 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
6408 ranges can be specified with two time stamps, like
6410 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
6412 In the headline of the entry itself, a time(range) may also appear as
6413 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
6414 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
6415 specifications in diary entries are recognized as well.
6417 For agenda display, Org mode extracts the time and displays it in a
6418 standard 24 hour format as part of the prefix.  The example times in
6419 the previous paragraphs would end up in the agenda like this:
6421 @example
6422     8:30-13:00 Arthur Dent lies in front of the bulldozer
6423    12:45...... Ford Prefect arrives and takes Arthur to the pub
6424    19:00...... The Vogon reads his poem
6425    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6426 @end example
6428 @cindex time grid
6429 If the agenda is in single-day mode, or for the display of today, the
6430 timed entries are embedded in a time grid, like
6432 @example
6433     8:00...... ------------------
6434     8:30-13:00 Arthur Dent lies in front of the bulldozer
6435    10:00...... ------------------
6436    12:00...... ------------------
6437    12:45...... Ford Prefect arrives and takes Arthur to the pub
6438    14:00...... ------------------
6439    16:00...... ------------------
6440    18:00...... ------------------
6441    19:00...... The Vogon reads his poem
6442    20:00...... ------------------
6443    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6444 @end example
6446 @vindex org-agenda-use-time-grid
6447 @vindex org-agenda-time-grid
6448 The time grid can be turned on and off with the variable
6449 @code{org-agenda-use-time-grid}, and can be configured with
6450 @code{org-agenda-time-grid}.
6452 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
6453 @subsection Sorting of agenda items
6454 @cindex sorting, of agenda items
6455 @cindex priorities, of agenda items
6456 Before being inserted into a view, the items are sorted.  How this is
6457 done depends on the type of view.
6458 @itemize @bullet
6459 @item
6460 @vindex org-agenda-files
6461 For the daily/weekly agenda, the items for each day are sorted.  The
6462 default order is to first collect all items containing an explicit
6463 time-of-day specification.  These entries will be shown at the beginning
6464 of the list, as a @emph{schedule} for the day.  After that, items remain
6465 grouped in categories, in the sequence given by @code{org-agenda-files}.
6466 Within each category, items are sorted by priority (@pxref{Priorities}),
6467 which is composed of the base priority (2000 for priority @samp{A}, 1000
6468 for @samp{B}, and 0 for @samp{C}), plus additional increments for
6469 overdue scheduled or deadline items.
6470 @item
6471 For the TODO list, items remain in the order of categories, but within
6472 each category, sorting takes place according to priority
6473 (@pxref{Priorities}).
6474 @item
6475 For tags matches, items are not sorted at all, but just appear in the
6476 sequence in which they are found in the agenda files.
6477 @end itemize
6479 @vindex org-agenda-sorting-strategy
6480 Sorting can be customized using the variable
6481 @code{org-agenda-sorting-strategy}, and may also include criteria based on
6482 the estimated effort of an entry (@pxref{Effort estimates}).
6484 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
6485 @section Commands in the agenda buffer
6486 @cindex commands, in agenda buffer
6488 Entries in the agenda buffer are linked back to the org file or diary
6489 file where they originate.  You are not allowed to edit the agenda
6490 buffer itself, but commands are provided to show and jump to the
6491 original entry location, and to edit the org-files ``remotely'' from
6492 the agenda buffer.  In this way, all information is stored only once,
6493 removing the risk that your agenda and note files may diverge.
6495 Some commands can be executed with mouse clicks on agenda lines.  For
6496 the other commands, the cursor needs to be in the desired line.
6498 @table @kbd
6499 @tsubheading{Motion}
6500 @cindex motion commands in agenda
6501 @kindex n
6502 @item n
6503 Next line (same as @key{up} and @kbd{C-p}).
6504 @kindex p
6505 @item p
6506 Previous line (same as @key{down} and @kbd{C-n}).
6507 @tsubheading{View/Go to org file}
6508 @kindex mouse-3
6509 @kindex @key{SPC}
6510 @item mouse-3
6511 @itemx @key{SPC}
6512 Display the original location of the item in another window.
6513 With prefix arg, make sure that the entire entry is made visible in the
6514 outline, not only the heading.
6516 @kindex L
6517 @item L
6518 Display original location and recenter that window.
6520 @kindex mouse-2
6521 @kindex mouse-1
6522 @kindex @key{TAB}
6523 @item mouse-2
6524 @itemx mouse-1
6525 @itemx @key{TAB}
6526 Go to the original location of the item in another window.  Under Emacs
6527 22, @kbd{mouse-1} will also works for this.
6529 @kindex @key{RET}
6530 @itemx @key{RET}
6531 Go to the original location of the item and delete other windows.
6533 @kindex f
6534 @item f
6535 @vindex org-agenda-start-with-follow-mode
6536 Toggle Follow mode.  In Follow mode, as you move the cursor through
6537 the agenda buffer, the other window always shows the corresponding
6538 location in the org file.  The initial setting for this mode in new
6539 agenda buffers can be set with the variable
6540 @code{org-agenda-start-with-follow-mode}.
6542 @kindex b
6543 @item b
6544 Display the entire subtree of the current item in an indirect buffer.  With a
6545 numeric prefix argument N, go up to level N and then take that tree.  If N is
6546 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
6547 previously used indirect buffer.
6549 @kindex l
6550 @item l
6551 @vindex org-log-done
6552 @vindex org-agenda-log-mode-items
6553 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
6554 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
6555 entries that have been clocked on that day.  You can configure the entry
6556 types that should be included in log mode using the variable
6557 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
6558 all possible logbook entries, including state changes.  When called with two
6559 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
6561 @kindex v
6562 @item v
6563 Toggle Archives mode.  In archives mode, trees that are marked
6564 @code{ARCHIVED} are also scanned when producing the agenda.  When you call
6565 this command with a @kbd{C-u} prefix argument, even all archive files are
6566 included.  To exit archives mode, press @kbd{v} again.
6568 @kindex R
6569 @item R
6570 @vindex org-agenda-start-with-clockreport-mode
6571 Toggle Clockreport mode.  In clockreport mode, the daily/weekly agenda will
6572 always show a table with the clocked times for the timespan and file scope
6573 covered by the current agenda view.  The initial setting for this mode in new
6574 agenda buffers can be set with the variable
6575 @code{org-agenda-start-with-clockreport-mode}.
6577 @tsubheading{Change display}
6578 @cindex display changing, in agenda
6579 @kindex o
6580 @item o
6581 Delete other windows.
6583 @kindex d
6584 @kindex w
6585 @kindex m
6586 @kindex y
6587 @item d w m y
6588 Switch to day/week/month/year view.  When switching to day or week view,
6589 this setting becomes the default for subsequent agenda commands.  Since
6590 month and year views are slow to create, they do not become the default.
6591 A numeric prefix argument may be used to jump directly to a specific day
6592 of the year, ISO week, month, or year, respectively.  For example,
6593 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
6594 setting day, week, or month view, a year may be encoded in the prefix
6595 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
6596 2007.  If such a year specification has only one or two digits, it will
6597 be mapped to the interval 1938-2037.
6599 @kindex D
6600 @item D
6601 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
6603 @kindex G
6604 @item G
6605 @vindex org-agenda-use-time-grid
6606 @vindex org-agenda-time-grid
6607 Toggle the time grid on and off.  See also the variables
6608 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
6610 @kindex r
6611 @item r
6612 Recreate the agenda buffer, for example to reflect the changes
6613 after modification of the time stamps of items with S-@key{left} and
6614 S-@key{right}.  When the buffer is the global TODO list, a prefix
6615 argument is interpreted to create a selective list for a specific TODO
6616 keyword.
6617 @kindex g
6618 @item g
6619 Same as @kbd{r}.
6621 @kindex s
6622 @kindex C-x C-s
6623 @item s
6624 @itemx C-x C-s
6625 Save all Org buffers in the current Emacs session, and also the locations of
6626 IDs.
6628 @kindex @key{right}
6629 @item @key{right}
6630 @vindex org-agenda-ndays
6631 Display the following @code{org-agenda-ndays} days.  For example, if
6632 the display covers a week, switch to the following week.  With prefix
6633 arg, go forward that many times @code{org-agenda-ndays} days.
6635 @kindex @key{left}
6636 @item @key{left}
6637 Display the previous dates.
6639 @kindex .
6640 @item .
6641 Go to today.
6643 @kindex C-c C-x C-c
6644 @item C-c C-x C-c
6645 @vindex org-columns-default-format
6646 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
6647 view format is taken from the entry at point, or (if there is no entry at
6648 point), from the first entry in the agenda view.  So whatever the format for
6649 that entry would be in the original buffer (taken from a property, from a
6650 @code{#+COLUMNS} line, or from the default variable
6651 @code{org-columns-default-format}), will be used in the agenda.
6653 @tsubheading{Secondary filtering and query editing}
6654 @cindex filtering, by tag and effort, in agenda
6655 @cindex tag filtering, in agenda
6656 @cindex effort filtering, in agenda
6657 @cindex query editing, in agenda
6659 @kindex /
6660 @item /
6661 @vindex org-agenda-filter-preset
6662 Filter the current agenda view with respect to a tag and/or effort estimates.
6663 The difference between this and a custom agenda command is that filtering is
6664 very fast, so that you can switch quickly between different filters without
6665 having to recreate the agenda@footnote{Custom commands can preset a filter by
6666 binding the variable @code{org-agenda-filter-preset} as an option.  This
6667 filter will then be applied to the view and presist as a basic filter through
6668 refreshes and more secondary filtering.}
6670 You will be prompted for a tag selection letter.  Pressing @key{TAB} at that
6671 prompt will offer use completion to select a tag (including any tags that do
6672 not have a selection character).  The command then hides all entries that do
6673 not contain or inherit this tag.  When called with prefix arg, remove the
6674 entries that @emph{do} have the tag.  A second @kbd{/} at the prompt will
6675 turn off the filter and unhide any hidden entries.  If the first key you
6676 press is either @kbd{+} or @kbd{-}, the previous filter will be narrowed by
6677 requiring or forbidding the selected additional tag.  Instead of pressing
6678 @kbd{+} or @kbd{-} after @kbd{/}, you can also immediately use the @kbd{\}
6679 command.
6681 In order to filter for effort estimates, you should set-up allowed
6682 efforts globally, for example
6683 @lisp
6684 (setq org-global-properties
6685     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
6686 @end lisp
6687 You can then filter for an effort by first typing an operator, one of @kbd{<},
6688 @kbd{>}, and @kbd{=}, and then the one-digit index of an effort estimate in
6689 your array of allowed values, where @kbd{0} means the 10th value.  The filter
6690 will then restrict to entries with effort smaller-or-equal, equal, or
6691 larger-or-equal than the selected value.  If the digits 0-9 are not used as
6692 fast access keys to tags, you can also simply press the index digit directly
6693 without an operator.  In this case, @kbd{<} will be assumed.
6695 @kindex \
6696 @item \
6697 Narrow the current agenda filter by an additional condition.  When called with
6698 prefix arg, remove the entries that @emph{do} have the tag, or that do match
6699 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
6700 @kbd{-} as the first key after the @kbd{/} command.
6702 @kindex [
6703 @kindex ]
6704 @kindex @{
6705 @kindex @}
6706 @item [ ] @{ @}
6707 In the @i{search view} (@pxref{Keyword search}), these keys add new search
6708 words (@kbd{[} and @kbd{]}) or new regular expressions (@kbd{@{} and
6709 @kbd{@}}) to the query string.  The opening bracket/brace will add a positive
6710 search term prefixed by @samp{+}, indicating that this search term @i{must}
6711 occur/match in the entry.  The closing bracket/brace will add a negative
6712 search term which @i{must not} occur/match in the entry for it to be
6713 selected.
6716 @tsubheading{Remote editing}
6717 @cindex remote editing, from agenda
6719 @item 0-9
6720 Digit argument.
6722 @cindex undoing remote-editing events
6723 @cindex remote editing, undo
6724 @kindex C-_
6725 @item C-_
6726 Undo a change due to a remote editing command.  The change is undone
6727 both in the agenda buffer and in the remote buffer.
6729 @kindex t
6730 @item t
6731 Change the TODO state of the item, both in the agenda and in the
6732 original org file.
6734 @kindex C-k
6735 @item C-k
6736 @vindex org-agenda-confirm-kill
6737 Delete the current agenda item along with the entire subtree belonging
6738 to it in the original Org file.  If the text to be deleted remotely
6739 is longer than one line, the kill needs to be confirmed by the user.  See
6740 variable @code{org-agenda-confirm-kill}.
6742 @kindex a
6743 @item a
6744 Toggle the ARCHIVE tag for the current headline.
6746 @kindex A
6747 @item A
6748 Move the subtree corresponding to the current entry to its @emph{Archive
6749 Sibling}.
6751 @kindex $
6752 @item $
6753 Archive the subtree corresponding to the current headline.  This means the
6754 entry will be moved to the configured archive location, most likely a
6755 different file.
6757 @kindex T
6758 @item T
6759 @vindex org-agenda-show-inherited-tags
6760 Show all tags associated with the current item.  This is useful if you have
6761 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
6762 tags of a headline occasionally.
6764 @kindex :
6765 @item :
6766 Set tags for the current headline.  If there is an active region in the
6767 agenda, change a tag for all headings in the region.
6769 @kindex ,
6770 @item ,
6771 Set the priority for the current item.  Org mode prompts for the
6772 priority character. If you reply with @key{SPC}, the priority cookie
6773 is removed from the entry.
6775 @kindex P
6776 @item P
6777 Display weighted priority of current item.
6779 @kindex +
6780 @kindex S-@key{up}
6781 @item +
6782 @itemx S-@key{up}
6783 Increase the priority of the current item.  The priority is changed in
6784 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
6785 key for this.
6787 @kindex -
6788 @kindex S-@key{down}
6789 @item -
6790 @itemx S-@key{down}
6791 Decrease the priority of the current item.
6793 @kindex z
6794 @item z
6795 @vindex org-log-state-notes-into-drawer
6796 Add a note to the entry.  This note will be recorded, and then files to the
6797 same location where state change notes a put.  Depending on
6798 @code{org-log-state-notes-into-drawer}, this maybe inside a drawer.
6800 @kindex C-c C-a
6801 @item C-c C-a
6802 Dispatcher for all command related to attachments.
6804 @kindex C-c C-s
6805 @item C-c C-s
6806 Schedule this item
6808 @kindex C-c C-d
6809 @item C-c C-d
6810 Set a deadline for this item.
6812 @kindex k
6813 @item k
6814 Agenda actions, to set dates for selected items to the cursor date.
6815 This command also works in the calendar!  The command prompts for an
6816 additional key:
6817 @example
6818 m   @r{Mark the entry at point for action.  You can also make entries}
6819     @r{in Org files with @kbd{C-c C-x C-k}.}
6820 d   @r{Set the deadline of the marked entry to the date at point.}
6821 s   @r{Schedule the marked entry at the date at point.}
6822 r   @r{Call @code{org-remember} with the cursor date as default date.}
6823 @end example
6824 Press @kbd{r} afterward to refresh the agenda and see the effect of the
6825 command.
6827 @kindex S-@key{right}
6828 @item S-@key{right}
6829 Change the time stamp associated with the current line by one day into the
6830 future.  With a numeric prefix argument, change it by that many days.  For
6831 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The stamp is
6832 changed in the original org file, but the change is not directly reflected in
6833 the agenda buffer.  Use the @kbd{r} key to update the buffer.
6835 @kindex S-@key{left}
6836 @item S-@key{left}
6837 Change the time stamp associated with the current line by one day
6838 into the past.
6840 @kindex >
6841 @item >
6842 Change the time stamp associated with the current line to today.
6843 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
6844 on my keyboard.
6846 @kindex I
6847 @item I
6848 Start the clock on the current item.  If a clock is running already, it
6849 is stopped first.
6851 @kindex O
6852 @item O
6853 Stop the previously started clock.
6855 @kindex X
6856 @item X
6857 Cancel the currently running clock.
6859 @kindex J
6860 @item J
6861 Jump to the running clock in another window.
6863 @tsubheading{Calendar commands}
6864 @cindex calendar commands, from agenda
6865 @kindex c
6866 @item c
6867 Open the Emacs calendar and move to the date at the agenda cursor.
6869 @item c
6870 When in the calendar, compute and show the Org mode agenda for the
6871 date at the cursor.
6873 @cindex diary entries, creating from agenda
6874 @kindex i
6875 @item i
6876 Insert a new entry into the diary.  Prompts for the type of entry
6877 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
6878 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
6879 The date is taken from the cursor position.
6881 @kindex M
6882 @item M
6883 Show the phases of the moon for the three months around current date.
6885 @kindex S
6886 @item S
6887 Show sunrise and sunset times.  The geographical location must be set
6888 with calendar variables, see documentation of the Emacs calendar.
6890 @kindex C
6891 @item C
6892 Convert the date at cursor into many other cultural and historic
6893 calendars.
6895 @kindex H
6896 @item H
6897 Show holidays for three month around the cursor date.
6899 @item M-x org-export-icalendar-combine-agenda-files
6900 Export a single iCalendar file containing entries from all agenda files.
6901 This is a globally available command, and also available in the agenda menu.
6903 @tsubheading{Exporting to a file}
6904 @kindex C-x C-w
6905 @item C-x C-w
6906 @cindex exporting agenda views
6907 @cindex agenda views, exporting
6908 @vindex org-agenda-exporter-settings
6909 Write the agenda view to a file.  Depending on the extension of the selected
6910 file name, the view will be exported as HTML (extension @file{.html} or
6911 @file{.htm}), Postscript (extension @file{.ps}), PDF
6912 (extension @file{.pdf}), or plain text (any other extension).  Use the
6913 variable @code{org-agenda-exporter-settings} to set options for
6914 @file{ps-print} and for @file{htmlize} to be used during export.
6916 @tsubheading{Quit and Exit}
6917 @kindex q
6918 @item q
6919 Quit agenda, remove the agenda buffer.
6921 @kindex x
6922 @cindex agenda files, removing buffers
6923 @item x
6924 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
6925 for the compilation of the agenda.  Buffers created by the user to
6926 visit org files will not be removed.
6927 @end table
6930 @node Custom agenda views, Agenda column view, Agenda commands, Agenda Views
6931 @section Custom agenda views
6932 @cindex custom agenda views
6933 @cindex agenda views, custom
6935 Custom agenda commands serve two purposes: to store and quickly access
6936 frequently used TODO and tags searches, and to create special composite
6937 agenda buffers.  Custom agenda commands will be accessible through the
6938 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
6940 @menu
6941 * Storing searches::            Type once, use often
6942 * Block agenda::                All the stuff you need in a single buffer
6943 * Setting Options::             Changing the rules
6944 * Exporting Agenda Views::      Writing agendas to files
6945 * Using the agenda elsewhere::  Using agenda information in other programs
6946 @end menu
6948 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
6949 @subsection Storing searches
6951 The first application of custom searches is the definition of keyboard
6952 shortcuts for frequently used searches, either creating an agenda
6953 buffer, or a sparse tree (the latter covering of course only the current
6954 buffer).
6955 @kindex C-c a C
6956 @vindex org-agenda-custom-commands
6957 Custom commands are configured in the variable
6958 @code{org-agenda-custom-commands}.  You can customize this variable, for
6959 example by pressing @kbd{C-c a C}.  You can also directly set it with
6960 Emacs Lisp in @file{.emacs}.  The following example contains all valid
6961 search types:
6963 @lisp
6964 @group
6965 (setq org-agenda-custom-commands
6966       '(("w" todo "WAITING")
6967         ("W" todo-tree "WAITING")
6968         ("u" tags "+boss-urgent")
6969         ("v" tags-todo "+boss-urgent")
6970         ("U" tags-tree "+boss-urgent")
6971         ("f" occur-tree "\\<FIXME\\>")
6972         ("h" . "HOME+Name tags searches") ; description for "h" prefix
6973         ("hl" tags "+home+Lisa")
6974         ("hp" tags "+home+Peter")
6975         ("hk" tags "+home+Kim")))
6976 @end group
6977 @end lisp
6979 @noindent
6980 The initial string in each entry defines the keys you have to press
6981 after the dispatcher command @kbd{C-c a} in order to access the command.
6982 Usually this will be just a single character, but if you have many
6983 similar commands, you can also define two-letter combinations where the
6984 first character is the same in several combinations and serves as a
6985 prefix key@footnote{You can provide a description for a prefix key by
6986 inserting a cons cell with the prefix and the description.}.  The second
6987 parameter is the search type, followed by the string or regular
6988 expression to be used for the matching.  The example above will
6989 therefore define:
6991 @table @kbd
6992 @item C-c a w
6993 as a global search for TODO entries with @samp{WAITING} as the TODO
6994 keyword
6995 @item C-c a W
6996 as the same search, but only in the current buffer and displaying the
6997 results as a sparse tree
6998 @item C-c a u
6999 as a global tags search for headlines marked @samp{:boss:} but not
7000 @samp{:urgent:}
7001 @item C-c a v
7002 as the same search as @kbd{C-c a u}, but limiting the search to
7003 headlines that are also TODO items
7004 @item C-c a U
7005 as the same search as @kbd{C-c a u}, but only in the current buffer and
7006 displaying the result as a sparse tree
7007 @item C-c a f
7008 to create a sparse tree (again: current buffer only) with all entries
7009 containing the word @samp{FIXME}
7010 @item C-c a h
7011 as a prefix command for a HOME tags search where you have to press an
7012 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
7013 Peter, or Kim) as additional tag to match.
7014 @end table
7016 @node Block agenda, Setting Options, Storing searches, Custom agenda views
7017 @subsection Block agenda
7018 @cindex block agenda
7019 @cindex agenda, with block views
7021 Another possibility is the construction of agenda views that comprise
7022 the results of @emph{several} commands, each of which creates a block in
7023 the agenda buffer.  The available commands include @code{agenda} for the
7024 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
7025 for the global TODO list (as constructed with @kbd{C-c a t}), and the
7026 matching commands discussed above: @code{todo}, @code{tags}, and
7027 @code{tags-todo}.  Here are two examples:
7029 @lisp
7030 @group
7031 (setq org-agenda-custom-commands
7032       '(("h" "Agenda and Home-related tasks"
7033          ((agenda "")
7034           (tags-todo "home")
7035           (tags "garden")))
7036         ("o" "Agenda and Office-related tasks"
7037          ((agenda "")
7038           (tags-todo "work")
7039           (tags "office")))))
7040 @end group
7041 @end lisp
7043 @noindent
7044 This will define @kbd{C-c a h} to create a multi-block view for stuff
7045 you need to attend to at home.  The resulting agenda buffer will contain
7046 your agenda for the current week, all TODO items that carry the tag
7047 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
7048 command @kbd{C-c a o} provides a similar view for office tasks.
7050 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
7051 @subsection Setting options for custom commands
7052 @cindex options, for custom agenda views
7054 @vindex org-agenda-custom-commands
7055 Org mode contains a number of variables regulating agenda construction
7056 and display.  The global variables define the behavior for all agenda
7057 commands, including the custom commands.  However, if you want to change
7058 some settings just for a single custom view, you can do so.  Setting
7059 options requires inserting a list of variable names and values at the
7060 right spot in @code{org-agenda-custom-commands}.  For example:
7062 @lisp
7063 @group
7064 (setq org-agenda-custom-commands
7065       '(("w" todo "WAITING"
7066          ((org-agenda-sorting-strategy '(priority-down))
7067           (org-agenda-prefix-format "  Mixed: ")))
7068         ("U" tags-tree "+boss-urgent"
7069          ((org-show-following-heading nil)
7070           (org-show-hierarchy-above nil)))
7071         ("N" search ""
7072          ((org-agenda-files '("~org/notes.org"))
7073           (org-agenda-text-search-extra-files nil)))))
7074 @end group
7075 @end lisp
7077 @noindent
7078 Now the @kbd{C-c a w} command will sort the collected entries only by
7079 priority, and the prefix format is modified to just say @samp{  Mixed: }
7080 instead of giving the category of the entry.  The sparse tags tree of
7081 @kbd{C-c a U} will now turn out ultra-compact, because neither the
7082 headline hierarchy above the match, nor the headline following the match
7083 will be shown.  The command @kbd{C-c a N} will do a text search limited
7084 to only a single file.
7086 @vindex org-agenda-custom-commands
7087 For command sets creating a block agenda,
7088 @code{org-agenda-custom-commands} has two separate spots for setting
7089 options.  You can add options that should be valid for just a single
7090 command in the set, and options that should be valid for all commands in
7091 the set.  The former are just added to the command entry, the latter
7092 must come after the list of command entries.  Going back to the block
7093 agenda example (@pxref{Block agenda}), let's change the sorting strategy
7094 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
7095 the results for GARDEN tags query in the opposite order,
7096 @code{priority-up}.  This would look like this:
7098 @lisp
7099 @group
7100 (setq org-agenda-custom-commands
7101       '(("h" "Agenda and Home-related tasks"
7102          ((agenda)
7103           (tags-todo "home")
7104           (tags "garden"
7105                 ((org-agenda-sorting-strategy '(priority-up)))))
7106          ((org-agenda-sorting-strategy '(priority-down))))
7107         ("o" "Agenda and Office-related tasks"
7108          ((agenda)
7109           (tags-todo "work")
7110           (tags "office")))))
7111 @end group
7112 @end lisp
7114 As you see, the values and parenthesis setting is a little complex.
7115 When in doubt, use the customize interface to set this variable - it
7116 fully supports its structure.  Just one caveat: When setting options in
7117 this interface, the @emph{values} are just lisp expressions.  So if the
7118 value is a string, you need to add the double quotes around the value
7119 yourself.
7122 @node Exporting Agenda Views, Using the agenda elsewhere, Setting Options, Custom agenda views
7123 @subsection Exporting Agenda Views
7124 @cindex agenda views, exporting
7126 If you are away from your computer, it can be very useful to have a printed
7127 version of some agenda views to carry around.  Org mode can export custom
7128 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
7129 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
7130 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
7131 a pdf file with also create the postscript file.}, and iCalendar files.  If
7132 you want to do this only occasionally, use the command
7134 @table @kbd
7135 @kindex C-x C-w
7136 @item C-x C-w
7137 @cindex exporting agenda views
7138 @cindex agenda views, exporting
7139 @vindex org-agenda-exporter-settings
7140 Write the agenda view to a file.  Depending on the extension of the
7141 selected file name, the view will be exported as HTML (extension
7142 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
7143 iCalendar (extension @file{.ics}), or plain text (any other extension).
7144 Use the variable @code{org-agenda-exporter-settings} to
7145 set options for @file{ps-print} and for @file{htmlize} to be used during
7146 export, for example
7148 @vindex org-agenda-add-entry-text-maxlines
7149 @vindex htmlize-output-type
7150 @vindex ps-number-of-columns
7151 @vindex ps-landscape-mode
7152 @lisp
7153 (setq org-agenda-exporter-settings
7154       '((ps-number-of-columns 2)
7155         (ps-landscape-mode t)
7156         (org-agenda-add-entry-text-maxlines 5)
7157         (htmlize-output-type 'css)))
7158 @end lisp
7159 @end table
7161 If you need to export certain agenda views frequently, you can associate
7162 any custom agenda command with a list of output file names
7163 @footnote{If you want to store standard views like the weekly agenda
7164 or the global TODO list as well, you need to define custom commands for
7165 them in order to be able to specify file names.}.  Here is an example
7166 that first does define custom commands for the agenda and the global
7167 todo list, together with a number of files to which to export them.
7168 Then we define two block agenda commands and specify file names for them
7169 as well.  File names can be relative to the current working directory,
7170 or absolute.
7172 @lisp
7173 @group
7174 (setq org-agenda-custom-commands
7175       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
7176         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
7177         ("h" "Agenda and Home-related tasks"
7178          ((agenda "")
7179           (tags-todo "home")
7180           (tags "garden"))
7181          nil
7182          ("~/views/home.html"))
7183         ("o" "Agenda and Office-related tasks"
7184          ((agenda)
7185           (tags-todo "work")
7186           (tags "office"))
7187          nil
7188          ("~/views/office.ps" "~/calendars/office.ics"))))
7189 @end group
7190 @end lisp
7192 The extension of the file name determines the type of export.  If it is
7193 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
7194 the buffer to HTML and save it to this file name.  If the extension is
7195 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
7196 postscript output.  If the extension is @file{.ics}, iCalendar export is
7197 run export over all files that were used to construct the agenda, and
7198 limit the export to entries listed in the agenda now.  Any other
7199 extension produces a plain ASCII file.
7201 The export files are @emph{not} created when you use one of those
7202 commands interactively because this might use too much overhead.
7203 Instead, there is a special command to produce @emph{all} specified
7204 files in one step:
7206 @table @kbd
7207 @kindex C-c a e
7208 @item C-c a e
7209 Export all agenda views that have export file names associated with
7210 them.
7211 @end table
7213 You can use the options section of the custom agenda commands to also
7214 set options for the export commands.  For example:
7216 @lisp
7217 (setq org-agenda-custom-commands
7218       '(("X" agenda ""
7219          ((ps-number-of-columns 2)
7220           (ps-landscape-mode t)
7221           (org-agenda-prefix-format " [ ] ")
7222           (org-agenda-with-colors nil)
7223           (org-agenda-remove-tags t))
7224          ("theagenda.ps"))))
7225 @end lisp
7227 @noindent
7228 This command sets two options for the postscript exporter, to make it
7229 print in two columns in landscape format - the resulting page can be cut
7230 in two and then used in a paper agenda.  The remaining settings modify
7231 the agenda prefix to omit category and scheduling information, and
7232 instead include a checkbox to check off items.  We also remove the tags
7233 to make the lines compact, and we don't want to use colors for the
7234 black-and-white printer.  Settings specified in
7235 @code{org-agenda-exporter-settings} will also apply, but the settings
7236 in @code{org-agenda-custom-commands} take precedence.
7238 @noindent
7239 From the command line you may also use
7240 @example
7241 emacs -f org-batch-store-agenda-views -kill
7242 @end example
7243 @noindent
7244 or, if you need to modify some parameters@footnote{Quoting may depend on the
7245 system you use, please check th FAQ for examples.}
7246 @example
7247 emacs -eval '(org-batch-store-agenda-views                      \
7248               org-agenda-ndays 30                               \
7249               org-agenda-start-day "2007-11-01"                 \
7250               org-agenda-include-diary nil                      \
7251               org-agenda-files (quote ("~/org/project.org")))'  \
7252       -kill
7253 @end example
7254 @noindent
7255 which will create the agenda views restricted to the file
7256 @file{~/org/project.org}, without diary entries and with 30 days
7257 extent.
7259 @node Using the agenda elsewhere,  , Exporting Agenda Views, Custom agenda views
7260 @subsection Using agenda information outside of Org
7261 @cindex agenda, pipe
7262 @cindex Scripts, for agenda processing
7264 @vindex org-agenda-custom-commands
7265 Org provides commands to access agenda information for the command
7266 line in emacs batch mode.  This extracted information can be sent
7267 directly to a printer, or it can be read by a program that does further
7268 processing of the data.  The first of these commands is the function
7269 @code{org-batch-agenda}, that produces an agenda view and sends it as
7270 ASCII text to STDOUT.  The command takes a single string as parameter.
7271 If the string has length 1, it is used as a key to one of the commands
7272 you have configured in @code{org-agenda-custom-commands}, basically any
7273 key you can use after @kbd{C-c a}.  For example, to directly print the
7274 current TODO list, you could use
7276 @example
7277 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
7278 @end example
7280 If the parameter is a string with 2 or more characters, it is used as a
7281 tags/todo match string.  For example, to print your local shopping list
7282 (all items with the tag @samp{shop}, but excluding the tag
7283 @samp{NewYork}), you could use
7285 @example
7286 emacs -batch -l ~/.emacs                                      \
7287       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
7288 @end example
7290 @noindent
7291 You may also modify parameters on the fly like this:
7293 @example
7294 emacs -batch -l ~/.emacs                                      \
7295    -eval '(org-batch-agenda "a"                               \
7296             org-agenda-ndays 30                               \
7297             org-agenda-include-diary nil                      \
7298             org-agenda-files (quote ("~/org/project.org")))'  \
7299    | lpr
7300 @end example
7302 @noindent
7303 which will produce a 30 day agenda, fully restricted to the Org file
7304 @file{~/org/projects.org}, not even including the diary.
7306 If you want to process the agenda data in more sophisticated ways, you
7307 can use the command @code{org-batch-agenda-csv} to get a comma-separated
7308 list of values for each agenda item.  Each line in the output will
7309 contain a number of fields separated by commas.  The fields in a line
7310 are:
7312 @example
7313 category     @r{The category of the item}
7314 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
7315 type         @r{The type of the agenda entry, can be}
7316                 todo               @r{selected in TODO match}
7317                 tagsmatch          @r{selected in tags match}
7318                 diary              @r{imported from diary}
7319                 deadline           @r{a deadline}
7320                 scheduled          @r{scheduled}
7321                 timestamp          @r{appointment, selected by timestamp}
7322                 closed             @r{entry was closed on date}
7323                 upcoming-deadline  @r{warning about nearing deadline}
7324                 past-scheduled     @r{forwarded scheduled item}
7325                 block              @r{entry has date block including date}
7326 todo         @r{The TODO keyword, if any}
7327 tags         @r{All tags including inherited ones, separated by colons}
7328 date         @r{The relevant date, like 2007-2-14}
7329 time         @r{The time, like 15:00-16:50}
7330 extra        @r{String with extra planning info}
7331 priority-l   @r{The priority letter if any was given}
7332 priority-n   @r{The computed numerical priority}
7333 @end example
7335 @noindent
7336 Time and date will only be given if a timestamp (or deadline/scheduled)
7337 lead to the selection of the item.
7339 A CSV list like this is very easy to use in a post processing script.
7340 For example, here is a Perl program that gets the TODO list from
7341 Emacs/Org and prints all the items, preceded by a checkbox:
7343 @example
7344 #!/usr/bin/perl
7346 # define the Emacs command to run
7347 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
7349 # run it and capture the output
7350 $agenda = qx@{$cmd 2>/dev/null@};
7352 # loop over all lines
7353 foreach $line (split(/\n/,$agenda)) @{
7354   # get the individual values
7355   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
7356    $priority_l,$priority_n) = split(/,/,$line);
7357   # process and print
7358   print "[ ] $head\n";
7360 @end example
7362 @node Agenda column view,  , Custom agenda views, Agenda Views
7363 @section Using column view in the agenda
7364 @cindex column view, in agenda
7365 @cindex agenda, column view
7367 Column view (@pxref{Column view}) is normally used to view and edit
7368 properties embedded in the hierarchical structure of an Org file.  It can be
7369 quite useful to use column view also from the agenda, where entries are
7370 collected by certain criteria.
7372 @table @kbd
7373 @kindex C-c C-x C-c
7374 @item C-c C-x C-c
7375 Turn on column view in the agenda.
7376 @end table
7378 To understand how to use this properly, it is important to realize that the
7379 entries in the agenda are no longer in their proper outline environment.
7380 This causes the following issues:
7382 @enumerate
7383 @item
7384 @vindex org-columns-default-format
7385 @vindex org-overriding-columns-format
7386 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
7387 entries in the agenda are collected from different files, and different files
7388 may have different @code{COLUMNS} formats, this is a non-trivial problem.
7389 Org first checks if the variable @code{org-overriding-columns-format} is
7390 currently set, and if yes takes the format from there.  Otherwise it takes
7391 the format associated with the first item in the agenda, or, if that item
7392 does not have a specific format (defined in a property, or in it's file), it
7393 uses @code{org-columns-default-format}.
7394 @item
7395 If any of the columns has a summary type defined (@pxref{Column attributes}),
7396 turning on column view in the agenda will visit all relevant agenda files and
7397 make sure that the computations of this property are up to date.  This is
7398 also true for the special @code{CLOCKSUM} property.  Org will then sum the
7399 values displayed in the agenda.  In the daily/weekly agenda, the sums will
7400 cover a single day, in all other views they cover the entire block.  It is
7401 vital to realize that the agenda may show the same entry @emph{twice} (for
7402 example as scheduled and as a deadline), and it may show two entries from the
7403 same hierarchy (for example a @emph{parent} and it's @emph{child}).  In these
7404 cases, the summation in the agenda will lead to incorrect results because
7405 some values will count double.
7406 @item
7407 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
7408 the entire clocked time for this item.  So even in the daily/weekly agenda,
7409 the clocksum listed in column view may originate from times outside the
7410 current view.  This has the advantage that you can compare these values with
7411 a column listing the planned total effort for a task - one of the major
7412 applications for column view in the agenda.  If you want information about
7413 clocked time in the displayed period use clock table mode (press @kbd{R} in
7414 the agenda).
7415 @end enumerate
7418 @node Embedded LaTeX, Exporting, Agenda Views, Top
7419 @chapter Embedded LaTeX
7420 @cindex @TeX{} interpretation
7421 @cindex La@TeX{} interpretation
7423 Plain ASCII is normally sufficient for almost all note taking.  One
7424 exception, however, are scientific notes which need to be able to contain
7425 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
7426 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
7427 features described here as ``La@TeX{}'' are really from @TeX{}, but for
7428 simplicity I am blurring this distinction.}  is widely used to typeset
7429 scientific documents. Org mode supports embedding La@TeX{} code into its
7430 files, because many academics are used to reading La@TeX{} source code, and
7431 because it can be readily processed into images for HTML production.
7433 It is not necessary to mark La@TeX{} macros and code in any special way.
7434 If you observe a few conventions, Org mode knows how to find it and what
7435 to do with it.
7437 @menu
7438 * Math symbols::                TeX macros for symbols and Greek letters
7439 * Subscripts and superscripts::  Simple syntax for raising/lowering text
7440 * LaTeX fragments::             Complex formulas made easy
7441 * Processing LaTeX fragments::  Previewing LaTeX processing
7442 * CDLaTeX mode::                Speed up entering of formulas
7443 @end menu
7445 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
7446 @section Math symbols
7447 @cindex math symbols
7448 @cindex TeX macros
7450 You can use La@TeX{} macros to insert special symbols like @samp{\alpha} to
7451 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
7452 for these macros is available, just type @samp{\} and maybe a few letters,
7453 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike La@TeX{}
7454 code, Org mode allows these macros to be present without surrounding math
7455 delimiters, for example:
7457 @example
7458 Angles are written as Greek letters \alpha, \beta and \gamma.
7459 @end example
7461 During HTML export (@pxref{HTML export}), these symbols are translated
7462 into the proper syntax for HTML, for the above examples this is
7463 @samp{&alpha;} and @samp{&rarr;}, respectively.  If you need such a symbol
7464 inside a word, terminate it like this: @samp{\Aacute@{@}stor}.
7466 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
7467 @section Subscripts and superscripts
7468 @cindex subscript
7469 @cindex superscript
7471 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
7472 and subscripts.  Again, these can be used without embedding them in
7473 math-mode delimiters.  To increase the readability of ASCII text, it is
7474 not necessary (but OK) to surround multi-character sub- and superscripts
7475 with curly braces.  For example
7477 @example
7478 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
7479 the sun is R_@{sun@} = 6.96 x 10^8 m.
7480 @end example
7482 To avoid interpretation as raised or lowered text, you can quote
7483 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
7485 During HTML export (@pxref{HTML export}), subscript and superscripts
7486 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
7488 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
7489 @section LaTeX fragments
7490 @cindex LaTeX fragments
7492 @vindex org-format-latex-header
7493 With symbols, sub- and superscripts, HTML is pretty much at its end when
7494 it comes to representing mathematical formulas@footnote{Yes, there is
7495 MathML, but that is not yet fully supported by many browsers, and there
7496 is no decent converter for turning La@TeX{} or ASCII representations of
7497 formulas into MathML. So for the time being, converting formulas into
7498 images seems the way to go.}. More complex expressions need a dedicated
7499 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
7500 fragments. It provides commands to preview the typeset result of these
7501 fragments, and upon export to HTML, all fragments will be converted to
7502 images and inlined into the HTML document@footnote{The La@TeX{} export
7503 will not use images for displaying La@TeX{} fragments but include these
7504 fragments directly into the La@TeX{} code.}. For this to work you
7505 need to be on a system with a working La@TeX{} installation. You also
7506 need the @file{dvipng} program, available at
7507 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
7508 will be used when processing a fragment can be configured with the
7509 variable @code{org-format-latex-header}.
7511 La@TeX{} fragments don't need any special marking at all.  The following
7512 snippets will be identified as La@TeX{} source code:
7513 @itemize @bullet
7514 @item
7515 Environments of any kind.  The only requirement is that the
7516 @code{\begin} statement appears on a new line, preceded by only
7517 whitespace.
7518 @item
7519 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
7520 currency specifications, single @samp{$} characters are only recognized as
7521 math delimiters if the enclosed text contains at most two line breaks, is
7522 directly attached to the @samp{$} characters with no whitespace in between,
7523 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
7524 For the other delimiters, there is no such restriction, so when in doubt, use
7525 @samp{\(...\)} as inline math delimiters.
7526 @end itemize
7528 @noindent For example:
7530 @example
7531 \begin@{equation@}                          % arbitrary environments,
7532 x=\sqrt@{b@}                                % even tables, figures
7533 \end@{equation@}                            % etc
7535 If $a^2=b$ and \( b=2 \), then the solution must be
7536 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
7537 @end example
7539 @noindent
7540 @vindex org-format-latex-options
7541 If you need any of the delimiter ASCII sequences for other purposes, you
7542 can configure the option @code{org-format-latex-options} to deselect the
7543 ones you do not wish to have interpreted by the La@TeX{} converter.
7545 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
7546 @section Processing LaTeX fragments
7547 @cindex LaTeX fragments, preview
7549 La@TeX{} fragments can be processed to produce a preview images of the
7550 typeset expressions:
7552 @table @kbd
7553 @kindex C-c C-x C-l
7554 @item C-c C-x C-l
7555 Produce a preview image of the La@TeX{} fragment at point and overlay it
7556 over the source code.  If there is no fragment at point, process all
7557 fragments in the current entry (between two headlines).  When called
7558 with a prefix argument, process the entire subtree.  When called with
7559 two prefix arguments, or when the cursor is before the first headline,
7560 process the entire buffer.
7561 @kindex C-c C-c
7562 @item C-c C-c
7563 Remove the overlay preview images.
7564 @end table
7566 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
7567 converted into images and inlined into the document if the following
7568 setting is active:
7570 @lisp
7571 (setq org-export-with-LaTeX-fragments t)
7572 @end lisp
7574 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
7575 @section Using CDLaTeX to enter math
7576 @cindex CDLaTeX
7578 CDLaTeX mode is a minor mode that is normally used in combination with a
7579 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
7580 environments and math templates.  Inside Org mode, you can make use of
7581 some of the features of CDLaTeX mode.  You need to install
7582 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
7583 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
7584 Don't use CDLaTeX mode itself under Org mode, but use the light
7585 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
7586 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
7587 Org files with
7589 @lisp
7590 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
7591 @end lisp
7593 When this mode is enabled, the following features are present (for more
7594 details see the documentation of CDLaTeX mode):
7595 @itemize @bullet
7596 @kindex C-c @{
7597 @item
7598 Environment templates can be inserted with @kbd{C-c @{}.
7599 @item
7600 @kindex @key{TAB}
7601 The @key{TAB} key will do template expansion if the cursor is inside a
7602 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
7603 inside such a fragment, see the documentation of the function
7604 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
7605 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
7606 correctly inside the first brace.  Another @key{TAB} will get you into
7607 the second brace.  Even outside fragments, @key{TAB} will expand
7608 environment abbreviations at the beginning of a line.  For example, if
7609 you write @samp{equ} at the beginning of a line and press @key{TAB},
7610 this abbreviation will be expanded to an @code{equation} environment.
7611 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
7612 @item
7613 @kindex _
7614 @kindex ^
7615 @vindex cdlatex-simplify-sub-super-scripts
7616 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
7617 characters together with a pair of braces.  If you use @key{TAB} to move
7618 out of the braces, and if the braces surround only a single character or
7619 macro, they are removed again (depending on the variable
7620 @code{cdlatex-simplify-sub-super-scripts}).
7621 @item
7622 @kindex `
7623 Pressing the backquote @kbd{`} followed by a character inserts math
7624 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
7625 after the backquote, a help window will pop up.
7626 @item
7627 @kindex '
7628 Pressing the normal quote @kbd{'} followed by another character modifies
7629 the symbol before point with an accent or a font.  If you wait more than
7630 1.5 seconds after the backquote, a help window will pop up.  Character
7631 modification will work only inside La@TeX{} fragments, outside the quote
7632 is normal.
7633 @end itemize
7635 @node Exporting, Publishing, Embedded LaTeX, Top
7636 @chapter Exporting
7637 @cindex exporting
7639 Org mode documents can be exported into a variety of other formats.  For
7640 printing and sharing of notes, ASCII export produces a readable and
7641 simple version of an Org file.  HTML export allows you to publish a
7642 notes file on the web, while the XOXO format provides a solid base for
7643 exchange with a broad range of other applications. La@TeX{} export lets
7644 you use Org mode and its structured editing functions to easily create
7645 La@TeX{} files.  To incorporate entries with associated times like
7646 deadlines or appointments into a desktop calendar program like iCal,
7647 Org mode can also produce extracts in the iCalendar format.  Currently
7648 Org mode only supports export, not import of these different formats.
7650 Org supports export of selected regions when @code{transient-mark-mode} is
7651 enabled (default in Emacs 23).
7653 @menu
7654 * Markup rules::                Which structures are recognized?
7655 * Selective export::            Using tags to select and exclude trees
7656 * Export options::              Per-file export settings
7657 * The export dispatcher::       How to access exporter commands
7658 * ASCII export::                Exporting to plain ASCII
7659 * HTML export::                 Exporting to HTML
7660 * LaTeX and PDF export::        Exporting to LaTeX, and processing to PDF
7661 * XOXO export::                 Exporting to XOXO
7662 * iCalendar export::            Exporting in iCalendar format
7663 @end menu
7665 @node Markup rules, Selective export, Exporting, Exporting
7666 @section Markup rules
7668 When exporting Org mode documents,  the exporter tries to reflect the
7669 structure of the document as accurately as possible in the back-end.  Since
7670 export targets like HTML or La@TeX{} allow much richer formatting, Org mode
7671 has rules how to prepare text for rich export.  This section summarizes the
7672 markup rule used in an Org mode buffer.
7674 @menu
7675 * Document title::              How the document title is determined
7676 * Headings and sections::       The main structure of the exported document
7677 * Table of contents::           If, where, how to create a table of contents
7678 * Initial text::                Text before the first headline
7679 * Lists::                       Plain lists are exported
7680 * Paragraphs::                  What determines beginning and ending
7681 * Literal examples::            Source code and other examples
7682 * Include files::               Include the contents of a file during export
7683 * Tables exported::             Tables are exported richly
7684 * Inlined images::              How to inline images during export
7685 * Footnote markup::             ASCII representation of footnotes
7686 * Emphasis and monospace::      To bold or not to bold
7687 * TeX macros and LaTeX fragments::  Create special, rich export.
7688 * Horizontal rules::            A line across the page
7689 * Comment lines::               Some lines will not be exported
7690 * Macro replacement::           Global replacement of place holdes
7691 @end menu
7693 @node Document title, Headings and sections, Markup rules, Markup rules
7694 @subheading Document title
7695 @cindex document title, markup rules
7697 @noindent
7698 The title of the exported document is taken from the special line
7700 @example
7701 #+TITLE: This is the title of the document
7702 @end example
7704 @noindent
7705 If this line does not exist, the title is derived from the first non-empty,
7706 non-comment line in the buffer.  If no such line exists, or if you have
7707 turned off exporting of the text before the first headline (see below), the
7708 title will be the file name without extension.
7710 If you are exporting only a subtree by marking is as the region, the heading
7711 of the subtree will become the title of the document.  If the subtree has a
7712 property @code{EXPORT_TITLE}, that will take precedence.
7714 @node Headings and sections, Table of contents, Document title, Markup rules
7715 @subheading Headings and sections
7716 @cindex headings and sections, markup rules
7718 @vindex org-headline-levels
7719 The outline structure of the document as described in @ref{Document
7720 Structure} forms the basis for defining sections of the exported document.
7721 However, since the outline structure is also used for (for example) lists of
7722 tasks, only the first three outline levels will be used as headings.  Deeper
7723 levels will become itemized lists.  You can change the location of this
7724 switch, globally by setting the variable @code{org-headline-levels}, or on a
7725 per file basis with a line
7727 @example
7728 #+OPTIONS: H:4
7729 @end example
7731 @node Table of contents, Initial text, Headings and sections, Markup rules
7732 @subheading Table of contents
7733 @cindex table of contents, markup rules
7735 @vindex org-export-with-toc
7736 The table of contents is normally inserted directly before the first headline
7737 of the file.  If you would like to get it to a different location, insert the
7738 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
7739 location.  The depth of the table of contents is by default the same as the
7740 number of headline levels, but you can choose a smaller number or turn off
7741 the table of contents entirely by configuring the variable
7742 @code{org-export-with-toc}, or on a per-file basis with a line like
7744 @example
7745 #+OPTIONS: toc:2          (only to two levels in TOC)
7746 #+OPTIONS: toc:nil        (no TOC at all)
7747 @end example
7749 @node Initial text, Lists, Table of contents, Markup rules
7750 @subheading Text before the first headline
7751 @cindex text before first headline, markup rules
7752 @cindex #+TEXT
7754 Org mode normally exports the text before the first headline, and even uses
7755 the first line as the document title.  The text will be fully marked up.  If
7756 you need to include literal HTML or La@TeX{} code, use the special constructs
7757 described below in the sections for the individual exporters.
7759 @vindex org-export-skip-text-before-1st-heading
7760 Some people like to use the space before the first headline for setup and
7761 internal links and therefore would like to control the exported text before
7762 the first headline in a different way.  You can do so by setting the variable
7763 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
7764 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
7766 @noindent
7767 If you still want to have some text before the first headline, use the
7768 @code{#+TEXT} construct:
7770 @example
7771 #+OPTIONS: skip:t
7772 #+TEXT: This text will go before the *first* headline.
7773 #+TEXT: [TABLE-OF-CONTENTS]
7774 #+TEXT: This goes between the table of contents and the first headline
7775 @end example
7777 @node Lists, Paragraphs, Initial text, Markup rules
7778 @subheading Lists
7779 @cindex lists, markup rules
7781 Plain lists as described in @ref{Plain lists} are translated to the back-ends
7782 syntax for such lists.  Most back-ends support unordered, ordered, and
7783 description lists.
7785 @node Paragraphs, Literal examples, Lists, Markup rules
7786 @subheading Paragraphs, line breaks, and quoting
7787 @cindex paragraphs, markup rules
7789 Paragraphs are separated by at least one empty line.  If you need to enforce
7790 a line break within a paragraph, use @samp{\\} at the end of a line.
7792 To keep the line breaks in a region, but otherwise use normal formatting, you
7793 can use this construct, which can also be used to format poetry.
7795 @example
7796 #+BEGIN_VERSE
7797  Great clouds overhead
7798  Tiny black birds rise and fall
7799  Snow covers Emacs
7801      -- AlexSchroeder
7802 #+END_VERSE
7803 @end example
7805 When quoting a passage from another document, it is customary to format this
7806 as a paragraph that is indented on both the left and the right margin.  You
7807 can include quotations in Org mode documents like this:
7809 @example
7810 #+BEGIN_QUOTE
7811 Everything should be made as simple as possible,
7812 but not any simpler -- Albert Einstein
7813 #+END_QUOTE
7814 @end example
7817 @node Literal examples, Include files, Paragraphs, Markup rules
7818 @subheading Literal examples
7819 @cindex literal examples, markup rules
7820 @cindex code line refenences, markup rules
7822 You can include literal examples that should not be subjected to
7823 markup.  Such examples will be typeset in monospace, so this is well suited
7824 for source code and similar examples.
7825 @cindex #+BEGIN_EXAMPLE
7827 @example
7828 #+BEGIN_EXAMPLE
7829 Some example from a text file.
7830 #+END_EXAMPLE
7831 @end example
7833 For simplicity when using small examples, you can also start the example
7834 lines with a colon followed by a space.  There may also be additional
7835 whitespace before the colon:
7837 @example
7838 Here is an example
7839    : Some example from a text file.
7840 @end example
7842 @cindex formatting source code, markup rules
7843 If the example is source code from a programming language, or any other text
7844 that can be marked up by font-lock in Emacs, you can ask for the example to
7845 look like the fontified Emacs buffer@footnote{Currently this works only for
7846 the HTML back-end, and requires the @file{htmlize.el} package version 1.34 or
7847 later.}.  This is done with the @samp{src} block, where you also need to
7848 specify the name of the major mode that should be used to fontify the
7849 example:
7850 @cindex #+BEGIN_SRC
7852 @example
7853 #+BEGIN_SRC emacs-lisp
7854 (defun org-xor (a b)
7855    "Exclusive or."
7856    (if a (not b) b))
7857 #+END_SRC
7858 @end example
7860 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
7861 switch to the end of the @code{BEGIN} line, to get the lines of the example
7862 numbered.  If you use a @code{+n} switch, the numbering from the previous
7863 numbered snippet will be continued in the current one.  In literal examples,
7864 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
7865 targets for special hyperlinks like @code{[[(name)]]} (i.e. the reference
7866 name enclosed in single parenthesis).  In HTML, hovering the mouse over such
7867 a link will remote-highlight the corresponding code line, which is kind of
7868 cool.  If the example/src snippet is numbered, you can also add a @code{-r}
7869 switch.  Then labels will be @i{removed} from the source code and the links
7870 will be @i{replaced}@footnote{If you want to explain the use of such labels
7871 themelves in org-mode example code, you can use the @code{-k} switch to make
7872 sure they are not touched.} with line numbers from the code listing.  Here is
7873 an example:
7875 @example
7876 #+BEGIN_SRC emacs-lisp -n -r
7877 (save-excursion                  (ref:sc)
7878    (goto-char (point-min))       (ref:jump)
7879 #+END SRC
7880 In line [[(sc)]] we remember the current positon.  [[(jump)][Line (jump)]]
7881 jumps to point-min.
7882 @end example
7884 @vindex org-coderef-label-format
7885 If the syntax for the label format conflicts with the language syntax, use a
7886 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
7887 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
7889 HTML export also allows examples to be published as text areas, @pxref{Text
7890 areas in HTML export}.
7892 @table @kbd
7893 @kindex C-c '
7894 @item C-c '
7895 Edit the source code example at point in its native mode.  This works by
7896 switching to an indirect buffer, narrowing the buffer and switching to the
7897 other mode.  You need to exit by pressing @kbd{C-c '} again@footnote{Upon
7898 exit, lines starting with @samp{*} or @samp{#} will get a comma prepended, to
7899 keep them from being interpreted by Org as outline nodes or special
7900 comments.  These commas will be striped for editing with @kbd{C-c '}, and
7901 also for export.}.  Fixed-width
7902 regions (where each line starts with a colon followed by a space) will be
7903 edited using @code{artist-mode}@footnote{You may select a different-mode with
7904 the variable @code{org-edit-fixed-width-region-mode}.} to allow creating
7905 ASCII drawings easily.  Using this command in an empty line will create a new
7906 fixed-width region.
7907 @kindex C-c l
7908 @item C-c l
7909 Calling @code{org-store-link} while editing a source code example in a
7910 temporary buffer created with @kbd{C-c '} will prompt for a label, make sure
7911 that it is unique in the current buffer, and insert it with the proper
7912 formatting like @samp{(ref:label)} at the end of the current line.  Then the
7913 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
7914 @end table
7917 @node Include files, Tables exported, Literal examples, Markup rules
7918 @subheading Include files
7919 @cindex include files, markup rules
7921 During export, you can include the content of another file.  For example, to
7922 include your .emacs file, you could use:
7923 @cindex #+INCLUDE
7925 @example
7926 #+INCLUDE: "~/.emacs" src emacs-lisp
7927 @end example
7929 The optional second and third parameter are the markup (@samp{quote},
7930 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
7931 language for formatting the contents.  The markup is optional, if it is not
7932 given, the text will be assumed to be in Org mode format and will be
7933 processed normally.  The include line will also allow additional keyword
7934 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
7935 first line and for each following line, as well as any options accepted by
7936 the selected markup.  For example, to include a file as an item, use
7938 @example
7939 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
7940 @end example
7942 @table @kbd
7943 @kindex C-c '
7944 @item C-c '
7945 Visit the include file at point.
7946 @end table
7948 @node Tables exported, Inlined images, Include files, Markup rules
7949 @subheading Tables
7950 @cindex tables, markup rules
7952 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
7953 the @file{table.el} package will be exported properly.  For Org mode tables,
7954 the lines before the first horizontal separator line will become table header
7955 lines.  You can use the following lines somewhere before the table to assign
7956 a caption and a label for cross references:
7958 @example
7959 #+CAPTION: This is the caption for the next table (or link)
7960 #+LABEL:   tbl:basic-data
7961 @end example
7963 @node Inlined images, Footnote markup, Tables exported, Markup rules
7964 @subheading Inlined Images
7965 @cindex inlined images, markup rules
7967 Some backends (HTML and LaTeX) allow to directly include images into the
7968 exported document.  Org does this, if a link to an image files does not have
7969 a description part, for example @code{[[./img/a.jpg]]}.  If you wish to
7970 define a caption for the image and maybe a label for internal cross
7971 references, you can use (before, but close to the link)
7973 @example
7974 #+CAPTION: This is the caption for the next figure link (or table)
7975 #+LABEL:   fig:SED-HR4049
7976 @end example
7978 You may also define additional attributes for the figure.  As this is
7979 backend-specific, see the sections about the individual backends for more
7980 information.
7982 @node Footnote markup, Emphasis and monospace, Inlined images, Markup rules
7983 @subheading Footnote markup
7984 @cindex footnotes, markup rules
7985 @cindex @file{footnote.el}
7987 Footnotes defined in the way descriped in @ref{Footnotes} will be exported by
7988 all backends.  Org does allow multiple references to the same note, and
7989 different backends support this to varying degree.
7991 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnote markup, Markup rules
7992 @subheading Emphasis and monospace
7994 @cindex underlined text, markup rules
7995 @cindex bold text, markup rules
7996 @cindex italic text, markup rules
7997 @cindex verbatim text, markup rules
7998 @cindex code text, markup rules
7999 @cindex strike-through text, markup rules
8000 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
8001 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
8002 in the code and verbatim string is not processed for Org mode specific
8003 syntax, it is exported verbatim.
8005 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
8006 @subheading @TeX{} macros and La@TeX{} fragments
8007 @cindex LaTeX fragments, markup rules
8008 @cindex TeX macros, markup rules
8009 @cindex HTML entities
8010 @cindex LaTeX entities
8012 @vindex org-html-entities
8013 A @TeX{}-like syntax is used to specify special characters.  Where possible,
8014 these will be transformed into the native format of the exporter back-end.
8015 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
8016 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
8017 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
8018 This applies for a large number of entities, with names taken from both HTML
8019 and La@TeX{}, see the variable @code{org-html-entities} for the complete
8020 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
8021 after having typed the backslash and maybe a few characters
8022 (@pxref{Completion}).
8024 La@TeX{} fragments are converted into images for HTML export, and they are
8025 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
8027 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
8028 @samp{...} are all converted into special commands creating hyphens of
8029 different lengths or a compact set of dots.
8031 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
8032 @subheading  Horizontal rules
8033 @cindex horizontal rules, markup rules
8034 A line consisting of only dashes, and at least 5 of them, will be
8035 exported as a horizontal line (@samp{<hr/>} in HTML).
8037 @node Comment lines, Macro replacement, Horizontal rules, Markup rules
8038 @subheading Comment lines
8039 @cindex comment lines
8040 @cindex exporting, not
8042 Lines starting with @samp{#} in column zero are treated as comments and will
8043 never be exported.  Also entire subtrees starting with the word
8044 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
8045 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
8047 @table @kbd
8048 @kindex C-c ;
8049 @item C-c ;
8050 Toggle the COMMENT keyword at the beginning of an entry.
8051 @end table
8053 @node Macro replacement,  , Comment lines, Markup rules
8054 @subheading Macro replacement
8056 You can define text snippets with
8058 @example
8059 #+MACRO: name   replacement text
8060 @end example
8062 @noindent which can be referenced anywhere in the document (even in
8063 code examples) with @code{@{@{@{name@}@}@}}.  In addition to defined macros,
8064 @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc will reference
8065 information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and similar lines.
8067 @node Selective export, Export options, Markup rules, Exporting
8068 @section Selective export
8069 @cindex export, selective by tags
8071 @vindex org-export-select-tags
8072 @vindex org-export-exclude-tags
8073 You may use tags to select the parts of a document that should be exported,
8074 or to exclude parts from export.  This behavior is governed by two variables:
8075 @code{org-export-select-tags} and @code{org-export-exclude-tags}.
8077 Org first checks if any of the @emph{select} tags is present in the buffer.
8078 If yes, all trees that do not carry one of these tags will be excluded.  If a
8079 selected tree is a subtree, the heading hierarchy above it will also be
8080 selected for export, but not the text below those headings.
8082 @noindent
8083 If none of the select tags is found, the whole buffer will be selected for
8084 export.
8086 @noindent
8087 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
8088 be removed from the export buffer.
8090 @node Export options, The export dispatcher, Selective export, Exporting
8091 @section Export options
8092 @cindex options, for export
8094 @cindex completion, of option keywords
8095 The exporter recognizes special lines in the buffer which provide
8096 additional information.  These lines may be put anywhere in the file.
8097 The whole set of lines can be inserted into the buffer with @kbd{C-c
8098 C-e t}.  For individual lines, a good way to make sure the keyword is
8099 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
8100 (@pxref{Completion}).
8102 @table @kbd
8103 @kindex C-c C-e t
8104 @item C-c C-e t
8105 Insert template with export options, see example below.
8106 @end table
8108 @cindex #+TITLE:
8109 @cindex #+AUTHOR:
8110 @cindex #+DATE:
8111 @cindex #+EMAIL:
8112 @cindex #+DESCRIPTION:
8113 @cindex #+KEYWORDS:
8114 @cindex #+LANGUAGE:
8115 @cindex #+TEXT:
8116 @cindex #+OPTIONS:
8117 @cindex #+LINK_UP:
8118 @cindex #+LINK_HOME:
8119 @cindex #+EXPORT_SELECT_TAGS:
8120 @cindex #+EXPORT_EXCLUDE_TAGS:
8121 @cindex #+LATEX_HEADER:
8122 @vindex user-full-name
8123 @vindex user-mail-address
8124 @vindex org-export-default-language
8125 @example
8126 #+TITLE:       the title to be shown (default is the buffer name)
8127 #+AUTHOR:      the author (default taken from @code{user-full-name})
8128 #+DATE:        a date, fixed, of a format string for @code{format-time-string}
8129 #+EMAIL:       his/her email address (default from @code{user-mail-address})
8130 #+DESCRIPTION: the page description, e.g. for the XHTML meta tag
8131 #+KEYWORDS:    the page keywords, e.g. for the XHTML meta tag
8132 #+LANGUAGE:    language for HTML, e.g. @samp{en} (@code{org-export-default-language})
8133 #+TEXT:        Some descriptive text to be inserted at the beginning.
8134 #+TEXT:        Several lines may be given.
8135 #+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
8136 #+LINK_UP:     the ``up'' link of an exported page
8137 #+LINK_HOME:   the ``home'' link of an exported page
8138 #+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
8139 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
8140 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
8141 @end example
8143 @noindent
8144 The OPTIONS line is a compact@footnote{If you want to configure many options
8145 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
8146 you can:
8147 @cindex headline levels
8148 @cindex section-numbers
8149 @cindex table of contents
8150 @cindex line-break preservation
8151 @cindex quoted HTML tags
8152 @cindex fixed-width sections
8153 @cindex tables
8154 @cindex @TeX{}-like syntax for sub- and superscripts
8155 @cindex footnotes
8156 @cindex special strings
8157 @cindex emphasized text
8158 @cindex @TeX{} macros
8159 @cindex La@TeX{} fragments
8160 @cindex author info, in export
8161 @cindex time info, in export
8162 @example
8163 H:         @r{set the number of headline levels for export}
8164 num:       @r{turn on/off section-numbers}
8165 toc:       @r{turn on/off table of contents, or set level limit (integer)}
8166 \n:        @r{turn on/off line-break-preservation}
8167 @@:         @r{turn on/off quoted HTML tags}
8168 ::         @r{turn on/off fixed-width sections}
8169 |:         @r{turn on/off tables}
8170 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
8171            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
8172            @r{the simple @code{a_b} will be left as it is.}
8173 -:         @r{turn on/off conversion of special strings.}
8174 f:         @r{turn on/off footnotes like this[1].}
8175 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
8176 pri:       @r{turn on/off priority cookies}
8177 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
8178 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
8179 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
8180 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
8181 LaTeX:     @r{turn on/off La@TeX{} fragments}
8182 skip:      @r{turn on/off skipping the text before the first heading}
8183 author:    @r{turn on/off inclusion of author name/email into exported file}
8184 creator:   @r{turn on/off inclusion of creator info into exported file}
8185 timestamp: @r{turn on/off inclusion creation time into exported file}
8186 d:         @r{turn on/off inclusion of drawers}
8187 @end example
8189 These options take effect in both the HTML and La@TeX{} export, except
8190 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
8191 @code{nil} for the La@TeX{} export.
8193 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
8194 calling an export command, the subtree can overrule some of the file's export
8195 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
8196 @code{EXPORT_TEXT}, and @code{EXPORT_OPTIONS}.
8198 @node The export dispatcher, ASCII export, Export options, Exporting
8199 @section The export dispatcher
8200 @cindex dispatcher, for export commands
8202 All export commands can be reached using the export dispatcher, which is a
8203 prefix key that prompts for an additional key specifying the command.
8204 Normally the entire file is exported, but if there is an active region that
8205 contains one outline tree, the first heading is used as document title and
8206 the subtrees are exported.
8208 @table @kbd
8209 @kindex C-c C-e
8210 @item C-c C-e
8211 @vindex org-export-run-in-background
8212 Dispatcher for export and publishing commands.  Displays a help-window
8213 listing the additional key(s) needed to launch an export or publishing
8214 command.  The prefix arg is passed through to the exporter.  A double prefix
8215 @kbd{C-u C-u} causes most commands to be executed in the background, in a
8216 separate emacs process@footnote{To make this behavior the default, customize
8217 the variable @code{org-export-run-in-background}.}.
8218 @kindex C-c C-e v
8219 @item C-c C-e v
8220 Like @kbd{C-c C-e}, but only export the text that is currently visible
8221 (i.e. not hidden by outline visibility).
8222 @kindex C-u C-u C-c C-e
8223 @item C-u C-u C-c C-e
8224 @vindex org-export-run-in-background
8225 Call an the exporter, but reverse the setting of
8226 @code{org-export-run-in-background}, i.e. request background processing if
8227 not set, or force processing in the current Emacs process if st.
8228 @end table
8230 @node ASCII export, HTML export, The export dispatcher, Exporting
8231 @section ASCII export
8232 @cindex ASCII export
8234 ASCII export produces a simple and very readable version of an Org mode
8235 file.
8237 @cindex region, active
8238 @cindex active region
8239 @cindex transient-mark-mode
8240 @table @kbd
8241 @kindex C-c C-e a
8242 @item C-c C-e a
8243 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
8244 will be @file{myfile.txt}.  The file will be overwritten without
8245 warning.  If there is an active region@footnote{this requires
8246 @code{transient-mark-mode} to be turned on}, only the region will be
8247 exported. If the selected region is a single tree@footnote{To select the
8248 current subtree, use @kbd{C-c @@}.}, the tree head will
8249 become the document title.  If the tree head entry has or inherits an
8250 @code{EXPORT_FILE_NAME} property, that name will be used for the
8251 export.
8252 @kindex C-c C-e v a
8253 @item C-c C-e v a
8254 Export only the visible part of the document.
8255 @end table
8257 @cindex headline levels, for exporting
8258 In the exported version, the first 3 outline levels will become
8259 headlines, defining a general document structure.  Additional levels
8260 will be exported as itemized lists.  If you want that transition to occur
8261 at a different level, specify it with a prefix argument.  For example,
8263 @example
8264 @kbd{C-1 C-c C-e a}
8265 @end example
8267 @noindent
8268 creates only top level headlines and does the rest as items.  When
8269 headlines are converted to items, the indentation of the text following
8270 the headline is changed to fit nicely under the item.  This is done with
8271 the assumption that the first body line indicates the base indentation of
8272 the body text.  Any indentation larger than this is adjusted to preserve
8273 the layout relative to the first line.  Should there be lines with less
8274 indentation than the first, these are left alone.
8276 @vindex org-export-ascii-links-to-notes
8277 Links will be exported in a footnote-like style, with the descriptive part in
8278 the text and the link in a note before the next heading.  See the variable
8279 @code{org-export-ascii-links-to-notes} for details and other options.
8281 @node HTML export, LaTeX and PDF export, ASCII export, Exporting
8282 @section HTML export
8283 @cindex HTML export
8285 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
8286 HTML formatting, in ways similar to John Gruber's @emph{markdown}
8287 language, but with additional support for tables.
8289 @menu
8290 * HTML Export commands::        How to invoke HTML export
8291 * Quoting HTML tags::           Using direct HTML in Org mode
8292 * Links::                       Transformation of links for HTML
8293 * Images in HTML export::       How to insert figures into HTML output
8294 * Text areas in HTML export::   An alternative way to show an example
8295 * CSS support::                 Changing the appearance of the output
8296 * Javascript support::          Info and Folding in a web browser
8297 @end menu
8299 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
8300 @subsection HTML export commands
8302 @cindex region, active
8303 @cindex active region
8304 @cindex transient-mark-mode
8305 @table @kbd
8306 @kindex C-c C-e h
8307 @item C-c C-e h
8308 Export as HTML file @file{myfile.html}.  For an org file @file{myfile.org},
8309 the ASCII file will be @file{myfile.html}.  The file will be overwritten
8310 without warning.  If there is an active region@footnote{this requires
8311 @code{transient-mark-mode} to be turned on}, only the region will be
8312 exported. If the selected region is a single tree@footnote{To select the
8313 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
8314 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
8315 property, that name will be used for the export.
8316 @kindex C-c C-e b
8317 @item C-c C-e b
8318 Export as HTML file and immediately open it with a browser.
8319 @kindex C-c C-e H
8320 @item C-c C-e H
8321 Export to a temporary buffer, do not create a file.
8322 @kindex C-c C-e R
8323 @item C-c C-e R
8324 Export the active region to a temporary buffer.  With a prefix argument, do
8325 not produce the file header and footer, but just the plain HTML section for
8326 the region.  This is good for cut-and-paste operations.
8327 @kindex C-c C-e v h
8328 @kindex C-c C-e v b
8329 @kindex C-c C-e v H
8330 @kindex C-c C-e v R
8331 @item C-c C-e v h
8332 @item C-c C-e v b
8333 @item C-c C-e v H
8334 @item C-c C-e v R
8335 Export only the visible part of the document.
8336 @item M-x org-export-region-as-html
8337 Convert the region to HTML under the assumption that it was Org mode
8338 syntax before.  This is a global command that can be invoked in any
8339 buffer.
8340 @item M-x org-replace-region-by-HTML
8341 Replace the active region (assumed to be in Org mode syntax) by HTML
8342 code.
8343 @end table
8345 @cindex headline levels, for exporting
8346 In the exported version, the first 3 outline levels will become headlines,
8347 defining a general document structure.  Additional levels will be exported as
8348 itemized lists.  If you want that transition to occur at a different level,
8349 specify it with a numeric prefix argument.  For example,
8351 @example
8352 @kbd{C-2 C-c C-e b}
8353 @end example
8355 @noindent
8356 creates two levels of headings and does the rest as items.
8358 @node Quoting HTML tags, Links, HTML Export commands, HTML export
8359 @subsection Quoting HTML tags
8361 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
8362 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
8363 which should be interpreted as such, mark them with @samp{@@} as in
8364 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
8365 simple tags.  For more extensive HTML that should be copied verbatim to
8366 the exported file use either
8368 @example
8369 #+HTML: Literal HTML code for export
8370 @end example
8372 @noindent or
8373 @cindex #+BEGIN_HTML
8375 @example
8376 #+BEGIN_HTML
8377 All lines between these markers are exported literally
8378 #+END_HTML
8379 @end example
8382 @node Links, Images in HTML export, Quoting HTML tags, HTML export
8383 @subsection Links
8385 @cindex links, in HTML export
8386 @cindex internal links, in HTML export
8387 @cindex external links, in HTML export
8388 Internal links (@pxref{Internal links}) will continue to work in HTML.  This
8389 does include automatic links created by radio targets (@pxref{Radio
8390 targets}).  Links to external files will still work if the target file is on
8391 the same @i{relative} path as the published Org file.  Links to other
8392 @file{.org} files will be translated into HTML links under the assumption
8393 that an HTML version also exists of the linked file, at the same relative
8394 path.  @samp{id:} links can then be used to jump to specific entries across
8395 files.  For information related to linking files while publishing them to a
8396 publishing directory see @ref{Publishing links}.
8398 If you want to specify attributes for links, you can do so using a special
8399 @code{#+ATTR_HTML} line to define attributes that will be added to the
8400 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
8401 and @code{style} attributes for a link:
8403 @example
8404 #+ATTR_HTML: title="The Org-mode homepage" style="color:red;"
8405 [[http://orgmode.org]]
8406 @end example
8408 @node Images in HTML export, Text areas in HTML export, Links, HTML export
8409 @subsection Images
8411 @cindex images, inline in HTML
8412 @cindex inlining images in HTML
8413 @vindex org-export-html-inline-images
8414 HTML export can inline images given as links in the Org file, and
8415 it can make an image the clickable part of a link.  By
8416 default@footnote{but see the variable
8417 @code{org-export-html-inline-images}}, images are inlined if a link does
8418 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
8419 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
8420 @samp{the image} that points to the image.  If the description part
8421 itself is a @code{file:} link or a @code{http:} URL pointing to an
8422 image, this image will be inlined and activated so that clicking on the
8423 image will activate the link.  For example, to include a thumbnail that
8424 will link to a high resolution version of the image, you could use:
8426 @example
8427 [[file:highres.jpg][file:thumb.jpg]]
8428 @end example
8430 If you need to add attributes to an inlines image, use a @code{#+ATTR_HTML},
8431 for example:
8433 @example
8434 #+CAPTION: A black cat stalking a spider
8435 #+ATTR_HTML: alt="cat/spider image" title="one second before action"
8436 [[./img/a.jpg]]
8437 @end example
8439 @noindent
8440 and you could use @code{http} addresses just as well.
8442 @node Text areas in HTML export, CSS support, Images in HTML export, HTML export
8443 @subsection Text areas
8445 @cindex text areas, in HTML
8446 An alternative way to publish literal code examples in HTML is to use text
8447 areas, where the example can even be edited before pasting it into an
8448 application.  It is triggered by a @code{-t} switch at an @code{example} or
8449 @code{src} block.  Using this switch disables any options for syntax and
8450 label highlighting, and line numbering, which may be present.  You may also
8451 use @code{-h} and @code{-w} switches to specify the height and width of the
8452 text area, which default to the number of lines in the example, and 80,
8453 respectively.  For example
8455 @example
8456 #+BEGIN_EXAMPLE -t -w 40
8457 (defun org-xor (a b)
8458    "Exclusive or."
8459    (if a (not b) b))
8460 #+END_EXAMPLE
8461 @end example
8464 @node CSS support, Javascript support, Text areas in HTML export, HTML export
8465 @subsection CSS support
8466 @cindex CSS, for HTML export
8467 @cindex HTML export, CSS
8469 @vindex org-export-html-todo-kwd-class-prefix
8470 @vindex org-export-html-tag-class-prefix
8471 You can also give style information for the exported file.  The HTML exporter
8472 assigns the following special CSS classes@footnote{If the classes on TODO
8473 keywords and tags lead to conflicts, use the variables
8474 @code{org-export-html-todo-kwd-class-prefix} and
8475 @code{org-export-html-tag-class-prefix} to make them unique.} to appropriate
8476 parts of the document - your style specifications may change these, in
8477 addition to any of the standard classes like for headlines, tables etc.
8478 @example
8479 p.author           @r{author information, including email}
8480 p.date             @r{publishing date}
8481 p.creator          @r{creator info, about Org-mode version}
8482 .title             @r{document title}
8483 .todo              @r{TODO keywords, all not-done states}
8484 .done              @r{the DONE keywords, all stated the count as done}
8485 .WAITING           @r{each TODO keyword also uses a class named after itself}
8486 .timestamp         @r{time stamp}
8487 .timestamp-kwd     @r{keyword associated with a time stamp, like SCHEDULED}
8488 .tag               @r{tag in a headline}
8489 ._HOME             @r{each tag uses itself as a class, "@@" replaced by "_"}
8490 .target            @r{target for links}
8491 .linenr            @r{the line number in a code example}
8492 .code-highlighted  @r{for highlighting referenced code lines}
8493 div.outline-N      @r{div for outline level N (headline plus text))}
8494 div.outline-text-N @r{extra div for text at outline level N}
8495 .section-number-N  @r{section number in headlines, different for each level}
8496 div.figure         @r{how to format an inlined image}
8497 pre.src            @r{formatted source code}
8498 pre.example        @r{normal example}
8499 p.verse            @r{verse paragraph}
8500 div.footnotes      @r{footnote section headline}
8501 p.footnote         @r{footnote definition paragraph, containing a footnote}
8502 .footref           @r{a footnote reference number (always a <sup>)}
8503 .footnum           @r{footnote number in footnote definition (always <sup>)}
8504 @end example
8506 @vindex org-export-html-style-default
8507 @vindex org-export-html-style-include-default
8508 @vindex org-export-html-style
8509 @vindex org-export-html-extra
8510 @vindex org-export-html-style-default
8511 Each exported files contains a compact default style that defines these
8512 classes in a basic way@footnote{This style is defined in the constant
8513 @code{org-export-html-style-default}, which you should not modify.  To turn
8514 inclusion of these defaults off, customize
8515 @code{org-export-html-style-include-default}}.  You may overwrite these
8516 settings, or add to them by using the variables @code{org-export-html-style}
8517 (for Org-wide settings) and @code{org-export-html-style-extra} (for more
8518 granular settings, like file-local settings).  To set the latter variable
8519 individually for each file, you can use
8521 @example
8522 #+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
8523 @end example
8525 @noindent
8526 For longer style definitions, you can use several such lines.  You could also
8527 directly write a @code{<style>} @code{</style>} section in this way, without
8528 referring to an external file.
8530 @c FIXME: More about header and footer styles
8531 @c FIXME: Talk about links and targets.
8533 @node Javascript support,  , CSS support, HTML export
8534 @subsection Javascript supported display of web pages
8536 @emph{Sebastian Rose} has written a JavaScript program especially designed to
8537 enhance the web viewing experience of HTML files created with Org.  This
8538 program allows you to view large files in two different ways.  The first one
8539 is an @emph{Info}-like mode where each section is displayed separately and
8540 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
8541 as well, press @kbd{?} for an overview of the available keys).  The second
8542 view type is a @emph{folding} view much like Org provides inside Emacs.  The
8543 script is available at @url{http://orgmode.org/org-info.js} and you can find
8544 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
8545 We are serving the script from our site, but if you use it a lot, you might
8546 not want to be dependent on @url{orgmode.org} and prefer to install a local
8547 copy on your own web server.
8549 To use the script, you need to make sure that the @file{org-jsinfo.el} module
8550 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
8551 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
8552 this is indeed the case.  All it then takes to make use of the program is
8553 adding a single line to the Org file:
8555 @example
8556 #+INFOJS_OPT: view:info toc:nil
8557 @end example
8559 @noindent
8560 If this line is found, the HTML header will automatically contain the code
8561 needed to invoke the script.  Using the line above, you can set the following
8562 viewing options:
8564 @example
8565 path:    @r{The path to the script.  The default is to grab the script from}
8566          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
8567          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
8568 view:    @r{Initial view when website is first shown.  Possible values are:}
8569          info      @r{Info-like interface with one section per page.}
8570          overview  @r{Folding interface, initially showing only top-level.}
8571          content   @r{Folding interface, starting with all headlines visible.}
8572          showall   @r{Folding interface, all headlines and text visible.}
8573 sdepth:  @r{Maximum headline level that will still become an independent}
8574          @r{section for info and folding modes.  The default is taken from}
8575          @r{@code{org-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
8576          @r{If this is smaller than in @code{org-headline-levels}, each}
8577          @r{info/folding section can still contain children headlines.}
8578 toc:     @r{Should the table of content @emph{initially} be visible?}
8579          @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
8580 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
8581          @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
8582 ftoc:    @r{Does the css of the page specify a fixed position for the toc?}
8583          @r{If yes, the toc will never be displayed as a section.}
8584 ltoc:    @r{Should there be short contents (children) in each section?}
8585          @r{Make this @code{above} it the section should be above initial text.}
8586 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
8587          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
8588 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
8589          @r{default), only one such button will be present.}
8590 @end example
8592 @vindex org-infojs-options
8593 @vindex org-export-html-use-infojs
8594 You can choose default values for these options by customizing the variable
8595 @code{org-infojs-options}.  If you always want to apply the script to your
8596 pages, configure the variable @code{org-export-html-use-infojs}.
8598 @node LaTeX and PDF export, XOXO export, HTML export, Exporting
8599 @section LaTeX and PDF export
8600 @cindex LaTeX export
8601 @cindex PDF export
8603 Org mode contains a La@TeX{} exporter written by Bastien Guerry.  With
8604 further processing, this backend is also used to produce PDF output.  Since
8605 the LaTeX output uses @file{hyperref} to implement links and cross
8606 references, the PDF output file will be fully linked.
8608 @menu
8609 * LaTeX/PDF export commands::   Which key invokes which commands
8610 * Quoting LaTeX code::          Incorporating literal LaTeX code
8611 * Sectioning structure::        Changing sectioning in LaTeX output
8612 * Tables in LaTeX export::      Options for exporting tables to LaTeX
8613 * Images in LaTeX export::      How to insert figures into LaTeX output
8614 @end menu
8616 @node LaTeX/PDF export commands, Quoting LaTeX code, LaTeX and PDF export, LaTeX and PDF export
8617 @subsection LaTeX export commands
8619 @cindex region, active
8620 @cindex active region
8621 @cindex transient-mark-mode
8622 @table @kbd
8623 @kindex C-c C-e l
8624 @item C-c C-e l
8625 Export as La@TeX{} file @file{myfile.tex}.  For an org file
8626 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
8627 be overwritten without warning.  If there is an active region@footnote{this
8628 requires @code{transient-mark-mode} to be turned on}, only the region will be
8629 exported. If the selected region is a single tree@footnote{To select the
8630 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
8631 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
8632 property, that name will be used for the export.
8633 @kindex C-c C-e L
8634 @item C-c C-e L
8635 Export to a temporary buffer, do not create a file.
8636 @kindex C-c C-e v l
8637 @kindex C-c C-e v L
8638 @item C-c C-e v l
8639 @item C-c C-e v L
8640 Export only the visible part of the document.
8641 @item M-x org-export-region-as-latex
8642 Convert the region to La@TeX{} under the assumption that it was Org mode
8643 syntax before.  This is a global command that can be invoked in any
8644 buffer.
8645 @item M-x org-replace-region-by-latex
8646 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
8647 code.
8648 @kindex C-c C-e p
8649 @item C-c C-e p
8650 Export as LaTeX and then process to PDF.
8651 @kindex C-c C-e d
8652 @item C-c C-e d
8653 Export as LaTeX and then process to PDF, then open the resulting PDF file.
8654 @end table
8656 @cindex headline levels, for exporting
8657 @vindex org-latex-low-levels
8658 In the exported version, the first 3 outline levels will become
8659 headlines, defining a general document structure.  Additional levels
8660 will be exported as description lists.  The exporter can ignore them or
8661 convert them to a custom string depending on
8662 @code{org-latex-low-levels}.
8664 If you want that transition to occur at a different level, specify it
8665 with a numeric prefix argument. For example,
8667 @example
8668 @kbd{C-2 C-c C-e l}
8669 @end example
8671 @noindent
8672 creates two levels of headings and does the rest as items.
8674 @node Quoting LaTeX code, Sectioning structure, LaTeX/PDF export commands, LaTeX and PDF export
8675 @subsection Quoting LaTeX code
8677 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
8678 inserted into the La@TeX{} file.  This includes simple macros like
8679 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
8680 you can add special code that should only be present in La@TeX{} export with
8681 the following constructs:
8683 @example
8684 #+LaTeX: Literal LaTeX code for export
8685 @end example
8687 @noindent or
8688 @cindex #+BEGIN_LaTeX
8690 @example
8691 #+BEGIN_LaTeX
8692 All lines between these markers are exported literally
8693 #+END_LaTeX
8694 @end example
8696 @node  Sectioning structure, Tables in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
8697 @subsection Sectioning structure
8698 @cindex LaTeX class
8699 @cindex LaTeX sectioning structure
8701 By default, the La@TeX{} output uses the class @code{article}.
8703 @vindex org-export-latex-default-class
8704 @vindex org-export-latex-classes
8705 @cindex #+LATEX_HEADER:
8706 You can change this globally by setting a different value for
8707 @code{org-export-latex-default-class} or locally by adding an option like
8708 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
8709 property that applies when exporting a region containing only this (sub)tree.
8710 The class should be listed in @code{org-export-latex-classes}, where you can
8711 also define the sectioning structure for each class, as well as defining
8712 additional classes.  You can also use @code{#+LATEX_HEADER:
8713 \usepackage@{xyz@}} to add lines to the header.
8715 @node Tables in LaTeX export, Images in LaTeX export, Sectioning structure, LaTeX and PDF export
8716 @subsection Tables in LaTeX export
8717 @cindex tables, in LaTeX export
8719 For LaTeX export of a table, you can specify a label and a caption
8720 (@pxref{Markup rules}).  You can also use the @code{ATTR_LaTeX} line to
8721 request a longtable environment for the table, so that it may span several
8722 pages:
8724 @example
8725 #+CAPTION: A long table
8726 #+LABEL: tbl:long
8727 #+ATTR_LaTeX: longtable
8728 | ..... | ..... |
8729 | ..... | ..... |
8730 @end example
8733 @node Images in LaTeX export,  , Tables in LaTeX export, LaTeX and PDF export
8734 @subsection Images in LaTeX export
8735 @cindex images, inline in LaTeX
8736 @cindex inlining images in LaTeX
8738 Images that are linked to without a description part in the link, like
8739 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
8740 output files resulting from LaTeX output.  Org will use an
8741 @code{\includegraphics} macro to insert the image.  If you have specified a
8742 caption and/or a label as described in @ref{Markup rules}, the figure will
8743 be wrapped into a @code{figure} environment and thus become a floating
8744 element.  Finally, you can use an @code{#+ATTR_LaTeX:} line to specify the
8745 options that can be used in the optional argument of the
8746 @code{\includegraphics} macro.
8748 @example
8749 #+CAPTION:    The black-body emission of the disk around HR 4049
8750 #+LABEL:      fig:SED-HR4049
8751 #+ATTR_LaTeX: width=5cm,angle=90
8752 [[./img/sed-hr4049.pdf]]
8753 @end example
8755 @vindex org-export-latex-inline-image-extensions
8756 If you need references to a label created in this way, write
8757 @samp{\ref@{fig:SED-HR4049@}} just like in LaTeX.  The default settings will
8758 recognize files types that can be included as images during processing by
8759 pdflatex (@file{png}, @file{jpg}, and @file{pdf} files).  If you process your
8760 files in a different way, you may need to customize the variable
8761 @code{org-export-latex-inline-image-extensions}.
8763 @node XOXO export, iCalendar export, LaTeX and PDF export, Exporting
8764 @section XOXO export
8765 @cindex XOXO export
8767 Org mode contains an exporter that produces XOXO-style output.
8768 Currently, this exporter only handles the general outline structure and
8769 does not interpret any additional Org mode features.
8771 @table @kbd
8772 @kindex C-c C-e x
8773 @item C-c C-e x
8774 Export as XOXO file @file{myfile.html}.
8775 @kindex C-c C-e v
8776 @item C-c C-e v x
8777 Export only the visible part of the document.
8778 @end table
8780 @node iCalendar export,  , XOXO export, Exporting
8781 @section iCalendar export
8782 @cindex iCalendar export
8784 @vindex org-icalendar-include-todo
8785 @vindex org-icalendar-use-deadline
8786 @vindex org-icalendar-use-scheduled
8787 @vindex org-icalendar-categories
8788 Some people like to use Org mode for keeping track of projects, but still
8789 prefer a standard calendar application for anniversaries and appointments.
8790 In this case it can be useful to have deadlines and other time-stamped items
8791 in Org files show up in the calendar application.  Org mode can export
8792 calendar information in the standard iCalendar format.  If you also want to
8793 have TODO entries included in the export, configure the variable
8794 @code{org-icalendar-include-todo}.  iCalendar export will export plain time
8795 stamps as VEVENT, and TODO items as VTODO.  It will also create events from
8796 deadlines that are in non-TODO items.  Deadlines and scheduling dates in TODO
8797 items will be used to set the start and due dates for the todo
8798 entry@footnote{See the variables @code{org-icalendar-use-deadline} and
8799 @code{org-icalendar-use-scheduled}.}.  As categories, it will use the tags
8800 locally defined in the heading, and the file/tree category@footnote{To add
8801 inherited tags or the TODO state, configure the variable
8802 @code{org-icalendar-categories}.}.
8804 @vindex org-icalendar-store-UID
8805 The iCalendar standard requires each entry to have a globally unique
8806 identifier (UID).  Org creates these identifiers during export.  If you set
8807 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
8808 @code{:ID:} property of the entry and re-used next time you report this
8809 entry.  Since a single entry can give rise to multiple iCalendar entries (as
8810 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
8811 prefixes to the UID, depending on what triggered the inclusion of the entry.
8812 In this way the UID remains unique, but a synchronization program can still
8813 figure out from which entry all the different instances originate.
8815 @table @kbd
8816 @kindex C-c C-e i
8817 @item C-c C-e i
8818 Create iCalendar entries for the current file and store them in the same
8819 directory, using a file extension @file{.ics}.
8820 @kindex C-c C-e I
8821 @item C-c C-e I
8822 @vindex org-agenda-files
8823 Like @kbd{C-c C-e i}, but do this for all files in
8824 @code{org-agenda-files}.  For each of these files, a separate iCalendar
8825 file will be written.
8826 @kindex C-c C-e c
8827 @item C-c C-e c
8828 @vindex org-combined-agenda-icalendar-file
8829 Create a single large iCalendar file from all files in
8830 @code{org-agenda-files} and write it to the file given by
8831 @code{org-combined-agenda-icalendar-file}.
8832 @end table
8834 @vindex org-use-property-inheritance
8835 @vindex org-icalendar-include-body
8836 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
8837 property can be inherited from higher in the hierarchy if you configure
8838 @code{org-use-property-inheritance} accordingly.} properties if the selected
8839 entries have them.  If not, the summary will be derived from the headline,
8840 and the description from the body (limited to
8841 @code{org-icalendar-include-body} characters).
8843 How this calendar is best read and updated, that depends on the application
8844 you are using.  The FAQ covers this issue.
8846 @node Publishing, Miscellaneous, Exporting, Top
8847 @chapter Publishing
8848 @cindex publishing
8850 Org includes@footnote{@file{org-publish.el} is not distributed with
8851 Emacs 21, if you are still using Emacs 21, you need you need to download
8852 this file separately.} a publishing management system that allows you to
8853 configure automatic HTML conversion of @emph{projects} composed of
8854 interlinked org files.  This system is called @emph{org-publish}.  You can
8855 also configure org-publish to automatically upload your exported HTML
8856 pages and related attachments, such as images and source code files, to
8857 a web server. Org-publish turns Org into a web-site authoring tool.
8859 You can also use Org-publish to convert files into La@TeX{}, or even
8860 combine HTML and La@TeX{} conversion so that files are available in both
8861 formats on the server@footnote{Since La@TeX{} files on a server are not
8862 that helpful, you surely want to perform further conversion on them --
8863 e.g. convert them to @code{PDF} format.}.
8865 Org-publish has been contributed to Org by David O'Toole.
8867 @menu
8868 * Configuration::               Defining projects
8869 * Sample configuration::        Example projects
8870 * Triggering publication::      Publication commands
8871 @end menu
8873 @node Configuration, Sample configuration, Publishing, Publishing
8874 @section Configuration
8876 Publishing needs significant configuration to specify files, destination
8877 and many other properties of a project.
8879 @menu
8880 * Project alist::               The central configuration variable
8881 * Sources and destinations::    From here to there
8882 * Selecting files::             What files are part of the project?
8883 * Publishing action::           Setting the function doing the publishing
8884 * Publishing options::          Tweaking HTML export
8885 * Publishing links::            Which links keep working after publishing?
8886 * Project page index::          Publishing a list of project files
8887 @end menu
8889 @node Project alist, Sources and destinations, Configuration, Configuration
8890 @subsection The variable @code{org-publish-project-alist}
8891 @cindex org-publish-project-alist
8892 @cindex projects, for publishing
8894 @vindex org-publish-project-alist
8895 Org-publish is configured almost entirely through setting the value of
8896 one variable, called @code{org-publish-project-alist}.
8897 Each element of the list configures one project, and may be in one of
8898 the two following forms:
8900 @lisp
8901 ("project-name" :property value :property value ...)
8903 @r{or}
8905 ("project-name" :components ("project-name" "project-name" ...))
8907 @end lisp
8909 In both cases, projects are configured by specifying property values.
8910 A project defines the set of files that will be published, as well as
8911 the publishing configuration to use when publishing those files.  When
8912 a project takes the second form listed above, the individual members
8913 of the ``components'' property are taken to be components of the
8914 project, which group together files requiring different publishing
8915 options. When you publish such a ``meta-project'' all the components
8916 will also publish.  The @code{:components} are published in the sequence
8917 provided.
8919 @node Sources and destinations, Selecting files, Project alist, Configuration
8920 @subsection Sources and destinations for files
8921 @cindex directories, for publishing
8923 Most properties are optional, but some should always be set. In
8924 particular, org-publish needs to know where to look for source files,
8925 and where to put published files.
8927 @multitable @columnfractions 0.3 0.7
8928 @item @code{:base-directory}
8929 @tab Directory containing publishing source files
8930 @item @code{:publishing-directory}
8931 @tab Directory (possibly remote) where output files will be published.
8932 @item @code{:preparation-function}
8933 @tab Function called before starting the publishing process, for example to
8934 run @code{make} for updating files to be published.
8935 @item @code{:completion-function}
8936 @tab Function called after finishing the publishing process, for example to
8937 change permissions of the resulting files.
8938 @end multitable
8939 @noindent
8941 @node Selecting files, Publishing action, Sources and destinations, Configuration
8942 @subsection Selecting files
8943 @cindex files, selecting for publishing
8945 By default, all files with extension @file{.org} in the base directory
8946 are considered part of the project.  This can be modified by setting the
8947 properties
8948 @multitable @columnfractions 0.25 0.75
8949 @item @code{:base-extension}
8950 @tab Extension (without the dot!) of source files.  This actually is a
8951 regular expression.  Set this to the symbol @code{any} if you want to get all
8952 files in @code{:base-directory}, even without extension.
8954 @item @code{:exclude}
8955 @tab Regular expression to match file names that should not be
8956 published, even though they have been selected on the basis of their
8957 extension.
8959 @item @code{:include}
8960 @tab List of files to be included regardless of @code{:base-extension}
8961 and @code{:exclude}.
8962 @end multitable
8964 @node Publishing action, Publishing options, Selecting files, Configuration
8965 @subsection Publishing action
8966 @cindex action, for publishing
8968 Publishing means that a file is copied to the destination directory and
8969 possibly transformed in the process.  The default transformation is to export
8970 Org files as HTML files, and this is done by the function
8971 @code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
8972 export}). But you also can publish your files in La@TeX{} by using the
8973 function @code{org-publish-org-to-latex} instead, or as PDF files using
8974 @code{org-publish-org-to-pdf}.  Other files like images only need to be
8975 copied to the publishing destination. For non-Org files, you need to provide
8976 your own publishing function:
8978 @multitable @columnfractions 0.3 0.7
8979 @item @code{:publishing-function}
8980 @tab Function executing the publication of a file.  This may also be a
8981 list of functions, which will all be called in turn.
8982 @end multitable
8984 The function must accept two arguments: a property list containing at
8985 least a @code{:publishing-directory} property, and the name of the file
8986 to be published.  It should take the specified file, make the necessary
8987 transformation (if any) and place the result into the destination folder.
8988 You can write your own publishing function, but @code{org-publish}
8989 provides one for attachments (files that only need to be copied):
8990 @code{org-publish-attachment}.
8992 @node Publishing options, Publishing links, Publishing action, Configuration
8993 @subsection Options for the HTML/LaTeX exporters
8994 @cindex options, for publishing
8996 The property list can be used to set many export options for the HTML
8997 and La@TeX{} exporters.  In most cases, these properties correspond to user
8998 variables in Org.  The table below lists these properties along
8999 with the variable they belong to.  See the documentation string for the
9000 respective variable for details.
9002 @vindex org-export-html-link-up
9003 @vindex org-export-html-link-home
9004 @vindex org-export-default-language
9005 @vindex org-display-custom-times
9006 @vindex org-export-headline-levels
9007 @vindex org-export-with-section-numbers
9008 @vindex org-export-section-number-format
9009 @vindex org-export-with-toc
9010 @vindex org-export-preserve-breaks
9011 @vindex org-export-with-archived-trees
9012 @vindex org-export-with-emphasize
9013 @vindex org-export-with-sub-superscripts
9014 @vindex org-export-with-special-strings
9015 @vindex org-export-with-footnotes
9016 @vindex org-export-with-drawers
9017 @vindex org-export-with-tags
9018 @vindex org-export-with-todo-keywords
9019 @vindex org-export-with-priority
9020 @vindex org-export-with-TeX-macros
9021 @vindex org-export-with-LaTeX-fragments
9022 @vindex org-export-skip-text-before-1st-heading
9023 @vindex org-export-with-fixed-width
9024 @vindex org-export-with-timestamps
9025 @vindex org-export-author-info
9026 @vindex org-export-creator-info
9027 @vindex org-export-with-tables
9028 @vindex org-export-highlight-first-table-line
9029 @vindex org-export-html-style-include-default
9030 @vindex org-export-html-style
9031 @vindex org-export-html-style-extra
9032 @vindex org-export-html-link-org-files-as-html
9033 @vindex org-export-html-inline-images
9034 @vindex org-export-html-extension
9035 @vindex org-export-html-table-tag
9036 @vindex org-export-html-expand
9037 @vindex org-export-html-with-timestamp
9038 @vindex org-export-publishing-directory
9039 @vindex org-export-html-preamble
9040 @vindex org-export-html-postamble
9041 @vindex org-export-html-auto-preamble
9042 @vindex org-export-html-auto-postamble
9043 @vindex user-full-name
9044 @vindex user-mail-address
9045 @vindex org-export-select-tags
9046 @vindex org-export-exclude-tags
9048 @multitable @columnfractions 0.32 0.68
9049 @item @code{:link-up}               @tab @code{org-export-html-link-up}
9050 @item @code{:link-home}             @tab @code{org-export-html-link-home}
9051 @item @code{:language}              @tab @code{org-export-default-language}
9052 @item @code{:customtime}            @tab @code{org-display-custom-times}
9053 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
9054 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
9055 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
9056 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
9057 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
9058 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
9059 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
9060 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
9061 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
9062 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
9063 @item @code{:drawers}               @tab @code{org-export-with-drawers}
9064 @item @code{:tags}                  @tab @code{org-export-with-tags}
9065 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
9066 @item @code{:priority}              @tab @code{org-export-with-priority}
9067 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
9068 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
9069 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
9070 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
9071 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
9072 @item @code{:author-info}           @tab @code{org-export-author-info}
9073 @item @code{:creator-info}          @tab @code{org-export-creator-info}
9074 @item @code{:tables}                @tab @code{org-export-with-tables}
9075 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
9076 @item @code{:style-include-default} @tab @code{org-export-html-style-include-default}
9077 @item @code{:style}                 @tab @code{org-export-html-style}
9078 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
9079 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
9080 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
9081 @item @code{:html-extension}        @tab @code{org-export-html-extension}
9082 @item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
9083 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
9084 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
9085 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
9086 @item @code{:preamble}              @tab @code{org-export-html-preamble}
9087 @item @code{:postamble}             @tab @code{org-export-html-postamble}
9088 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
9089 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
9090 @item @code{:author}                @tab @code{user-full-name}
9091 @item @code{:email}                 @tab @code{user-mail-address}
9092 @item @code{:select-tags}           @tab @code{org-export-select-tags}
9093 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
9094 @end multitable
9096 If you use several email addresses, separate them by a semi-column.
9098 Most of the @code{org-export-with-*} variables have the same effect in
9099 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
9100 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
9101 La@TeX{} export.
9103 @vindex org-publish-project-alist
9104 When a property is given a value in @code{org-publish-project-alist},
9105 its setting overrides the value of the corresponding user variable (if
9106 any) during publishing.  Options set within a file (@pxref{Export
9107 options}), however, override everything.
9109 @node Publishing links, Project page index, Publishing options, Configuration
9110 @subsection Links between published files
9111 @cindex links, publishing
9113 To create a link from one Org file to another, you would use
9114 something like @samp{[[file:foo.org][The foo]]} or simply
9115 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
9116 becomes a link to @file{foo.html}.  In this way, you can interlink the
9117 pages of your "org web" project and the links will work as expected when
9118 you publish them to HTML.
9120 You may also link to related files, such as images. Provided you are
9121 careful with relative pathnames, and provided you have also configured
9122 @code{org-publish} to upload the related files, these links will work
9123 too. See @ref{Complex example} for an example of this usage.
9125 Sometime an Org file to be published may contain links that are
9126 only valid in your production environment, but not in the publishing
9127 location.  In this case, use the property
9129 @multitable @columnfractions 0.4 0.6
9130 @item @code{:link-validation-function}
9131 @tab Function to validate links
9132 @end multitable
9134 @noindent
9135 to define a function for checking link validity.  This function must
9136 accept two arguments, the file name and a directory relative to which
9137 the file name is interpreted in the production environment.  If this
9138 function returns @code{nil}, then the HTML generator will only insert a
9139 description into the HTML file, but no link.  One option for this
9140 function is @code{org-publish-validate-link} which checks if the given
9141 file is part of any project in @code{org-publish-project-alist}.
9143 @node Project page index,  , Publishing links, Configuration
9144 @subsection Project page index
9145 @cindex index, of published pages
9147 The following properties may be used to control publishing of an
9148 index of files or summary page for a given project.
9150 @multitable @columnfractions 0.25 0.75
9151 @item @code{:auto-index}
9152 @tab When non-nil, publish an index during org-publish-current-project or
9153 org-publish-all.
9155 @item @code{:index-filename}
9156 @tab Filename for output of index. Defaults to @file{index.org} (which
9157 becomes @file{index.html}).
9159 @item @code{:index-title}
9160 @tab Title of index page. Defaults to name of file.
9162 @item @code{:index-function}
9163 @tab Plug-in function to use for generation of index.
9164 Defaults to @code{org-publish-org-index}, which generates a plain list
9165 of links to all files in the project.
9166 @end multitable
9168 @node Sample configuration, Triggering publication, Configuration, Publishing
9169 @section Sample configuration
9171 Below we provide two example configurations.  The first one is a simple
9172 project publishing only a set of Org files.  The second example is
9173 more complex, with a multi-component project.
9175 @menu
9176 * Simple example::              One-component publishing
9177 * Complex example::             A multi-component publishing example
9178 @end menu
9180 @node Simple example, Complex example, Sample configuration, Sample configuration
9181 @subsection Example: simple publishing configuration
9183 This example publishes a set of Org files to the @file{public_html}
9184 directory on the local machine.
9186 @lisp
9187 (setq org-publish-project-alist
9188       '(("org"
9189          :base-directory "~/org/"
9190          :publishing-directory "~/public_html"
9191          :section-numbers nil
9192          :table-of-contents nil
9193          :style "<link rel=\"stylesheet\"
9194                 href=\"../other/mystyle.css\"
9195                 type=\"text/css\">")))
9196 @end lisp
9198 @node Complex example,  , Simple example, Sample configuration
9199 @subsection Example: complex publishing configuration
9201 This more complicated example publishes an entire website, including
9202 org files converted to HTML, image files, emacs lisp source code, and
9203 style sheets. The publishing-directory is remote and private files are
9204 excluded.
9206 To ensure that links are preserved, care should be taken to replicate
9207 your directory structure on the web server, and to use relative file
9208 paths. For example, if your org files are kept in @file{~/org} and your
9209 publishable images in @file{~/images}, you'd link to an image with
9211 @example
9212 file:../images/myimage.png
9213 @end example
9215 On the web server, the relative path to the image should be the
9216 same. You can accomplish this by setting up an "images" folder in the
9217 right place on the web server, and publishing images to it.
9219 @lisp
9220 (setq org-publish-project-alist
9221       '(("orgfiles"
9222           :base-directory "~/org/"
9223           :base-extension "org"
9224           :publishing-directory "/ssh:user@@host:~/html/notebook/"
9225           :publishing-function org-publish-org-to-html
9226           :exclude "PrivatePage.org"   ;; regexp
9227           :headline-levels 3
9228           :section-numbers nil
9229           :table-of-contents nil
9230           :style "<link rel=\"stylesheet\"
9231                   href=\"../other/mystyle.css\" type=\"text/css\">"
9232           :auto-preamble t
9233           :auto-postamble nil)
9235          ("images"
9236           :base-directory "~/images/"
9237           :base-extension "jpg\\|gif\\|png"
9238           :publishing-directory "/ssh:user@@host:~/html/images/"
9239           :publishing-function org-publish-attachment)
9241          ("other"
9242           :base-directory "~/other/"
9243           :base-extension "css\\|el"
9244           :publishing-directory "/ssh:user@@host:~/html/other/"
9245           :publishing-function org-publish-attachment)
9246          ("website" :components ("orgfiles" "images" "other"))))
9247 @end lisp
9249 @node Triggering publication,  , Sample configuration, Publishing
9250 @section Triggering publication
9252 Once org-publish is properly configured, you can publish with the
9253 following functions:
9255 @table @kbd
9256 @item C-c C-e C
9257 Prompt for a specific project and publish all files that belong to it.
9258 @item C-c C-e P
9259 Publish the project containing the current file.
9260 @item C-c C-e F
9261 Publish only the current file.
9262 @item C-c C-e A
9263 Publish all projects.
9264 @end table
9266 Org uses timestamps to track when a file has changed. The above
9267 functions normally only publish changed files. You can override this and
9268 force publishing of all files by giving a prefix argument.
9270 @node Miscellaneous, Hacking, Publishing, Top
9271 @chapter Miscellaneous
9273 @menu
9274 * Completion::                  M-TAB knows what you need
9275 * Customization::               Adapting Org to your taste
9276 * In-buffer settings::          Overview of the #+KEYWORDS
9277 * The very busy C-c C-c key::   When in doubt, press C-c C-c
9278 * Clean view::                  Getting rid of leading stars in the outline
9279 * TTY keys::                    Using Org on a tty
9280 * Interaction::                 Other Emacs packages
9281 @end menu
9284 @node Completion, Customization, Miscellaneous, Miscellaneous
9285 @section Completion
9286 @cindex completion, of @TeX{} symbols
9287 @cindex completion, of TODO keywords
9288 @cindex completion, of dictionary words
9289 @cindex completion, of option keywords
9290 @cindex completion, of tags
9291 @cindex completion, of property keys
9292 @cindex completion, of link abbreviations
9293 @cindex @TeX{} symbol completion
9294 @cindex TODO keywords completion
9295 @cindex dictionary word completion
9296 @cindex option keyword completion
9297 @cindex tag completion
9298 @cindex link abbreviations, completion of
9300 Org supports in-buffer completion.  This type of completion does
9301 not make use of the minibuffer.  You simply type a few letters into
9302 the buffer and use the key to complete text right there.
9304 @table @kbd
9305 @kindex M-@key{TAB}
9306 @item M-@key{TAB}
9307 Complete word at point
9308 @itemize @bullet
9309 @item
9310 At the beginning of a headline, complete TODO keywords.
9311 @item
9312 After @samp{\}, complete @TeX{} symbols supported by the exporter.
9313 @item
9314 After @samp{*}, complete headlines in the current buffer so that they
9315 can be used in search links like @samp{[[*find this headline]]}.
9316 @item
9317 After @samp{:} in a headline, complete tags.  The list of tags is taken
9318 from the variable @code{org-tag-alist} (possibly set through the
9319 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
9320 dynamically from all tags used in the current buffer.
9321 @item
9322 After @samp{:} and not in a headline, complete property keys.  The list
9323 of keys is constructed dynamically from all keys used in the current
9324 buffer.
9325 @item
9326 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
9327 @item
9328 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
9329 @samp{OPTIONS} which set file-specific options for Org mode.  When the
9330 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
9331 will insert example settings for this keyword.
9332 @item
9333 In the line after @samp{#+STARTUP: }, complete startup keywords,
9334 i.e. valid keys for this line.
9335 @item
9336 Elsewhere, complete dictionary words using Ispell.
9337 @end itemize
9338 @end table
9340 @node Customization, In-buffer settings, Completion, Miscellaneous
9341 @section Customization
9342 @cindex customization
9343 @cindex options, for customization
9344 @cindex variables, for customization
9346 There are more than 180 variables that can be used to customize
9347 Org.  For the sake of compactness of the manual, I am not
9348 describing the variables here.  A structured overview of customization
9349 variables is available with @kbd{M-x org-customize}.  Or select
9350 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
9351 settings can also be activated on a per-file basis, by putting special
9352 lines into the buffer (@pxref{In-buffer settings}).
9354 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
9355 @section Summary of in-buffer settings
9356 @cindex in-buffer settings
9357 @cindex special keywords
9359 Org mode uses special lines in the buffer to define settings on a
9360 per-file basis.  These lines start with a @samp{#+} followed by a
9361 keyword, a colon, and then individual words defining a setting.  Several
9362 setting words can be in the same line, but you can also have multiple
9363 lines for the keyword.  While these settings are described throughout
9364 the manual, here is a summary.  After changing any of those lines in the
9365 buffer, press @kbd{C-c C-c} with the cursor still in the line to
9366 activate the changes immediately.  Otherwise they become effective only
9367 when the file is visited again in a new Emacs session.
9369 @vindex org-archive-location
9370 @table @kbd
9371 @item #+ARCHIVE: %s_done::
9372 This line sets the archive location for the agenda file.  It applies for
9373 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
9374 of the file.  The first such line also applies to any entries before it.
9375 The corresponding variable is @code{org-archive-location}.
9376 @item #+CATEGORY:
9377 This line sets the category for the agenda file.  The category applies
9378 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
9379 end of the file.  The first such line also applies to any entries before it.
9380 @item #+COLUMNS: %25ITEM .....
9381 Set the default format for columns view.  This format applies when
9382 columns view is invoked in location where no @code{COLUMNS} property
9383 applies.
9384 @item #+CONSTANTS: name1=value1 ...
9385 @vindex org-table-formula-constants
9386 @vindex org-table-formula
9387 Set file-local values for constants to be used in table formulas.  This
9388 line set the local variable @code{org-table-formula-constants-local}.
9389 The global version of this variable is
9390 @code{org-table-formula-constants}.
9391 @item #+FILETAGS: :tag1:tag2:tag3:
9392 Set tags that can be inherited by any entry in the file, including the
9393 top-level entries.
9394 @item #+DRAWERS: NAME1 .....
9395 @vindex org-drawers
9396 Set the file-local set of drawers.  The corresponding global variable is
9397 @code{org-drawers}.
9398 @item #+LINK:  linkword replace
9399 @vindex org-link-abbrev-alist
9400 These lines (several are allowed) specify link abbreviations.
9401 @xref{Link abbreviations}.  The corresponding variable is
9402 @code{org-link-abbrev-alist}.
9403 @item #+PRIORITIES: highest lowest default
9404 @vindex org-highest-priority
9405 @vindex org-lowest-priority
9406 @vindex org-default-priority
9407 This line sets the limits and the default for the priorities.  All three
9408 must be either letters A-Z or numbers 0-9.  The highest priority must
9409 have a lower ASCII number that the lowest priority.
9410 @item #+PROPERTY: Property_Name Value
9411 This line sets a default inheritance value for entries in the current
9412 buffer, most useful for specifying the allowed values of a property.
9413 @item #+SETUPFILE: file
9414 This line defines a file that holds more in-buffer setup.  Normally this is
9415 entirely ignored.  Only when the buffer is parsed for option-setting lines
9416 (i.e. when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
9417 settings line, or when exporting), then the contents of this file are parsed
9418 as if they had been included in the buffer.  In particular, the file can be
9419 any other Org mode file with internal setup.  You can visit the file the
9420 cursor is in the line with @kbd{C-c '}.
9421 @item #+STARTUP:
9422 @vindex org-startup-folded
9423 This line sets options to be used at startup of Org mode, when an
9424 Org file is being visited.  The first set of options deals with the
9425 initial visibility of the outline tree.  The corresponding variable for
9426 global default settings is @code{org-startup-folded}, with a default
9427 value @code{t}, which means @code{overview}.
9428 @cindex @code{overview}, STARTUP keyword
9429 @cindex @code{content}, STARTUP keyword
9430 @cindex @code{showall}, STARTUP keyword
9431 @example
9432 overview   @r{top-level headlines only}
9433 content    @r{all headlines}
9434 showall    @r{no folding at all, show everything}
9435 @end example
9436 @vindex org-startup-align-all-tables
9437 Then there are options for aligning tables upon visiting a file.  This
9438 is useful in files containing narrowed table columns.  The corresponding
9439 variable is @code{org-startup-align-all-tables}, with a default value
9440 @code{nil}.
9441 @cindex @code{align}, STARTUP keyword
9442 @cindex @code{noalign}, STARTUP keyword
9443 @example
9444 align      @r{align all tables}
9445 noalign    @r{don't align tables on startup}
9446 @end example
9447 @vindex org-log-done
9448 @vindex org-log-note-clock-out
9449 @vindex org-log-repeat
9450 Logging closing and reinstating TODO items, and clock intervals
9451 (variables @code{org-log-done}, @code{org-log-note-clock-out}, and
9452 @code{org-log-repeat}) can be configured using these options.
9453 @cindex @code{logdone}, STARTUP keyword
9454 @cindex @code{lognotedone}, STARTUP keyword
9455 @cindex @code{nologdone}, STARTUP keyword
9456 @cindex @code{lognoteclock-out}, STARTUP keyword
9457 @cindex @code{nolognoteclock-out}, STARTUP keyword
9458 @cindex @code{logrepeat}, STARTUP keyword
9459 @cindex @code{lognoterepeat}, STARTUP keyword
9460 @cindex @code{nologrepeat}, STARTUP keyword
9461 @example
9462 logdone            @r{record a timestamp when an item is marked DONE}
9463 lognotedone        @r{record timestamp and a note when DONE}
9464 nologdone          @r{don't record when items are marked DONE}
9465 logrepeat          @r{record a time when reinstating a repeating item}
9466 lognoterepeat      @r{record a note when reinstating a repeating item}
9467 nologrepeat        @r{do not record when reinstating repeating item}
9468 lognoteclock-out   @r{record a note when clocking out}
9469 nolognoteclock-out @r{don't record a note when clocking out}
9470 @end example
9471 @vindex org-hide-leading-stars
9472 @vindex org-odd-levels-only
9473 Here are the options for hiding leading stars in outline headings, and for
9474 indenting outlines.  The corresponding variables are
9475 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
9476 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
9477 @cindex @code{hidestars}, STARTUP keyword
9478 @cindex @code{showstars}, STARTUP keyword
9479 @cindex @code{odd}, STARTUP keyword
9480 @cindex @code{even}, STARTUP keyword
9481 @example
9482 hidestars  @r{make all but one of the stars starting a headline invisible.}
9483 showstars  @r{show all stars starting a headline}
9484 indent     @r{virtual indentation according to outline level}
9485 noindent   @r{no virtual indentation according to outline level}
9486 odd        @r{allow only odd outline levels (1,3,...)}
9487 oddeven    @r{allow all outline levels}
9488 @end example
9489 @vindex org-put-time-stamp-overlays
9490 @vindex org-time-stamp-overlay-formats
9491 To turn on custom format overlays over time stamps (variables
9492 @code{org-put-time-stamp-overlays} and
9493 @code{org-time-stamp-overlay-formats}), use
9494 @cindex @code{customtime}, STARTUP keyword
9495 @example
9496 customtime @r{overlay custom time format}
9497 @end example
9498 @vindex constants-unit-system
9499 The following options influence the table spreadsheet (variable
9500 @code{constants-unit-system}).
9501 @cindex @code{constcgs}, STARTUP keyword
9502 @cindex @code{constSI}, STARTUP keyword
9503 @example
9504 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
9505 constSI    @r{@file{constants.el} should use the SI unit system}
9506 @end example
9507 @vindex org-footnote-define-inline
9508 @vindex org-footnote-auto-label
9509 To influence footnote settings, use the following keywords.  The
9510 corresponding variables are @code{org-footnote-define-inline} and
9511 @code{org-footnote-auto-label}.
9512 @cindex @code{fninline}, STARTUP keyword
9513 @cindex @code{fnnoinline}, STARTUP keyword
9514 @cindex @code{fnlocal}, STARTUP keyword
9515 @cindex @code{fnprompt}, STARTUP keyword
9516 @cindex @code{fnauto}, STARTUP keyword
9517 @cindex @code{fnconfirm}, STARTUP keyword
9518 @cindex @code{fnplain}, STARTUP keyword
9519 @example
9520 fninline    @r{define footnotes inline}
9521 fnnoinline  @r{define footnotes in separate section}
9522 fnlocal     @r{define footnotes near first reference, but not inline}
9523 fnprompt    @r{prompt for footnote labels}
9524 fnauto      @r{create [fn:1]-like labels automatically (default)}
9525 fnconfirm   @r{offer automatic label for editing or confirmation}
9526 fnplain     @r{create [1]-like labels automatically}
9527 @end example
9528 @item #+TAGS:  TAG1(c1) TAG2(c2)
9529 @vindex org-tag-alist
9530 These lines (several such lines are allowed) specify the valid tags in
9531 this file, and (potentially) the corresponding @emph{fast tag selection}
9532 keys.  The corresponding variable is @code{org-tag-alist}.
9533 @item #+TBLFM:
9534 This line contains the formulas for the table directly above the line.
9535 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:,
9536 @itemx #+DESCRIPTION:, #+KEYWORDS:
9537 @itemx #+LATEX_HEADER:, #+STYLE:, #+LINK_UP:, #+LINK_HOME:, 
9538 @itemx #+EXPORT_SELECT_TAGS:, #+EXPORT_EXCLUDE_TAGS:
9539 These lines provide settings for exporting files.  For more details see
9540 @ref{Export options}.
9541 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
9542 @vindex org-todo-keywords
9543 These lines set the TODO keywords and their interpretation in the
9544 current file.  The corresponding variable is @code{org-todo-keywords}.
9545 @end table
9547 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
9548 @section The very busy C-c C-c key
9549 @kindex C-c C-c
9550 @cindex C-c C-c, overview
9552 The key @kbd{C-c C-c} has many purposes in Org, which are all
9553 mentioned scattered throughout this manual.  One specific function of
9554 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
9555 other circumstances it means something like @emph{Hey Org, look
9556 here and update according to what you see here}.  Here is a summary of
9557 what this means in different contexts.
9559 @itemize @minus
9560 @item
9561 If there are highlights in the buffer from the creation of a sparse
9562 tree, or from clock display, remove these highlights.
9563 @item
9564 If the cursor is in one of the special @code{#+KEYWORD} lines, this
9565 triggers scanning the buffer for these lines and updating the
9566 information.
9567 @item
9568 If the cursor is inside a table, realign the table.  This command
9569 works even if the automatic table editor has been turned off.
9570 @item
9571 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
9572 the entire table.
9573 @item
9574 If the cursor is inside a table created by the @file{table.el} package,
9575 activate that table.
9576 @item
9577 If the current buffer is a remember buffer, close the note and file it.
9578 With a prefix argument, file it, without further interaction, to the
9579 default location.
9580 @item
9581 If the cursor is on a @code{<<<target>>>}, update radio targets and
9582 corresponding links in this buffer.
9583 @item
9584 If the cursor is in a property line or at the start or end of a property
9585 drawer, offer property commands.
9586 @item
9587 If the cursor is at a footnote reference, go to the corresponding
9588 definition, and vice versa.
9589 @item
9590 If the cursor is in a plain list item with a checkbox, toggle the status
9591 of the checkbox.
9592 @item
9593 If the cursor is on a numbered item in a plain list, renumber the
9594 ordered list.
9595 @item
9596 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
9597 block is updated.
9598 @end itemize
9600 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
9601 @section A cleaner outline view
9602 @cindex hiding leading stars
9603 @cindex dynamic indentation
9604 @cindex odd-levels-only outlines
9605 @cindex clean outline view
9607 Some people find it noisy and distracting that the Org headlines are starting
9608 with a potentially large number of stars, and that text below the headlines
9609 is not indented.  This is not really a problem when you are writing a book
9610 where the outline headings are really section headlines.  However, in a more
9611 list-oriented outline, it is clear that an indented structure is a lot
9612 cleaner, as can be seen by comparing the two columns in the following
9613 example:
9615 @example
9616 @group
9617 * Top level headline             |    * Top level headline
9618 ** Second level                  |      * Second level
9619 *** 3rd level                    |        * 3rd level
9620 some text                        |          some text
9621 *** 3rd level                    |        * 3rd level
9622 more text                        |          more text
9623 * Another top level headline     |    * Another top level headline
9624 @end group
9625 @end example
9627 @noindent
9628 It is non-trivial to make such a look work in Emacs, but Org contains three
9629 separate features that, combined, achieve just that.
9631 @enumerate
9632 @item
9633 @emph{Indentation of text below headlines}@*
9634 You may indent text below each headline to make the left boundary line up
9635 with the headline, like
9637 @example
9638 *** 3rd level
9639     more text, now indented
9640 @end example
9642 @vindex org-adapt-indentation
9643 A good way to get this indentation is by hand, and Org supports this with
9644 paragraph filling, line wrapping, and structure editing@footnote{See also the
9645 variable @code{org-adapt-indentation}.} preserving or adapting the
9646 indentation appropriate.  A different approach would be to have a way to
9647 automatically indent lines according to outline structure by adding overlays
9648 or text properties.  But I have not yet found a robust and efficient way to
9649 do this in large files.
9651 @item
9652 @vindex org-hide-leading-stars
9653 @emph{Hiding leading stars}@* You can modify the display in such a way that
9654 all leading stars become invisible.  To do this in a global way, configure
9655 the variable @code{org-hide-leading-stars} or change this on a per-file basis
9656 with
9658 @example
9659 #+STARTUP: hidestars
9660 @end example
9662 @noindent
9663 Note that the opposite behavior is selected with @code{showstars}.
9665 With hidden stars, the tree becomes:
9667 @example
9668 @group
9669 * Top level headline
9670  * Second level
9671   * 3rd level
9672   ...
9673 @end group
9674 @end example
9676 @noindent
9677 @vindex org-hide @r{(face)}
9678 Note that the leading stars are not truly replaced by whitespace, they
9679 are only fontified with the face @code{org-hide} that uses the
9680 background color as font color.  If you are not using either white or
9681 black background, you may have to customize this face to get the wanted
9682 effect.  Another possibility is to set this font such that the extra
9683 stars are @i{almost} invisible, for example using the color
9684 @code{grey90} on a white background.
9686 @item
9687 @cindex org-odd-levels-only
9688 Things become cleaner still if you skip all the even levels and use only odd
9689 levels 1, 3, 5..., effectively adding two stars to go from one outline level
9690 to the next@footnote{When you need to specify a level for a property search
9691 or refile targets, @samp{LEVEL=2} will correspond to 3 stars etc.}.  In this
9692 way we get the outline view shown at the beginning of this section.  In order
9693 to make the structure editing and export commands handle this convention
9694 correctly, configure the variable @code{org-odd-levels-only}, or set this on
9695 a per-file basis with one of the following lines:
9697 @example
9698 #+STARTUP: odd
9699 #+STARTUP: oddeven
9700 @end example
9702 You can convert an Org file from single-star-per-level to the
9703 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
9704 RET} in that file.  The reverse operation is @kbd{M-x
9705 org-convert-to-oddeven-levels}.
9706 @end enumerate
9708 @node TTY keys, Interaction, Clean view, Miscellaneous
9709 @section Using Org on a tty
9710 @cindex tty key bindings
9712 Because Org contains a large number of commands, by default much of
9713 Org's core commands are bound to keys that are generally not
9714 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
9715 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
9716 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
9717 these commands on a tty when special keys are unavailable, the following
9718 alternative bindings can be used.  The tty bindings below will likely be
9719 more cumbersome; you may find for some of the bindings below that a
9720 customized work-around suits you better.  For example, changing a time
9721 stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
9722 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
9724 @multitable @columnfractions 0.15 0.2 0.2
9725 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
9726 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
9727 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
9728 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
9729 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x i}           @tab @kbd{@key{Esc} @key{right}}
9730 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
9731 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
9732 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
9733 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
9734 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
9735 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
9736 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
9737 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
9738 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
9739 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
9740 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
9741 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
9742 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
9743 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
9744 @end multitable
9747 @node Interaction,  , TTY keys, Miscellaneous
9748 @section Interaction with other packages
9749 @cindex packages, interaction with other
9750 Org lives in the world of GNU Emacs and interacts in various ways
9751 with other code out there.
9753 @menu
9754 * Cooperation::                 Packages Org cooperates with
9755 * Conflicts::                   Packages that lead to conflicts
9756 @end menu
9758 @node Cooperation, Conflicts, Interaction, Interaction
9759 @subsection Packages that Org cooperates with
9761 @table @asis
9762 @cindex @file{calc.el}
9763 @item @file{calc.el} by Dave Gillespie
9764 Org uses the Calc package for implementing spreadsheet
9765 functionality in its tables (@pxref{The spreadsheet}).  Org
9766 checks for the availability of Calc by looking for the function
9767 @code{calc-eval} which should be autoloaded in your setup if Calc has
9768 been installed properly.  As of Emacs 22, Calc is part of the Emacs
9769 distribution.  Another possibility for interaction between the two
9770 packages is using Calc for embedded calculations. @xref{Embedded Mode,
9771 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
9772 @cindex @file{constants.el}
9773 @item @file{constants.el} by Carsten Dominik
9774 @vindex org-table-formula-constants
9775 In a table formula (@pxref{The spreadsheet}), it is possible to use
9776 names for natural constants or units.  Instead of defining your own
9777 constants in the variable @code{org-table-formula-constants}, install
9778 the @file{constants} package which defines a large number of constants
9779 and units, and lets you use unit prefixes like @samp{M} for
9780 @samp{Mega} etc.  You will need version 2.0 of this package, available
9781 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
9782 the function @code{constants-get}, which has to be autoloaded in your
9783 setup.  See the installation instructions in the file
9784 @file{constants.el}.
9785 @item @file{cdlatex.el} by Carsten Dominik
9786 @cindex @file{cdlatex.el}
9787 Org mode can make use of the CDLaTeX package to efficiently enter
9788 La@TeX{} fragments into Org files. See @ref{CDLaTeX mode}.
9789 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
9790 @cindex @file{imenu.el}
9791 Imenu allows menu access to an index of items in a file.  Org mode
9792 supports Imenu - all you need to do to get the index is the following:
9793 @lisp
9794 (add-hook 'org-mode-hook
9795           (lambda () (imenu-add-to-menubar "Imenu")))
9796 @end lisp
9797 @vindex org-imenu-depth
9798 By default the index is two levels deep - you can modify the depth using
9799 the option @code{org-imenu-depth}.
9800 @item @file{remember.el} by John Wiegley
9801 @cindex @file{remember.el}
9802 Org cooperates with remember, see @ref{Remember}.
9803 @file{Remember.el} is not part of Emacs, find it on the web.
9804 @item @file{speedbar.el} by Eric M. Ludlam
9805 @cindex @file{speedbar.el}
9806 Speedbar is a package that creates a special frame displaying files and
9807 index items in files.  Org mode supports Speedbar and allows you to
9808 drill into Org files directly from the Speedbar.  It also allows to
9809 restrict the scope of agenda commands to a file or a subtree by using
9810 the command @kbd{<} in the Speedbar frame.
9811 @cindex @file{table.el}
9812 @item @file{table.el} by Takaaki Ota
9813 @kindex C-c C-c
9814 @cindex table editor, @file{table.el}
9815 @cindex @file{table.el}
9817 Complex ASCII tables with automatic line wrapping, column- and
9818 row-spanning, and alignment can be created using the Emacs table
9819 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
9820 and also part of Emacs 22).
9821 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
9822 will call @command{table-recognize-table} and move the cursor into the
9823 table.  Inside a table, the keymap of Org mode is inactive.  In order
9824 to execute Org mode-related commands, leave the table.
9826 @table @kbd
9827 @kindex C-c C-c
9828 @item C-c C-c
9829 Recognize @file{table.el} table.  Works when the cursor is in a
9830 table.el table.
9832 @kindex C-c ~
9833 @item C-c ~
9834 Insert a table.el table.  If there is already a table at point, this
9835 command converts it between the table.el format and the Org mode
9836 format.  See the documentation string of the command
9837 @code{org-convert-table} for the restrictions under which this is
9838 possible.
9839 @end table
9840 @file{table.el} is part of Emacs 22.
9841 @cindex @file{footnote.el}
9842 @item @file{footnote.el} by Steven L. Baur
9843 Org mode recognizes numerical footnotes as provided by this package.
9844 However, Org-mode also has its own footnote support (@pxref{Footnotes}),
9845 which makes using @file{footnote.el} unnecessary.
9846 @end table
9848 @node Conflicts,  , Cooperation, Interaction
9849 @subsection Packages that lead to conflicts with Org mode
9851 @table @asis
9853 @cindex @code{shift-selection-mode}
9854 @vindex org-support-shift-select
9855 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
9856 cursor motions combined with the shift key should start or enlarge regions.
9857 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
9858 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
9859 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
9860 special contexts don't do anything, but you can customize the variable
9861 @code{org-support-shift-select}.  Org-mode then tries to accommodate shift
9862 selection by (i) using it outside of the special contexts where special
9863 commands apply, and by (ii) extending an existing active region even if the
9864 cursor moves across a special context.
9866 @cindex @file{CUA.el}
9867 @item @file{CUA.el} by Kim. F. Storm
9868 @vindex org-replace-disputed-keys
9869 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
9870 (as well as pc-select-mode and s-region-mode) to select and extend the
9871 region.  In fact, Emacs 23 has this built-in in the form of
9872 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
9873 23 you probably don't want to use another package for this purpose.  However,
9874 if you prefer to leave these keys to a different package while working in
9875 Org-mode, configure the variable @code{org-replace-disputed-keys}.  When set,
9876 Org will move the following key bindings in Org files, and in the agenda
9877 buffer (but not during date selection).
9879 @example
9880 S-UP      ->  M-p             S-DOWN     ->  M-n
9881 S-LEFT    ->  M--             S-RIGHT    ->  M-+
9882 C-S-LEFT  ->  M-S--           C-S-RIGHT  ->  M-S-+
9883 @end example
9885 @vindex org-disputed-keys
9886 Yes, these are unfortunately more difficult to remember.  If you want
9887 to have other replacement keys, look at the variable
9888 @code{org-disputed-keys}.
9890 @item @file{windmove.el} by Hovav Shacham
9891 @cindex @file{windmove.el}
9892 Also this package uses the @kbd{S-<cursor>} keys, so everything written
9893 in the paragraph above about CUA mode also applies here.
9895 @end table
9897 @node Hacking, History and Acknowledgments, Miscellaneous, Top
9898 @appendix Hacking
9899 @cindex hacking
9901 This appendix covers some aspects where users can extend the functionality of
9902 Org.
9904 @menu
9905 * Hooks::                       Who to reach into Org's internals
9906 * Add-on packages::             Available extensions
9907 * Adding hyperlink types::      New custom link types
9908 * Context-sensitive commands::  How to add functioality to such commands
9909 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
9910 * Dynamic blocks::              Automatically filled blocks
9911 * Special agenda views::        Customized views
9912 * Using the property API::      Writing programs that use entry properties
9913 * Using the mapping API::       Mapping over all or selected entries
9914 @end menu
9916 @node Hooks, Add-on packages, Hacking, Hacking
9917 @section Hooks
9918 @cindex hooks
9920 Org has a large number of hook variables that can be used to add
9921 functionality to it.  This appendix about hacking is going to illustrate the
9922 use of some of them.  A complete list of all hooks with documentation is
9923 maintained by the worg project and can be found at
9924 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
9926 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
9927 @section Add-on packages
9928 @cindex add-on packages
9930 A large number of add-on packages have been written by various authors.
9931 These packages are not part of Emacs, but they are distributed as contributed
9932 packages with the separate release available at the Org-mode home page at
9933 @uref{http://orgmode.org}.  The list of contributed packages, along with
9934 documentation about each package, is maintained by the Worg project at
9935 @uref{http://orgmode.org/worg/org-contrib/}.
9939 @node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
9940 @section Adding hyperlink types
9941 @cindex hyperlinks, adding new types
9943 Org has a large number of hyperlink types built-in
9944 (@pxref{Hyperlinks}).  If you would like to add new link types, it
9945 provides an interface for doing so.  Let's look at an example file
9946 @file{org-man.el} that will add support for creating links like
9947 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
9948 emacs:
9950 @lisp
9951 ;;; org-man.el - Support for links to manpages in Org
9953 (require 'org)
9955 (org-add-link-type "man" 'org-man-open)
9956 (add-hook 'org-store-link-functions 'org-man-store-link)
9958 (defcustom org-man-command 'man
9959   "The Emacs command to be used to display a man page."
9960   :group 'org-link
9961   :type '(choice (const man) (const woman)))
9963 (defun org-man-open (path)
9964   "Visit the manpage on PATH.
9965 PATH should be a topic that can be thrown at the man command."
9966   (funcall org-man-command path))
9968 (defun org-man-store-link ()
9969   "Store a link to a manpage."
9970   (when (memq major-mode '(Man-mode woman-mode))
9971     ;; This is a man page, we do make this link
9972     (let* ((page (org-man-get-page-name))
9973            (link (concat "man:" page))
9974            (description (format "Manpage for %s" page)))
9975       (org-store-link-props
9976        :type "man"
9977        :link link
9978        :description description))))
9980 (defun org-man-get-page-name ()
9981   "Extract the page name from the buffer name."
9982   ;; This works for both `Man-mode' and `woman-mode'.
9983   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
9984       (match-string 1 (buffer-name))
9985     (error "Cannot create link to this man page")))
9987 (provide 'org-man)
9989 ;;; org-man.el ends here
9990 @end lisp
9992 @noindent
9993 You would activate this new link type in @file{.emacs} with
9995 @lisp
9996 (require 'org-man)
9997 @end lisp
9999 @noindent
10000 Let's go through the file and see what it does.
10001 @enumerate
10002 @item
10003 It does @code{(require 'org)} to make sure that @file{org.el} has been
10004 loaded.
10005 @item
10006 The next line calls @code{org-add-link-type} to define a new link type
10007 with prefix @samp{man}.  The call also contains the name of a function
10008 that will be called to follow such a link.
10009 @item
10010 @vindex org-store-link-functions
10011 The next line adds a function to @code{org-store-link-functions}, in
10012 order to allow the command @kbd{C-c l} to record a useful link in a
10013 buffer displaying a man page.
10014 @end enumerate
10016 The rest of the file defines the necessary variables and functions.
10017 First there is a customization variable that determines which emacs
10018 command should be used to display man pages.  There are two options,
10019 @code{man} and @code{woman}.  Then the function to follow a link is
10020 defined.  It gets the link path as an argument - in this case the link
10021 path is just a topic for the manual command.  The function calls the
10022 value of @code{org-man-command} to display the man page.
10024 Finally the function @code{org-man-store-link} is defined.  When you try
10025 to store a link with @kbd{C-c l}, also this function will be called to
10026 try to make a link.  The function must first decide if it is supposed to
10027 create the link for this buffer type, we do this by checking the value
10028 of the variable @code{major-mode}.  If not, the function must exit and
10029 return the value @code{nil}.  If yes, the link is created by getting the
10030 manual topic from the buffer name and prefixing it with the string
10031 @samp{man:}.  Then it must call the command @code{org-store-link-props}
10032 and set the @code{:type} and @code{:link} properties.  Optionally you
10033 can also set the @code{:description} property to provide a default for
10034 the link description when the link is later inserted into an Org
10035 buffer with @kbd{C-c C-l}.
10037 @node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
10038 @section Context-sensitive commands
10039 @cindex context-sensitive commands, hooks
10040 @cindex add-ons, context-sensitive commands
10041 @vindex org-ctrl-c-ctrl-c-hook
10043 Org has several commands that act differently depending on context.  The most
10044 important example it the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
10045 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys do have this property.
10047 Add-ons can tap into this functionality by providing a function that detects
10048 special context for that add-on and executes functionality appropriate for
10049 the context.  Here is an example from Dan Davison's @file{org-R.el} which
10050 allows to evaluate commands based on the @file{R} programming language.  For
10051 this package, special contexts are lines that start with @code{#+R:} or
10052 @code{#+RR:}.
10054 @lisp
10055 (defun org-R-apply-maybe ()
10056   "Detect if this is context for org-R and execute R commands."
10057   (if (save-excursion
10058         (beginning-of-line 1)
10059         (looking-at "#\\+RR?:"))
10060       (progn (call-interactively 'org-R-apply)
10061              t) ;; to signal that we took action
10062     nil)) ;; to signal that we did not
10064 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
10065 @end lisp
10067 The function first checks if the cursor is in such a line.  If that is the
10068 case, @code{org-R-apply} is called and the function returns @code{t} to
10069 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
10070 contexts.  If the function finds it should do nothing locally, it returns @code{nil} so that other, similar functions can have a try.
10073 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
10074 @section Tables and lists in arbitrary syntax
10075 @cindex tables, in other modes
10076 @cindex lists, in other modes
10077 @cindex Orgtbl mode
10079 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
10080 frequent feature request has been to make it work with native tables in
10081 specific languages, for example La@TeX{}.  However, this is extremely
10082 hard to do in a general way, would lead to a customization nightmare,
10083 and would take away much of the simplicity of the Orgtbl mode table
10084 editor.
10087 This appendix describes a different approach.  We keep the Orgtbl mode
10088 table in its native format (the @i{source table}), and use a custom
10089 function to @i{translate} the table to the correct syntax, and to
10090 @i{install} it in the right location (the @i{target table}).  This puts
10091 the burden of writing conversion functions on the user, but it allows
10092 for a very flexible system.
10094 Bastien added the ability to do the same with lists.  You can use Org's
10095 facilities to edit and structure lists by turning @code{orgstruct-mode}
10096 on, then locally exporting such lists in another format (HTML, La@TeX{}
10097 or Texinfo.)
10100 @menu
10101 * Radio tables::                Sending and receiving
10102 * A LaTeX example::             Step by step, almost a tutorial
10103 * Translator functions::        Copy and modify
10104 * Radio lists::                 Doing the same for lists
10105 @end menu
10107 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
10108 @subsection Radio tables
10109 @cindex radio tables
10111 To define the location of the target table, you first need to create two
10112 lines that are comments in the current mode, but contain magic words for
10113 Orgtbl mode to find.  Orgtbl mode will insert the translated table
10114 between these lines, replacing whatever was there before.  For example:
10116 @example
10117 /* BEGIN RECEIVE ORGTBL table_name */
10118 /* END RECEIVE ORGTBL table_name */
10119 @end example
10121 @noindent
10122 Just above the source table, we put a special line that tells
10123 Orgtbl mode how to translate this table and where to install it.  For
10124 example:
10125 @example
10126 #+ORGTBL: SEND table_name translation_function arguments....
10127 @end example
10129 @noindent
10130 @code{table_name} is the reference name for the table that is also used
10131 in the receiver lines. @code{translation_function} is the Lisp function
10132 that does the translation.  Furthermore, the line can contain a list of
10133 arguments (alternating key and value) at the end.  The arguments will be
10134 passed as a property list to the translation function for
10135 interpretation.  A few standard parameters are already recognized and
10136 acted upon before the translation function is called:
10138 @table @code
10139 @item :skip N
10140 Skip the first N lines of the table.  Hlines do count as separate lines for
10141 this parameter!
10143 @item :skipcols (n1 n2 ...)
10144 List of columns that should be skipped.  If the table has a column with
10145 calculation marks, that column is automatically discarded as well.
10146 Please note that the translator function sees the table @emph{after} the
10147 removal of these columns, the function never knows that there have been
10148 additional columns.
10149 @end table
10151 @noindent
10152 The one problem remaining is how to keep the source table in the buffer
10153 without disturbing the normal workings of the file, for example during
10154 compilation of a C file or processing of a La@TeX{} file.  There are a
10155 number of different solutions:
10157 @itemize @bullet
10158 @item
10159 The table could be placed in a block comment if that is supported by the
10160 language.  For example, in C mode you could wrap the table between
10161 @samp{/*} and @samp{*/} lines.
10162 @item
10163 Sometimes it is possible to put the table after some kind of @i{END}
10164 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
10165 in La@TeX{}.
10166 @item
10167 You can just comment the table line by line whenever you want to process
10168 the file, and uncomment it whenever you need to edit the table.  This
10169 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
10170 make this comment-toggling very easy, in particular if you bind it to a
10171 key.
10172 @end itemize
10174 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
10175 @subsection A LaTeX example of radio tables
10176 @cindex LaTeX, and Orgtbl mode
10178 The best way to wrap the source table in La@TeX{} is to use the
10179 @code{comment} environment provided by @file{comment.sty}.  It has to be
10180 activated by placing @code{\usepackage@{comment@}} into the document
10181 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
10182 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
10183 variable @code{orgtbl-radio-tables} to install templates for other
10184 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
10185 be prompted for a table name, let's say we use @samp{salesfigures}.  You
10186 will then get the following template:
10188 @cindex #+ORGTBL: SEND
10189 @example
10190 % BEGIN RECEIVE ORGTBL salesfigures
10191 % END RECEIVE ORGTBL salesfigures
10192 \begin@{comment@}
10193 #+ORGTBL: SEND salesfigures orgtbl-to-latex
10194 | | |
10195 \end@{comment@}
10196 @end example
10198 @noindent
10199 @vindex LaTeX-verbatim-environments
10200 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
10201 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
10202 into the receiver location with name @code{salesfigures}.  You may now
10203 fill in the table, feel free to use the spreadsheet features@footnote{If
10204 the @samp{#+TBLFM} line contains an odd number of dollar characters,
10205 this may cause problems with font-lock in LaTeX mode.  As shown in the
10206 example you can fix this by adding an extra line inside the
10207 @code{comment} environment that is used to balance the dollar
10208 expressions.  If you are using AUCTeX with the font-latex library, a
10209 much better solution is to add the @code{comment} environment to the
10210 variable @code{LaTeX-verbatim-environments}.}:
10212 @example
10213 % BEGIN RECEIVE ORGTBL salesfigures
10214 % END RECEIVE ORGTBL salesfigures
10215 \begin@{comment@}
10216 #+ORGTBL: SEND salesfigures orgtbl-to-latex
10217 | Month | Days | Nr sold | per day |
10218 |-------+------+---------+---------|
10219 | Jan   |   23 |      55 |     2.4 |
10220 | Feb   |   21 |      16 |     0.8 |
10221 | March |   22 |     278 |    12.6 |
10222 #+TBLFM: $4=$3/$2;%.1f
10223 % $ (optional extra dollar to keep font-lock happy, see footnote)
10224 \end@{comment@}
10225 @end example
10227 @noindent
10228 When you are done, press @kbd{C-c C-c} in the table to get the converted
10229 table inserted between the two marker lines.
10231 Now let's assume you want to make the table header by hand, because you
10232 want to control how columns are aligned etc.  In this case we make sure
10233 that the table translator does skip the first 2 lines of the source
10234 table, and tell the command to work as a @i{splice}, i.e. to not produce
10235 header and footer commands of the target table:
10237 @example
10238 \begin@{tabular@}@{lrrr@}
10239 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
10240 % BEGIN RECEIVE ORGTBL salesfigures
10241 % END RECEIVE ORGTBL salesfigures
10242 \end@{tabular@}
10244 \begin@{comment@}
10245 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
10246 | Month | Days | Nr sold | per day |
10247 |-------+------+---------+---------|
10248 | Jan   |   23 |      55 |     2.4 |
10249 | Feb   |   21 |      16 |     0.8 |
10250 | March |   22 |     278 |    12.6 |
10251 #+TBLFM: $4=$3/$2;%.1f
10252 \end@{comment@}
10253 @end example
10255 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
10256 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
10257 and marks horizontal lines with @code{\hline}.  Furthermore, it
10258 interprets the following parameters (see also @ref{Translator functions}):
10260 @table @code
10261 @item :splice nil/t
10262 When set to t, return only table body lines, don't wrap them into a
10263 tabular environment.  Default is nil.
10265 @item :fmt fmt
10266 A format to be used to wrap each field, should contain @code{%s} for the
10267 original field value.  For example, to wrap each field value in dollars,
10268 you could use @code{:fmt "$%s$"}.  This may also be a property list with
10269 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
10270 A function of one argument can be used in place of the strings; the
10271 function must return a formatted string.
10273 @item :efmt efmt
10274 Use this format to print numbers with exponentials.  The format should
10275 have @code{%s} twice for inserting mantissa and exponent, for example
10276 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
10277 may also be a property list with column numbers and formats, for example
10278 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
10279 @code{efmt} has been applied to a value, @code{fmt} will also be
10280 applied.  Similar to @code{fmt}, functions of two arguments can be
10281 supplied instead of strings.
10282 @end table
10284 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
10285 @subsection Translator functions
10286 @cindex HTML, and Orgtbl mode
10287 @cindex translator function
10289 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
10290 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
10291 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
10292 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
10293 code that produces tables during HTML export.}, these all use a generic
10294 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
10295 itself is a very short function that computes the column definitions for the
10296 @code{tabular} environment, defines a few field and line separators and then
10297 hands over to the generic translator.  Here is the entire code:
10299 @lisp
10300 @group
10301 (defun orgtbl-to-latex (table params)
10302   "Convert the Orgtbl mode TABLE to LaTeX."
10303   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
10304                                org-table-last-alignment ""))
10305          (params2
10306           (list
10307            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
10308            :tend "\\end@{tabular@}"
10309            :lstart "" :lend " \\\\" :sep " & "
10310            :efmt "%s\\,(%s)" :hline "\\hline")))
10311     (orgtbl-to-generic table (org-combine-plists params2 params))))
10312 @end group
10313 @end lisp
10315 As you can see, the properties passed into the function (variable
10316 @var{PARAMS}) are combined with the ones newly defined in the function
10317 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
10318 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
10319 would like to use the La@TeX{} translator, but wanted the line endings to
10320 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
10321 overrule the default with
10323 @example
10324 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
10325 @end example
10327 For a new language, you can either write your own converter function in
10328 analogy with the La@TeX{} translator, or you can use the generic function
10329 directly.  For example, if you have a language where a table is started
10330 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
10331 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
10332 separator is a TAB, you could call the generic translator like this (on
10333 a single line!):
10335 @example
10336 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
10337                               :lstart "!BL! " :lend " !EL!" :sep "\t"
10338 @end example
10340 @noindent
10341 Please check the documentation string of the function
10342 @code{orgtbl-to-generic} for a full list of parameters understood by
10343 that function and remember that you can pass each of them into
10344 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
10345 using the generic function.
10347 Of course you can also write a completely new function doing complicated
10348 things the generic translator cannot do.  A translator function takes
10349 two arguments.  The first argument is the table, a list of lines, each
10350 line either the symbol @code{hline} or a list of fields.  The second
10351 argument is the property list containing all parameters specified in the
10352 @samp{#+ORGTBL: SEND} line.  The function must return a single string
10353 containing the formatted table.  If you write a generally useful
10354 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
10355 others can benefit from your work.
10357 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
10358 @subsection Radio lists
10359 @cindex radio lists
10360 @cindex org-list-insert-radio-list
10362 Sending and receiving radio lists works exactly the same way than
10363 sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
10364 need to load the @code{org-export-latex.el} package to use radio lists
10365 since the relevant code is there for now.}.  As for radio tables, you
10366 can insert radio lists templates in HTML, La@TeX{} and Texinfo modes by
10367 calling @code{org-list-insert-radio-list}.
10369 Here are the differences with radio tables:
10371 @itemize @minus
10372 @item
10373 Use @code{ORGLST} instead of @code{ORGTBL}.
10374 @item
10375 The available translation functions for radio lists don't take
10376 parameters.
10377 @item
10378 `C-c C-c' will work when pressed on the first item of the list.
10379 @end itemize
10381 Here is a La@TeX{} example.  Let's say that you have this in your
10382 La@TeX{} file:
10384 @example
10385 % BEGIN RECEIVE ORGLST to-buy
10386 % END RECEIVE ORGLST to-buy
10387 \begin@{comment@}
10388 #+ORGLIST: SEND to-buy orgtbl-to-latex
10389 - a new house
10390 - a new computer
10391   + a new keyboard
10392   + a new mouse
10393 - a new life
10394 \end@{comment@}
10395 @end example
10397 Pressing `C-c C-c' on @code{a new house} and will insert the converted
10398 La@TeX{} list between the two marker lines.
10400 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
10401 @section Dynamic blocks
10402 @cindex dynamic blocks
10404 Org documents can contain @emph{dynamic blocks}.  These are
10405 specially marked regions that are updated by some user-written function.
10406 A good example for such a block is the clock table inserted by the
10407 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
10409 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
10410 to the block and can also specify parameters for the function producing
10411 the content of the block.
10413 #+BEGIN:dynamic block
10414 @example
10415 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
10417 #+END:
10418 @end example
10420 Dynamic blocks are updated with the following commands
10422 @table @kbd
10423 @kindex C-c C-x C-u
10424 @item C-c C-x C-u
10425 Update dynamic block at point.
10426 @kindex C-u C-c C-x C-u
10427 @item C-u C-c C-x C-u
10428 Update all dynamic blocks in the current file.
10429 @end table
10431 Updating a dynamic block means to remove all the text between BEGIN and
10432 END, parse the BEGIN line for parameters and then call the specific
10433 writer function for this block to insert the new content.  If you want
10434 to use the original content in the writer function, you can use the
10435 extra parameter @code{:content}.
10437 For a block with name @code{myblock}, the writer function is
10438 @code{org-dblock-write:myblock} with as only parameter a property list
10439 with the parameters given in the begin line.  Here is a trivial example
10440 of a block that keeps track of when the block update function was last
10441 run:
10443 @example
10444 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
10446 #+END:
10447 @end example
10449 @noindent
10450 The corresponding block writer function could look like this:
10452 @lisp
10453 (defun org-dblock-write:block-update-time (params)
10454    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
10455      (insert "Last block update at: "
10456              (format-time-string fmt (current-time)))))
10457 @end lisp
10459 If you want to make sure that all dynamic blocks are always up-to-date,
10460 you could add the function @code{org-update-all-dblocks} to a hook, for
10461 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
10462 written in a way that is does nothing in buffers that are not in
10463 @code{org-mode}.
10465 @node Special agenda views, Using the property API, Dynamic blocks, Hacking
10466 @section Special agenda views
10467 @cindex agenda views, user-defined
10469 Org provides a special hook that can be used to narrow down the
10470 selection made by any of the agenda views.  You may specify a function
10471 that is used at each match to verify if the match should indeed be part
10472 of the agenda view, and if not, how much should be skipped.
10474 Let's say you want to produce a list of projects that contain a WAITING
10475 tag anywhere in the project tree.  Let's further assume that you have
10476 marked all tree headings that define a project with the TODO keyword
10477 PROJECT.  In this case you would run a TODO search for the keyword
10478 PROJECT, but skip the match unless there is a WAITING tag anywhere in
10479 the subtree belonging to the project line.
10481 To achieve this, you must write a function that searches the subtree for
10482 the tag.  If the tag is found, the function must return @code{nil} to
10483 indicate that this match should not be skipped.  If there is no such
10484 tag, return the location of the end of the subtree, to indicate that
10485 search should continue from there.
10487 @lisp
10488 (defun my-skip-unless-waiting ()
10489   "Skip trees that are not waiting"
10490   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
10491     (if (re-search-forward ":waiting:" subtree-end t)
10492         nil          ; tag found, do not skip
10493       subtree-end))) ; tag not found, continue after end of subtree
10494 @end lisp
10496 Now you may use this function in an agenda custom command, for example
10497 like this:
10499 @lisp
10500 (org-add-agenda-custom-command
10501  '("b" todo "PROJECT"
10502    ((org-agenda-skip-function 'my-skip-unless-waiting)
10503     (org-agenda-overriding-header "Projects waiting for something: "))))
10504 @end lisp
10506 @vindex org-agenda-overriding-header
10507 Note that this also binds @code{org-agenda-overriding-header} to get a
10508 meaningful header in the agenda view.
10510 @vindex org-odd-levels-only
10511 @vindex org-agenda-skip-function
10512 A general way to create custom searches is to base them on a search for
10513 entries with a certain level limit.  If you want to study all entries with
10514 your custom search function, simply do a search for
10515 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
10516 level number corresponds to order in the hierarchy, not to the number of
10517 stars.}, and then use @code{org-agenda-skip-function} to select the entries
10518 you really want to have.
10520 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
10521 particular, you may use the functions @code{org-agenda-skip-entry-if}
10522 and @code{org-agenda-skip-subtree-if} in this form, for example:
10524 @table @code
10525 @item '(org-agenda-skip-entry-if 'scheduled)
10526 Skip current entry if it has been scheduled.
10527 @item '(org-agenda-skip-entry-if 'notscheduled)
10528 Skip current entry if it has not been scheduled.
10529 @item '(org-agenda-skip-entry-if 'deadline)
10530 Skip current entry if it has a deadline.
10531 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
10532 Skip current entry if it has a deadline, or if it is scheduled.
10533 @item '(org-agenda-skip-entry-if 'timestamp)
10534 Skip current entry if it has any timestamp, may also be deadline or scheduled.
10535 @item '(org-agenda-skip-entry 'regexp "regular expression")
10536 Skip current entry if the regular expression matches in the entry.
10537 @item '(org-agenda-skip-entry 'notregexp "regular expression")
10538 Skip current entry unless the regular expression matches.
10539 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
10540 Same as above, but check and skip the entire subtree.
10541 @end table
10543 Therefore we could also have written the search for WAITING projects
10544 like this, even without defining a special function:
10546 @lisp
10547 (org-add-agenda-custom-command
10548  '("b" todo "PROJECT"
10549    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
10550                                 'regexp ":waiting:"))
10551     (org-agenda-overriding-header "Projects waiting for something: "))))
10552 @end lisp
10554 @node Using the property API, Using the mapping API, Special agenda views, Hacking
10555 @section Using the property API
10556 @cindex API, for properties
10557 @cindex properties, API
10559 Here is a description of the functions that can be used to work with
10560 properties.
10562 @defun org-entry-properties &optional pom which
10563 Get all properties of the entry at point-or-marker POM.
10564 This includes the TODO keyword, the tags, time strings for deadline,
10565 scheduled, and clocking, and any additional properties defined in the
10566 entry.  The return value is an alist, keys may occur multiple times
10567 if the property key was used several times.
10568 POM may also be nil, in which case the current entry is used.
10569 If WHICH is nil or `all', get all properties.  If WHICH is
10570 `special' or `standard', only get that subclass.
10571 @end defun
10572 @vindex org-use-property-inheritance
10573 @defun org-entry-get pom property &optional inherit
10574 Get value of PROPERTY for entry at point-or-marker POM.  By default,
10575 this only looks at properties defined locally in the entry.  If INHERIT
10576 is non-nil and the entry does not have the property, then also check
10577 higher levels of the hierarchy.  If INHERIT is the symbol
10578 @code{selective}, use inheritance if and only if the setting of
10579 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
10580 @end defun
10582 @defun org-entry-delete pom property
10583 Delete the property PROPERTY from entry at point-or-marker POM.
10584 @end defun
10586 @defun org-entry-put pom property value
10587 Set PROPERTY to VALUE for entry at point-or-marker POM.
10588 @end defun
10590 @defun org-buffer-property-keys &optional include-specials
10591 Get all property keys in the current buffer.
10592 @end defun
10594 @defun org-insert-property-drawer
10595 Insert a property drawer at point.
10596 @end defun
10598 @defun org-entry-put-multivalued-property pom property &rest values
10599 Set PROPERTY at point-or-marker POM to VALUES.  VALUES should be a list of
10600 strings.  They will be concatenated, with spaces as separators.
10601 @end defun
10603 @defun org-entry-get-multivalued-property pom property
10604 Treat the value of the property PROPERTY as a whitespace-separated list of
10605 values and return the values as a list of strings.
10606 @end defun
10608 @defun org-entry-add-to-multivalued-property pom property value
10609 Treat the value of the property PROPERTY as a whitespace-separated list of
10610 values and make sure that VALUE is in this list.
10611 @end defun
10613 @defun org-entry-remove-from-multivalued-property pom property value
10614 Treat the value of the property PROPERTY as a whitespace-separated list of
10615 values and make sure that VALUE is @emph{not} in this list.
10616 @end defun
10618 @defun org-entry-member-in-multivalued-property pom property value
10619 Treat the value of the property PROPERTY as a whitespace-separated list of
10620 values and check if VALUE is in this list.
10621 @end defun
10623 @node Using the mapping API,  , Using the property API, Hacking
10624 @section Using the mapping API
10625 @cindex API, for mapping
10626 @cindex mapping entries, API
10628 Org has sophisticated mapping capabilities to find all entries satisfying
10629 certain criteria.  Internally, this functionality is used to produce agenda
10630 views, but there is also an API that can be used to execute arbitrary
10631 functions for each or selected entries.  The main entry point for this API
10634 @defun org-map-entries func &optional match scope &rest skip
10635 Call FUNC at each headline selected by MATCH in SCOPE.
10637 FUNC is a function or a lisp form.  The function will be called without
10638 arguments, with the cursor positioned at the beginning of the headline.
10639 The return values of all calls to the function will be collected and
10640 returned as a list.
10642 MATCH is a tags/property/todo match as it is used in the agenda match view.
10643 Only headlines that are matched by this query will be considered during
10644 the iteration.  When MATCH is nil or t, all headlines will be
10645 visited by the iteration.
10647 SCOPE determines the scope of this command.  It can be any of:
10649 @example
10650 nil     @r{the current buffer, respecting the restriction if any}
10651 tree    @r{the subtree started with the entry at point}
10652 file    @r{the current buffer, without restriction}
10653 file-with-archives
10654         @r{the current buffer, and any archives associated with it}
10655 agenda  @r{all agenda files}
10656 agenda-with-archives
10657         @r{all agenda files with any archive files associated with them}
10658 (file1 file2 ...)
10659         @r{if this is a list, all files in the list will be scanned}
10660 @end example
10662 The remaining args are treated as settings for the skipping facilities of
10663 the scanner.  The following items can be given here:
10665 @vindex org-agenda-skip-function
10666 @example
10667 archive   @r{skip trees with the archive tag}
10668 comment   @r{skip trees with the COMMENT keyword}
10669 function or Lisp form
10670           @r{will be used as value for @code{org-agenda-skip-function},}
10671           @r{so whenever the function returns t, FUNC}
10672           @r{will not be called for that entry and search will}
10673           @r{continue from the point where the function leaves it}
10674 @end example
10675 @end defun
10677 The function given to that mapping routine can really do anything you like.
10678 It can use the property API (@pxref{Using the property API}) to gather more
10679 information about the entry, or in order to change metadata in the entry.
10680 Here are a couple of functions that might be handy:
10682 @defun org-todo &optional arg
10683 Change the TODO state of the entry, see the docstring of the functions for
10684 the many possible values for the argument ARG.
10685 @end defun
10687 @defun org-priority &optional action
10688 Change the priority of the entry, see the docstring of this function for the
10689 possible values for ACTION.
10690 @end defun
10692 @defun org-toggle-tag tag &optional onoff
10693 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
10694 or @code{off} will not toggle tag, but ensure that it is either on or off.
10695 @end defun
10697 @defun org-promote
10698 Promote the current entry.
10699 @end defun
10701 @defun org-demote
10702 Demote the current entry.
10703 @end defun
10705 Here is a simple example that will turn all entries in the current file with
10706 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
10707 Entries in comment trees and in archive trees will be ignored.
10709 @lisp
10710 (org-map-entries
10711    '(org-todo "UPCOMING")
10712    "+TOMORROW" 'file 'archive 'comment)
10713 @end lisp
10715 The following example counts the number of entries with TODO keyword
10716 @code{WAITING}, in all agenda files.
10718 @lisp
10719 (length (org-map-entries t "/+WAITING" 'agenda))
10720 @end lisp
10722 @node History and Acknowledgments, Main Index, Hacking, Top
10723 @appendix History and Acknowledgments
10724 @cindex acknowledgments
10725 @cindex history
10726 @cindex thanks
10728 Org was borne in 2003, out of frustration over the user interface
10729 of the Emacs Outline mode.  I was trying to organize my notes and
10730 projects, and using Emacs seemed to be the natural way to go.  However,
10731 having to remember eleven different commands with two or three keys per
10732 command, only to hide and show parts of the outline tree, that seemed
10733 entirely unacceptable to me.  Also, when using outlines to take notes, I
10734 constantly want to restructure the tree, organizing it parallel to my
10735 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
10736 editing} were originally implemented in the package
10737 @file{outline-magic.el}, but quickly moved to the more general
10738 @file{org.el}.  As this environment became comfortable for project
10739 planning, the next step was adding @emph{TODO entries}, basic @emph{time
10740 stamps}, and @emph{table support}.  These areas highlight the two main
10741 goals that Org still has today: To create a new, outline-based,
10742 plain text mode with innovative and intuitive editing features, and to
10743 incorporate project planning functionality directly into a notes file.
10745 A special thanks goes to @i{Bastien Guerry} who has not only written a large
10746 number of extensions to Org (most of them integrated into the core by now),
10747 but has also helped the development and maintenance of Org so much that he
10748 should be considered the main co-contributor to this package.
10750 Since the first release, literally thousands of emails to me or on
10751 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
10752 reports, feedback, new ideas, and sometimes patches and add-on code.
10753 Many thanks to everyone who has helped to improve this package.  I am
10754 trying to keep here a list of the people who had significant influence
10755 in shaping one or more aspects of Org.  The list may not be
10756 complete, if I have forgotten someone, please accept my apologies and
10757 let me know.
10759 @itemize @bullet
10761 @item
10762 @i{Russel Adams} came up with the idea for drawers.
10763 @item
10764 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
10765 @item
10766 @i{Christophe Bataillon} created the great unicorn logo that we use on the
10767 Org-mode website.
10768 @item
10769 @i{Alex Bochannek} provided a patch for rounding time stamps.
10770 @item
10771 @i{Tom Breton} wrote @file{org-choose.el}.
10772 @item
10773 @i{Charles Cave}'s suggestion sparked the implementation of templates
10774 for Remember.
10775 @item
10776 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
10777 specified time.
10778 @item
10779 @i{Gregory Chernov} patched support for lisp forms into table
10780 calculations and improved XEmacs compatibility, in particular by porting
10781 @file{nouline.el} to XEmacs.
10782 @item
10783 @i{Sacha Chua} suggested to copy some linking code from Planner.
10784 @item
10785 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
10786 came up with the idea of properties, and that there should be an API for
10787 them.
10788 @item
10789 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
10790 inspired some of the early development, including HTML export.  He also
10791 asked for a way to narrow wide table columns.
10792 @item
10793 @i{Christian Egli} converted the documentation into Texinfo format,
10794 patched CSS formatting into the HTML exporter, and inspired the agenda.
10795 @item
10796 @i{David Emery} provided a patch for custom CSS support in exported
10797 HTML agendas.
10798 @item
10799 @i{Nic Ferrier} contributed mailcap and XOXO support.
10800 @item
10801 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
10802 @item
10803 @i{John Foerch} figured out how to make incremental search show context
10804 around a match in a hidden outline tree.
10805 @item
10806 @i{Niels Giesen} had the idea to automatically archive DONE trees.
10807 @item
10808 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
10809 has been prolific with patches, ideas, and bug reports.
10810 @item
10811 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
10812 @item
10813 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
10814 task state change logging, and the clocktable.  His clear explanations have
10815 been critical when we started to adopt the GIT version control system.
10816 @item
10817 @i{Manuel Hermenegildo} has contributed various ideas, small fixed and
10818 patches.
10819 @item
10820 @i{Phil Jackson} wrote @file{org-irc.el}.
10821 @item
10822 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
10823 folded entries, and column view for properties.
10824 @item
10825 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
10826 @item
10827 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
10828 provided frequent feedback and some patches.
10829 @item
10830 @i{Matt Lundin} has proposed last-row references for table formulas and named
10831 invisible anchors.  He has also worked a lot on the FAQ.
10832 @item
10833 @i{Jason F. McBrayer} suggested agenda export to CSV format.
10834 @item
10835 @i{Max Mikhanosha} came up with the idea of refiling.
10836 @item
10837 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
10838 basis.
10839 @item
10840 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
10841 happy.
10842 @item
10843 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
10844 and to be able to quickly restrict the agenda to a subtree.
10845 @item
10846 @i{Todd Neal} provided patches for links to Info files and elisp forms.
10847 @item
10848 @i{Tim O'Callaghan} suggested in-file links, search options for general
10849 file links, and TAGS.
10850 @item
10851 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
10852 into Japanese.
10853 @item
10854 @i{Oliver Oppitz} suggested multi-state TODO items.
10855 @item
10856 @i{Scott Otterson} sparked the introduction of descriptive text for
10857 links, among other things.
10858 @item
10859 @i{Pete Phillips} helped during the development of the TAGS feature, and
10860 provided frequent feedback.
10861 @item
10862 @i{Martin Pohlack} provided the code snippet to bundle character insertion
10863 into bundles of 20 for undo.
10864 @item
10865 @i{T.V. Raman} reported bugs and suggested improvements.
10866 @item
10867 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
10868 control.
10869 @item
10870 @i{Paul Rivier} provided the basic implementation of named footnotes.
10871 @item
10872 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
10873 @item
10874 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
10875 webpages derived from Org using an Info-like, or a folding interface with
10876 single key navigation.
10877 @item
10878 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
10879 conflict with @file{allout.el}.
10880 @item
10881 @i{Jason Riedy} generalized the send-receive mechanism for orgtbl tables with
10882 extensive patches.
10883 @item
10884 @i{Philip Rooke} created the Org reference card, provided lots
10885 of feedback, developed and applied standards to the Org documentation.
10886 @item
10887 @i{Christian Schlauer} proposed angular brackets around links, among
10888 other things.
10889 @item
10890 @i{Eric Schulte} wrote @file{org-plot.el}.
10891 @item
10892 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
10893 @file{organizer-mode.el}.
10894 @item
10895 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
10896 examples, and remote highlighting for referenced code lines.
10897 @item
10898 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
10899 now packaged into Org's @file{contrib} directory.
10900 @item
10901 @i{Daniel Sinder} came up with the idea of internal archiving by locking
10902 subtrees.
10903 @item
10904 @i{Dale Smith} proposed link abbreviations.
10905 @item
10906 @i{James TD Smith} has contributed a large number of patches for useful
10907 tweaks and features.
10908 @item
10909 @i{Adam Spiers} asked for global linking commands, inspired the link
10910 extension system, added support for mairix, and proposed the mapping API.
10911 @item
10912 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
10913 with links transformation to Org syntax.
10914 @item
10915 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
10916 chapter about publishing.
10917 @item
10918 @i{J@"urgen Vollmer} contributed code generating the table of contents
10919 in HTML output.
10920 @item
10921 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
10922 keyword.
10923 @item
10924 @i{David Wainberg} suggested archiving, and improvements to the linking
10925 system.
10926 @item
10927 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
10928 @file{muse.el}, which have some overlap with Org.  Initially the development
10929 of Org was fully independent because I was not aware of the existence of
10930 these packages.  But with time I have occasionally looked at John's code and
10931 learned a lot from it.  John has also contributed a number of great ideas and
10932 patches directly to Org, including the attachment system
10933 (@file{org-attach.el}), integration with Apple Mail
10934 (@file{org-mac-message.el}), and hierarchical dependencies of TODO items.
10935 @item
10936 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
10937 linking to Gnus.
10938 @item
10939 @i{Roland Winkler} requested additional key bindings to make Org
10940 work on a tty.
10941 @item
10942 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
10943 and contributed various ideas and code snippets.
10944 @end itemize
10947 @node Main Index, Key Index, History and Acknowledgments, Top
10948 @unnumbered Concept Index
10950 @printindex cp
10952 @node Key Index, Variable and Faces Index, Main Index, Top
10953 @unnumbered Key Index
10955 @printindex ky
10957 @node Variable and Faces Index,  , Key Index, Top
10958 @unnumbered Variable Index
10960 This is not a complete index of variables and faces, only the ones that are
10961 mentioned in the manual.  For a more complete list, use @kbd{M-x
10962 org-customize @key{RET}} and then klick yourself through the tree.
10964 @printindex vr
10966 @bye
10968 @ignore
10969         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
10970 @end ignore
10972 @c Local variables:
10973 @c ispell-local-dictionary: "en_US-w_accents"
10974 @c ispell-local-pdict: "./.aspell.org.pws"
10975 @c fill-column: 77
10976 @c End: