Release 6.30d
[org-mode.git] / doc / org.texi
blob7b0785226b4ce141bcdcd1897110a1a887e6e58c
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.30d
7 @set DATE September 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
19 @iftex
20 @c @hyphenation{time-stamp time-stamps time-stamp-ing time-stamp-ed}
21 @end iftex
22 @macro Ie {}
23 I.e.,
24 @end macro
25 @macro ie {}
26 i.e.,
27 @end macro
28 @macro Eg {}
29 E.g.,
30 @end macro
31 @macro eg {}
32 e.g.,
33 @end macro
35 @c Subheadings inside a table.
36 @macro tsubheading{text}
37 @ifinfo
38 @subsubheading \text\
39 @end ifinfo
40 @ifnotinfo
41 @item @b{\text\}
42 @end ifnotinfo
43 @end macro
45 @copying
46 This manual is for Org version @value{VERSION}.
48 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
50 @quotation
51 Permission is granted to copy, distribute and/or modify this document
52 under the terms of the GNU Free Documentation License, Version 1.3 or
53 any later version published by the Free Software Foundation; with no
54 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
55 and with the Back-Cover Texts as in (a) below.  A copy of the license
56 is included in the section entitled ``GNU Free Documentation License.''
58 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
59 modify this GNU manual.  Buying copies from the FSF supports it in
60 developing GNU and promoting software freedom.''
62 This document is part of a collection distributed under the GNU Free
63 Documentation License.  If you want to distribute this document
64 separately from the collection, you can do so by adding a copy of the
65 license to the document, as described in section 6 of the license.
66 @end quotation
67 @end copying
69 @dircategory Emacs
70 @direntry
71 * Org Mode: (org).      Outline-based notes management and organizer
72 @end direntry
74 @titlepage
75 @title The Org Manual
77 @subtitle Release @value{VERSION}
78 @author by Carsten Dominik
80 @c The following two commands start the copyright page.
81 @page
82 @vskip 0pt plus 1filll
83 @insertcopying
84 @end titlepage
86 @c Output the table of contents at the beginning.
87 @contents
89 @ifnottex
90 @node Top, Introduction, (dir), (dir)
91 @top Org Mode Manual
93 @insertcopying
94 @end ifnottex
96 @menu
97 * Introduction::                Getting started
98 * Document Structure::          A tree works like your brain
99 * Tables::                      Pure magic for quick formatting
100 * Hyperlinks::                  Notes in context
101 * TODO Items::                  Every tree branch can be a TODO item
102 * Tags::                        Tagging headlines and matching sets of tags
103 * Properties and Columns::      Storing information about an entry
104 * Dates and Times::             Making items useful for planning
105 * Capture::                     Creating tasks and attaching files
106 * Agenda Views::                Collecting information into views
107 * Embedded LaTeX::              LaTeX fragments and formulas
108 * Exporting::                   Sharing and publishing of notes
109 * Publishing::                  Create a web site of linked Org files
110 * Miscellaneous::               All the rest which did not fit elsewhere
111 * Hacking::                     How to hack your way around
112 * History and Acknowledgments::  How Org came into being
113 * Main Index::                  An index of Org's concepts and features
114 * Key Index::                   Key bindings and where they are described
115 * Variable Index::              Variables mentioned in the manual
117 @detailmenu
118  --- The Detailed Node Listing ---
120 Introduction
122 * Summary::                     Brief summary of what Org does
123 * Installation::                How to install a downloaded version of Org
124 * Activation::                  How to activate Org for certain buffers
125 * Feedback::                    Bug reports, ideas, patches etc.
126 * Conventions::                 Type-setting conventions in the manual
128 Document Structure
130 * Outlines::                    Org is based on Outline mode
131 * Headlines::                   How to typeset Org tree headlines
132 * Visibility cycling::          Show and hide, much simplified
133 * Motion::                      Jumping to other headlines
134 * Structure editing::           Changing sequence and level of headlines
135 * Archiving::                   Move done task trees to a different place
136 * Sparse trees::                Matches embedded in context
137 * Plain lists::                 Additional structure within an entry
138 * Drawers::                     Tucking stuff away
139 * Blocks::                      Folding blocks
140 * Footnotes::                   How footnotes are defined in Org's syntax
141 * Orgstruct mode::              Structure editing outside Org
143 Archiving
145 * ARCHIVE tag::                 Marking a tree as inactive
146 * Moving subtrees::             Moving a tree to an archive file
148 Tables
150 * Built-in table editor::       Simple tables
151 * Column width and alignment::  Overrule the automatic settings
152 * Column groups::               Grouping to trigger vertical lines
153 * Orgtbl mode::                 The table editor as minor mode
154 * The spreadsheet::             The table editor has spreadsheet capabilities
155 * Org-Plot::                    Plotting from org tables
157 The spreadsheet
159 * References::                  How to refer to another field or range
160 * Formula syntax for Calc::     Using Calc to compute stuff
161 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
162 * Field formulas::              Formulas valid for a single field
163 * Column formulas::             Formulas valid for an entire column
164 * Editing and debugging formulas::  Fixing formulas
165 * Updating the table::          Recomputing all dependent fields
166 * Advanced features::           Field names, parameters and automatic recalc
168 Hyperlinks
170 * Link format::                 How links in Org are formatted
171 * Internal links::              Links to other places in the current file
172 * External links::              URL-like links to the world
173 * Handling links::              Creating, inserting and following
174 * Using links outside Org::     Linking from my C source code?
175 * Link abbreviations::          Shortcuts for writing complex links
176 * Search options::              Linking to a specific location
177 * Custom searches::             When the default search is not enough
179 Internal links
181 * Radio targets::               Make targets trigger links in plain text
183 TODO Items
185 * TODO basics::                 Marking and displaying TODO entries
186 * TODO extensions::             Workflow and assignments
187 * Progress logging::            Dates and notes for progress
188 * Priorities::                  Some things are more important than others
189 * Breaking down tasks::         Splitting a task into manageable pieces
190 * Checkboxes::                  Tick-off lists
192 Extended use of TODO keywords
194 * Workflow states::             From TODO to DONE in steps
195 * TODO types::                  I do this, Fred does the rest
196 * Multiple sets in one file::   Mixing it all, and still finding your way
197 * Fast access to TODO states::  Single letter selection of a state
198 * Per-file keywords::           Different files, different requirements
199 * Faces for TODO keywords::     Highlighting states
200 * TODO dependencies::           When one task needs to wait for others
202 Progress logging
204 * Closing items::               When was this entry marked DONE?
205 * Tracking TODO state changes::  When did the status change?
207 Tags
209 * Tag inheritance::             Tags use the tree structure of the outline
210 * Setting tags::                How to assign tags to a headline
211 * Tag searches::                Searching for combinations of tags
213 Properties and Columns
215 * Property syntax::             How properties are spelled out
216 * Special properties::          Access to other Org mode features
217 * Property searches::           Matching property values
218 * Property inheritance::        Passing values down the tree
219 * Column view::                 Tabular viewing and editing
220 * Property API::                Properties for Lisp programmers
222 Column view
224 * Defining columns::            The COLUMNS format property
225 * Using column view::           How to create and use column view
226 * Capturing column view::       A dynamic block for column view
228 Defining columns
230 * Scope of column definitions::  Where defined, where valid?
231 * Column attributes::           Appearance and content of a column
233 Dates and Times
235 * Timestamps::                  Assigning a time to a tree entry
236 * Creating timestamps::         Commands which insert timestamps
237 * Deadlines and scheduling::    Planning your work
238 * Clocking work time::          Tracking how long you spend on a task
239 * Effort estimates::            Planning work effort in advance
240 * Relative timer::              Notes with a running timer
242 Creating timestamps
244 * The date/time prompt::        How Org mode helps you entering date and time
245 * Custom time format::          Making dates look different
247 Deadlines and scheduling
249 * Inserting deadline/schedule::  Planning items
250 * Repeated tasks::              Items that show up again and again
252 Capture
254 * Remember::                    Capture new tasks/ideas with little interruption
255 * Attachments::                 Add files to tasks.
256 * RSS Feeds::                   Getting input from RSS feeds
257 * Protocols::                   External (@eg Browser) access to Emacs and Org
259 Remember
261 * Setting up Remember for Org:: Some code for .emacs to get things going
262 * Remember templates::          Define the outline of different note types
263 * Storing notes::               Directly get the note to where it belongs
264 * Refiling notes::              Moving a note or task to a project
266 Agenda Views
268 * Agenda files::                Files being searched for agenda information
269 * Agenda dispatcher::           Keyboard access to agenda views
270 * Built-in agenda views::       What is available out of the box?
271 * Presentation and sorting::    How agenda items are prepared for display
272 * Agenda commands::             Remote editing of Org trees
273 * Custom agenda views::         Defining special searches and views
274 * Exporting Agenda Views::
275 * Agenda column view::          Using column view for collected entries
277 The built-in agenda views
279 * Weekly/daily agenda::         The calendar page with current tasks
280 * Global TODO list::            All unfinished action items
281 * Matching tags and properties::  Structured information with fine-tuned search
282 * Timeline::                    Time-sorted view for single file
283 * Keyword search::              Finding entries by keyword
284 * Stuck projects::              Find projects you need to review
286 Presentation and sorting
288 * Categories::                  Not all tasks are equal
289 * Time-of-day specifications::  How the agenda knows the time
290 * Sorting of agenda items::     The order of things
292 Custom agenda views
294 * Storing searches::            Type once, use often
295 * Block agenda::                All the stuff you need in a single buffer
296 * Setting Options::             Changing the rules
298 Embedded La@TeX{}
300 * Math symbols::                @TeX{} macros for symbols and Greek letters
301 * Subscripts and superscripts::  Simple syntax for raising/lowering text
302 * LaTeX fragments::             Complex formulas made easy
303 * Processing LaTeX fragments::  Previewing La@TeX{} processing
304 * CDLaTeX mode::                Speed up entering of formulas
306 Exporting
308 * Markup rules::                Which structures are recognized?
309 * Selective export::            Using tags to select and exclude trees
310 * Export options::              Per-file export settings
311 * The export dispatcher::       How to access exporter commands
312 * ASCII export::                Exporting to plain ASCII
313 * HTML export::                 Exporting to HTML
314 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
315 * DocBook export::              Exporting to DocBook
316 * XOXO export::                 Exporting to XOXO
317 * iCalendar export::            Exporting in iCalendar format
319 Markup rules
321 * Document title::              How the document title is determined
322 * Headings and sections::       The main structure of the exported document
323 * Table of contents::           If, where, how to create a table of contents
324 * Initial text::                Text before the first headline
325 * Lists::                       Plain lists are exported
326 * Paragraphs::                  What determines beginning and ending
327 * Literal examples::            Source code and other examples
328 * Include files::               Include the contents of a file during export
329 * Tables exported::             Tables are exported richly
330 * Inlined images::              How to inline images during export
331 * Footnote markup::             ASCII representation of footnotes
332 * Emphasis and monospace::      To bold or not to bold
333 * TeX macros and LaTeX fragments::  Create special, rich export.
334 * Horizontal rules::            A line across the page
335 * Comment lines::               Some lines will not be exported
336 * Macro replacement::           Global replacement of place holders
338 HTML export
340 * HTML Export commands::        How to invoke HTML export
341 * Quoting HTML tags::           Using direct HTML in Org mode
342 * Links::                       Transformation of links for HTML
343 * Tables in HTML export::       How to modify the formatting of tables
344 * Images in HTML export::       How to insert figures into HTML output
345 * Text areas in HTML export::   An alternative way to show an example
346 * CSS support::                 Changing the appearance of the output
347 * Javascript support::          Info and Folding in a web browser
349 La@TeX{} and PDF export
351 * LaTeX/PDF export commands::   Which key invokes which commands
352 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
353 * Sectioning structure::        Changing sectioning in La@TeX{} output
354 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
355 * Images in LaTeX export::      How to insert figures into La@TeX{} output
357 DocBook export
359 * DocBook export commands::     How to invoke DocBook export
360 * Quoting DocBook code::        Incorporating DocBook code in Org files
361 * Recursive sections::          Recursive sections in DocBook
362 * Tables in DocBook export::    Tables are exported as HTML tables
363 * Images in DocBook export::    How to insert figures into DocBook output
364 * Special characters::          How to handle special characters
366 Publishing
368 * Configuration::               Defining projects
369 * Uploading files::             How to get files up on the server
370 * Sample configuration::        Example projects
371 * Triggering publication::      Publication commands
373 Configuration
375 * Project alist::               The central configuration variable
376 * Sources and destinations::    From here to there
377 * Selecting files::             What files are part of the project?
378 * Publishing action::           Setting the function doing the publishing
379 * Publishing options::          Tweaking HTML export
380 * Publishing links::            Which links keep working after publishing?
381 * Project page index::          Publishing a list of project files
383 Sample configuration
385 * Simple example::              One-component publishing
386 * Complex example::             A multi-component publishing example
388 Miscellaneous
390 * Completion::                  M-TAB knows what you need
391 * Customization::               Adapting Org to your taste
392 * In-buffer settings::          Overview of the #+KEYWORDS
393 * The very busy C-c C-c key::   When in doubt, press C-c C-c
394 * Clean view::                  Getting rid of leading stars in the outline
395 * TTY keys::                    Using Org on a tty
396 * Interaction::                 Other Emacs packages
398 Interaction with other packages
400 * Cooperation::                 Packages Org cooperates with
401 * Conflicts::                   Packages that lead to conflicts
403 Hacking
405 * Hooks::                       Who to reach into Org's internals
406 * Add-on packages::             Available extensions
407 * Adding hyperlink types::      New custom link types
408 * Context-sensitive commands::  How to add functionality to such commands
409 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
410 * Dynamic blocks::              Automatically filled blocks
411 * Special agenda views::        Customized views
412 * Extracting agenda information::  Postprocessing of agenda information
413 * Using the property API::      Writing programs that use entry properties
414 * Using the mapping API::       Mapping over all or selected entries
416 Tables and lists in arbitrary syntax
418 * Radio tables::                Sending and receiving radio tables
419 * A LaTeX example::             Step by step, almost a tutorial
420 * Translator functions::        Copy and modify
421 * Radio lists::                 Doing the same for lists
423 @end detailmenu
424 @end menu
426 @node Introduction, Document Structure, Top, Top
427 @chapter Introduction
428 @cindex introduction
430 @menu
431 * Summary::                     Brief summary of what Org does
432 * Installation::                How to install a downloaded version of Org
433 * Activation::                  How to activate Org for certain buffers
434 * Feedback::                    Bug reports, ideas, patches etc.
435 * Conventions::                 Type-setting conventions in the manual
436 @end menu
438 @node Summary, Installation, Introduction, Introduction
439 @section Summary
440 @cindex summary
442 Org is a mode for keeping notes, maintaining TODO lists, and doing
443 project planning with a fast and effective plain-text system.
445 Org develops organizational tasks around NOTES files that contain
446 lists or information about projects as plain text.  Org is
447 implemented on top of Outline mode, which makes it possible to keep the
448 content of large files well structured.  Visibility cycling and
449 structure editing help to work with the tree.  Tables are easily created
450 with a built-in table editor.  Org supports TODO items, deadlines,
451 timestamps, and scheduling.  It dynamically compiles entries into an
452 agenda that utilizes and smoothly integrates much of the Emacs calendar
453 and diary.  Plain text URL-like links connect to websites, emails,
454 Usenet messages, BBDB entries, and any files related to the projects.
455 For printing and sharing of notes, an Org file can be exported as a
456 structured ASCII file, as HTML, or (TODO and agenda items only) as an
457 iCalendar file.  It can also serve as a publishing tool for a set of
458 linked web pages.
460 An important design aspect that distinguishes Org from, for example,
461 Planner/Muse is that it encourages you to store every piece of information
462 only once.  In Planner, you have project pages, day pages and possibly
463 other files, duplicating some information such as tasks.  In Org,
464 you only have notes files.  In your notes you mark entries as tasks, and
465 label them with tags and timestamps.  All necessary lists, like a
466 schedule for the day, the agenda for a meeting, tasks lists selected by
467 tags, etc., are created dynamically when you need them.
469 Org keeps simple things simple.  When first fired up, it should
470 feel like a straightforward, easy to use outliner.  Complexity is not
471 imposed, but a large amount of functionality is available when you need
472 it.  Org is a toolbox and can be used in different ways, for
473 example as:
475 @example
476 @r{@bullet{} an outline extension with visibility cycling and structure editing}
477 @r{@bullet{} an ASCII system and table editor for taking structured notes}
478 @r{@bullet{} an ASCII table editor with spreadsheet-like capabilities}
479 @r{@bullet{} a TODO list editor}
480 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
481 @pindex GTD, Getting Things Done
482 @r{@bullet{} an environment to implement David Allen's GTD system}
483 @r{@bullet{} a basic database application}
484 @r{@bullet{} a simple hypertext system, with HTML and La@TeX{} export}
485 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
486 @end example
488 Org's automatic, context-sensitive table editor with spreadsheet
489 capabilities can be integrated into any major mode by activating the
490 minor Orgtbl mode.  Using a translation step, it can be used to maintain
491 tables in arbitrary file types, for example in La@TeX{}.  The structure
492 editing and list creation capabilities can be used outside Org with
493 the minor Orgstruct mode.
495 @cindex FAQ
496 There is a website for Org which provides links to the newest
497 version of Org, as well as additional information, frequently asked
498 questions (FAQ), links to tutorials, etc@.  This page is located at
499 @uref{http://orgmode.org}.
501 @page
504 @node Installation, Activation, Summary, Introduction
505 @section Installation
506 @cindex installation
507 @cindex XEmacs
509 @b{Important:} @i{If Org is part of the Emacs distribution or an
510 XEmacs package, please skip this section and go directly to
511 @ref{Activation}.}
513 If you have downloaded Org from the Web, either as a distribution @file{.zip}
514 or @file{.tar} file, or as a Git archive, you must take the following steps
515 to install it: go into the unpacked Org distribution directory and edit the
516 top section of the file @file{Makefile}.  You must set the name of the Emacs
517 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
518 directories where local Lisp and Info files are kept.  If you don't have
519 access to the system-wide directories, you can simply run Org directly from
520 the distribution directory by adding the @file{lisp} subdirectory to the
521 Emacs load path.  To do this, add the following line to @file{.emacs}:
523 @example
524 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
525 @end example
527 @noindent
528 If you plan to use code from the @file{contrib} subdirectory, do a similar
529 step for this directory:
531 @example
532 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
533 @end example
535 @b{XEmacs users now need to install the file @file{noutline.el} from
536 the @file{xemacs} sub-directory of the Org distribution.  Use the
537 command:}
539 @example
540 @b{make install-noutline}
541 @end example
543 @noindent Now byte-compile the Lisp files with the shell command:
545 @example
546 make
547 @end example
549 @noindent If you are running Org from the distribution directory, this is
550 all.  If you want to install Org into the system directories, use (as
551 administrator)
553 @example
554 make install
555 @end example
557 Installing Info files is system dependent, because of differences in the
558 @file{install-info} program.  In Debian it copies the info files into the
559 correct directory and modifies the info directory file.  In many other
560 systems, the files need to be copied to the correct directory separately, and
561 @file{install-info} then only modifies the directory file.  Check your system
562 documentation to find out which of the following commands you need:
564 @example
565 make install-info
566 make install-info-debian
567 @end example
569 @noindent Then add to @file{.emacs}:
571 @lisp
572 ;; This line only if Org is not part of the X/Emacs distribution.
573 (require 'org-install)
574 @end lisp
576 Do not forget to activate Org as described in the following section.
578 @node Activation, Feedback, Installation, Introduction
579 @section Activation
580 @cindex activation
581 @cindex autoload
582 @cindex global key bindings
583 @cindex key bindings, global
585 @iftex
586 @b{Important:} @i{If you use copy-and-paste to copy Lisp code from the
587 PDF documentation as viewed by some PDF viewers to your @file{.emacs} file, the
588 single-quote character comes out incorrectly and the code will not work.
589 You need to fix the single-quotes by hand, or copy from Info
590 documentation.}
591 @end iftex
593 Add the following lines to your @file{.emacs} file.  The last three lines
594 define @emph{global} keys for the commands @command{org-store-link},
595 @command{org-agenda}, and @command{org-iswitchb}---please choose suitable
596 keys yourself.
598 @lisp
599 ;; The following lines are always needed.  Choose your own keys.
600 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
601 (global-set-key "\C-cl" 'org-store-link)
602 (global-set-key "\C-ca" 'org-agenda)
603 (global-set-key "\C-cb" 'org-iswitchb)
604 @end lisp
606 Furthermore, you must activate @code{font-lock-mode} in Org
607 buffers, because significant functionality depends on font-locking being
608 active.  You can do this with either one of the following two lines
609 (XEmacs users must use the second option):
610 @lisp
611 (global-font-lock-mode 1)                     ; for all buffers
612 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
613 @end lisp
615 @cindex Org mode, turning on
616 With this setup, all files with extension @samp{.org} will be put
617 into Org mode.  As an alternative, make the first line of a file look
618 like this:
620 @example
621 MY PROJECTS    -*- mode: org; -*-
622 @end example
624 @vindex org-insert-mode-line-in-empty-file
625 @noindent which will select Org mode for this buffer no matter what
626 the file's name is.  See also the variable
627 @code{org-insert-mode-line-in-empty-file}.
629 Many commands in Org work on the region if the region is @i{active}.  To make
630 use of this, you need to have @code{transient-mark-mode}
631 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
632 in Emacs 22 you need to do this yourself with
633 @lisp
634 (transient-mark-mode 1)
635 @end lisp
636 @noindent If you do not like @code{transient-mark-mode}, you can create an
637 active region by using the mouse to select a region, or pressing
638 @kbd{C-@key{SPC}} twice before moving the cursor.
640 @node Feedback, Conventions, Activation, Introduction
641 @section Feedback
642 @cindex feedback
643 @cindex bug reports
644 @cindex maintainer
645 @cindex author
647 If you find problems with Org, or if you have questions, remarks, or ideas
648 about it, please mail to the Org mailing list @email{emacs-orgmode@@gnu.org}.
649 If you are not a member of the mailing list, your mail will be passed to the
650 list after a moderator has approved it.
652 For bug reports, please provide as much information as possible, including
653 the version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
654 (@kbd{M-x org-version @key{RET}}), as well as the Org related setup in
655 @file{.emacs}.  The easiest way to do this is to use the command
656 @example
657 @kbd{M-x org-submit-bug-report}
658 @end example
659 @noindent which will put all this information into an Emacs mail buffer so
660 that you only need to add your description.  If you re not sending the Email
661 from within Emacs, please copy and paste the content into your Email program.
663 If an error occurs, a backtrace can be very useful (see below on how to
664 create one).  Often a small example file helps, along with clear information
665 about:
667 @enumerate
668 @item What exactly did you do?
669 @item What did you expect to happen?
670 @item What happened instead?
671 @end enumerate
672 @noindent Thank you for helping to improve this mode.
674 @subsubheading How to create a useful backtrace
676 @cindex backtrace of an error
677 If working with Org produces an error with a message you don't
678 understand, you may have hit a bug.  The best way to report this is by
679 providing, in addition to what was mentioned above, a @emph{backtrace}.
680 This is information from the built-in debugger about where and how the
681 error occurred.  Here is how to produce a useful backtrace:
683 @enumerate
684 @item
685 Reload uncompiled versions of all Org-mode Lisp files.  The backtrace
686 contains much more information if it is produced with uncompiled code.
687 To do this, use
688 @example
689 C-u M-x org-reload RET
690 @end example
691 @noindent
692 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
693 menu.
694 @item
695 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
696 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
697 @item
698 Do whatever you have to do to hit the error.  Don't forget to
699 document the steps you take.
700 @item
701 When you hit the error, a @file{*Backtrace*} buffer will appear on the
702 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
703 attach it to your bug report.
704 @end enumerate
706 @node Conventions,  , Feedback, Introduction
707 @section Typesetting conventions used in this manual
709 Org uses three types of keywords: TODO keywords, tags, and property
710 names.  In this manual we use the following conventions:
712 @table @code
713 @item TODO
714 @itemx WAITING
715 TODO keywords are written with all capitals, even if they are
716 user-defined.
717 @item boss
718 @itemx ARCHIVE
719 User-defined tags are written in lowercase; built-in tags with special
720 meaning are written with all capitals.
721 @item Release
722 @itemx PRIORITY
723 User-defined properties are capitalized; built-in properties with
724 special meaning are written with all capitals.
725 @end table
727 @node Document Structure, Tables, Introduction, Top
728 @chapter Document Structure
729 @cindex document structure
730 @cindex structure of document
732 Org is based on Outline mode and provides flexible commands to
733 edit the structure of the document.
735 @menu
736 * Outlines::                    Org is based on Outline mode
737 * Headlines::                   How to typeset Org tree headlines
738 * Visibility cycling::          Show and hide, much simplified
739 * Motion::                      Jumping to other headlines
740 * Structure editing::           Changing sequence and level of headlines
741 * Archiving::                   Move done task trees to a different place
742 * Sparse trees::                Matches embedded in context
743 * Plain lists::                 Additional structure within an entry
744 * Drawers::                     Tucking stuff away
745 * Blocks::                      Folding blocks
746 * Footnotes::                   How footnotes are defined in Org's syntax
747 * Orgstruct mode::              Structure editing outside Org
748 @end menu
750 @node Outlines, Headlines, Document Structure, Document Structure
751 @section Outlines
752 @cindex outlines
753 @cindex Outline mode
755 Org is implemented on top of Outline mode.  Outlines allow a
756 document to be organized in a hierarchical structure, which (at least
757 for me) is the best representation of notes and thoughts.  An overview
758 of this structure is achieved by folding (hiding) large parts of the
759 document to show only the general document structure and the parts
760 currently being worked on.  Org greatly simplifies the use of
761 outlines by compressing the entire show/hide functionality into a single
762 command, @command{org-cycle}, which is bound to the @key{TAB} key.
764 @node Headlines, Visibility cycling, Outlines, Document Structure
765 @section Headlines
766 @cindex headlines
767 @cindex outline tree
768 @vindex org-special-ctrl-a/e
770 Headlines define the structure of an outline tree.  The headlines in
771 Org start with one or more stars, on the left margin@footnote{See
772 the variable @code{org-special-ctrl-a/e} to configure special behavior
773 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
775 @example
776 * Top level headline
777 ** Second level
778 *** 3rd level
779     some text
780 *** 3rd level
781     more text
783 * Another top level headline
784 @end example
786 @noindent Some people find the many stars too noisy and would prefer an
787 outline that has whitespace followed by a single star as headline
788 starters.  @ref{Clean view}, describes a setup to realize this.
790 @vindex org-cycle-separator-lines
791 An empty line after the end of a subtree is considered part of it and
792 will be hidden when the subtree is folded.  However, if you leave at
793 least two empty lines, one empty line will remain visible after folding
794 the subtree, in order to structure the collapsed view.  See the
795 variable @code{org-cycle-separator-lines} to modify this behavior.
797 @node Visibility cycling, Motion, Headlines, Document Structure
798 @section Visibility cycling
799 @cindex cycling, visibility
800 @cindex visibility cycling
801 @cindex trees, visibility
802 @cindex show hidden text
803 @cindex hide text
805 Outlines make it possible to hide parts of the text in the buffer.
806 Org uses just two commands, bound to @key{TAB} and
807 @kbd{S-@key{TAB}} to change the visibility in the buffer.
809 @cindex subtree visibility states
810 @cindex subtree cycling
811 @cindex folded, subtree visibility state
812 @cindex children, subtree visibility state
813 @cindex subtree, subtree visibility state
814 @table @kbd
815 @kindex @key{TAB}
816 @item @key{TAB}
817 @emph{Subtree cycling}: Rotate current subtree among the states
819 @example
820 ,-> FOLDED -> CHILDREN -> SUBTREE --.
821 '-----------------------------------'
822 @end example
824 @vindex org-cycle-emulate-tab
825 @vindex org-cycle-global-at-bob
826 The cursor must be on a headline for this to work@footnote{see, however,
827 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
828 beginning of the buffer and the first line is not a headline, then
829 @key{TAB} actually runs global cycling (see below)@footnote{see the
830 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
831 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
833 @cindex global visibility states
834 @cindex global cycling
835 @cindex overview, global visibility state
836 @cindex contents, global visibility state
837 @cindex show all, global visibility state
838 @kindex S-@key{TAB}
839 @item S-@key{TAB}
840 @itemx C-u @key{TAB}
841 @emph{Global cycling}: Rotate the entire buffer among the states
843 @example
844 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
845 '--------------------------------------'
846 @end example
848 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
849 CONTENTS view up to headlines of level N will be shown.  Note that inside
850 tables, @kbd{S-@key{TAB}} jumps to the previous field.
852 @cindex show all, command
853 @kindex C-u C-u C-u @key{TAB}
854 @item C-u C-u C-u @key{TAB}
855 Show all, including drawers.
856 @kindex C-c C-r
857 @item C-c C-r
858 Reveal context around point, showing the current entry, the following heading
859 and the hierarchy above.  Useful for working near a location that has been
860 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
861 (@pxref{Agenda commands}).  With a prefix argument show, on each
862 level, all sibling headings.
863 @kindex C-c C-x b
864 @item C-c C-x b
865 Show the current subtree in an indirect buffer@footnote{The indirect
866 buffer
867 @ifinfo
868 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
869 @end ifinfo
870 @ifnotinfo
871 (see the Emacs manual for more information about indirect buffers)
872 @end ifnotinfo
873 will contain the entire buffer, but will be narrowed to the current
874 tree.  Editing the indirect buffer will also change the original buffer,
875 but without affecting visibility in that buffer.}.  With a numeric
876 prefix argument N, go up to level N and then take that tree.  If N is
877 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
878 the previously used indirect buffer.
879 @end table
881 @vindex org-startup-folded
882 @cindex @code{overview}, STARTUP keyword
883 @cindex @code{content}, STARTUP keyword
884 @cindex @code{showall}, STARTUP keyword
886 When Emacs first visits an Org file, the global state is set to
887 OVERVIEW, @ie only the top level headlines are visible.  This can be
888 configured through the variable @code{org-startup-folded}, or on a
889 per-file basis by adding one of the following lines anywhere in the
890 buffer:
892 @example
893 #+STARTUP: overview
894 #+STARTUP: content
895 #+STARTUP: showall
896 @end example
898 @cindex property, VISIBILITY
899 @noindent
900 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
901 and Columns}) will get their visibility adapted accordingly.  Allowed values
902 for this property are @code{folded}, @code{children}, @code{content}, and
903 @code{all}.
904 @table @kbd
905 @kindex C-u C-u @key{TAB}
906 @item C-u C-u @key{TAB}
907 Switch back to the startup visibility of the buffer, @ie whatever is
908 requested by startup options and @samp{VISIBILITY} properties in individual
909 entries.
910 @end table
912 @node Motion, Structure editing, Visibility cycling, Document Structure
913 @section Motion
914 @cindex motion, between headlines
915 @cindex jumping, to headlines
916 @cindex headline navigation
917 The following commands jump to other headlines in the buffer.
919 @table @kbd
920 @kindex C-c C-n
921 @item C-c C-n
922 Next heading.
923 @kindex C-c C-p
924 @item C-c C-p
925 Previous heading.
926 @kindex C-c C-f
927 @item C-c C-f
928 Next heading same level.
929 @kindex C-c C-b
930 @item C-c C-b
931 Previous heading same level.
932 @kindex C-c C-u
933 @item C-c C-u
934 Backward to higher level heading.
935 @kindex C-c C-j
936 @item C-c C-j
937 Jump to a different place without changing the current outline
938 visibility.  Shows the document structure in a temporary buffer, where
939 you can use the following keys to find your destination:
940 @vindex org-goto-auto-isearch
941 @example
942 @key{TAB}         @r{Cycle visibility.}
943 @key{down} / @key{up}   @r{Next/previous visible headline.}
944 @key{RET}         @r{Select this location.}
945 @kbd{/}           @r{Do a Sparse-tree search}
946 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
947 n / p        @r{Next/previous visible headline.}
948 f / b        @r{Next/previous headline same level.}
949 u            @r{One level up.}
950 0-9          @r{Digit argument.}
951 q            @r{Quit}
952 @end example
953 @vindex org-goto-interface
954 @noindent
955 See also the variable @code{org-goto-interface}.
956 @end table
958 @node Structure editing, Archiving, Motion, Document Structure
959 @section Structure editing
960 @cindex structure editing
961 @cindex headline, promotion and demotion
962 @cindex promotion, of subtrees
963 @cindex demotion, of subtrees
964 @cindex subtree, cut and paste
965 @cindex pasting, of subtrees
966 @cindex cutting, of subtrees
967 @cindex copying, of subtrees
968 @cindex sorting, of subtrees
969 @cindex subtrees, cut and paste
971 @table @kbd
972 @kindex M-@key{RET}
973 @item M-@key{RET}
974 @vindex org-M-RET-may-split-line
975 Insert new heading with same level as current.  If the cursor is in a
976 plain list item, a new item is created (@pxref{Plain lists}).  To force
977 creation of a new headline, use a prefix argument, or first press @key{RET}
978 to get to the beginning of the next line.  When this command is used in
979 the middle of a line, the line is split and the rest of the line becomes
980 the new headline@footnote{If you do not want the line to be split,
981 customize the variable @code{org-M-RET-may-split-line}.}.  If the
982 command is used at the beginning of a headline, the new headline is
983 created before the current line.  If at the beginning of any other line,
984 the content of that line is made the new heading.  If the command is
985 used at the end of a folded subtree (@ie behind the ellipses at the end
986 of a headline), then a headline like the current one will be inserted
987 after the end of the subtree.
988 @kindex C-@key{RET}
989 @item C-@key{RET}
990 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
991 current heading, the new heading is placed after the body instead of before
992 it.  This command works from anywhere in the entry.
993 @kindex M-S-@key{RET}
994 @item M-S-@key{RET}
995 @vindex org-treat-insert-todo-heading-as-state-change
996 Insert new TODO entry with same level as current heading.  See also the
997 variable @code{org-treat-insert-todo-heading-as-state-change}.
998 @kindex C-S-@key{RET}
999 @item C-S-@key{RET}
1000 Insert new TODO entry with same level as current heading.  Like
1001 @kbd{C-@key{RET}}, the new headline will be inserted after the current
1002 subtree.
1003 @kindex M-@key{left}
1004 @item M-@key{left}
1005 Promote current heading by one level.
1006 @kindex M-@key{right}
1007 @item M-@key{right}
1008 Demote current heading by one level.
1009 @kindex M-S-@key{left}
1010 @item M-S-@key{left}
1011 Promote the current subtree by one level.
1012 @kindex M-S-@key{right}
1013 @item M-S-@key{right}
1014 Demote the current subtree by one level.
1015 @kindex M-S-@key{up}
1016 @item M-S-@key{up}
1017 Move subtree up (swap with previous subtree of same
1018 level).
1019 @kindex M-S-@key{down}
1020 @item M-S-@key{down}
1021 Move subtree down (swap with next subtree of same level).
1022 @kindex C-c C-x C-w
1023 @item C-c C-x C-w
1024 Kill subtree, @ie remove it from buffer but save in kill ring.
1025 With a numeric prefix argument N, kill N sequential subtrees.
1026 @kindex C-c C-x M-w
1027 @item C-c C-x M-w
1028 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
1029 sequential subtrees.
1030 @kindex C-c C-x C-y
1031 @item C-c C-x C-y
1032 Yank subtree from kill ring.  This does modify the level of the subtree to
1033 make sure the tree fits in nicely at the yank position.  The yank level can
1034 also be specified with a numeric prefix argument, or by yanking after a
1035 headline marker like @samp{****}.
1036 @kindex C-y
1037 @item C-y
1038 @vindex org-yank-adjusted-subtrees
1039 @vindex org-yank-folded-subtrees
1040 Depending on the variables @code{org-yank-adjusted-subtrees} and
1041 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
1042 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
1043 C-x C-y}.  With the default settings, no level adjustment will take place,
1044 but the yanked tree will be folded unless doing so would swallow text
1045 previously visible.  Any prefix argument to this command will force a normal
1046 @code{yank} to be executed, with the prefix passed along.  A good way to
1047 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
1048 yank, it will yank previous kill items plainly, without adjustment and
1049 folding.
1050 @kindex C-c C-x c
1051 @item C-c C-x c
1052 Clone a subtree by making a number of sibling copies of it.  You will be
1053 prompted for the number of copies to make, and you can also specify if any
1054 timestamps in the entry should be shifted.  This can be useful, for example,
1055 to create a number of tasks related to a series of lectures to prepare.  For
1056 more details, see the docstring of the command
1057 @code{org-clone-subtree-with-time-shift}.
1058 @kindex C-c C-w
1059 @item C-c C-w
1060 Refile entry or region to a different location.  @xref{Refiling notes}.
1061 @kindex C-c ^
1062 @item C-c ^
1063 Sort same-level entries.  When there is an active region, all entries in the
1064 region will be sorted.  Otherwise the children of the current headline are
1065 sorted.  The command prompts for the sorting method, which can be
1066 alphabetically, numerically, by time (first timestamp with active preferred,
1067 creation time, scheduled time, deadline time), by priority, by TODO keyword
1068 (in the sequence the keywords have been defined in the setup) or by the value
1069 of a property.  Reverse sorting is possible as well.  You can also supply
1070 your own function to extract the sorting key.  With a @kbd{C-u} prefix,
1071 sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes, duplicate
1072 entries will also be removed.
1073 @kindex C-x n s
1074 @item C-x n s
1075 Narrow buffer to current subtree.
1076 @kindex C-x n w
1077 @item C-x n w
1078 Widen buffer to remove narrowing.
1079 @kindex C-c *
1080 @item C-c *
1081 Turn a normal line or plain list item into a headline (so that it becomes a
1082 subheading at its location).  Also turn a headline into a normal line by
1083 removing the stars.  If there is an active region, turn all lines in the
1084 region into headlines.  If the first line in the region was an item, turn
1085 only the item lines into headlines.  Finally, if the first line is a
1086 headline, remove the stars from all headlines in the region.
1087 @end table
1089 @cindex region, active
1090 @cindex active region
1091 @cindex transient mark mode
1092 When there is an active region (Transient Mark mode), promotion and
1093 demotion work on all headlines in the region.  To select a region of
1094 headlines, it is best to place both point and mark at the beginning of a
1095 line, mark at the beginning of the first headline, and point at the line
1096 just after the last headline to change.  Note that when the cursor is
1097 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1098 functionality.
1100 @node Archiving, Sparse trees, Structure editing, Document Structure
1101 @section Archiving
1102 @cindex archiving
1104 When a project represented by a (sub)tree is finished, you may want
1105 to move the tree out of the way and to stop it from contributing to the
1106 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
1107 the ARCHIVE tag, or you can move an entire (sub)tree to a different
1108 location.
1110 @menu
1111 * ARCHIVE tag::                 Marking a tree as inactive
1112 * Moving subtrees::             Moving a tree to an archive file
1113 @end menu
1115 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
1116 @subsection The ARCHIVE tag
1117 @cindex internal archiving
1119 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
1120 its location in the outline tree, but behaves in the following way:
1121 @itemize @minus
1122 @item
1123 @vindex org-cycle-open-archived-trees
1124 It does not open when you attempt to do so with a visibility cycling
1125 command (@pxref{Visibility cycling}).  You can force cycling archived
1126 subtrees with @kbd{C-@key{TAB}}, or by setting the option
1127 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
1128 @code{show-all} will open archived subtrees.
1129 @item
1130 @vindex org-sparse-tree-open-archived-trees
1131 During sparse tree construction (@pxref{Sparse trees}), matches in
1132 archived subtrees are not exposed, unless you configure the option
1133 @code{org-sparse-tree-open-archived-trees}.
1134 @item
1135 @vindex org-agenda-skip-archived-trees
1136 During agenda view construction (@pxref{Agenda Views}), the content of
1137 archived trees is ignored unless you configure the option
1138 @code{org-agenda-skip-archived-trees}, in which case these trees will always
1139 be included.  In the agenda you can press the @kbd{v} key to get archives
1140 temporarily included.
1141 @item
1142 @vindex org-export-with-archived-trees
1143 Archived trees are not exported (@pxref{Exporting}), only the headline
1144 is.  Configure the details using the variable
1145 @code{org-export-with-archived-trees}.
1146 @item
1147 @vindex org-columns-skip-arrchived-trees
1148 Archived trees are excluded from column view unless the variable
1149 @code{org-columns-skip-arrchived-trees} is configured to @code{nil}.
1150 @end itemize
1152 The following commands help managing the ARCHIVE tag:
1154 @table @kbd
1155 @kindex C-c C-x a
1156 @item C-c C-x a
1157 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
1158 the headline changes to a shadowed face, and the subtree below it is
1159 hidden.
1160 @kindex C-u C-c C-x a
1161 @item C-u C-c C-x a
1162 Check if any direct children of the current headline should be archived.
1163 To do this, each subtree is checked for open TODO entries.  If none are
1164 found, the command offers to set the ARCHIVE tag for the child.  If the
1165 cursor is @emph{not} on a headline when this command is invoked, the
1166 level 1 trees will be checked.
1167 @kindex C-@kbd{TAB}
1168 @item C-@kbd{TAB}
1169 Cycle a tree even if it is tagged with ARCHIVE.
1170 @end table
1172 @node Moving subtrees,  , ARCHIVE tag, Archiving
1173 @subsection Moving subtrees
1174 @cindex external archiving
1176 Once an entire project is finished, you may want to move it to a different
1177 location.  Org can move it to an @emph{Archive Sibling} in the same tree, to a
1178 different tree in the current file, or to a different file, the archive file.
1180 @table @kbd
1181 @kindex C-c C-x A
1182 @item C-c C-x A
1183 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
1184 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}
1185 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1186 way retains a lot of its original context, including inherited tags and
1187 approximate position in the outline.
1188 @kindex C-c $
1189 @kindex C-c C-x C-s
1190 @itemx C-c $
1191 @item C-c C-x C-s
1192 @vindex org-archive-location
1193 Archive the subtree starting at the cursor position to the location
1194 given by @code{org-archive-location}.  Context information that could be
1195 lost, like the file name, the category, inherited tags, and the TODO
1196 state will be stored as properties in the entry.
1197 @kindex C-u C-c C-x C-s
1198 @item C-u C-c C-x C-s
1199 Check if any direct children of the current headline could be moved to
1200 the archive.  To do this, each subtree is checked for open TODO entries.
1201 If none are found, the command offers to move it to the archive
1202 location.  If the cursor is @emph{not} on a headline when this command
1203 is invoked, the level 1 trees will be checked.
1204 @end table
1206 @cindex archive locations
1207 The default archive location is a file in the same directory as the
1208 current file, with the name derived by appending @file{_archive} to the
1209 current file name.  For information and examples on how to change this,
1210 see the documentation string of the variable
1211 @code{org-archive-location}.  There is also an in-buffer option for
1212 setting this variable, for example@footnote{For backward compatibility,
1213 the following also works: If there are several such lines in a file,
1214 each specifies the archive location for the text below it.  The first
1215 such line also applies to any text before its definition.  However,
1216 using this method is @emph{strongly} deprecated as it is incompatible
1217 with the outline structure of the document.  The correct method for
1218 setting multiple archive locations in a buffer is using properties.}:
1220 @cindex #+ARCHIVE
1221 @example
1222 #+ARCHIVE: %s_done::
1223 @end example
1225 @cindex property, ARCHIVE
1226 @noindent
1227 If you would like to have a special ARCHIVE location for a single entry
1228 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1229 location as the value (@pxref{Properties and Columns}).
1231 @vindex org-archive-save-context-info
1232 When a subtree is moved, it receives a number of special properties that
1233 record context information like the file from where the entry came, its
1234 outline path the archiving time etc.  Configure the variable
1235 @code{org-archive-save-context-info} to adjust the amount of information
1236 added.
1238 @node Sparse trees, Plain lists, Archiving, Document Structure
1239 @section Sparse trees
1240 @cindex sparse trees
1241 @cindex trees, sparse
1242 @cindex folding, sparse trees
1243 @cindex occur, command
1245 @vindex org-show-hierarchy-above
1246 @vindex org-show-following-heading
1247 @vindex org-show-siblings
1248 @vindex org-show-entry-below
1249 An important feature of Org mode is the ability to construct @emph{sparse
1250 trees} for selected information in an outline tree, so that the entire
1251 document is folded as much as possible, but the selected information is made
1252 visible along with the headline structure above it@footnote{See also the
1253 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1254 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1255 control on how much context is shown around each match.}.  Just try it out
1256 and you will see immediately how it works.
1258 Org mode contains several commands creating such trees, all these
1259 commands can be accessed through a dispatcher:
1261 @table @kbd
1262 @kindex C-c /
1263 @item C-c /
1264 This prompts for an extra key to select a sparse-tree creating command.
1265 @kindex C-c / r
1266 @item C-c / r
1267 @vindex org-remove-highlights-with-change
1268 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
1269 the match is in a headline, the headline is made visible.  If the match is in
1270 the body of an entry, headline and body are made visible.  In order to
1271 provide minimal context, also the full hierarchy of headlines above the match
1272 is shown, as well as the headline following the match.  Each match is also
1273 highlighted; the highlights disappear when the buffer is changed by an
1274 editing command@footnote{This depends on the option
1275 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1276 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1277 so several calls to this command can be stacked.
1278 @end table
1280 @noindent
1281 @vindex org-agenda-custom-commands
1282 For frequently used sparse trees of specific search strings, you can
1283 use the variable @code{org-agenda-custom-commands} to define fast
1284 keyboard access to specific sparse trees.  These commands will then be
1285 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1286 For example:
1288 @lisp
1289 (setq org-agenda-custom-commands
1290       '(("f" occur-tree "FIXME")))
1291 @end lisp
1293 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1294 a sparse tree matching the string @samp{FIXME}.
1296 The other sparse tree commands select headings based on TODO keywords,
1297 tags, or properties and will be discussed later in this manual.
1299 @kindex C-c C-e v
1300 @cindex printing sparse trees
1301 @cindex visible text, printing
1302 To print a sparse tree, you can use the Emacs command
1303 @code{ps-print-buffer-with-faces} which does not print invisible parts
1304 of the document @footnote{This does not work under XEmacs, because
1305 XEmacs uses selective display for outlining, not text properties.}.
1306 Or you can use the command @kbd{C-c C-e v} to export only the visible
1307 part of the document and print the resulting file.
1309 @node Plain lists, Drawers, Sparse trees, Document Structure
1310 @section Plain lists
1311 @cindex plain lists
1312 @cindex lists, plain
1313 @cindex lists, ordered
1314 @cindex ordered lists
1316 Within an entry of the outline tree, hand-formatted lists can provide
1317 additional structure.  They also provide a way to create lists of
1318 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1319 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1321 Org knows ordered lists, unordered lists, and description lists.
1322 @itemize @bullet
1323 @item
1324 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1325 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1326 they will be seen as top-level headlines.  Also, when you are hiding leading
1327 stars to get a clean outline view, plain list items starting with a star are
1328 visually indistinguishable from true headlines.  In short: even though
1329 @samp{*} is supported, it may be better to not use it for plain list items.}
1330 as bullets.
1331 @item
1332 @emph{Ordered} list items start with a numeral followed by either a period or
1333 a right parenthesis, such as @samp{1.} or @samp{1)}.
1334 @item
1335 @emph{Description} list items are like unordered list items, but contain the
1336 separator @samp{ :: } to separate the description @emph{term} from the
1337 description.
1338 @end itemize
1340 @vindex org-empty-line-terminates-plain-lists
1341 Items belonging to the same list must have the same indentation on the first
1342 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1343 2--digit numbers must be written left-aligned with the other numbers in the
1344 list.  Indentation also determines the end of a list item.  It ends before
1345 the next line that is indented like the bullet/number, or less.  Empty lines
1346 are part of the previous item, so you can have several paragraphs in one
1347 item.  If you would like an empty line to terminate all currently open plain
1348 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1349 Here is an example:
1351 @example
1352 @group
1353 ** Lord of the Rings
1354    My favorite scenes are (in this order)
1355    1. The attack of the Rohirrim
1356    2. Eowyn's fight with the witch king
1357       + this was already my favorite scene in the book
1358       + I really like Miranda Otto.
1359    3. Peter Jackson being shot by Legolas
1360        - on DVD only
1361       He makes a really funny face when it happens.
1362    But in the end, no individual scenes matter but the film as a whole.
1363    Important actors in this film are:
1364    - @b{Elijah Wood} :: He plays Frodo
1365    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1366      him very well from his role as Mikey Walsh in @i{The Goonies}.
1367 @end group
1368 @end example
1370 Org supports these lists by tuning filling and wrapping commands to deal with
1371 them correctly@footnote{Org only changes the filling settings for Emacs.  For
1372 XEmacs, you should use Kyle E. Jones' @file{filladapt.el}.  To turn this on,
1373 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
1374 properly (@pxref{Exporting}).  Since indentation is what governs the
1375 structure of these lists, many structural constructs like @code{#+BEGIN_...}
1376 blocks can be indented to signal that they should be part of a list item.
1378 The following commands act on items when the cursor is in the first line
1379 of an item (the line with the bullet or number).
1381 @table @kbd
1382 @kindex @key{TAB}
1383 @item @key{TAB}
1384 @vindex org-cycle-include-plain-lists
1385 Items can be folded just like headline levels.  Normally this works only if
1386 the cursor is on a plain list item.  For more details, see the variable
1387 @code{org-cycle-include-plain-lists}. to @code{integrate}, plain list items
1388 will be treated like low-level.  The level of an item is then given by the
1389 indentation of the bullet/number.  Items are always subordinate to real
1390 headlines, however; the hierarchies remain completely separated.
1392 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1393 fixes the indentation of the current line in a heuristic way.
1394 @kindex M-@key{RET}
1395 @item M-@key{RET}
1396 @vindex org-M-RET-may-split-line
1397 Insert new item at current level.  With a prefix argument, force a new
1398 heading (@pxref{Structure editing}).  If this command is used in the middle
1399 of a line, the line is @emph{split} and the rest of the line becomes the new
1400 item@footnote{If you do not want the line to be split, customize the variable
1401 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1402 @emph{whitespace before a bullet or number}, the new item is created
1403 @emph{before} the current item.  If the command is executed in the white
1404 space before the text that is part of an item but does not contain the
1405 bullet, a bullet is added to the current line.
1406 @kindex M-S-@key{RET}
1407 @item M-S-@key{RET}
1408 Insert a new item with a checkbox (@pxref{Checkboxes}).
1409 @kindex S-@key{up}
1410 @kindex S-@key{down}
1411 @item S-@key{up}
1412 @itemx S-@key{down}
1413 @cindex shift-selection-mode
1414 @vindex org-support-shift-select
1415 Jump to the previous/next item in the current list, but only if
1416 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1417 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1418 similar effect.
1419 @kindex M-S-@key{up}
1420 @kindex M-S-@key{down}
1421 @item M-S-@key{up}
1422 @itemx M-S-@key{down}
1423 Move the item including subitems up/down (swap with previous/next item
1424 of same indentation).  If the list is ordered, renumbering is
1425 automatic.
1426 @kindex M-S-@key{left}
1427 @kindex M-S-@key{right}
1428 @item M-S-@key{left}
1429 @itemx M-S-@key{right}
1430 Decrease/increase the indentation of the item, including subitems.
1431 Initially, the item tree is selected based on current indentation.
1432 When these commands are executed several times in direct succession,
1433 the initially selected region is used, even if the new indentation
1434 would imply a different hierarchy.  To use the new hierarchy, break
1435 the command chain with a cursor motion or so.
1436 @kindex C-c C-c
1437 @item C-c C-c
1438 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1439 state of the checkbox.  If not, this command makes sure that all the
1440 items on this list level use the same bullet.  Furthermore, if this is
1441 an ordered list, make sure the numbering is OK.
1442 @kindex C-c -
1443 @item C-c -
1444 Cycle the entire list level through the different itemize/enumerate bullets
1445 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1446 argument N, select the Nth bullet from this list.  If there is an active
1447 region when calling this, all lines will be converted to list items.  If the
1448 first line already was a list item, any item markers will be removed from the
1449 list.  Finally, even without an active region, a normal line will be
1450 converted into a list item.
1451 @kindex C-c *
1452 @item C-c *
1453 Turn a plain list item into a headline (so that it becomes a subheading at
1454 its location). @xref{Structure editing}, for a detailed explanation.
1455 @kindex S-@key{left}
1456 @kindex S-@key{right}
1457 @item S-@key{left}/@key{right}
1458 @vindex org-support-shift-select
1459 This command also cycles bullet styles when the cursor in on the bullet or
1460 anywhere in an item line, details depending on
1461 @code{org-support-shift-select}.
1462 @kindex C-c ^
1463 @item C-c ^
1464 Sort the plain list.  You will be prompted for the sorting method:
1465 numerically, alphabetically, by time, or by custom function.
1466 @end table
1468 @node Drawers, Blocks, Plain lists, Document Structure
1469 @section Drawers
1470 @cindex drawers
1471 @cindex #+DRAWERS
1472 @cindex visibility cycling, drawers
1474 @vindex org-drawers
1475 Sometimes you want to keep information associated with an entry, but you
1476 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1477 Drawers need to be configured with the variable
1478 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1479 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1480 look like this:
1482 @example
1483 ** This is a headline
1484    Still outside the drawer
1485    :DRAWERNAME:
1486       This is inside the drawer.
1487    :END:
1488    After the drawer.
1489 @end example
1491 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1492 show the entry, but keep the drawer collapsed to a single line.  In order to
1493 look inside the drawer, you need to move the cursor to the drawer line and
1494 press @key{TAB} there.  Org mode uses the @code{PROPERTIES} drawer for
1495 storing properties (@pxref{Properties and Columns}), and you can also arrange
1496 for state change notes (@pxref{Tracking TODO state changes}) and clock times
1497 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.
1499 @node Blocks, Footnotes, Drawers, Document Structure
1500 @section Blocks
1502 @vindex org-hide-block-startup
1503 @cindex blocks, folding
1504 Org-mode uses begin...end blocks for various purposes from including source
1505 code examples (@pxref{Literal examples}) to capturing time logging
1506 information (@pxref{Clocking work time}).  These blocks can be folded and
1507 unfolded by pressing TAB in the begin line.  You can also get all blocks
1508 folded at startup by configuring the variable @code{org-hide-block-startup}
1509 or on a per-file basis by using
1511 @cindex @code{hideblocks}, STARTUP keyword
1512 @cindex @code{nohideblocks}, STARTUP keyword
1513 @example
1514 #+STARTUP: hideblocks
1515 #+STARTUP: nohideblocks
1516 @end example
1518 @node Footnotes, Orgstruct mode, Blocks, Document Structure
1519 @section Footnotes
1520 @cindex footnotes
1522 Org mode supports the creation of footnotes.  In contrast to the
1523 @file{footnote.el} package, Org mode's footnotes are designed for work on a
1524 larger document, not only for one-off documents like emails.  The basic
1525 syntax is similar to the one used by @file{footnote.el}, @ie a footnote is
1526 defined in a paragraph that is started by a footnote marker in square
1527 brackets in column 0, no indentation allowed.  If you need a paragraph break
1528 inside a footnote, use the La@TeX{} idiom @samp{\par}.  The footnote reference
1529 is simply the marker in square brackets, inside text.  For example:
1531 @example
1532 The Org homepage[fn:1] now looks a lot better than it used to.
1534 [fn:1] The link is: http://orgmode.org
1535 @end example
1537 Org mode extends the number-based syntax to @emph{named} footnotes and
1538 optional inline definition.  Using plain numbers as markers (as
1539 @file{footnote.el} does) is supported for backward compatibility, but not
1540 encouraged because of possible conflicts with La@TeX{} snippets (@pxref{Embedded
1541 LaTeX}).  Here are the valid references:
1543 @table @code
1544 @item [1]
1545 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
1546 recommended because somthing like @samp{[1]} could easily be part of a code
1547 snippet.
1548 @item [fn:name]
1549 A named footnote reference, where @code{name} is a unique label word, or, for
1550 simplicity of automatic creation, a number.
1551 @item [fn:: This is the inline definition of this footnote]
1552 A La@TeX{}-like anonymous footnote where the definition is given directly at the
1553 reference point.
1554 @item [fn:name: a definition]
1555 An inline definition of a footnote, which also specifies a name for the note.
1556 Since Org allows multiple references to the same note, you can then use
1557 @code{[fn:name]} to create additional references.
1558 @end table
1560 @vindex org-footnote-auto-label
1561 Footnote labels can be created automatically, or you can create names yourself.
1562 This is handled by the variable @code{org-footnote-auto-label} and its
1563 corresponding @code{#+STARTUP} keywords, see the docstring of that variable
1564 for details.
1566 @noindent The following command handles footnotes:
1568 @table @kbd
1569 @kindex C-c C-x f
1570 @item C-c C-x f
1571 The footnote action command.
1573 When the cursor is on a footnote reference, jump to the definition.  When it
1574 is at a definition, jump to the (first) reference.
1576 @vindex org-footnote-define-inline
1577 @vindex org-footnote-section
1578 @vindex org-footnote-auto-adjust
1579 Otherwise, create a new footnote.  Depending on the variable
1580 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1581 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1582 definition will be placed right into the text as part of the reference, or
1583 separately into the location determined by the variable
1584 @code{org-footnote-section}.
1586 When this command is called with a prefix argument, a menu of additional
1587 options is offered:
1588 @example
1589 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1590     @r{Org makes no effort to sort footnote definitions into a particular}
1591     @r{sequence.  If you want them sorted, use this command, which will}
1592     @r{also move entries according to @code{org-footnote-section}.  Automatic}
1593     @r{sorting after each insertion/deletion can be configured using the}
1594     @r{variable @code{org-footnote-auto-adjust}.}
1595 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
1596     @r{after each insertion/deletion can be configured using the variable}
1597     @r{@code{org-footnote-auto-adjust}.}
1598 S   @r{Short for first @code{r}, then @code{s} action.}
1599 n   @r{Normalize the footnotes by collecting all definitions (including}
1600     @r{inline definitions) into a special section, and then numbering them}
1601     @r{in sequence.  The references will then also be numbers.  This is}
1602     @r{meant to be the final step before finishing a document (e.g. sending}
1603     @r{off an email).  The exporters do this automatically, and so could}
1604     @r{something like @code{message-send-hook}.}
1605 d   @r{Delete the footnote at point, and all definitions of and references}
1606     @r{to it.}
1607 @end example
1608 Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
1609 corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
1610 renumbering and sorting footnotes can be automatic after each insertion or
1611 deletion.
1613 @kindex C-c C-c
1614 @item C-c C-c
1615 If the cursor is on a footnote reference, jump to the definition.  If it is a
1616 the definition, jump back to the reference.  When called at a footnote
1617 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1618 @kindex C-c C-o
1619 @kindex mouse-1
1620 @kindex mouse-2
1621 @item C-c C-o  @r{or} mouse-1/2
1622 Footnote labels are also links to the corresponding definition/reference, and
1623 you can use the usual commands to follow these links.
1624 @end table
1626 @node Orgstruct mode,  , Footnotes, Document Structure
1627 @section The Orgstruct minor mode
1628 @cindex Orgstruct mode
1629 @cindex minor mode for structure editing
1631 If you like the intuitive way the Org mode structure editing and list
1632 formatting works, you might want to use these commands in other modes like
1633 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
1634 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
1635 turn it on by default, for example in Mail mode, with one of:
1637 @lisp
1638 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1639 (add-hook 'mail-mode-hook 'turn-on-orgstruct++)
1640 @end lisp
1642 When this mode is active and the cursor is on a line that looks to Org like a
1643 headline or the first line of a list item, most structure editing commands
1644 will work, even if the same keys normally have different functionality in the
1645 major mode you are using.  If the cursor is not in one of those special
1646 lines, Orgstruct mode lurks silently in the shadow.  When you use
1647 @code{orgstruct++-mode}, Org will also export indentation and autofill
1648 settings into that mode, and detect item context after the first line of an
1649 item.
1651 @node Tables, Hyperlinks, Document Structure, Top
1652 @chapter Tables
1653 @cindex tables
1654 @cindex editing tables
1656 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1657 calculations are supported in connection with the Emacs @file{calc}
1658 package
1659 @ifinfo
1660 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1661 @end ifinfo
1662 @ifnotinfo
1663 (see the Emacs Calculator manual for more information about the Emacs
1664 calculator).
1665 @end ifnotinfo
1667 @menu
1668 * Built-in table editor::       Simple tables
1669 * Column width and alignment::  Overrule the automatic settings
1670 * Column groups::               Grouping to trigger vertical lines
1671 * Orgtbl mode::                 The table editor as minor mode
1672 * The spreadsheet::             The table editor has spreadsheet capabilities
1673 * Org-Plot::                    Plotting from org tables
1674 @end menu
1676 @node Built-in table editor, Column width and alignment, Tables, Tables
1677 @section The built-in table editor
1678 @cindex table editor, built-in
1680 Org makes it easy to format tables in plain ASCII.  Any line with
1681 @samp{|} as the first non-whitespace character is considered part of a
1682 table.  @samp{|} is also the column separator.  A table might look like
1683 this:
1685 @example
1686 | Name  | Phone | Age |
1687 |-------+-------+-----|
1688 | Peter |  1234 |  17 |
1689 | Anna  |  4321 |  25 |
1690 @end example
1692 A table is re-aligned automatically each time you press @key{TAB} or
1693 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1694 the next field (@key{RET} to the next row) and creates new table rows
1695 at the end of the table or before horizontal lines.  The indentation
1696 of the table is set by the first line.  Any line starting with
1697 @samp{|-} is considered as a horizontal separator line and will be
1698 expanded on the next re-align to span the whole table width.  So, to
1699 create the above table, you would only type
1701 @example
1702 |Name|Phone|Age|
1704 @end example
1706 @noindent and then press @key{TAB} to align the table and start filling in
1707 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
1708 @kbd{C-c @key{RET}}.
1710 @vindex org-enable-table-editor
1711 @vindex org-table-auto-blank-field
1712 When typing text into a field, Org treats @key{DEL},
1713 @key{Backspace}, and all character keys in a special way, so that
1714 inserting and deleting avoids shifting other fields.  Also, when
1715 typing @emph{immediately after the cursor was moved into a new field
1716 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1717 field is automatically made blank.  If this behavior is too
1718 unpredictable for you, configure the variables
1719 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1721 @table @kbd
1722 @tsubheading{Creation and conversion}
1723 @kindex C-c |
1724 @item C-c |
1725 Convert the active region to table. If every line contains at least one
1726 TAB character, the function assumes that the material is tab separated.
1727 If every line contains a comma, comma-separated values (CSV) are assumed.
1728 If not, lines are split at whitespace into fields.  You can use a prefix
1729 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1730 C-u} forces TAB, and a numeric argument N indicates that at least N
1731 consecutive spaces, or alternatively a TAB will be the separator.
1733 If there is no active region, this command creates an empty Org
1734 table.  But it's easier just to start typing, like
1735 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1737 @tsubheading{Re-aligning and field motion}
1738 @kindex C-c C-c
1739 @item C-c C-c
1740 Re-align the table without moving the cursor.
1742 @kindex @key{TAB}
1743 @item @key{TAB}
1744 Re-align the table, move to the next field.  Creates a new row if
1745 necessary.
1747 @kindex S-@key{TAB}
1748 @item S-@key{TAB}
1749 Re-align, move to previous field.
1751 @kindex @key{RET}
1752 @item @key{RET}
1753 Re-align the table and move down to next row.  Creates a new row if
1754 necessary.  At the beginning or end of a line, @key{RET} still does
1755 NEWLINE, so it can be used to split a table.
1757 @kindex M-a
1758 @item M-a
1759 Move to beginning of the current table field, or on to the previous field.
1760 @kindex M-e
1761 @item M-e
1762 Move to end of the current table field, or on to the next field.
1764 @tsubheading{Column and row editing}
1765 @kindex M-@key{left}
1766 @kindex M-@key{right}
1767 @item M-@key{left}
1768 @itemx M-@key{right}
1769 Move the current column left/right.
1771 @kindex M-S-@key{left}
1772 @item M-S-@key{left}
1773 Kill the current column.
1775 @kindex M-S-@key{right}
1776 @item M-S-@key{right}
1777 Insert a new column to the left of the cursor position.
1779 @kindex M-@key{up}
1780 @kindex M-@key{down}
1781 @item M-@key{up}
1782 @itemx M-@key{down}
1783 Move the current row up/down.
1785 @kindex M-S-@key{up}
1786 @item M-S-@key{up}
1787 Kill the current row or horizontal line.
1789 @kindex M-S-@key{down}
1790 @item M-S-@key{down}
1791 Insert a new row above the current row.  With a prefix argument, the line is
1792 created below the current one.
1794 @kindex C-c -
1795 @item C-c -
1796 Insert a horizontal line below current row.  With a prefix argument, the line
1797 is created above the current line.
1799 @kindex C-c @key{RET}
1800 @item C-c @key{RET}
1801 Insert a horizontal line below current row, and move the cursor into the row
1802 below that line.
1804 @kindex C-c ^
1805 @item C-c ^
1806 Sort the table lines in the region.  The position of point indicates the
1807 column to be used for sorting, and the range of lines is the range
1808 between the nearest horizontal separator lines, or the entire table.  If
1809 point is before the first column, you will be prompted for the sorting
1810 column.  If there is an active region, the mark specifies the first line
1811 and the sorting column, while point should be in the last line to be
1812 included into the sorting.  The command prompts for the sorting type
1813 (alphabetically, numerically, or by time).  When called with a prefix
1814 argument, alphabetic sorting will be case-sensitive.
1816 @tsubheading{Regions}
1817 @kindex C-c C-x M-w
1818 @item C-c C-x M-w
1819 Copy a rectangular region from a table to a special clipboard.  Point and
1820 mark determine edge fields of the rectangle.  If there is no active region,
1821 copy just the current field.  The process ignores horizontal separator lines.
1823 @kindex C-c C-x C-w
1824 @item C-c C-x C-w
1825 Copy a rectangular region from a table to a special clipboard, and
1826 blank all fields in the rectangle.  So this is the ``cut'' operation.
1828 @kindex C-c C-x C-y
1829 @item C-c C-x C-y
1830 Paste a rectangular region into a table.
1831 The upper left corner ends up in the current field.  All involved fields
1832 will be overwritten.  If the rectangle does not fit into the present table,
1833 the table is enlarged as needed.  The process ignores horizontal separator
1834 lines.
1836 @kindex M-@key{RET}
1837 @itemx M-@kbd{RET}
1838 Wrap several fields in a column like a paragraph.  If there is an active
1839 region, and both point and mark are in the same column, the text in the
1840 column is wrapped to minimum width for the given number of lines.  A numeric
1841 prefix argument may be used to change the number of desired lines.  If there
1842 is no region, the current field is split at the cursor position and the text
1843 fragment to the right of the cursor is prepended to the field one line
1844 down. If there is no region, but you specify a prefix argument, the current
1845 field is made blank, and the content is appended to the field above.
1847 @tsubheading{Calculations}
1848 @cindex formula, in tables
1849 @cindex calculations, in tables
1850 @cindex region, active
1851 @cindex active region
1852 @cindex transient mark mode
1853 @kindex C-c +
1854 @item C-c +
1855 Sum the numbers in the current column, or in the rectangle defined by
1856 the active region.  The result is shown in the echo area and can
1857 be inserted with @kbd{C-y}.
1859 @kindex S-@key{RET}
1860 @item S-@key{RET}
1861 @vindex org-table-copy-increment
1862 When current field is empty, copy from first non-empty field above.  When not
1863 empty, copy current field down to next row and move cursor along with it.
1864 Depending on the variable @code{org-table-copy-increment}, integer field
1865 values will be incremented during copy.  Integers that are too large will not
1866 be incremented.  Also, a @code{0} prefix argument temporarily disables the
1867 increment.  This key is also used by shift-selection and related modes
1868 (@pxref{Conflicts}).
1870 @tsubheading{Miscellaneous}
1871 @kindex C-c `
1872 @item C-c `
1873 Edit the current field in a separate window.  This is useful for fields that
1874 are not fully visible (@pxref{Column width and alignment}).  When called with
1875 a @kbd{C-u} prefix, just make the full field visible, so that it can be
1876 edited in place.
1878 @item M-x org-table-import
1879 Import a file as a table.  The table should be TAB or whitespace
1880 separated.  Use, for example, to import a spreadsheet table or data
1881 from a database, because these programs generally can write
1882 TAB-separated text files.  This command works by inserting the file into
1883 the buffer and then converting the region to a table.  Any prefix
1884 argument is passed on to the converter, which uses it to determine the
1885 separator.
1886 @item C-c |
1887 Tables can also be imported by pasting tabular text into the Org
1888 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1889 @kbd{C-c |} command (see above under @i{Creation and conversion}).
1891 @item M-x org-table-export
1892 @vindex org-table-export-default-format
1893 Export the table, by default as a TAB-separated file.  Use for data
1894 exchange with, for example, spreadsheet or database programs.  The format
1895 used to export the file can be configured in the variable
1896 @code{org-table-export-default-format}.  You may also use properties
1897 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1898 name and the format for table export in a subtree.  Org supports quite
1899 general formats for exported tables.  The exporter format is the same as the
1900 format used by Orgtbl radio tables, see @ref{Translator functions}, for a
1901 detailed description.
1902 @end table
1904 If you don't like the automatic table editor because it gets in your
1905 way on lines which you would like to start with @samp{|}, you can turn
1906 it off with
1908 @lisp
1909 (setq org-enable-table-editor nil)
1910 @end lisp
1912 @noindent Then the only table command that still works is
1913 @kbd{C-c C-c} to do a manual re-align.
1915 @node Column width and alignment, Column groups, Built-in table editor, Tables
1916 @section Column width and alignment
1917 @cindex narrow columns in tables
1918 @cindex alignment in tables
1920 The width of columns is automatically determined by the table editor.  And
1921 also the alignment of a column is determined automatically from the fraction
1922 of number-like versus non-number fields in the column.
1924 Sometimes a single field or a few fields need to carry more text,
1925 leading to inconveniently wide columns.  To limit@footnote{This feature
1926 does not work on XEmacs.} the width of a column, one field anywhere in
1927 the column may contain just the string @samp{<N>} where @samp{N} is an
1928 integer specifying the width of the column in characters.  The next
1929 re-align will then set the width of this column to no more than this
1930 value.
1932 @example
1933 @group
1934 |---+------------------------------|               |---+--------|
1935 |   |                              |               |   | <6>    |
1936 | 1 | one                          |               | 1 | one    |
1937 | 2 | two                          |     ----\     | 2 | two    |
1938 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1939 | 4 | four                         |               | 4 | four   |
1940 |---+------------------------------|               |---+--------|
1941 @end group
1942 @end example
1944 @noindent
1945 Fields that are wider become clipped and end in the string @samp{=>}.
1946 Note that the full text is still in the buffer, it is only invisible.
1947 To see the full text, hold the mouse over the field---a tool-tip window
1948 will show the full content.  To edit such a field, use the command
1949 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1950 open a new window with the full field.  Edit it and finish with @kbd{C-c
1951 C-c}.
1953 @vindex org-startup-align-all-tables
1954 When visiting a file containing a table with narrowed columns, the
1955 necessary character hiding has not yet happened, and the table needs to
1956 be aligned before it looks nice.  Setting the option
1957 @code{org-startup-align-all-tables} will realign all tables in a file
1958 upon visiting, but also slow down startup.  You can also set this option
1959 on a per-file basis with:
1961 @example
1962 #+STARTUP: align
1963 #+STARTUP: noalign
1964 @end example
1966 If you would like to overrule the automatic alignment of number-rich columns
1967 to the right and of string-rich column to the left, you and use @samp{<r>} or
1968 @samp{<l>} in a similar fashion.  You may also combine alignment and field
1969 width like this: @samp{<l10>}.
1971 @node Column groups, Orgtbl mode, Column width and alignment, Tables
1972 @section Column groups
1973 @cindex grouping columns in tables
1975 When Org exports tables, it does so by default without vertical
1976 lines because that is visually more satisfying in general.  Occasionally
1977 however, vertical lines can be useful to structure a table into groups
1978 of columns, much like horizontal lines can do for groups of rows.  In
1979 order to specify column groups, you can use a special row where the
1980 first field contains only @samp{/}.  The further fields can either
1981 contain @samp{<} to indicate that this column should start a group,
1982 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1983 a group of its own.  Boundaries between column groups will upon export be
1984 marked with vertical lines.  Here is an example:
1986 @example
1987 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1988 |---+----+-----+-----+-----+---------+------------|
1989 | / | <> |   < |     |   > |       < |          > |
1990 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1991 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1992 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1993 |---+----+-----+-----+-----+---------+------------|
1994 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2)))
1995 @end example
1997 It is also sufficient to just insert the column group starters after
1998 every vertical line you'd like to have:
2000 @example
2001 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2002 |----+-----+-----+-----+---------+------------|
2003 | /  | <   |     |     | <       |            |
2004 @end example
2006 @node Orgtbl mode, The spreadsheet, Column groups, Tables
2007 @section The Orgtbl minor mode
2008 @cindex Orgtbl mode
2009 @cindex minor mode for tables
2011 If you like the intuitive way the Org table editor works, you
2012 might also want to use it in other modes like Text mode or Mail mode.
2013 The minor mode Orgtbl mode makes this possible.  You can always toggle
2014 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
2015 example in mail mode, use
2017 @lisp
2018 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
2019 @end lisp
2021 Furthermore, with some special setup, it is possible to maintain tables
2022 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
2023 construct La@TeX{} tables with the underlying ease and power of
2024 Orgtbl mode, including spreadsheet capabilities.  For details, see
2025 @ref{Tables in arbitrary syntax}.
2027 @node The spreadsheet, Org-Plot, Orgtbl mode, Tables
2028 @section The spreadsheet
2029 @cindex calculations, in tables
2030 @cindex spreadsheet capabilities
2031 @cindex @file{calc} package
2033 The table editor makes use of the Emacs @file{calc} package to implement
2034 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
2035 derive fields from other fields.  While fully featured, Org's
2036 implementation is not identical to other spreadsheets.  For example,
2037 Org knows the concept of a @emph{column formula} that will be
2038 applied to all non-header fields in a column without having to copy the
2039 formula to each relevant field.
2041 @menu
2042 * References::                  How to refer to another field or range
2043 * Formula syntax for Calc::     Using Calc to compute stuff
2044 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
2045 * Field formulas::              Formulas valid for a single field
2046 * Column formulas::             Formulas valid for an entire column
2047 * Editing and debugging formulas::  Fixing formulas
2048 * Updating the table::          Recomputing all dependent fields
2049 * Advanced features::           Field names, parameters and automatic recalc
2050 @end menu
2052 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
2053 @subsection References
2054 @cindex references
2056 To compute fields in the table from other fields, formulas must
2057 reference other fields or ranges.  In Org, fields can be referenced
2058 by name, by absolute coordinates, and by relative coordinates.  To find
2059 out what the coordinates of a field are, press @kbd{C-c ?} in that
2060 field, or press @kbd{C-c @}} to toggle the display of a grid.
2062 @subsubheading Field references
2063 @cindex field references
2064 @cindex references, to fields
2066 Formulas can reference the value of another field in two ways.  Like in
2067 any other spreadsheet, you may reference fields with a letter/number
2068 combination like @code{B3}, meaning the 2nd field in the 3rd row.
2069 @c Such references are always fixed to that field, they don't change
2070 @c when you copy and paste a formula to a different field.  So
2071 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
2073 @noindent
2074 Org also uses another, more general operator that looks like this:
2075 @example
2076 @@@var{row}$@var{column}
2077 @end example
2079 @noindent
2080 Column references can be absolute like @samp{1}, @samp{2},...@samp{@var{N}},
2081 or relative to the current column like @samp{+1} or @samp{-2}.
2083 The row specification only counts data lines and ignores horizontal
2084 separator lines (hlines).  You can use absolute row numbers
2085 @samp{1}...@samp{@var{N}}, and row numbers relative to the current row like
2086 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
2087 hlines: @samp{I} refers to the first hline@footnote{Note that only
2088 hlines are counted that @emph{separate} table lines.  If the table
2089 starts with a hline above the header, it does not count.}, @samp{II} to
2090 the second, etc@.  @samp{-I} refers to the first such line above the
2091 current line, @samp{+I} to the first such line below the current line.
2092 You can also write @samp{III+2} which is the second data line after the
2093 third hline in the table.
2095 @samp{0} refers to the current row and column.  Also, if you omit
2096 either the column or the row part of the reference, the current
2097 row/column is implied.
2099 Org's references with @emph{unsigned} numbers are fixed references
2100 in the sense that if you use the same reference in the formula for two
2101 different fields, the same field will be referenced each time.
2102 Org's references with @emph{signed} numbers are floating
2103 references because the same reference operator can reference different
2104 fields depending on the field being calculated by the formula.
2106 As a special case, references like @samp{$LR5} and @samp{$LR12} can be used
2107 to refer in a stable way to the 5th and 12th field in the last row of the
2108 table.
2110 Here are a few examples:
2112 @example
2113 @@2$3      @r{2nd row, 3rd column}
2114 C2        @r{same as previous}
2115 $5        @r{column 5 in the current row}
2116 E&        @r{same as previous}
2117 @@2        @r{current column, row 2}
2118 @@-1$-3    @r{the field one row up, three columns to the left}
2119 @@-I$2     @r{field just under hline above current row, column 2}
2120 @end example
2122 @subsubheading Range references
2123 @cindex range references
2124 @cindex references, to ranges
2126 You may reference a rectangular range of fields by specifying two field
2127 references connected by two dots @samp{..}.  If both fields are in the
2128 current row, you may simply use @samp{$2..$7}, but if at least one field
2129 is in a different row, you need to use the general @code{@@row$column}
2130 format at least for the first field (i.e the reference must start with
2131 @samp{@@} in order to be interpreted correctly).  Examples:
2133 @example
2134 $1..$3        @r{First three fields in the current row.}
2135 $P..$Q        @r{Range, using column names (see under Advanced)}
2136 @@2$1..@@4$3    @r{6 fields between these two fields.}
2137 A2..C4        @r{Same as above.}
2138 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
2139 @end example
2141 @noindent Range references return a vector of values that can be fed
2142 into Calc vector functions.  Empty fields in ranges are normally
2143 suppressed, so that the vector contains only the non-empty fields (but
2144 see the @samp{E} mode switch below).  If there are no non-empty fields,
2145 @samp{[0]} is returned to avoid syntax errors in formulas.
2147 @subsubheading Named references
2148 @cindex named references
2149 @cindex references, named
2150 @cindex name, of column or field
2151 @cindex constants, in calculations
2152 @cindex #+CONSTANTS
2154 @vindex org-table-formula-constants
2155 @samp{$name} is interpreted as the name of a column, parameter or
2156 constant.  Constants are defined globally through the variable
2157 @code{org-table-formula-constants}, and locally (for the file) through a
2158 line like
2160 @example
2161 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2162 @end example
2164 @noindent
2165 @vindex constants-unit-system
2166 @pindex constants.el
2167 Also properties (@pxref{Properties and Columns}) can be used as
2168 constants in table formulas: for a property @samp{:Xyz:} use the name
2169 @samp{$PROP_Xyz}, and the property will be searched in the current
2170 outline entry and in the hierarchy above it.  If you have the
2171 @file{constants.el} package, it will also be used to resolve constants,
2172 including natural constants like @samp{$h} for Planck's constant, and
2173 units like @samp{$km} for kilometers@footnote{@file{constants.el} can
2174 supply the values of constants in two different unit systems, @code{SI}
2175 and @code{cgs}.  Which one is used depends on the value of the variable
2176 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2177 @code{constSI} and @code{constcgs} to set this value for the current
2178 buffer.}.  Column names and parameters can be specified in special table
2179 lines.  These are described below, see @ref{Advanced features}.  All
2180 names must start with a letter, and further consist of letters and
2181 numbers.
2183 @subsubheading Remote references
2184 @cindex remote references
2185 @cindex references, remote
2186 @cindex references, to a different table
2187 @cindex name, of column or field
2188 @cindex constants, in calculations
2189 @cindex #+TBLNAME
2191 You may also reference constants, fields and ranges from a different table,
2192 either in the current file or even in a different file.  The syntax is
2194 @example
2195 remote(NAME-OR-ID,REF)
2196 @end example
2198 @noindent
2199 where NAME can be the name of a table in the current file as set by a
2200 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2201 entry, even in a different file, and the reference then refers to the first
2202 table in that entry.  REF is an absolute field or range reference as
2203 described above for example @code{@@3$3} or @code{$somename}, valid in the
2204 referenced table.
2206 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2207 @subsection Formula syntax for Calc
2208 @cindex formula syntax, Calc
2209 @cindex syntax, of formulas
2211 A formula can be any algebraic expression understood by the Emacs
2212 @file{Calc} package.  @b{Note that @file{calc} has the
2213 non-standard convention that @samp{/} has lower precedence than
2214 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2215 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2216 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
2217 Emacs Calc Manual}),
2218 @c FIXME:  The link to the Calc manual in HTML does not work.
2219 variable substitution takes place according to the rules described above.
2220 @cindex vectors, in table calculations
2221 The range vectors can be directly fed into the Calc vector functions
2222 like @samp{vmean} and @samp{vsum}.
2224 @cindex format specifier
2225 @cindex mode, for @file{calc}
2226 @vindex org-calc-default-modes
2227 A formula can contain an optional mode string after a semicolon.  This
2228 string consists of flags to influence Calc and other modes during
2229 execution.  By default, Org uses the standard Calc modes (precision
2230 12, angular units degrees, fraction and symbolic modes off).  The display
2231 format, however, has been changed to @code{(float 8)} to keep tables
2232 compact.  The default settings can be configured using the variable
2233 @code{org-calc-default-modes}.
2235 @example
2236 p20           @r{switch the internal precision to 20 digits}
2237 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
2238 D R           @r{angle modes: degrees, radians}
2239 F S           @r{fraction and symbolic modes}
2240 N             @r{interpret all fields as numbers, use 0 for non-numbers}
2241 T             @r{force text interpretation}
2242 E             @r{keep empty fields in ranges}
2243 L             @r{literal}
2244 @end example
2246 @noindent
2247 In addition, you may provide a @code{printf} format specifier to
2248 reformat the final result.  A few examples:
2250 @example
2251 $1+$2                @r{Sum of first and second field}
2252 $1+$2;%.2f           @r{Same, format result to two decimals}
2253 exp($2)+exp($1)      @r{Math functions can be used}
2254 $0;%.1f              @r{Reformat current cell to 1 decimal}
2255 ($3-32)*5/9          @r{Degrees F -> C conversion}
2256 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2257 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2258 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2259 vmean($2..$7)        @r{Compute column range mean, using vector function}
2260 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2261 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
2262 @end example
2264 Calc also contains a complete set of logical operations.  For example
2266 @example
2267 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
2268 @end example
2270 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
2271 @subsection Emacs Lisp forms as formulas
2272 @cindex Lisp forms, as table formulas
2274 It is also possible to write a formula in Emacs Lisp; this can be useful
2275 for string manipulation and control structures, if Calc's
2276 functionality is not enough.  If a formula starts with a single-quote
2277 followed by an opening parenthesis, then it is evaluated as a Lisp form.
2278 The evaluation should return either a string or a number.  Just as with
2279 @file{calc} formulas, you can specify modes and a printf format after a
2280 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
2281 field references are interpolated into the form.  By default, a
2282 reference will be interpolated as a Lisp string (in double-quotes)
2283 containing the field.  If you provide the @samp{N} mode switch, all
2284 referenced elements will be numbers (non-number fields will be zero) and
2285 interpolated as Lisp numbers, without quotes.  If you provide the
2286 @samp{L} flag, all fields will be interpolated literally, without quotes.
2287 @Ie{}, if you want a reference to be interpreted as a string by the Lisp
2288 form, enclose the reference operator itself in double-quotes, like
2289 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
2290 embed them in list or vector syntax.  A few examples, note how the
2291 @samp{N} mode is used when we do computations in Lisp.
2293 @example
2294 @r{Swap the first two characters of the content of column 1}
2295   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2296 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2297   '(+ $1 $2);N
2298 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
2299   '(apply '+ '($1..$4));N
2300 @end example
2302 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
2303 @subsection Field formulas
2304 @cindex field formula
2305 @cindex formula, for individual table field
2307 To assign a formula to a particular field, type it directly into the
2308 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
2309 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
2310 the field, the formula will be stored as the formula for this field,
2311 evaluated, and the current field replaced with the result.
2313 @cindex #+TBLFM
2314 Formulas are stored in a special line starting with @samp{#+TBLFM:}
2315 directly below the table.  If you typed the equation in the 4th field of
2316 the 3rd data line in the table, the formula will look like
2317 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
2318 with the appropriate commands, @i{absolute references} (but not relative
2319 ones) in stored formulas are modified in order to still reference the
2320 same field.  Of course this is not true if you edit the table structure
2321 with normal editing commands---then you must fix the equations yourself.
2322 The left-hand side of a formula may also be a named field (@pxref{Advanced
2323 features}), or a last-row reference like @samp{$LR3}.
2325 Instead of typing an equation into the field, you may also use the
2326 following command
2328 @table @kbd
2329 @kindex C-u C-c =
2330 @item C-u C-c =
2331 Install a new formula for the current field.  The command prompts for a
2332 formula with default taken from the @samp{#+TBLFM:} line, applies
2333 it to the current field, and stores it.
2334 @end table
2336 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
2337 @subsection Column formulas
2338 @cindex column formula
2339 @cindex formula, for table column
2341 Often in a table, the same formula should be used for all fields in a
2342 particular column.  Instead of having to copy the formula to all fields
2343 in that column, Org allows you to assign a single formula to an entire
2344 column.  If the table contains horizontal separator hlines, everything
2345 before the first such line is considered part of the table @emph{header}
2346 and will not be modified by column formulas.
2348 To assign a formula to a column, type it directly into any field in the
2349 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2350 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2351 the formula will be stored as the formula for the current column, evaluated
2352 and the current field replaced with the result.  If the field contains only
2353 @samp{=}, the previously stored formula for this column is used.  For each
2354 column, Org will only remember the most recently used formula.  In the
2355 @samp{#+TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The left-hand
2356 side of a column formula cannot currently be the name of column, it
2357 must be the numeric column reference.
2359 Instead of typing an equation into the field, you may also use the
2360 following command:
2362 @table @kbd
2363 @kindex C-c =
2364 @item C-c =
2365 Install a new formula for the current column and replace current field with
2366 the result of the formula.  The command prompts for a formula, with default
2367 taken from the @samp{#+TBLFM} line, applies it to the current field and
2368 stores it.  With a numeric prefix argument(@eg @kbd{C-5 C-c =}) the command
2369 will apply it to that many consecutive fields in the current column.
2370 @end table
2372 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2373 @subsection Editing and debugging formulas
2374 @cindex formula editing
2375 @cindex editing, of table formulas
2377 @vindex org-table-use-standard-references
2378 You can edit individual formulas in the minibuffer or directly in the
2379 field.  Org can also prepare a special buffer with all active
2380 formulas of a table.  When offering a formula for editing, Org
2381 converts references to the standard format (like @code{B3} or @code{D&})
2382 if possible.  If you prefer to only work with the internal format (like
2383 @code{@@3$2} or @code{$4}), configure the variable
2384 @code{org-table-use-standard-references}.
2386 @table @kbd
2387 @kindex C-c =
2388 @kindex C-u C-c =
2389 @item C-c =
2390 @itemx C-u C-c =
2391 Edit the formula associated with the current column/field in the
2392 minibuffer.  See @ref{Column formulas}, and @ref{Field formulas}.
2393 @kindex C-u C-u C-c =
2394 @item C-u C-u C-c =
2395 Re-insert the active formula (either a
2396 field formula, or a column formula) into the current field, so that you
2397 can edit it directly in the field.  The advantage over editing in the
2398 minibuffer is that you can use the command @kbd{C-c ?}.
2399 @kindex C-c ?
2400 @item C-c ?
2401 While editing a formula in a table field, highlight the field(s)
2402 referenced by the reference at the cursor position in the formula.
2403 @kindex C-c @}
2404 @item C-c @}
2405 Toggle the display of row and column numbers for a table, using
2406 overlays.  These are updated each time the table is aligned; you can
2407 force it with @kbd{C-c C-c}.
2408 @kindex C-c @{
2409 @item C-c @{
2410 Toggle the formula debugger on and off.  See below.
2411 @kindex C-c '
2412 @item C-c '
2413 Edit all formulas for the current table in a special buffer, where the
2414 formulas will be displayed one per line.  If the current field has an
2415 active formula, the cursor in the formula editor will mark it.
2416 While inside the special buffer, Org will automatically highlight
2417 any field or range reference at the cursor position.  You may edit,
2418 remove and add formulas, and use the following commands:
2419 @table @kbd
2420 @kindex C-c C-c
2421 @kindex C-x C-s
2422 @item C-c C-c
2423 @itemx C-x C-s
2424 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2425 prefix, also apply the new formulas to the entire table.
2426 @kindex C-c C-q
2427 @item C-c C-q
2428 Exit the formula editor without installing changes.
2429 @kindex C-c C-r
2430 @item C-c C-r
2431 Toggle all references in the formula editor between standard (like
2432 @code{B3}) and internal (like @code{@@3$2}).
2433 @kindex @key{TAB}
2434 @item @key{TAB}
2435 Pretty-print or indent Lisp formula at point.  When in a line containing
2436 a Lisp formula, format the formula according to Emacs Lisp rules.
2437 Another @key{TAB} collapses the formula back again.  In the open
2438 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
2439 @kindex M-@key{TAB}
2440 @item M-@key{TAB}
2441 Complete Lisp symbols, just like in Emacs Lisp mode.
2442 @kindex S-@key{up}
2443 @kindex S-@key{down}
2444 @kindex S-@key{left}
2445 @kindex S-@key{right}
2446 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2447 Shift the reference at point.  For example, if the reference is
2448 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2449 This also works for relative references and for hline references.
2450 @kindex M-S-@key{up}
2451 @kindex M-S-@key{down}
2452 @item M-S-@key{up}/@key{down}
2453 Move the test line for column formulas in the Org buffer up and
2454 down.
2455 @kindex M-@key{up}
2456 @kindex M-@key{down}
2457 @item M-@key{up}/@key{down}
2458 Scroll the window displaying the table.
2459 @kindex C-c @}
2460 @item C-c @}
2461 Turn the coordinate grid in the table on and off.
2462 @end table
2463 @end table
2465 Making a table field blank does not remove the formula associated with
2466 the field, because that is stored in a different line (the @samp{#+TBLFM}
2467 line)---during the next recalculation the field will be filled again.
2468 To remove a formula from a field, you have to give an empty reply when
2469 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2471 @kindex C-c C-c
2472 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2473 equations with @kbd{C-c C-c} in that line or with the normal
2474 recalculation commands in the table.
2476 @subsubheading Debugging formulas
2477 @cindex formula debugging
2478 @cindex debugging, of table formulas
2479 When the evaluation of a formula leads to an error, the field content
2480 becomes the string @samp{#ERROR}.  If you would like see what is going
2481 on during variable substitution and calculation in order to find a bug,
2482 turn on formula debugging in the @code{Tbl} menu and repeat the
2483 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2484 field.  Detailed information will be displayed.
2486 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2487 @subsection Updating the table
2488 @cindex recomputing table fields
2489 @cindex updating, table
2491 Recalculation of a table is normally not automatic, but needs to be
2492 triggered by a command.  See @ref{Advanced features}, for a way to make
2493 recalculation at least semi-automatic.
2495 In order to recalculate a line of a table or the entire table, use the
2496 following commands:
2498 @table @kbd
2499 @kindex C-c *
2500 @item C-c *
2501 Recalculate the current row by first applying the stored column formulas
2502 from left to right, and all field formulas in the current row.
2504 @kindex C-u C-c *
2505 @item C-u C-c *
2506 @kindex C-u C-c C-c
2507 @itemx C-u C-c C-c
2508 Recompute the entire table, line by line.  Any lines before the first
2509 hline are left alone, assuming that these are part of the table header.
2511 @kindex C-u C-u C-c *
2512 @kindex C-u C-u C-c C-c
2513 @item C-u C-u C-c *
2514 @itemx C-u C-u C-c C-c
2515 Iterate the table by recomputing it until no further changes occur.
2516 This may be necessary if some computed fields use the value of other
2517 fields that are computed @i{later} in the calculation sequence.
2518 @end table
2520 @node Advanced features,  , Updating the table, The spreadsheet
2521 @subsection Advanced features
2523 If you want the recalculation of fields to happen automatically, or if
2524 you want to be able to assign @i{names} to fields and columns, you need
2525 to reserve the first column of the table for special marking characters.
2526 @table @kbd
2527 @kindex C-#
2528 @item C-#
2529 Rotate the calculation mark in first column through the states @samp{},
2530 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
2531 change all marks in the region.
2532 @end table
2534 Here is an example of a table that collects exam results of students and
2535 makes use of these features:
2537 @example
2538 @group
2539 |---+---------+--------+--------+--------+-------+------|
2540 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2541 |---+---------+--------+--------+--------+-------+------|
2542 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2543 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2544 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2545 |---+---------+--------+--------+--------+-------+------|
2546 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2547 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2548 |---+---------+--------+--------+--------+-------+------|
2549 |   | Average |        |        |        |  29.7 |      |
2550 | ^ |         |        |        |        |    at |      |
2551 | $ | max=50  |        |        |        |       |      |
2552 |---+---------+--------+--------+--------+-------+------|
2553 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2554 @end group
2555 @end example
2557 @noindent @b{Important}: please note that for these special tables,
2558 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2559 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2560 to the field itself.  The column formulas are not applied in rows with
2561 empty first field.
2563 @cindex marking characters, tables
2564 The marking characters have the following meaning:
2565 @table @samp
2566 @item !
2567 The fields in this line define names for the columns, so that you may
2568 refer to a column as @samp{$Tot} instead of @samp{$6}.
2569 @item ^
2570 This row defines names for the fields @emph{above} the row.  With such
2571 a definition, any formula in the table may use @samp{$m1} to refer to
2572 the value @samp{10}.  Also, if you assign a formula to a names field, it
2573 will be stored as @samp{$name=...}.
2574 @item _
2575 Similar to @samp{^}, but defines names for the fields in the row
2576 @emph{below}.
2577 @item $
2578 Fields in this row can define @emph{parameters} for formulas.  For
2579 example, if a field in a @samp{$} row contains @samp{max=50}, then
2580 formulas in this table can refer to the value 50 using @samp{$max}.
2581 Parameters work exactly like constants, only that they can be defined on
2582 a per-table basis.
2583 @item #
2584 Fields in this row are automatically recalculated when pressing
2585 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2586 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2587 lines will be left alone by this command.
2588 @item *
2589 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2590 not for automatic recalculation.  Use this when automatic
2591 recalculation slows down editing too much.
2592 @item
2593 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2594 All lines that should be recalculated should be marked with @samp{#}
2595 or @samp{*}.
2596 @item /
2597 Do not export this line.  Useful for lines that contain the narrowing
2598 @samp{<N>} markers or column group markers.
2599 @end table
2601 Finally, just to whet your appetite for what can be done with the
2602 fantastic @file{calc.el} package, here is a table that computes the Taylor
2603 series of degree @code{n} at location @code{x} for a couple of
2604 functions.
2606 @example
2607 @group
2608 |---+-------------+---+-----+--------------------------------------|
2609 |   | Func        | n | x   | Result                               |
2610 |---+-------------+---+-----+--------------------------------------|
2611 | # | exp(x)      | 1 | x   | 1 + x                                |
2612 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2613 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2614 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2615 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2616 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2617 |---+-------------+---+-----+--------------------------------------|
2618 #+TBLFM: $5=taylor($2,$4,$3);n3
2619 @end group
2620 @end example
2622 @node Org-Plot,  , The spreadsheet, Tables
2623 @section Org-Plot
2624 @cindex graph, in tables
2625 @cindex plot tables using gnuplot
2626 @cindex #+PLOT
2628 Org-Plot can produce 2D and 3D graphs of information stored in org tables
2629 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
2630 @uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html}.  To see
2631 this in action, ensure that you have both Gnuplot and Gnuplot mode installed
2632 on your system, then call @code{org-plot/gnuplot} on the following table.
2634 @example
2635 @group
2636 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2637 | Sede      | Max cites | H-index |
2638 |-----------+-----------+---------|
2639 | Chile     |    257.72 |   21.39 |
2640 | Leeds     |    165.77 |   19.68 |
2641 | Sao Paolo |     71.00 |   11.50 |
2642 | Stockholm |    134.19 |   14.33 |
2643 | Morelia   |    257.56 |   17.67 |
2644 @end group
2645 @end example
2647 Notice that Org Plot is smart enough to apply the table's headers as labels.
2648 Further control over the labels, type, content, and appearance of plots can
2649 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
2650 for a complete list of Org-plot options.  For more information and examples
2651 see the Org-plot tutorial at
2652 @uref{http://orgmode.org/worg/org-tutorials/org-plot.php}.
2654 @subsubheading Plot Options
2656 @table @code
2657 @item set
2658 Specify any @command{gnuplot} option to be set when graphing.
2660 @item title
2661 Specify the title of the plot.
2663 @item ind
2664 Specify which column of the table to use as the @code{x} axis.
2666 @item deps
2667 Specify the columns to graph as a Lisp style list, surrounded by parentheses
2668 and separated by spaces for example @code{dep:(3 4)} to graph the third and
2669 fourth columns (defaults to graphing all other columns aside from the @code{ind}
2670 column).
2672 @item type
2673 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
2675 @item with
2676 Specify a @code{with} option to be inserted for every col being plotted
2677 (@eg @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
2678 Defaults to @code{lines}.
2680 @item file
2681 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
2683 @item labels
2684 List of labels to be used for the deps (defaults to the column headers if
2685 they exist).
2687 @item line
2688 Specify an entire line to be inserted in the Gnuplot script.
2690 @item map
2691 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
2692 flat mapping rather than a @code{3d} slope.
2694 @item timefmt
2695 Specify format of Org-mode timestamps as they will be parsed by Gnuplot.
2696 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
2698 @item script
2699 If you want total control, you can specify a script file (place the file name
2700 between double-quotes) which will be used to plot.  Before plotting, every
2701 instance of @code{$datafile} in the specified script will be replaced with
2702 the path to the generated data file.  Note: even if you set this option, you
2703 may still want to specify the plot type, as that can impact the content of
2704 the data file.
2705 @end table
2707 @node Hyperlinks, TODO Items, Tables, Top
2708 @chapter Hyperlinks
2709 @cindex hyperlinks
2711 Like HTML, Org provides links inside a file, external links to
2712 other files, Usenet articles, emails, and much more.
2714 @menu
2715 * Link format::                 How links in Org are formatted
2716 * Internal links::              Links to other places in the current file
2717 * External links::              URL-like links to the world
2718 * Handling links::              Creating, inserting and following
2719 * Using links outside Org::     Linking from my C source code?
2720 * Link abbreviations::          Shortcuts for writing complex links
2721 * Search options::              Linking to a specific location
2722 * Custom searches::             When the default search is not enough
2723 @end menu
2725 @node Link format, Internal links, Hyperlinks, Hyperlinks
2726 @section Link format
2727 @cindex link format
2728 @cindex format, of links
2730 Org will recognize plain URL-like links and activate them as
2731 clickable links.  The general link format, however, looks like this:
2733 @example
2734 [[link][description]]       @r{or alternatively}           [[link]]
2735 @end example
2737 @noindent
2738 Once a link in the buffer is complete (all brackets present), Org
2739 will change the display so that @samp{description} is displayed instead
2740 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2741 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2742 which by default is an underlined face.  You can directly edit the
2743 visible part of a link.  Note that this can be either the @samp{link}
2744 part (if there is no description) or the @samp{description} part.  To
2745 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2746 cursor on the link.
2748 If you place the cursor at the beginning or just behind the end of the
2749 displayed text and press @key{BACKSPACE}, you will remove the
2750 (invisible) bracket at that location.  This makes the link incomplete
2751 and the internals are again displayed as plain text.  Inserting the
2752 missing bracket hides the link internals again.  To show the
2753 internal structure of all links, use the menu entry
2754 @code{Org->Hyperlinks->Literal links}.
2756 @node Internal links, External links, Link format, Hyperlinks
2757 @section Internal links
2758 @cindex internal links
2759 @cindex links, internal
2760 @cindex targets, for links
2762 @cindex property, CUSTOM_ID
2763 If the link does not look like a URL, it is considered to be internal in the
2764 current file.  The most important case is a link like
2765 @samp{[[#my-custom-id]]} which will link to the entry with the
2766 @code{CUSTOM_ID} property @samp{my-custom-id}.  Such custom IDs are very good
2767 for HTML export (@pxref{HTML export}) where they produce pretty section
2768 links.  You are responsible yourself to make sure these custom IDs are unique
2769 in a file.
2771 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
2772 lead to a text search in the current file.
2774 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
2775 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
2776 point to the corresponding headline.  The preferred match for a text link is
2777 a @i{dedicated target}: the same string in double angular brackets.  Targets
2778 may be located anywhere; sometimes it is convenient to put them into a
2779 comment line. For example
2781 @example
2782 # <<My Target>>
2783 @end example
2785 @noindent In HTML export (@pxref{HTML export}), such targets will become
2786 named anchors for direct access through @samp{http} links@footnote{Note that
2787 text before the first headline is usually not exported, so the first such
2788 target should be after the first headline, or in the line directly before the
2789 first headline.}.
2791 If no dedicated target exists, Org will search for the words in the link.  In
2792 the above example the search would be for @samp{my target}.  Links starting
2793 with a star like @samp{*My Target} restrict the search to
2794 headlines@footnote{To insert a link targeting a headline, in-buffer
2795 completion can be used.  Just type a star followed by a few optional letters
2796 into the buffer and press @kbd{M-@key{TAB}}.  All headlines in the current
2797 buffer will be offered as completions.  @xref{Handling links}, for more
2798 commands creating links.}.  When searching, Org mode will first try an
2799 exact match, but then move on to more and more lenient searches.  For
2800 example, the link @samp{[[*My Targets]]} will find any of the following:
2802 @example
2803 ** My targets
2804 ** TODO my targets are bright
2805 ** my 20 targets are
2806 @end example
2809 Following a link pushes a mark onto Org's own mark ring.  You can
2810 return to the previous position with @kbd{C-c &}.  Using this command
2811 several times in direct succession goes back to positions recorded
2812 earlier.
2814 @menu
2815 * Radio targets::               Make targets trigger links in plain text
2816 @end menu
2818 @node Radio targets,  , Internal links, Internal links
2819 @subsection Radio targets
2820 @cindex radio targets
2821 @cindex targets, radio
2822 @cindex links, radio targets
2824 Org can automatically turn any occurrences of certain target names
2825 in normal text into a link.  So without explicitly creating a link, the
2826 text connects to the target radioing its position.  Radio targets are
2827 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2828 Target>>>} causes each occurrence of @samp{my target} in normal text to
2829 become activated as a link.  The Org file is scanned automatically
2830 for radio targets only when the file is first loaded into Emacs.  To
2831 update the target list during editing, press @kbd{C-c C-c} with the
2832 cursor on or at a target.
2834 @node External links, Handling links, Internal links, Hyperlinks
2835 @section External links
2836 @cindex links, external
2837 @cindex external links
2838 @cindex links, external
2839 @cindex Gnus links
2840 @cindex BBDB links
2841 @cindex IRC links
2842 @cindex URL links
2843 @cindex file links
2844 @cindex VM links
2845 @cindex RMAIL links
2846 @cindex WANDERLUST links
2847 @cindex MH-E links
2848 @cindex USENET links
2849 @cindex SHELL links
2850 @cindex Info links
2851 @cindex Elisp links
2853 Org supports links to files, websites, Usenet and email messages,
2854 BBDB database entries and links to both IRC conversations and their
2855 logs.  External links are URL-like locators.  They start with a short
2856 identifying string followed by a colon.  There can be no space after
2857 the colon.  The following list shows examples for each link type.
2859 @example
2860 http://www.astro.uva.nl/~dominik          @r{on the web}
2861 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2862 /home/dominik/images/jupiter.jpg          @r{same as above}
2863 file:papers/last.pdf                      @r{file, relative path}
2864 ./papers/last.pdf                         @r{same as above}
2865 file:projects.org                         @r{another Org file}
2866 file:projects.org::some words             @r{text search in Org file}
2867 file:projects.org::*task title            @r{heading search in Org file}
2868 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
2869 news:comp.emacs                           @r{Usenet link}
2870 mailto:adent@@galaxy.net                   @r{Mail link}
2871 vm:folder                                 @r{VM folder link}
2872 vm:folder#id                              @r{VM message link}
2873 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2874 wl:folder                                 @r{WANDERLUST folder link}
2875 wl:folder#id                              @r{WANDERLUST message link}
2876 mhe:folder                                @r{MH-E folder link}
2877 mhe:folder#id                             @r{MH-E message link}
2878 rmail:folder                              @r{RMAIL folder link}
2879 rmail:folder#id                           @r{RMAIL message link}
2880 gnus:group                                @r{Gnus group link}
2881 gnus:group#id                             @r{Gnus article link}
2882 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
2883 irc:/irc.com/#emacs/bob                   @r{IRC link}
2884 shell:ls *.org                            @r{A shell command}
2885 elisp:org-agenda                          @r{Interactive Elisp command}
2886 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
2887 @end example
2889 A link should be enclosed in double brackets and may contain a
2890 descriptive text to be displayed instead of the URL (@pxref{Link
2891 format}), for example:
2893 @example
2894 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2895 @end example
2897 @noindent
2898 If the description is a file name or URL that points to an image, HTML
2899 export (@pxref{HTML export}) will inline the image as a clickable
2900 button.  If there is no description at all and the link points to an
2901 image,
2902 that image will be inlined into the exported HTML file.
2904 @cindex square brackets, around links
2905 @cindex plain text external links
2906 Org also finds external links in the normal text and activates them
2907 as links.  If spaces must be part of the link (for example in
2908 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2909 about the end of the link, enclose them in square brackets.
2911 @node Handling links, Using links outside Org, External links, Hyperlinks
2912 @section Handling links
2913 @cindex links, handling
2915 Org provides methods to create a link in the correct syntax, to
2916 insert it into an Org file, and to follow the link.
2918 @table @kbd
2919 @kindex C-c l
2920 @cindex storing links
2921 @item C-c l
2922 Store a link to the current location.  This is a @emph{global} command (you
2923 must create the key binding yourself) which can be used in any buffer to
2924 create a link.  The link will be stored for later insertion into an Org
2925 buffer (see below).  What kind of link will be created depends on the current
2926 buffer:
2928 @b{Org-mode buffers}@*
2929 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
2930 to the target.  Otherwise it points to the current headline, which will also
2931 be the description.
2933 @vindex org-link-to-org-use-id
2934 @cindex property, CUSTOM_ID
2935 @cindex property, ID
2936 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
2937 will be stored.  In addition or alternatively (depending on the value of
2938 @code{org-link-to-org-use-id}), a globally unique @code{ID} property will be
2939 created and/or used to construct a link.  So using this command in Org
2940 buffers will potentially create two links: a human-readable from the custom
2941 ID, and one that is globally unique and works even if the entry is moved from
2942 file to file.  Later, when inserting the link, you need to decide which one
2943 to use.
2945 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
2946 Pretty much all Emacs mail clients are supported.  The link will point to the
2947 current article, or, in some GNUS buffers, to the group.  The description is
2948 constructed from the author and the subject.
2950 @b{Web browsers: W3 and W3M}@*
2951 Here the link will be the current URL, with the page title as description.
2953 @b{Contacts: BBDB}@*
2954 Links created in a BBDB buffer will point to the current entry.
2956 @b{Chat: IRC}@*
2957 @vindex org-irc-link-to-logs
2958 For IRC links, if you set the variable @code{org-irc-link-to-logs} to
2959 @code{t}, a @samp{file:/} style link to the relevant point in the logs for
2960 the current conversation is created.  Otherwise an @samp{irc:/} style link to
2961 the user/channel/server under the point will be stored.
2963 @b{Other files}@*
2964 For any other files, the link will point to the file, with a search string
2965 (@pxref{Search options}) pointing to the contents of the current line.  If
2966 there is an active region, the selected words will form the basis of the
2967 search string.  If the automatically created link is not working correctly or
2968 accurately enough, you can write custom functions to select the search string
2969 and to do the search for particular file types---see @ref{Custom searches}.
2970 The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
2972 @kindex C-c C-l
2973 @cindex link completion
2974 @cindex completion, of links
2975 @cindex inserting links
2976 @item C-c C-l
2977 @vindex org-keep-stored-link-after-insertion
2978 Insert a link@footnote{ Note that you don't have to use this command to
2979 insert a link.  Links in Org are plain text, and you can type or paste them
2980 straight into the buffer.  By using this command, the links are automatically
2981 enclosed in double brackets, and you will be asked for the optional
2982 descriptive text.}.  This prompts for a link to be inserted into the buffer.
2983 You can just type a link, using text for an internal link, or one of the link
2984 type prefixes mentioned in the examples above.  The link will be inserted
2985 into the buffer@footnote{After insertion of a stored link, the link will be
2986 removed from the list of stored links.  To keep it in the list later use, use
2987 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2988 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2989 If some text was selected when this command is called, the selected text
2990 becomes the default description.
2992 @b{Inserting stored links}@*
2993 All links stored during the
2994 current session are part of the history for this prompt, so you can access
2995 them with @key{up} and @key{down} (or @kbd{M-p/n}).
2997 @b{Completion support}@* Completion with @key{TAB} will help you to insert
2998 valid link prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
2999 defined through link abbreviations (@pxref{Link abbreviations}).  If you
3000 press @key{RET} after inserting only the @var{prefix}, Org will offer
3001 specific completion support for some link types@footnote{This works by
3002 calling a special function @code{org-PREFIX-complete-link}.}  For
3003 example, if you type @kbd{file @key{RET}}, file name completion (alternative
3004 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
3005 @key{RET}} you can complete contact names.
3006 @kindex C-u C-c C-l
3007 @cindex file name completion
3008 @cindex completion, of file names
3009 @item C-u C-c C-l
3010 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
3011 a file will be inserted and you may use file name completion to select
3012 the name of the file.  The path to the file is inserted relative to the
3013 directory of the current Org file, if the linked file is in the current
3014 directory or in a sub-directory of it, or if the path is written relative
3015 to the current directory using @samp{../}.  Otherwise an absolute path
3016 is used, if possible with @samp{~/} for your home directory.  You can
3017 force an absolute path with two @kbd{C-u} prefixes.
3019 @item C-c C-l @r{(with cursor on existing link)}
3020 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
3021 link and description parts of the link.
3023 @cindex following links
3024 @kindex C-c C-o
3025 @kindex RET
3026 @item C-c C-o @r{or} @key{RET}
3027 @vindex org-file-apps
3028 Open link at point.  This will launch a web browser for URLs (using
3029 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
3030 the corresponding links, and execute the command in a shell link.  When the
3031 cursor is on an internal link, this commands runs the corresponding search.
3032 When the cursor is on a TAG list in a headline, it creates the corresponding
3033 TAGS view.  If the cursor is on a timestamp, it compiles the agenda for that
3034 date.  Furthermore, it will visit text and remote files in @samp{file:} links
3035 with Emacs and select a suitable application for local non-text files.
3036 Classification of files is based on file extension only.  See option
3037 @code{org-file-apps}.  If you want to override the default application and
3038 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
3039 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
3040 If the cursor is on a headline, but not on a link, offer all links in the
3041 headline and entry text.
3043 @kindex mouse-2
3044 @kindex mouse-1
3045 @item mouse-2
3046 @itemx mouse-1
3047 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
3048 would.  Under Emacs 22, @kbd{mouse-1} will also follow a link.
3050 @kindex mouse-3
3051 @item mouse-3
3052 @vindex org-display-internal-link-with-indirect-buffer
3053 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
3054 internal links to be displayed in another window@footnote{See the
3055 variable @code{org-display-internal-link-with-indirect-buffer}}.
3057 @cindex mark ring
3058 @kindex C-c %
3059 @item C-c %
3060 Push the current position onto the mark ring, to be able to return
3061 easily. Commands following an internal link do this automatically.
3063 @cindex links, returning to
3064 @kindex C-c &
3065 @item C-c &
3066 Jump back to a recorded position.  A position is recorded by the
3067 commands following internal links, and by @kbd{C-c %}.  Using this
3068 command several times in direct succession moves through a ring of
3069 previously recorded positions.
3071 @kindex C-c C-x C-n
3072 @kindex C-c C-x C-p
3073 @cindex links, finding next/previous
3074 @item C-c C-x C-n
3075 @itemx C-c C-x C-p
3076 Move forward/backward to the next link in the buffer.  At the limit of
3077 the buffer, the search fails once, and then wraps around.  The key
3078 bindings for this are really too long, you might want to bind this also
3079 to @kbd{C-n} and @kbd{C-p}
3080 @lisp
3081 (add-hook 'org-load-hook
3082   (lambda ()
3083     (define-key 'org-mode-map "\C-n" 'org-next-link)
3084     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
3085 @end lisp
3086 @end table
3088 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
3089 @section Using links outside Org
3091 You can insert and follow links that have Org syntax not only in
3092 Org, but in any Emacs buffer.  For this, you should create two
3093 global commands, like this (please select suitable global keys
3094 yourself):
3096 @lisp
3097 (global-set-key "\C-c L" 'org-insert-link-global)
3098 (global-set-key "\C-c o" 'org-open-at-point-global)
3099 @end lisp
3101 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
3102 @section Link abbreviations
3103 @cindex link abbreviations
3104 @cindex abbreviation, links
3106 Long URLs can be cumbersome to type, and often many similar links are
3107 needed in a document.  For this you can use link abbreviations.  An
3108 abbreviated link looks like this
3110 @example
3111 [[linkword:tag][description]]
3112 @end example
3114 @noindent
3115 @vindex org-link-abbrev-alist
3116 where the tag is optional.  The @i{linkword} must be a word; letter, numbers,
3117 @samp{-}, and @samp{_} are allowed here.  Abbreviations are resolved
3118 according to the information in the variable @code{org-link-abbrev-alist}
3119 that relates the linkwords to replacement text.  Here is an example:
3121 @lisp
3122 @group
3123 (setq org-link-abbrev-alist
3124   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3125     ("google"   . "http://www.google.com/search?q=")
3126     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
3127                    nph-abs_connect?author=%s&db_key=AST")))
3128 @end group
3129 @end lisp
3131 If the replacement text contains the string @samp{%s}, it will be
3132 replaced with the tag.  Otherwise the tag will be appended to the string
3133 in order to create the link.  You may also specify a function that will
3134 be called with the tag as the only argument to create the link.
3136 With the above setting, you could link to a specific bug with
3137 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
3138 @code{[[google:OrgMode]]} and find out what the Org author is
3139 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
3141 If you need special abbreviations just for a single Org buffer, you
3142 can define them in the file with
3144 @cindex #+LINK
3145 @example
3146 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3147 #+LINK: google    http://www.google.com/search?q=%s
3148 @end example
3150 @noindent
3151 In-buffer completion (@pxref{Completion}) can be used after @samp{[} to
3152 complete link abbreviations.  You may also define a function
3153 @code{org-PREFIX-complete-link} that implements special (@eg completion)
3154 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
3155 not accept any arguments, and return the full link with prefix.
3157 @node Search options, Custom searches, Link abbreviations, Hyperlinks
3158 @section Search options in file links
3159 @cindex search option in file links
3160 @cindex file links, searching
3162 File links can contain additional information to make Emacs jump to a
3163 particular location in the file when following a link.  This can be a
3164 line number or a search option after a double@footnote{For backward
3165 compatibility, line numbers can also follow a single colon.} colon. For
3166 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
3167 links}) to a file, it encodes the words in the current line as a search
3168 string that can be used to find this line back later when following the
3169 link with @kbd{C-c C-o}.
3171 Here is the syntax of the different ways to attach a search to a file
3172 link, together with an explanation:
3174 @example
3175 [[file:~/code/main.c::255]]
3176 [[file:~/xx.org::My Target]]
3177 [[file:~/xx.org::*My Target]]
3178 [[file:~/xx.org::/regexp/]]
3179 @end example
3181 @table @code
3182 @item 255
3183 Jump to line 255.
3184 @item My Target
3185 Search for a link target @samp{<<My Target>>}, or do a text search for
3186 @samp{my target}, similar to the search in internal links, see
3187 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3188 link will become an HTML reference to the corresponding named anchor in
3189 the linked file.
3190 @item *My Target
3191 In an Org file, restrict search to headlines.
3192 @item /regexp/
3193 Do a regular expression search for @code{regexp}.  This uses the Emacs
3194 command @code{occur} to list all matches in a separate window.  If the
3195 target file is in Org mode, @code{org-occur} is used to create a
3196 sparse tree with the matches.
3197 @c If the target file is a directory,
3198 @c @code{grep} will be used to search all files in the directory.
3199 @end table
3201 As a degenerate case, a file link with an empty file name can be used
3202 to search the current file.  For example, @code{[[file:::find me]]} does
3203 a search for @samp{find me} in the current file, just as
3204 @samp{[[find me]]} would.
3206 @node Custom searches,  , Search options, Hyperlinks
3207 @section Custom Searches
3208 @cindex custom search strings
3209 @cindex search strings, custom
3211 The default mechanism for creating search strings and for doing the
3212 actual search related to a file link may not work correctly in all
3213 cases.  For example, Bib@TeX{} database files have many entries like
3214 @samp{year="1993"} which would not result in good search strings,
3215 because the only unique identification for a Bib@TeX{} entry is the
3216 citation key.
3218 @vindex org-create-file-search-functions
3219 @vindex org-execute-file-search-functions
3220 If you come across such a problem, you can write custom functions to set
3221 the right search string for a particular file type, and to do the search
3222 for the string in the file.  Using @code{add-hook}, these functions need
3223 to be added to the hook variables
3224 @code{org-create-file-search-functions} and
3225 @code{org-execute-file-search-functions}.  See the docstring for these
3226 variables for more information.  Org actually uses this mechanism
3227 for Bib@TeX{} database files, and you can use the corresponding code as
3228 an implementation example.  See the file @file{org-bibtex.el}.
3230 @node TODO Items, Tags, Hyperlinks, Top
3231 @chapter TODO Items
3232 @cindex TODO items
3234 Org mode does not maintain TODO lists as separate documents@footnote{Of
3235 course, you can make a document that contains only long lists of TODO items,
3236 but this is not required.}.  Instead, TODO items are an integral part of the
3237 notes file, because TODO items usually come up while taking notes!  With Org
3238 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3239 information is not duplicated, and the entire context from which the TODO
3240 item emerged is always present.
3242 Of course, this technique for managing TODO items scatters them
3243 throughout your notes file.  Org mode compensates for this by providing
3244 methods to give you an overview of all the things that you have to do.
3246 @menu
3247 * TODO basics::                 Marking and displaying TODO entries
3248 * TODO extensions::             Workflow and assignments
3249 * Progress logging::            Dates and notes for progress
3250 * Priorities::                  Some things are more important than others
3251 * Breaking down tasks::         Splitting a task into manageable pieces
3252 * Checkboxes::                  Tick-off lists
3253 @end menu
3255 @node TODO basics, TODO extensions, TODO Items, TODO Items
3256 @section Basic TODO functionality
3258 Any headline becomes a TODO item when it starts with the word
3259 @samp{TODO}, for example:
3261 @example
3262 *** TODO Write letter to Sam Fortune
3263 @end example
3265 @noindent
3266 The most important commands to work with TODO entries are:
3268 @table @kbd
3269 @kindex C-c C-t
3270 @cindex cycling, of TODO states
3271 @item C-c C-t
3272 Rotate the TODO state of the current item among
3274 @example
3275 ,-> (unmarked) -> TODO -> DONE --.
3276 '--------------------------------'
3277 @end example
3279 The same rotation can also be done ``remotely'' from the timeline and
3280 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3282 @kindex C-u C-c C-t
3283 @item C-u C-c C-t
3284 Select a specific keyword using completion or (if it has been set up)
3285 the fast selection interface.  For the latter, you need to assign keys
3286 to TODO states, see @ref{Per-file keywords}, and @ref{Setting tags}, for
3287 more information.
3289 @kindex S-@key{right}
3290 @kindex S-@key{left}
3291 @vindex org-treat-S-cursor-todo-selection-as-state-change
3292 @item S-@key{right}
3293 @itemx S-@key{left}
3294 Select the following/preceding TODO state, similar to cycling.  Useful
3295 mostly if more than two TODO states are possible (@pxref{TODO
3296 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
3297 with @code{shift-selection-mode}.  See also the variable
3298 @code{org-treat-S-cursor-todo-selection-as-state-change}.
3299 @kindex C-c C-v
3300 @kindex C-c / t
3301 @cindex sparse tree, for TODO
3302 @item C-c C-v
3303 @itemx C-c / t
3304 @vindex org-todo-keywords
3305 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3306 entire buffer, but shows all TODO items and the headings hierarchy above
3307 them.  With a prefix argument, search for a specific TODO.  You will be
3308 prompted for the keyword, and you can also give a list of keywords like
3309 @code{KWD1|KWD2|...} to list entries that match any one of these keywords.
3310 With numeric prefix argument N, show the tree for the Nth keyword in the
3311 variable @code{org-todo-keywords}.  With two prefix arguments, find all TODO
3312 and DONE entries.
3313 @kindex C-c a t
3314 @item C-c a t
3315 Show the global TODO list.  Collects the TODO items from all agenda
3316 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
3317 be in @code{agenda-mode}, which provides commands to examine and
3318 manipulate the TODO entries from the new buffer (@pxref{Agenda
3319 commands}).  @xref{Global TODO list}, for more information.
3320 @kindex S-M-@key{RET}
3321 @item S-M-@key{RET}
3322 Insert a new TODO entry below the current one.
3323 @end table
3325 @noindent
3326 @vindex org-todo-state-tags-triggers
3327 Changing a TODO state can also trigger tag changes.  See the docstring of the
3328 option @code{org-todo-state-tags-triggers} for details.
3330 @node TODO extensions, Progress logging, TODO basics, TODO Items
3331 @section Extended use of TODO keywords
3332 @cindex extended TODO keywords
3334 @vindex org-todo-keywords
3335 By default, marked TODO entries have one of only two states: TODO and
3336 DONE.  Org mode allows you to classify TODO items in more complex ways
3337 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3338 special setup, the TODO keyword system can work differently in different
3339 files.
3341 Note that @i{tags} are another way to classify headlines in general and
3342 TODO items in particular (@pxref{Tags}).
3344 @menu
3345 * Workflow states::             From TODO to DONE in steps
3346 * TODO types::                  I do this, Fred does the rest
3347 * Multiple sets in one file::   Mixing it all, and still finding your way
3348 * Fast access to TODO states::  Single letter selection of a state
3349 * Per-file keywords::           Different files, different requirements
3350 * Faces for TODO keywords::     Highlighting states
3351 * TODO dependencies::           When one task needs to wait for others
3352 @end menu
3354 @node Workflow states, TODO types, TODO extensions, TODO extensions
3355 @subsection TODO keywords as workflow states
3356 @cindex TODO workflow
3357 @cindex workflow states as TODO keywords
3359 You can use TODO keywords to indicate different @emph{sequential} states
3360 in the process of working on an item, for example@footnote{Changing
3361 this variable only becomes effective after restarting Org mode in a
3362 buffer.}:
3364 @lisp
3365 (setq org-todo-keywords
3366   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3367 @end lisp
3369 The vertical bar separates the TODO keywords (states that @emph{need
3370 action}) from the DONE states (which need @emph{no further action}).  If
3371 you don't provide the separator bar, the last state is used as the DONE
3372 state.
3373 @cindex completion, of TODO keywords
3374 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3375 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
3376 also use a numeric prefix argument to quickly select a specific state.  For
3377 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
3378 Or you can use @kbd{S-@key{left}} to go backward through the sequence.  If you
3379 define many keywords, you can use in-buffer completion
3380 (@pxref{Completion}) or even a special one-key selection scheme
3381 (@pxref{Fast access to TODO states}) to insert these words into the
3382 buffer.  Changing a TODO state can be logged with a timestamp, see
3383 @ref{Tracking TODO state changes}, for more information.
3385 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3386 @subsection TODO keywords as types
3387 @cindex TODO types
3388 @cindex names as TODO keywords
3389 @cindex types as TODO keywords
3391 The second possibility is to use TODO keywords to indicate different
3392 @emph{types} of action items.  For example, you might want to indicate
3393 that items are for ``work'' or ``home''.  Or, when you work with several
3394 people on a single project, you might want to assign action items
3395 directly to persons, by using their names as TODO keywords.  This would
3396 be set up like this:
3398 @lisp
3399 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3400 @end lisp
3402 In this case, different keywords do not indicate a sequence, but rather
3403 different types.  So the normal work flow would be to assign a task to a
3404 person, and later to mark it DONE.  Org mode supports this style by adapting
3405 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3406 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3407 times in succession, it will still cycle through all names, in order to first
3408 select the right type for a task.  But when you return to the item after some
3409 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3410 to DONE.  Use prefix arguments or completion to quickly select a specific
3411 name.  You can also review the items of a specific TODO type in a sparse tree
3412 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
3413 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
3414 from all agenda files into a single buffer, you would use the numeric prefix
3415 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
3417 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3418 @subsection Multiple keyword sets in one file
3419 @cindex TODO keyword sets
3421 Sometimes you may want to use different sets of TODO keywords in
3422 parallel.  For example, you may want to have the basic
3423 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
3424 separate state indicating that an item has been canceled (so it is not
3425 DONE, but also does not require action).  Your setup would then look
3426 like this:
3428 @lisp
3429 (setq org-todo-keywords
3430       '((sequence "TODO" "|" "DONE")
3431         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3432         (sequence "|" "CANCELED")))
3433 @end lisp
3435 The keywords should all be different, this helps Org mode to keep track
3436 of which subsequence should be used for a given entry.  In this setup,
3437 @kbd{C-c C-t} only operates within a subsequence, so it switches from
3438 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
3439 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
3440 select the correct sequence.  Besides the obvious ways like typing a
3441 keyword or using completion, you may also apply the following commands:
3443 @table @kbd
3444 @kindex C-S-@key{right}
3445 @kindex C-S-@key{left}
3446 @kindex C-u C-u C-c C-t
3447 @item C-u C-u C-c C-t
3448 @itemx C-S-@key{right}
3449 @itemx C-S-@key{left}
3450 These keys jump from one TODO subset to the next.  In the above example,
3451 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
3452 @code{DONE} to @code{REPORT}, and any of the words in the second row to
3453 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
3454 @code{shift-selection-mode} (@pxref{Conflicts}).
3455 @kindex S-@key{right}
3456 @kindex S-@key{left}
3457 @item S-@key{right}
3458 @itemx S-@key{left}
3459 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
3460 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
3461 from @code{DONE} to @code{REPORT} in the example above.  See also
3462 @ref{Conflicts}, for a discussion of the interaction with
3463 @code{shift-selection-mode}.
3464 @end table
3466 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
3467 @subsection Fast access to TODO states
3469 If you would like to quickly change an entry to an arbitrary TODO state
3470 instead of cycling through the states, you can set up keys for
3471 single-letter access to the states.  This is done by adding the section
3472 key after each keyword, in parentheses.  For example:
3474 @lisp
3475 (setq org-todo-keywords
3476       '((sequence "TODO(t)" "|" "DONE(d)")
3477         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3478         (sequence "|" "CANCELED(c)")))
3479 @end lisp
3481 @vindex org-fast-tag-selection-include-todo
3482 If you then press @code{C-c C-t} followed by the selection key, the entry
3483 will be switched to this state.  @key{SPC} can be used to remove any TODO
3484 keyword from an entry.@footnote{Check also the variable
3485 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
3486 state through the tags interface (@pxref{Setting tags}), in case you like to
3487 mingle the two concepts.  Note that this means you need to come up with
3488 unique keys across both sets of keywords.}
3490 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
3491 @subsection Setting up keywords for individual files
3492 @cindex keyword options
3493 @cindex per-file keywords
3494 @cindex #+TODO
3495 @cindex #+TYP_TODO
3496 @cindex #+SEQ_TODO
3498 It can be very useful to use different aspects of the TODO mechanism in
3499 different files.  For file-local settings, you need to add special lines
3500 to the file which set the keywords and interpretation for that file
3501 only.  For example, to set one of the two examples discussed above, you
3502 need one of the following lines, starting in column zero anywhere in the
3503 file:
3505 @example
3506 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3507 @end example
3508 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
3509 interpretation, but it means the same as @code{#+TODO}), or
3510 @example
3511 #+TYP_TODO: Fred Sara Lucy Mike | DONE
3512 @end example
3514 A setup for using several sets in parallel would be:
3516 @example
3517 #+TODO: TODO | DONE
3518 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
3519 #+TODO: | CANCELED
3520 @end example
3522 @cindex completion, of option keywords
3523 @kindex M-@key{TAB}
3524 @noindent To make sure you are using the correct keyword, type
3525 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
3527 @cindex DONE, final TODO keyword
3528 Remember that the keywords after the vertical bar (or the last keyword
3529 if no bar is there) must always mean that the item is DONE (although you
3530 may use a different word).  After changing one of these lines, use
3531 @kbd{C-c C-c} with the cursor still in the line to make the changes
3532 known to Org mode@footnote{Org mode parses these lines only when
3533 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
3534 cursor in a line starting with @samp{#+} is simply restarting Org mode
3535 for the current buffer.}.
3537 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
3538 @subsection Faces for TODO keywords
3539 @cindex faces, for TODO keywords
3541 @vindex org-todo @r{(face)}
3542 @vindex org-done @r{(face)}
3543 @vindex org-todo-keyword-faces
3544 Org mode highlights TODO keywords with special faces: @code{org-todo}
3545 for keywords indicating that an item still has to be acted upon, and
3546 @code{org-done} for keywords indicating that an item is finished.  If
3547 you are using more than 2 different states, you might want to use
3548 special faces for some of them.  This can be done using the variable
3549 @code{org-todo-keyword-faces}.  For example:
3551 @lisp
3552 @group
3553 (setq org-todo-keyword-faces
3554       '(("TODO"      . org-warning)
3555         ("DEFERRED"  . shadow)
3556         ("CANCELED"  . (:foreground "blue" :weight bold))))
3557 @end group
3558 @end lisp
3560 While using a list with face properties as shown for CANCELED
3561 @emph{should} work, this does not aways seem to be the case.  If
3562 necessary, define a special face and use that.
3564 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
3565 @subsection TODO dependencies
3566 @cindex TODO dependencies
3567 @cindex dependencies, of TODO states
3569 @vindex org-enforce-todo-dependencies
3570 @cindex property, ORDERED
3571 The structure of Org files (hierarchy and lists) makes it easy to define TODO
3572 dependencies.  Usually, a parent TODO task should not be marked DONE until
3573 all subtasks (defined as children tasks) are marked as DONE.  And sometimes
3574 there is a logical sequence to a number of (sub)tasks, so that one task
3575 cannot be acted upon before all siblings above it are done.  If you customize
3576 the variable @code{org-enforce-todo-dependencies}, Org will block entries
3577 from changing state to DONE while they have children that are not DONE.
3578 Furthermore, if an entry has a property @code{ORDERED}, each of its children
3579 will be blocked until all earlier siblings are marked DONE.  Here is an
3580 example:
3582 @example
3583 * TODO Blocked until (two) is done
3584 ** DONE one
3585 ** TODO two
3587 * Parent
3588   :PROPERTIES:
3589     :ORDERED: t
3590   :END:
3591 ** TODO a
3592 ** TODO b, needs to wait for (a)
3593 ** TODO c, needs to wait for (a) and (b)
3594 @end example
3596 @table @kbd
3597 @kindex C-c C-x o
3598 @item C-c C-x o
3599 @vindex org-track-ordered-property-with-tag
3600 @cindex property, ORDERED
3601 Toggle the @code{ORDERED} property of the current entry.  A property is used
3602 for this behavior because this should be local to the current entry, not
3603 inherited like a tag.  However, if you would like to @i{track} the value of
3604 this property with a tag for better visibility, customize the variable
3605 @code{org-track-ordered-property-with-tag}.
3606 @kindex C-u C-u C-u C-c C-t
3607 @item C-u C-u C-u C-c C-t
3608 Change TODO state, circumventing any state blocking.
3609 @end table
3611 @vindex org-agenda-dim-blocked-tasks
3612 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
3613 that cannot be closed because of such dependencies will be shown in a dimmed
3614 font or even made invisible in agenda views (@pxref{Agenda Views}).
3616 @cindex checkboxes and TODO dependencies
3617 @vindex org-enforce-todo-dependencies
3618 You can also block changes of TODO states by looking at checkboxes
3619 (@pxref{Checkboxes}).  If you set the variable
3620 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
3621 checkboxes will be blocked from switching to DONE.
3623 If you need more complex dependency structures, for example dependencies
3624 between entries in different trees or files, check out the contributed
3625 module @file{org-depend.el}.
3627 @page
3628 @node Progress logging, Priorities, TODO extensions, TODO Items
3629 @section Progress logging
3630 @cindex progress logging
3631 @cindex logging, of progress
3633 Org mode can automatically record a timestamp and possibly a note when
3634 you mark a TODO item as DONE, or even each time you change the state of
3635 a TODO item.  This system is highly configurable, settings can be on a
3636 per-keyword basis and can be localized to a file or even a subtree.  For
3637 information on how to clock working time for a task, see @ref{Clocking
3638 work time}.
3640 @menu
3641 * Closing items::               When was this entry marked DONE?
3642 * Tracking TODO state changes::  When did the status change?
3643 @end menu
3645 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3646 @subsection Closing items
3648 The most basic logging is to keep track of @emph{when} a certain TODO
3649 item was finished.  This is achieved with@footnote{The corresponding
3650 in-buffer setting is: @code{#+STARTUP: logdone}}.
3652 @lisp
3653 (setq org-log-done 'time)
3654 @end lisp
3656 @noindent
3657 Then each time you turn an entry from a TODO (not-done) state into any
3658 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3659 just after the headline.  If you turn the entry back into a TODO item
3660 through further state cycling, that line will be removed again.  If you
3661 want to record a note along with the timestamp, use@footnote{The
3662 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3664 @lisp
3665 (setq org-log-done 'note)
3666 @end lisp
3668 @noindent
3669 You will then be prompted for a note, and that note will be stored below
3670 the entry with a @samp{Closing Note} heading.
3672 In the timeline (@pxref{Timeline}) and in the agenda
3673 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3674 display the TODO items with a @samp{CLOSED} timestamp on each day,
3675 giving you an overview of what has been done.
3677 @node Tracking TODO state changes,  , Closing items, Progress logging
3678 @subsection Tracking TODO state changes
3679 @cindex drawer, for state change recording
3681 @vindex org-log-states-order-reversed
3682 @vindex org-log-into-drawer
3683 @cindex property, LOG_INTO_DRAWER
3684 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
3685 might want to keep track of when a state change occurred and maybe take a
3686 note about this change.  You can either record just a timestamp, or a
3687 time-stamped note for a change.  These records will be inserted after the
3688 headline as an itemized list, newest first@footnote{See the variable
3689 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
3690 want to get the notes out of the way into a drawer (@pxref{Drawers}).
3691 Customize the variable @code{org-log-into-drawer} to get this
3692 behavior---the recommended drawer for this is called @code{LOGBOOK}.  You can
3693 also overrule the setting of this variable for a subtree by setting a
3694 @code{LOG_INTO_DRAWER} property.
3696 Since it is normally too much to record a note for every state, Org mode
3697 expects configuration on a per-keyword basis for this.  This is achieved by
3698 adding special markers @samp{!} (for a timestamp) and @samp{@@} (for a note)
3699 in parentheses after each keyword.  For example, with the setting
3701 @lisp
3702 (setq org-todo-keywords
3703   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3704 @end lisp
3706 @noindent
3707 @vindex org-log-done
3708 you not only define global TODO keywords and fast access keys, but also
3709 request that a time is recorded when the entry is set to
3710 DONE@footnote{It is possible that Org mode will record two timestamps
3711 when you are using both @code{org-log-done} and state change logging.
3712 However, it will never prompt for two notes---if you have configured
3713 both, the state change recording note will take precedence and cancel
3714 the @samp{Closing Note}.}, and that a note is recorded when switching to
3715 WAIT or CANCELED.  The setting for WAIT is even more special: the
3716 @samp{!} after the slash means that in addition to the note taken when
3717 entering the state, a timestamp should be recorded when @i{leaving} the
3718 WAIT state, if and only if the @i{target} state does not configure
3719 logging for entering it.  So it has no effect when switching from WAIT
3720 to DONE, because DONE is configured to record a timestamp only.  But
3721 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3722 setting now triggers a timestamp even though TODO has no logging
3723 configured.
3725 You can use the exact same syntax for setting logging preferences local
3726 to a buffer:
3727 @example
3728 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3729 @end example
3731 @cindex property, LOGGING
3732 In order to define logging settings that are local to a subtree or a
3733 single item, define a LOGGING property in this entry.  Any non-empty
3734 LOGGING property resets all logging settings to nil.  You may then turn
3735 on logging for this specific tree using STARTUP keywords like
3736 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3737 settings like @code{TODO(!)}.  For example
3739 @example
3740 * TODO Log each state with only a time
3741   :PROPERTIES:
3742   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3743   :END:
3744 * TODO Only log when switching to WAIT, and when repeating
3745   :PROPERTIES:
3746   :LOGGING: WAIT(@@) logrepeat
3747   :END:
3748 * TODO No logging at all
3749   :PROPERTIES:
3750   :LOGGING: nil
3751   :END:
3752 @end example
3754 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3755 @section Priorities
3756 @cindex priorities
3758 If you use Org mode extensively, you may end up enough TODO items that
3759 it starts to make sense to prioritize them.  Prioritizing can be done by
3760 placing a @emph{priority cookie} into the headline of a TODO item, like
3761 this
3763 @example
3764 *** TODO [#A] Write letter to Sam Fortune
3765 @end example
3767 @noindent
3768 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3769 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3770 is treated as priority @samp{B}.  Priorities make a difference only in
3771 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3772 no inherent meaning to Org mode.
3774 Priorities can be attached to any outline tree entries; they do not need
3775 to be TODO items.
3777 @table @kbd
3778 @kindex @kbd{C-c ,}
3779 @item @kbd{C-c ,}
3780 Set the priority of the current headline.  The command prompts for a
3781 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3782 @key{SPC} instead, the priority cookie is removed from the headline.
3783 The priorities can also be changed ``remotely'' from the timeline and
3784 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3786 @kindex S-@key{up}
3787 @kindex S-@key{down}
3788 @item S-@key{up}
3789 @itemx S-@key{down}
3790 @vindex org-priority-start-cycle-with-default
3791 Increase/decrease priority of current headline@footnote{See also the option
3792 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
3793 also used to modify timestamps (@pxref{Creating timestamps}).  See also
3794 @ref{Conflicts}, for a discussion of the interaction with
3795 @code{shift-selection-mode}.
3796 @end table
3798 @vindex org-highest-priority
3799 @vindex org-lowest-priority
3800 @vindex org-default-priority
3801 You can change the range of allowed priorities by setting the variables
3802 @code{org-highest-priority}, @code{org-lowest-priority}, and
3803 @code{org-default-priority}.  For an individual buffer, you may set
3804 these values (highest, lowest, default) like this (please make sure that
3805 the highest priority is earlier in the alphabet than the lowest
3806 priority):
3808 @cindex #+PRIORITIES
3809 @example
3810 #+PRIORITIES: A C B
3811 @end example
3813 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3814 @section Breaking tasks down into subtasks
3815 @cindex tasks, breaking down
3816 @cindex statistics, for TODO items
3818 @vindex org-agenda-todo-list-sublevels
3819 It is often advisable to break down large tasks into smaller, manageable
3820 subtasks.  You can do this by creating an outline tree below a TODO item,
3821 with detailed subtasks on the tree@footnote{To keep subtasks out of the
3822 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
3823 the overview over the fraction of subtasks that are already completed, insert
3824 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
3825 be updates each time the todo status of a child changes, or when pressing
3826 @kbd{C-c C-c} on the cookie.  For example:
3828 @example
3829 * Organize Party [33%]
3830 ** TODO Call people [1/2]
3831 *** TODO Peter
3832 *** DONE Sarah
3833 ** TODO Buy food
3834 ** DONE Talk to neighbor
3835 @end example
3837 @cindex property, COOKIE_DATA
3838 If a heading has both checkboxes and TODO children below it, the meaning of
3839 the statistics cookie become ambiguous.  Set the property
3840 @code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
3841 this issue.
3843 @vindex org-hierarchical-todo-statistics
3844 If you would like to have the statistics cookie count any TODO entries in the
3845 subtree (not just direct children), confgure the variable
3846 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
3847 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
3848 property.
3850 @example
3851 * Parent capturing statistics [2/20]
3852   :PROPERTIES:
3853   :COOKIE_DATA: todo recursive
3854   :END:
3855 @end example
3857 If you would like a TODO entry to automatically change to DONE
3858 when all children are done, you can use the following setup:
3860 @example
3861 (defun org-summary-todo (n-done n-not-done)
3862   "Switch entry to DONE when all subentries are done, to TODO otherwise."
3863   (let (org-log-done org-log-states)   ; turn off logging
3864     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3866 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3867 @end example
3870 Another possibility is the use of checkboxes to identify (a hierarchy of) a
3871 large number of subtasks (@pxref{Checkboxes}).
3874 @node Checkboxes,  , Breaking down tasks, TODO Items
3875 @section Checkboxes
3876 @cindex checkboxes
3878 Every item in a plain list (@pxref{Plain lists}) can be made into a
3879 checkbox by starting it with the string @samp{[ ]}.  This feature is
3880 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3881 Checkboxes are not included into the global TODO list, so they are often
3882 great to split a task into a number of simple steps.  Or you can use
3883 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3884 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3886 Here is an example of a checkbox list.
3888 @example
3889 * TODO Organize party [2/4]
3890   - [-] call people [1/3]
3891     - [ ] Peter
3892     - [X] Sarah
3893     - [ ] Sam
3894   - [X] order food
3895   - [ ] think about what music to play
3896   - [X] talk to the neighbors
3897 @end example
3899 Checkboxes work hierarchically, so if a checkbox item has children that
3900 are checkboxes, toggling one of the children checkboxes will make the
3901 parent checkbox reflect if none, some, or all of the children are
3902 checked.
3904 @cindex statistics, for checkboxes
3905 @cindex checkbox statistics
3906 @cindex property, COOKIE_DATA
3907 @vindex org-hierarchical-checkbox-statistics
3908 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
3909 indicating how many checkboxes present in this entry have been checked off,
3910 and the total number of checkboxes present.  This can give you an idea on how
3911 many checkboxes remain, even without opening a folded entry.  The cookies can
3912 be placed into a headline or into (the first line of) a plain list item.
3913 Each cookie covers checkboxes of direct children structurally below the
3914 headline/item on which the cookie appears@footnote{Set the variable
3915 @code{org-hierarchical-checkbox-statistics} if you want such cookies to
3916 represent the all checkboxes below the cookie, not just the direct
3917 children.}.  You have to insert the cookie yourself by typing either
3918 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
3919 result, as in the examples above.  With @samp{[%]} you get information about
3920 the percentage of checkboxes checked (in the above example, this would be
3921 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
3922 count either checkboxes below the heading or TODO states of children, and it
3923 will display whatever was changed last.  Set the property @code{COOKIE_DATA}
3924 to either @samp{checkbox} or @samp{todo} to resolve this issue.
3926 @cindex blocking, of checkboxes
3927 @cindex checkbox blocking
3928 @cindex property, ORDERED
3929 If the current outline node has an @code{ORDERED} property, checkboxes must
3930 be checked off in sequence, and an error will be thrown if you try to check
3931 off a box while there are unchecked boxes above it.
3933 @noindent The following commands work with checkboxes:
3935 @table @kbd
3936 @kindex C-c C-c
3937 @item C-c C-c
3938 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3939 double prefix argument, set it to @samp{[-]}, which is considered to be an
3940 intermediate state.
3941 @kindex C-c C-x C-b
3942 @item C-c C-x C-b
3943 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3944 double prefix argument, set it to @samp{[-]}, which is considered to be an
3945 intermediate state.
3946 @itemize @minus
3947 @item
3948 If there is an active region, toggle the first checkbox in the region
3949 and set all remaining boxes to the same status as the first.  With a prefix
3950 arg, add or remove the checkbox for all items in the region.
3951 @item
3952 If the cursor is in a headline, toggle checkboxes in the region between
3953 this headline and the next (so @emph{not} the entire subtree).
3954 @item
3955 If there is no active region, just toggle the checkbox at point.
3956 @end itemize
3957 @kindex M-S-@key{RET}
3958 @item M-S-@key{RET}
3959 Insert a new item with a checkbox.
3960 This works only if the cursor is already in a plain list item
3961 (@pxref{Plain lists}).
3962 @kindex C-c C-x o
3963 @item C-c C-x o
3964 @vindex org-track-ordered-property-with-tag
3965 @cindex property, ORDERED
3966 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
3967 be checked off in sequence.  A property is used for this behavior because
3968 this should be local to the current entry, not inherited like a tag.
3969 However, if you would like to @i{track} the value of this property with a tag
3970 for better visibility, customize the variable
3971 @code{org-track-ordered-property-with-tag}.
3972 @kindex C-c #
3973 @item C-c #
3974 Update the statistics cookie in the current outline entry.  When called with
3975 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
3976 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
3977 new ones with @kbd{M-S-@key{RET}}.  TODO statistics cookies update when
3978 changing TODO states.  If you delete boxes/entries or add/change them by
3979 hand, use this command to get things back into sync.  Or simply toggle any
3980 entry twice (checkboxes with @kbd{C-c C-c}).
3981 @end table
3983 @node Tags, Properties and Columns, TODO Items, Top
3984 @chapter Tags
3985 @cindex tags
3986 @cindex headline tagging
3987 @cindex matching, tags
3988 @cindex sparse tree, tag based
3990 An excellent way to implement labels and contexts for cross-correlating
3991 information is to assign @i{tags} to headlines.  Org mode has extensive
3992 support for tags.
3994 @vindex org-tag-faces
3995 Every headline can contain a list of tags; they occur at the end of the
3996 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
3997 @samp{@@}.  Tags must be preceded and followed by a single colon, @eg{},
3998 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
3999 Tags will by default be in bold face with the same color as the headline.
4000 You may specify special faces for specific tags using the variable
4001 @code{org-tag-faces}, in much the same way as you can for TODO keywords
4002 (@pxref{Faces for TODO keywords}).
4004 @menu
4005 * Tag inheritance::             Tags use the tree structure of the outline
4006 * Setting tags::                How to assign tags to a headline
4007 * Tag searches::                Searching for combinations of tags
4008 @end menu
4010 @node Tag inheritance, Setting tags, Tags, Tags
4011 @section Tag inheritance
4012 @cindex tag inheritance
4013 @cindex inheritance, of tags
4014 @cindex sublevels, inclusion into tags match
4016 @i{Tags} make use of the hierarchical structure of outline trees.  If a
4017 heading has a certain tag, all subheadings will inherit the tag as
4018 well.  For example, in the list
4020 @example
4021 * Meeting with the French group      :work:
4022 ** Summary by Frank                  :boss:notes:
4023 *** TODO Prepare slides for him      :action:
4024 @end example
4026 @noindent
4027 the final heading will have the tags @samp{:work:}, @samp{:boss:},
4028 @samp{:notes:}, and @samp{:action:} even though the final heading is not
4029 explicitly marked with those tags.  You can also set tags that all entries in
4030 a file should inherit just as if these tags were defined in a hypothetical
4031 level zero that surrounds the entire file.
4033 @cindex #+FILETAGS
4034 @example
4035 #+FILETAGS: :Peter:Boss:Secret:
4036 @end example
4038 @noindent
4039 @vindex org-use-tag-inheritance
4040 @vindex org-tags-exclude-from-inheritance
4041 To limit tag inheritance to specific tags, or to turn it off entirely, use
4042 the variables @code{org-use-tag-inheritance} and
4043 @code{org-tags-exclude-from-inheritance}.
4045 @vindex org-tags-match-list-sublevels
4046 When a headline matches during a tags search while tag inheritance is turned
4047 on, all the sublevels in the same tree will (for a simple match form) match
4048 as well@footnote{This is only true if the search does not involve more
4049 complex tests including properties (@pxref{Property searches}).}.  The list
4050 of matches may then become very long.  If you only want to see the first tags
4051 match in a subtree, configure the variable
4052 @code{org-tags-match-list-sublevels} (not recommended).
4054 @node Setting tags, Tag searches, Tag inheritance, Tags
4055 @section Setting tags
4056 @cindex setting tags
4057 @cindex tags, setting
4059 @kindex M-@key{TAB}
4060 Tags can simply be typed into the buffer at the end of a headline.
4061 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
4062 also a special command for inserting tags:
4064 @table @kbd
4065 @kindex C-c C-q
4066 @item C-c C-q
4067 @cindex completion, of tags
4068 @vindex org-tags-column
4069 Enter new tags for the current headline.  Org mode will either offer
4070 completion or a special single-key interface for setting tags, see
4071 below.  After pressing @key{RET}, the tags will be inserted and aligned
4072 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
4073 tags in the current buffer will be aligned to that column, just to make
4074 things look nice.  TAGS are automatically realigned after promotion,
4075 demotion, and TODO state changes (@pxref{TODO basics}).
4076 @kindex C-c C-c
4077 @item C-c C-c
4078 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
4079 @end table
4081 @vindex org-tag-alist
4082 Org will support tag insertion based on a @emph{list of tags}.  By
4083 default this list is constructed dynamically, containing all tags
4084 currently used in the buffer.  You may also globally specify a hard list
4085 of tags with the variable @code{org-tag-alist}.  Finally you can set
4086 the default tags for a given file with lines like
4088 @cindex #+TAGS
4089 @example
4090 #+TAGS: @@work @@home @@tennisclub
4091 #+TAGS: laptop car pc sailboat
4092 @end example
4094 If you have globally defined your preferred set of tags using the
4095 variable @code{org-tag-alist}, but would like to use a dynamic tag list
4096 in a specific file, add an empty TAGS option line to that file:
4098 @example
4099 #+TAGS:
4100 @end example
4102 @vindex org-tag-persistent-alist
4103 If you have a preferred set of tags that you would like to use in every file,
4104 in addition to those defined on a per-file basis by TAGS option lines, then
4105 you may specify a list of tags with the variable
4106 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
4107 by adding a STARTUP option line to that file:
4109 @example
4110 #+STARTUP: noptag
4111 @end example
4113 By default Org mode uses the standard minibuffer completion facilities for
4114 entering tags.  However, it also implements another, quicker, tag selection
4115 method called @emph{fast tag selection}.  This allows you to select and
4116 deselect tags with just a single key press.  For this to work well you should
4117 assign unique letters to most of your commonly used tags.  You can do this
4118 globally by configuring the variable @code{org-tag-alist} in your
4119 @file{.emacs} file.  For example, you may find the need to tag many items in
4120 different files with @samp{:@@home:}.  In this case you can set something
4121 like:
4123 @lisp
4124 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
4125 @end lisp
4127 @noindent If the tag is only relevant to the file you are working on, then you
4128 can instead set the TAGS option line as:
4130 @example
4131 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
4132 @end example
4134 @noindent The tags interface will show the available tags in a splash
4135 window.  If you want to start a new line after a specific tag, insert
4136 @samp{\n} into the tag list
4138 @example
4139 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
4140 @end example
4142 @noindent or write them in two lines:
4144 @example
4145 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
4146 #+TAGS: laptop(l)  pc(p)
4147 @end example
4149 @noindent
4150 You can also group together tags that are mutually exclusive by using
4151 braces, as in:
4153 @example
4154 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
4155 @end example
4157 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
4158 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
4160 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
4161 these lines to activate any changes.
4163 @noindent
4164 To set these mutually exclusive groups in the variable @code{org-tags-alist},
4165 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
4166 of the braces.  Similarly, you can use @code{:newline} to indicate a line
4167 break.  The previous example would be set globally by the following
4168 configuration:
4170 @lisp
4171 (setq org-tag-alist '((:startgroup . nil)
4172                       ("@@work" . ?w) ("@@home" . ?h)
4173                       ("@@tennisclub" . ?t)
4174                       (:endgroup . nil)
4175                       ("laptop" . ?l) ("pc" . ?p)))
4176 @end lisp
4178 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
4179 automatically present you with a special interface, listing inherited tags,
4180 the tags of the current headline, and a list of all valid tags with
4181 corresponding keys@footnote{Keys will automatically be assigned to tags which
4182 have no configured keys.}.  In this interface, you can use the following
4183 keys:
4185 @table @kbd
4186 @item a-z...
4187 Pressing keys assigned to tags will add or remove them from the list of
4188 tags in the current line.  Selecting a tag in a group of mutually
4189 exclusive tags will turn off any other tags from that group.
4190 @kindex @key{TAB}
4191 @item @key{TAB}
4192 Enter a tag in the minibuffer, even if the tag is not in the predefined
4193 list.  You will be able to complete on all tags present in the buffer.
4194 @kindex @key{SPC}
4195 @item @key{SPC}
4196 Clear all tags for this line.
4197 @kindex @key{RET}
4198 @item @key{RET}
4199 Accept the modified set.
4200 @item C-g
4201 Abort without installing changes.
4202 @item q
4203 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
4204 @item !
4205 Turn off groups of mutually exclusive tags.  Use this to (as an
4206 exception) assign several tags from such a group.
4207 @item C-c
4208 Toggle auto-exit after the next change (see below).
4209 If you are using expert mode, the first @kbd{C-c} will display the
4210 selection window.
4211 @end table
4213 @noindent
4214 This method lets you assign tags to a headline with very few keys.  With
4215 the above setup, you could clear the current tags and set @samp{@@home},
4216 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
4217 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
4218 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
4219 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
4220 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
4221 @key{RET} @key{RET}}.
4223 @vindex org-fast-tag-selection-single-key
4224 If you find that most of the time you need only a single key press to
4225 modify your list of tags, set the variable
4226 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
4227 press @key{RET} to exit fast tag selection---it will immediately exit
4228 after the first change.  If you then occasionally need more keys, press
4229 @kbd{C-c} to turn off auto-exit for the current tag selection process
4230 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
4231 C-c}).  If you set the variable to the value @code{expert}, the special
4232 window is not even shown for single-key tag selection, it comes up only
4233 when you press an extra @kbd{C-c}.
4235 @node Tag searches,  , Setting tags, Tags
4236 @section Tag searches
4237 @cindex tag searches
4238 @cindex searching for tags
4240 Once a system of tags has been set up, it can be used to collect related
4241 information into special lists.
4243 @table @kbd
4244 @kindex C-c \
4245 @kindex C-c / m
4246 @item C-c \
4247 @itemx C-c / m
4248 Create a sparse tree with all headlines matching a tags search.  With a
4249 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4250 @kindex C-c a m
4251 @item C-c a m
4252 Create a global list of tag matches from all agenda files.
4253 @xref{Matching tags and properties}.
4254 @kindex C-c a M
4255 @item C-c a M
4256 @vindex org-tags-match-list-sublevels
4257 Create a global list of tag matches from all agenda files, but check
4258 only TODO items and force checking subitems (see variable
4259 @code{org-tags-match-list-sublevels}).
4260 @end table
4262 These commands all prompt for a match string which allows basic Boolean logic
4263 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
4264 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
4265 which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of the search
4266 string is rich and allows also matching against TODO keywords, entry levels
4267 and properties.  For a complete description with many examples, see
4268 @ref{Matching tags and properties}.
4271 @node Properties and Columns, Dates and Times, Tags, Top
4272 @chapter Properties and Columns
4273 @cindex properties
4275 Properties are a set of key-value pairs associated with an entry.  There
4276 are two main applications for properties in Org mode.  First, properties
4277 are like tags, but with a value.  Second, you can use properties to
4278 implement (very basic) database capabilities in an Org buffer.  For
4279 an example of the first application, imagine maintaining a file where
4280 you document bugs and plan releases for a piece of software.  Instead of
4281 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
4282 property, say @code{:Release:}, that in different subtrees has different
4283 values, such as @code{1.0} or @code{2.0}.  For an example of the second
4284 application of properties, imagine keeping track of your music CDs,
4285 where properties could be things such as the album, artist, date of
4286 release, number of tracks, and so on.
4288 Properties can be conveniently edited and viewed in column view
4289 (@pxref{Column view}).
4291 @menu
4292 * Property syntax::             How properties are spelled out
4293 * Special properties::          Access to other Org mode features
4294 * Property searches::           Matching property values
4295 * Property inheritance::        Passing values down the tree
4296 * Column view::                 Tabular viewing and editing
4297 * Property API::                Properties for Lisp programmers
4298 @end menu
4300 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
4301 @section Property syntax
4302 @cindex property syntax
4303 @cindex drawer, for properties
4305 Properties are key-value pairs.  They need to be inserted into a special
4306 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
4307 is specified on a single line, with the key (surrounded by colons)
4308 first, and the value after it.  Here is an example:
4310 @example
4311 * CD collection
4312 ** Classic
4313 *** Goldberg Variations
4314     :PROPERTIES:
4315     :Title:     Goldberg Variations
4316     :Composer:  J.S. Bach
4317     :Artist:    Glen Gould
4318     :Publisher: Deutsche Grammophon
4319     :NDisks:    1
4320     :END:
4321 @end example
4323 You may define the allowed values for a particular property @samp{:Xyz:}
4324 by setting a property @samp{:Xyz_ALL:}.  This special property is
4325 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
4326 the entire tree.  When allowed values are defined, setting the
4327 corresponding property becomes easier and is less prone to typing
4328 errors.  For the example with the CD collection, we can predefine
4329 publishers and the number of disks in a box like this:
4331 @example
4332 * CD collection
4333   :PROPERTIES:
4334   :NDisks_ALL:  1 2 3 4
4335   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
4336   :END:
4337 @end example
4339 If you want to set properties that can be inherited by any entry in a
4340 file, use a line like
4341 @cindex property, _ALL
4342 @cindex #+PROPERTY
4343 @example
4344 #+PROPERTY: NDisks_ALL 1 2 3 4
4345 @end example
4347 @vindex org-global-properties
4348 Property values set with the global variable
4349 @code{org-global-properties} can be inherited by all entries in all
4350 Org files.
4352 @noindent
4353 The following commands help to work with properties:
4355 @table @kbd
4356 @kindex M-@key{TAB}
4357 @item M-@key{TAB}
4358 After an initial colon in a line, complete property keys.  All keys used
4359 in the current file will be offered as possible completions.
4360 @kindex C-c C-x p
4361 @item C-c C-x p
4362 Set a property.  This prompts for a property name and a value.  If
4363 necessary, the property drawer is created as well.
4364 @item M-x org-insert-property-drawer
4365 Insert a property drawer into the current entry.  The drawer will be
4366 inserted early in the entry, but after the lines with planning
4367 information like deadlines.
4368 @kindex C-c C-c
4369 @item C-c C-c
4370 With the cursor in a property drawer, this executes property commands.
4371 @item C-c C-c s
4372 Set a property in the current entry.  Both the property and the value
4373 can be inserted using completion.
4374 @kindex S-@key{right}
4375 @kindex S-@key{left}
4376 @item S-@key{left}/@key{right}
4377 Switch property at point to the next/previous allowed value.
4378 @item C-c C-c d
4379 Remove a property from the current entry.
4380 @item C-c C-c D
4381 Globally remove a property, from all entries in the current file.
4382 @item C-c C-c c
4383 Compute the property at point, using the operator and scope from the
4384 nearest column format definition.
4385 @end table
4387 @node Special properties, Property searches, Property syntax, Properties and Columns
4388 @section Special properties
4389 @cindex properties, special
4391 Special properties provide an alternative access method to Org mode
4392 features, like the TODO state or the priority of an entry, discussed in the
4393 previous chapters.  This interface exists so that you can include
4394 these states in a column view (@pxref{Column view}), or to use them in
4395 queries.  The following property names are special and should not be
4396 used as keys in the properties drawer:
4398 @cindex property, special, TODO
4399 @cindex property, special, TAGS
4400 @cindex property, special, ALLTAGS
4401 @cindex property, special, CATEGORY
4402 @cindex property, special, PRIORITY
4403 @cindex property, special, DEADLINE
4404 @cindex property, special, SCHEDULED
4405 @cindex property, special, CLOSED
4406 @cindex property, special, TIMESTAMP
4407 @cindex property, special, TIMESTAMP_IA
4408 @cindex property, special, CLOCKSUM
4409 @c guessing that ITEM is needed in this area; also, should this list be sorted?
4410 @cindex property, special, ITEM
4411 @example
4412 TODO         @r{The TODO keyword of the entry.}
4413 TAGS         @r{The tags defined directly in the headline.}
4414 ALLTAGS      @r{All tags, including inherited ones.}
4415 CATEGORY     @r{The category of an entry.}
4416 PRIORITY     @r{The priority of the entry, a string with a single letter.}
4417 DEADLINE     @r{The deadline time string, without the angular brackets.}
4418 SCHEDULED    @r{The scheduling timestamp, without the angular brackets.}
4419 CLOSED       @r{When was this entry closed?}
4420 TIMESTAMP    @r{The first keyword-less timestamp in the entry.}
4421 TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
4422 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
4423              @r{must be run first to compute the values.}
4424 ITEM         @r{The content of the entry.}
4425 @end example
4427 @node Property searches, Property inheritance, Special properties, Properties and Columns
4428 @section Property searches
4429 @cindex properties, searching
4430 @cindex searching, of properties
4432 To create sparse trees and special lists with selection based on properties,
4433 the same commands are used as for tag searches (@pxref{Tag searches}).
4434 @table @kbd
4435 @kindex C-c \
4436 @kindex C-c / m
4437 @item C-c \
4438 @itemx C-c / m
4439 Create a sparse tree with all matching entries.  With a
4440 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4441 @kindex C-c a m
4442 @item C-c a m
4443 Create a global list of tag/property  matches from all agenda files.
4444 @xref{Matching tags and properties}.
4445 @kindex C-c a M
4446 @item C-c a M
4447 @vindex org-tags-match-list-sublevels
4448 Create a global list of tag matches from all agenda files, but check
4449 only TODO items and force checking of subitems (see variable
4450 @code{org-tags-match-list-sublevels}).
4451 @end table
4453 The syntax for the search string is described in @ref{Matching tags and
4454 properties}.
4456 There is also a special command for creating sparse trees based on a
4457 single property:
4459 @table @kbd
4460 @kindex C-c / p
4461 @item C-c / p
4462 Create a sparse tree based on the value of a property.  This first
4463 prompts for the name of a property, and then for a value.  A sparse tree
4464 is created with all entries that define this property with the given
4465 value.  If you enclose the value into curly braces, it is interpreted as
4466 a regular expression and matched against the property values.
4467 @end table
4469 @node Property inheritance, Column view, Property searches, Properties and Columns
4470 @section Property Inheritance
4471 @cindex properties, inheritance
4472 @cindex inheritance, of properties
4474 @vindex org-use-property-inheritance
4475 The outline structure of Org-mode documents lends itself for an
4476 inheritance model of properties: if the parent in a tree has a certain
4477 property, the children can inherit this property.  Org mode does not
4478 turn this on by default, because it can slow down property searches
4479 significantly and is often not needed.  However, if you find inheritance
4480 useful, you can turn it on by setting the variable
4481 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
4482 all properties inherited from the parent, to a list of properties
4483 that should be inherited, or to a regular expression that matches
4484 inherited properties.
4486 Org mode has a few properties for which inheritance is hard-coded, at
4487 least for the special applications for which they are used:
4489 @cindex property, COLUMNS
4490 @table @code
4491 @item COLUMNS
4492 The @code{:COLUMNS:} property defines the format of column view
4493 (@pxref{Column view}).  It is inherited in the sense that the level
4494 where a @code{:COLUMNS:} property is defined is used as the starting
4495 point for a column view table, independently of the location in the
4496 subtree from where columns view is turned on.
4497 @item CATEGORY
4498 @cindex property, CATEGORY
4499 For agenda view, a category set through a @code{:CATEGORY:} property
4500 applies to the entire subtree.
4501 @item ARCHIVE
4502 @cindex property, ARCHIVE
4503 For archiving, the @code{:ARCHIVE:} property may define the archive
4504 location for the entire subtree (@pxref{Moving subtrees}).
4505 @item LOGGING
4506 @cindex property, LOGGING
4507 The LOGGING property may define logging settings for an entry or a
4508 subtree (@pxref{Tracking TODO state changes}).
4509 @end table
4511 @node Column view, Property API, Property inheritance, Properties and Columns
4512 @section Column view
4514 A great way to view and edit properties in an outline tree is
4515 @emph{column view}.  In column view, each outline node is turned into a
4516 table row.  Columns in this table provide access to properties of the
4517 entries.  Org mode implements columns by overlaying a tabular structure
4518 over the headline of each item.  While the headlines have been turned
4519 into a table row, you can still change the visibility of the outline
4520 tree.  For example, you get a compact table by switching to CONTENTS
4521 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
4522 is active), but you can still open, read, and edit the entry below each
4523 headline.  Or, you can switch to column view after executing a sparse
4524 tree command and in this way get a table only for the selected items.
4525 Column view also works in agenda buffers (@pxref{Agenda Views}) where
4526 queries have collected selected items, possibly from a number of files.
4528 @menu
4529 * Defining columns::            The COLUMNS format property
4530 * Using column view::           How to create and use column view
4531 * Capturing column view::       A dynamic block for column view
4532 @end menu
4534 @node Defining columns, Using column view, Column view, Column view
4535 @subsection Defining columns
4536 @cindex column view, for properties
4537 @cindex properties, column view
4539 Setting up a column view first requires defining the columns.  This is
4540 done by defining a column format line.
4542 @menu
4543 * Scope of column definitions::  Where defined, where valid?
4544 * Column attributes::           Appearance and content of a column
4545 @end menu
4547 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
4548 @subsubsection Scope of column definitions
4550 To define a column format for an entire file, use a line like
4552 @cindex #+COLUMNS
4553 @example
4554 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4555 @end example
4557 To specify a format that only applies to a specific tree, add a
4558 @code{:COLUMNS:} property to the top node of that tree, for example:
4560 @example
4561 ** Top node for columns view
4562    :PROPERTIES:
4563    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4564    :END:
4565 @end example
4567 If a @code{:COLUMNS:} property is present in an entry, it defines columns
4568 for the entry itself, and for the entire subtree below it.  Since the
4569 column definition is part of the hierarchical structure of the document,
4570 you can define columns on level 1 that are general enough for all
4571 sublevels, and more specific columns further down, when you edit a
4572 deeper part of the tree.
4574 @node Column attributes,  , Scope of column definitions, Defining columns
4575 @subsubsection Column attributes
4576 A column definition sets the attributes of a column.  The general
4577 definition looks like this:
4579 @example
4580  %[@var{width}]@var{property}[(@var{title})][@{@var{summary-type}@}]
4581 @end example
4583 @noindent
4584 Except for the percent sign and the property name, all items are
4585 optional.  The individual parts have the following meaning:
4587 @example
4588 @var{width}           @r{An integer specifying the width of the column in characters.}
4589                 @r{If omitted, the width will be determined automatically.}
4590 @var{property}        @r{The property that should be edited in this column.}
4591 (title)         @r{The header text for the column. If omitted, the}
4592                 @r{property name is used.}
4593 @{@var{summary-type}@}  @r{The summary type.  If specified, the column values for}
4594                 @r{parent nodes are computed from the children.}
4595                 @r{Supported summary types are:}
4596                 @{+@}       @r{Sum numbers in this column.}
4597                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
4598                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
4599                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
4600                 @{X@}       @r{Checkbox status, @samp{[X]} if all children are @samp{[X]}.}
4601                 @{X/@}      @r{Checkbox status, @samp{[n/m]}.}
4602                 @{X%@}      @r{Checkbox status, @samp{[n%]}.}
4603                 @{min@}     @r{Smallest number in column.}
4604                 @{max@}     @r{Largest number.}
4605                 @{mean@}    @r{Arithmetic mean of numbers.}
4606                 @{:min@}    @r{Smallest time value in column.}
4607                 @{:max@}    @r{Largest time value.}
4608                 @{:mean@}   @r{Arithmetic mean of time values.}
4609 @end example
4611 @noindent
4612 Here is an example for a complete columns definition, along with allowed
4613 values.
4615 @example
4616 :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.}
4617                    %10Time_Estimate@{:@} %CLOCKSUM
4618 :Owner_ALL:    Tammy Mark Karl Lisa Don
4619 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
4620 :Approved_ALL: "[ ]" "[X]"
4621 @end example
4623 @noindent
4624 The first column, @samp{%25ITEM}, means the first 25 characters of the
4625 item itself, @ie of the headline.  You probably always should start the
4626 column definition with the @samp{ITEM} specifier.  The other specifiers
4627 create columns @samp{Owner} with a list of names as allowed values, for
4628 @samp{Status} with four different possible values, and for a checkbox
4629 field @samp{Approved}.  When no width is given after the @samp{%}
4630 character, the column will be exactly as wide as it needs to be in order
4631 to fully display all values.  The @samp{Approved} column does have a
4632 modified title (@samp{Approved?}, with a question mark).  Summaries will
4633 be created for the @samp{Time_Estimate} column by adding time duration
4634 expressions like HH:MM, and for the @samp{Approved} column, by providing
4635 an @samp{[X]} status if all children have been checked.  The
4636 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
4637 in the subtree.
4639 @node Using column view, Capturing column view, Defining columns, Column view
4640 @subsection Using column view
4642 @table @kbd
4643 @tsubheading{Turning column view on and off}
4644 @kindex C-c C-x C-c
4645 @item C-c C-x C-c
4646 @vindex org-columns-default-format
4647 Turn on column view.  If the cursor is before the first headline in the file,
4648 column view is turned on for the entire file, using the @code{#+COLUMNS}
4649 definition.  If the cusor is somewhere inside the outline, this command
4650 searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
4651 defines a format.  When one is found, the column view table is established
4652 for the tree starting at the entry that contains the @code{:COLUMNS:}
4653 property.  If no such property is found, the format is taken from the
4654 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
4655 and column view is established for the current entry and its subtree.
4656 @kindex r
4657 @item r
4658 Recreate the column view, to include recent changes made in the buffer.
4659 @kindex g
4660 @item g
4661 Same as @kbd{r}.
4662 @kindex q
4663 @item q
4664 Exit column view.
4665 @tsubheading{Editing values}
4666 @item @key{left} @key{right} @key{up} @key{down}
4667 Move through the column view from field to field.
4668 @kindex S-@key{left}
4669 @kindex S-@key{right}
4670 @item  S-@key{left}/@key{right}
4671 Switch to the next/previous allowed value of the field.  For this, you
4672 have to have specified allowed values for a property.
4673 @item 1..9,0
4674 Directly select the nth allowed value, @kbd{0} selects the 10th value.
4675 @kindex n
4676 @kindex p
4677 @itemx  n / p
4678 Same as @kbd{S-@key{left}/@key{right}}
4679 @kindex e
4680 @item e
4681 Edit the property at point.  For the special properties, this will
4682 invoke the same interface that you normally use to change that
4683 property.  For example, when editing a TAGS property, the tag completion
4684 or fast selection interface will pop up.
4685 @kindex C-c C-c
4686 @item C-c C-c
4687 When there is a checkbox at point, toggle it.
4688 @kindex v
4689 @item v
4690 View the full value of this property.  This is useful if the width of
4691 the column is smaller than that of the value.
4692 @kindex a
4693 @item a
4694 Edit the list of allowed values for this property.  If the list is found
4695 in the hierarchy, the modified values is stored there.  If no list is
4696 found, the new value is stored in the first entry that is part of the
4697 current column view.
4698 @tsubheading{Modifying the table structure}
4699 @kindex <
4700 @kindex >
4701 @item < / >
4702 Make the column narrower/wider by one character.
4703 @kindex S-M-@key{right}
4704 @item S-M-@key{right}
4705 Insert a new column, to the left of the current column.
4706 @kindex S-M-@key{left}
4707 @item S-M-@key{left}
4708 Delete the current column.
4709 @end table
4711 @node Capturing column view,  , Using column view, Column view
4712 @subsection Capturing column view
4714 Since column view is just an overlay over a buffer, it cannot be
4715 exported or printed directly.  If you want to capture a column view, use
4716 a @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
4717 of this block looks like this:
4719 @cindex #+BEGIN, columnview
4720 @example
4721 * The column view
4722 #+BEGIN: columnview :hlines 1 :id "label"
4724 #+END:
4725 @end example
4727 @noindent This dynamic block has the following parameters:
4729 @table @code
4730 @item :id
4731 This is the most important parameter.  Column view is a feature that is
4732 often localized to a certain (sub)tree, and the capture block might be
4733 at a different location in the file.  To identify the tree whose view to
4734 capture, you can use 4 values:
4735 @cindex property, ID
4736 @example
4737 local     @r{use the tree in which the capture block is located}
4738 global    @r{make a global view, including all headings in the file}
4739 "file:@var{path-to-file}"
4740           @r{run column view at the top of this file}
4741 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
4742           @r{property with the value @i{label}.  You can use}
4743           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4744           @r{the current entry and copy it to the kill-ring.}
4745 @end example
4746 @item :hlines
4747 When @code{t}, insert an hline after every line.  When a number @var{N}, insert
4748 an hline before each headline with level @code{<= @var{N}}.
4749 @item :vlines
4750 When set to @code{t}, force column groups to get vertical lines.
4751 @item :maxlevel
4752 When set to a number, don't capture entries below this level.
4753 @item :skip-empty-rows
4754 When set to @code{t}, skip rows where the only non-empty specifier of the
4755 column view is @code{ITEM}.
4757 @end table
4759 @noindent
4760 The following commands insert or update the dynamic block:
4762 @table @kbd
4763 @kindex C-c C-x i
4764 @item C-c C-x i
4765 Insert a dynamic block capturing a column view.  You will be prompted
4766 for the scope or ID of the view.
4767 @kindex C-c C-c
4768 @item C-c C-c
4769 @kindex C-c C-x C-u
4770 @itemx C-c C-x C-u
4771 Update dynamic block at point.  The cursor needs to be in the
4772 @code{#+BEGIN} line of the dynamic block.
4773 @kindex C-u C-c C-x C-u
4774 @item C-u C-c C-x C-u
4775 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4776 you have several clock table blocks in a buffer.
4777 @end table
4779 You can add formulas to the column view table and you may add plotting
4780 instructions in front of the table---these will survive an update of the
4781 block.  If there is a @code{#+TBLFM:} after the table, the table will
4782 actually be recalculated automatically after an update.
4784 An alternative way to capture and process property values into a table is
4785 provided by Eric Schulte's @file{org-collector.el} which is a contributed
4786 package@footnote{Contributed packages are not part of Emacs, but are
4787 distributed with the main distribution of Org (visit
4788 @uref{http://orgmode.org}).}.  It provides a general API to collect
4789 properties from entries in a certain scope, and arbitrary Lisp expressions to
4790 process these values before inserting them into a table or a dynamic block.
4792 @node Property API,  , Column view, Properties and Columns
4793 @section The Property API
4794 @cindex properties, API
4795 @cindex API, for properties
4797 There is a full API for accessing and changing properties.  This API can
4798 be used by Emacs Lisp programs to work with properties and to implement
4799 features based on them.  For more information see @ref{Using the
4800 property API}.
4802 @node Dates and Times, Capture, Properties and Columns, Top
4803 @chapter Dates and Times
4804 @cindex dates
4805 @cindex times
4806 @cindex timestamp
4807 @cindex date stamp
4809 To assist project planning, TODO items can be labeled with a date and/or
4810 a time.  The specially formatted string carrying the date and time
4811 information is called a @emph{timestamp} in Org mode.  This may be a
4812 little confusing because timestamp is often used as indicating when
4813 something was created or last changed.  However, in Org mode this term
4814 is used in a much wider sense.
4816 @menu
4817 * Timestamps::                  Assigning a time to a tree entry
4818 * Creating timestamps::         Commands which insert timestamps
4819 * Deadlines and scheduling::    Planning your work
4820 * Clocking work time::          Tracking how long you spend on a task
4821 * Effort estimates::            Planning work effort in advance
4822 * Relative timer::              Notes with a running timer
4823 @end menu
4826 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4827 @section Timestamps, deadlines, and scheduling
4828 @cindex timestamps
4829 @cindex ranges, time
4830 @cindex date stamps
4831 @cindex deadlines
4832 @cindex scheduling
4834 A timestamp is a specification of a date (possibly with a time or a range
4835 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4836 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4837 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4838 use an alternative format, see @ref{Custom time format}.}.  A timestamp
4839 can appear anywhere in the headline or body of an Org tree entry.  Its
4840 presence causes entries to be shown on specific dates in the agenda
4841 (@pxref{Weekly/daily agenda}).  We distinguish:
4843 @table @var
4844 @item Plain timestamp; Event; Appointment
4845 @cindex timestamp
4846 A simple timestamp just assigns a date/time to an item.  This is just
4847 like writing down an appointment or event in a paper agenda.  In the
4848 timeline and agenda displays, the headline of an entry associated with a
4849 plain timestamp will be shown exactly on that date.
4851 @example
4852 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4853 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4854 @end example
4856 @item Timestamp with repeater interval
4857 @cindex timestamp, with repeater interval
4858 A timestamp may contain a @emph{repeater interval}, indicating that it
4859 applies not only on the given date, but again and again after a certain
4860 interval of N days (d), weeks (w), months (m), or years (y).  The
4861 following will show up in the agenda every Wednesday:
4863 @example
4864 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4865 @end example
4867 @item Diary-style sexp entries
4868 For more complex date specifications, Org mode supports using the
4869 special sexp diary entries implemented in the Emacs calendar/diary
4870 package.  For example
4872 @example
4873 * The nerd meeting on every 2nd Thursday of the month
4874   <%%(diary-float t 4 2)>
4875 @end example
4877 @item Time/Date range
4878 @cindex timerange
4879 @cindex date range
4880 Two timestamps connected by @samp{--} denote a range.  The headline
4881 will be shown on the first and last day of the range, and on any dates
4882 that are displayed and fall in the range.  Here is an example:
4884 @example
4885 ** Meeting in Amsterdam
4886    <2004-08-23 Mon>--<2004-08-26 Thu>
4887 @end example
4889 @item Inactive timestamp
4890 @cindex timestamp, inactive
4891 @cindex inactive timestamp
4892 Just like a plain timestamp, but with square brackets instead of
4893 angular ones.  These timestamps are inactive in the sense that they do
4894 @emph{not} trigger an entry to show up in the agenda.
4896 @example
4897 * Gillian comes late for the fifth time [2006-11-01 Wed]
4898 @end example
4900 @end table
4902 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4903 @section Creating timestamps
4904 @cindex creating timestamps
4905 @cindex timestamps, creating
4907 For Org mode to recognize timestamps, they need to be in the specific
4908 format.  All commands listed below produce timestamps in the correct
4909 format.
4911 @table @kbd
4912 @kindex C-c .
4913 @item C-c .
4914 Prompt for a date and insert a corresponding timestamp.  When the cursor is
4915 at an existing timestamp in the buffer, the command is used to modify this
4916 timestamp instead of inserting a new one.  When this command is used twice in
4917 succession, a time range is inserted.
4919 @kindex C-c !
4920 @item C-c !
4921 Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
4922 an agenda entry.
4924 @kindex C-u C-c .
4925 @kindex C-u C-c !
4926 @item C-u C-c .
4927 @itemx C-u C-c !
4928 @vindex org-time-stamp-rounding-minutes
4929 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
4930 contains date and time.  The default time can be rounded to multiples of 5
4931 minutes, see the option @code{org-time-stamp-rounding-minutes}.
4933 @kindex C-c <
4934 @item C-c <
4935 Insert a timestamp corresponding to the cursor date in the Calendar.
4937 @kindex C-c >
4938 @item C-c >
4939 Access the Emacs calendar for the current date.  If there is a
4940 timestamp in the current line, go to the corresponding date
4941 instead.
4943 @kindex C-c C-o
4944 @item C-c C-o
4945 Access the agenda for the date given by the timestamp or -range at
4946 point (@pxref{Weekly/daily agenda}).
4948 @kindex S-@key{left}
4949 @kindex S-@key{right}
4950 @item S-@key{left}
4951 @itemx S-@key{right}
4952 Change date at cursor by one day.  These key bindings conflict with
4953 shift-selection and related modes (@pxref{Conflicts}).
4955 @kindex S-@key{up}
4956 @kindex S-@key{down}
4957 @item S-@key{up}
4958 @itemx S-@key{down}
4959 Change the item under the cursor in a timestamp.  The cursor can be on a
4960 year, month, day, hour or minute.  When the timestamp contains a time range
4961 like @samp{15:30-16:30}, modifying the first time will also shift the second,
4962 shifting the time block with constant length.  To change the length, modify
4963 the second time.  Note that if the cursor is in a headline and not at a
4964 timestamp, these same keys modify the priority of an item.
4965 (@pxref{Priorities}). The key bindings also conflict with shift-selection and
4966 related modes (@pxref{Conflicts}).
4968 @kindex C-c C-y
4969 @cindex evaluate time range
4970 @item C-c C-y
4971 Evaluate a time range by computing the difference between start and end.
4972 With a prefix argument, insert result after the time range (in a table: into
4973 the following column).
4974 @end table
4977 @menu
4978 * The date/time prompt::        How Org mode helps you entering date and time
4979 * Custom time format::          Making dates look different
4980 @end menu
4982 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4983 @subsection The date/time prompt
4984 @cindex date, reading in minibuffer
4985 @cindex time, reading in minibuffer
4987 @vindex org-read-date-prefer-future
4988 When Org mode prompts for a date/time, the default is shown as an ISO
4989 date, and the prompt therefore seems to ask for an ISO date.  But it
4990 will in fact accept any string containing some date and/or time
4991 information, and it is really smart about interpreting your input.  You
4992 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4993 copied from an email message.  Org mode will find whatever information
4994 is in there and derive anything you have not specified from the
4995 @emph{default date and time}.  The default is usually the current date
4996 and time, but when modifying an existing timestamp, or when entering
4997 the second stamp of a range, it is taken from the stamp in the buffer.
4998 When filling in information, Org mode assumes that most of the time you
4999 will want to enter a date in the future: if you omit the month/year and
5000 the given day/month is @i{before} today, it will assume that you mean a
5001 future date@footnote{See the variable
5002 @code{org-read-date-prefer-future}.}.
5004 For example, let's assume that today is @b{June 13, 2006}.  Here is how
5005 various inputs will be interpreted, the items filled in by Org mode are
5006 in @b{bold}.
5008 @example
5009 3-2-5         --> 2003-02-05
5010 14            --> @b{2006}-@b{06}-14
5011 12            --> @b{2006}-@b{07}-12
5012 Fri           --> nearest Friday (defaultdate or later)
5013 sep 15        --> @b{2006}-09-15
5014 feb 15        --> @b{2007}-02-15
5015 sep 12 9      --> 2009-09-12
5016 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
5017 22 sept 0:34  --> @b{2006}-09-22 0:34
5018 w4            --> ISO week for of the current year @b{2006}
5019 2012 w4 fri   --> Friday of ISO week 4 in 2012
5020 2012-w04-5    --> Same as above
5021 @end example
5023 Furthermore you can specify a relative date by giving, as the
5024 @emph{first} thing in the input: a plus/minus sign, a number and a
5025 letter ([dwmy]) to indicate change in days, weeks, months, or years.  With a
5026 single plus or minus, the date is always relative to today.  With a
5027 double plus or minus, it is relative to the default date.  If instead of
5028 a single letter, you use the abbreviation of day name, the date will be
5029 the nth such day.  @Eg
5031 @example
5032 +0            --> today
5033 .             --> today
5034 +4d           --> four days from today
5035 +4            --> same as above
5036 +2w           --> two weeks from today
5037 ++5           --> five days from default date
5038 +2tue         --> second Tuesday from now.
5039 @end example
5041 @vindex parse-time-months
5042 @vindex parse-time-weekdays
5043 The function understands English month and weekday abbreviations.  If
5044 you want to use unabbreviated names and/or other languages, configure
5045 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
5047 @cindex calendar, for selecting date
5048 @vindex org-popup-calendar-for-date-prompt
5049 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
5050 you don't need/want the calendar, configure the variable
5051 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
5052 prompt, either by clicking on a date in the calendar, or by pressing
5053 @key{RET}, the date selected in the calendar will be combined with the
5054 information entered at the prompt.  You can control the calendar fully
5055 from the minibuffer:
5057 @kindex <
5058 @kindex >
5059 @kindex mouse-1
5060 @kindex S-@key{right}
5061 @kindex S-@key{left}
5062 @kindex S-@key{down}
5063 @kindex S-@key{up}
5064 @kindex M-S-@key{right}
5065 @kindex M-S-@key{left}
5066 @kindex @key{RET}
5067 @example
5068 > / <          @r{Scroll calendar forward/backward by one month.}
5069 mouse-1        @r{Select date by clicking on it.}
5070 S-@key{right}/@key{left}     @r{One day forward/backward.}
5071 S-@key{down}/@key{up}     @r{One week forward/backward.}
5072 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
5073 @key{RET}           @r{Choose date in calendar.}
5074 @end example
5076 @vindex org-read-date-display-live
5077 The actions of the date/time prompt may seem complex, but I assure you they
5078 will grow on you, and you will start getting annoyed by pretty much any other
5079 way of entering a date/time out there.  To help you understand what is going
5080 on, the current interpretation of your input will be displayed live in the
5081 minibuffer@footnote{If you find this distracting, turn the display of with
5082 @code{org-read-date-display-live}.}.
5084 @node Custom time format,  , The date/time prompt, Creating timestamps
5085 @subsection Custom time format
5086 @cindex custom date/time format
5087 @cindex time format, custom
5088 @cindex date format, custom
5090 @vindex org-display-custom-times
5091 @vindex org-time-stamp-custom-formats
5092 Org mode uses the standard ISO notation for dates and times as it is
5093 defined in ISO 8601.  If you cannot get used to this and require another
5094 representation of date and time to keep you happy, you can get it by
5095 customizing the variables @code{org-display-custom-times} and
5096 @code{org-time-stamp-custom-formats}.
5098 @table @kbd
5099 @kindex C-c C-x C-t
5100 @item C-c C-x C-t
5101 Toggle the display of custom formats for dates and times.
5102 @end table
5104 @noindent
5105 Org mode needs the default format for scanning, so the custom date/time
5106 format does not @emph{replace} the default format---instead it is put
5107 @emph{over} the default format using text properties.  This has the
5108 following consequences:
5109 @itemize @bullet
5110 @item
5111 You cannot place the cursor onto a timestamp anymore, only before or
5112 after.
5113 @item
5114 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
5115 each component of a timestamp.  If the cursor is at the beginning of
5116 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
5117 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
5118 time will be changed by one minute.
5119 @item
5120 If the timestamp contains a range of clock times or a repeater, these
5121 will not be overlayed, but remain in the buffer as they were.
5122 @item
5123 When you delete a timestamp character-by-character, it will only
5124 disappear from the buffer after @emph{all} (invisible) characters
5125 belonging to the ISO timestamp have been removed.
5126 @item
5127 If the custom timestamp format is longer than the default and you are
5128 using dates in tables, table alignment will be messed up.  If the custom
5129 format is shorter, things do work as expected.
5130 @end itemize
5133 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
5134 @section Deadlines and scheduling
5136 A timestamp may be preceded by special keywords to facilitate planning:
5138 @table @var
5139 @item DEADLINE
5140 @cindex DEADLINE keyword
5142 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
5143 to be finished on that date.
5145 @vindex org-deadline-warning-days
5146 On the deadline date, the task will be listed in the agenda.  In
5147 addition, the agenda for @emph{today} will carry a warning about the
5148 approaching or missed deadline, starting
5149 @code{org-deadline-warning-days} before the due date, and continuing
5150 until the entry is marked DONE.  An example:
5152 @example
5153 *** TODO write article about the Earth for the Guide
5154     The editor in charge is [[bbdb:Ford Prefect]]
5155     DEADLINE: <2004-02-29 Sun>
5156 @end example
5158 You can specify a different lead time for warnings for a specific
5159 deadlines using the following syntax.  Here is an example with a warning
5160 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
5162 @item SCHEDULED
5163 @cindex SCHEDULED keyword
5165 Meaning: you are planning to start working on that task on the given
5166 date.
5168 @vindex org-agenda-skip-scheduled-if-done
5169 The headline will be listed under the given date@footnote{It will still
5170 be listed on that date after it has been marked DONE.  If you don't like
5171 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
5172 addition, a reminder that the scheduled date has passed will be present
5173 in the compilation for @emph{today}, until the entry is marked DONE.
5174 @Ie the task will automatically be forwarded until completed.
5176 @example
5177 *** TODO Call Trillian for a date on New Years Eve.
5178     SCHEDULED: <2004-12-25 Sat>
5179 @end example
5181 @noindent
5182 @b{Important:} Scheduling an item in Org mode should @i{not} be
5183 understood in the same way that we understand @i{scheduling a meeting}.
5184 Setting a date for a meeting is just a simple appointment, you should
5185 mark this entry with a simple plain timestamp, to get this item shown
5186 on the date where it applies.  This is a frequent misunderstanding by
5187 Org users.  In Org mode, @i{scheduling} means setting a date when you
5188 want to start working on an action item.
5189 @end table
5191 You may use timestamps with repeaters in scheduling and deadline
5192 entries.  Org mode will issue early and late warnings based on the
5193 assumption that the timestamp represents the @i{nearest instance} of
5194 the repeater.  However, the use of diary sexp entries like
5196 @code{<%%(diary-float t 42)>}
5198 in scheduling and deadline timestamps is limited.  Org mode does not
5199 know enough about the internals of each sexp function to issue early and
5200 late warnings.  However, it will show the item on each day where the
5201 sexp entry matches.
5203 @menu
5204 * Inserting deadline/schedule::  Planning items
5205 * Repeated tasks::              Items that show up again and again
5206 @end menu
5208 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
5209 @subsection Inserting deadlines or schedules
5211 The following commands allow you to quickly insert a deadline or to schedule
5212 an item:
5214 @table @kbd
5216 @kindex C-c C-d
5217 @item C-c C-d
5218 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
5219 happen in the line directly following the headline.  When called with a
5220 prefix arg, an existing deadline will be removed from the entry.
5221 @c FIXME Any CLOSED timestamp will be removed.????????
5223 @kindex C-c C-s
5224 @item C-c C-s
5225 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
5226 happen in the line directly following the headline.  Any CLOSED
5227 timestamp will be removed.  When called with a prefix argument, remove
5228 the scheduling date from the entry.
5230 @kindex C-c C-x C-k
5231 @kindex k a
5232 @kindex k s
5233 @item C-c C-x C-k
5234 Mark the current entry for agenda action.  After you have marked the entry
5235 like this, you can open the agenda or the calendar to find an appropriate
5236 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
5237 schedule the marked item.
5239 @kindex C-c / d
5240 @cindex sparse tree, for deadlines
5241 @item C-c / d
5242 @vindex org-deadline-warning-days
5243 Create a sparse tree with all deadlines that are either past-due, or
5244 which will become due within @code{org-deadline-warning-days}.
5245 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
5246 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
5247 all deadlines due tomorrow.
5249 @kindex C-c / b
5250 @item C-c / b
5251 Sparse tree for deadlines and scheduled items before a given date.
5253 @kindex C-c / a
5254 @item C-c / a
5255 Sparse tree for deadlines and scheduled items after a given date.
5256 @end table
5258 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
5259 @subsection Repeated tasks
5260 @cindex tasks, repeated
5261 @cindex repeated tasks
5263 Some tasks need to be repeated again and again.  Org mode helps to
5264 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
5265 or plain timestamp.  In the following example
5266 @example
5267 ** TODO Pay the rent
5268    DEADLINE: <2005-10-01 Sat +1m>
5269 @end example
5270 @noindent
5271 the @code{+1m} is a repeater; the intended interpretation is that the task
5272 has a deadline on <2005-10-01> and repeats itself every (one) month starting
5273 from that time.  If you need both a repeater and a special warning period in
5274 a deadline entry, the repeater should come first and the warning period last:
5275 @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
5277 Deadlines and scheduled items produce entries in the agenda when they
5278 are over-due, so it is important to be able to mark such an entry as
5279 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
5280 with the TODO keyword DONE, it will no longer produce entries in the
5281 agenda.  The problem with this is, however, that then also the
5282 @emph{next} instance of the repeated entry will not be active.  Org mode
5283 deals with this in the following way: When you try to mark such an entry
5284 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
5285 timestamp by the repeater interval, and immediately set the entry state
5286 back to TODO.  In the example above, setting the state to DONE would
5287 actually switch the date like this:
5289 @example
5290 ** TODO Pay the rent
5291    DEADLINE: <2005-11-01 Tue +1m>
5292 @end example
5294 @vindex org-log-repeat
5295 A timestamp@footnote{You can change this using the option
5296 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
5297 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
5298 will also be prompted for a note.} will be added under the deadline, to keep
5299 a record that you actually acted on the previous instance of this deadline.
5301 As a consequence of shifting the base date, this entry will no longer be
5302 visible in the agenda when checking past dates, but all future instances
5303 will be visible.
5305 With the @samp{+1m} cookie, the date shift will always be exactly one
5306 month.  So if you have not paid the rent for three months, marking this
5307 entry DONE will still keep it as an overdue deadline.  Depending on the
5308 task, this may not be the best way to handle it.  For example, if you
5309 forgot to call you father for 3 weeks, it does not make sense to call
5310 him 3 times in a single day to make up for it.  Finally, there are tasks
5311 like changing batteries which should always repeat a certain time
5312 @i{after} the last time you did it.  For these tasks, Org mode has
5313 special repeaters markers with @samp{++} and @samp{.+}.  For example:
5315 @example
5316 ** TODO Call Father
5317    DEADLINE: <2008-02-10 Sun ++1w>
5318    Marking this DONE will shift the date by at least one week,
5319    but also by as many weeks as it takes to get this date into
5320    the future.  However, it stays on a Sunday, even if you called
5321    and marked it done on Saturday.
5322 ** TODO Check the batteries in the smoke detectors
5323    DEADLINE: <2005-11-01 Tue .+1m>
5324    Marking this DONE will shift the date to one month after
5325    today.
5326 @end example
5328 You may have both scheduling and deadline information for a specific
5329 task---just make sure that the repeater intervals on both are the same.
5331 An alternative to using a repeater is to create a number of copies of a task
5332 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
5333 created for this purpose, it is described in @ref{Structure editing}.
5336 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
5337 @section Clocking work time
5339 Org mode allows you to clock the time you spend on specific tasks in a
5340 project.  When you start working on an item, you can start the clock.
5341 When you stop working on that task, or when you mark the task done, the
5342 clock is stopped and the corresponding time interval is recorded.  It
5343 also computes the total time spent on each subtree of a project.
5345 Normally, the clock does not survive exiting and re-entering Emacs, but you
5346 can arrange for the clock information to persist across Emacs sessions with
5348 @lisp
5349 (setq org-clock-persist t)
5350 (org-clock-persistence-insinuate)
5351 @end lisp
5353 @table @kbd
5354 @kindex C-c C-x C-i
5355 @item C-c C-x C-i
5356 @vindex org-clock-into-drawer
5357 Start the clock on the current item (clock-in).  This inserts the CLOCK
5358 keyword together with a timestamp.  If this is not the first clocking of
5359 this item, the multiple CLOCK lines will be wrapped into a
5360 @code{:LOGBOOK:} drawer (see also the variable
5361 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
5362 select the task from a list of recently clocked tasks.  With two @kbd{C-u
5363 C-u} prefixes, clock into the task at point and mark it as the default task.
5364 The default task will always be available when selecting a clocking task,
5365 with letter @kbd{d}.@*
5366 @cindex property: CLOCK_MODELINE_TOTAL
5367 @cindex property: LAST_REPEAT
5368 @vindex org-clock-modeline-total
5369 While the clock is running, the current clocking time is shown in the mode
5370 line, along with the title of the task.  The clock time shown will be all
5371 time ever clocked for this task and its children.  If the task has an effort
5372 estimate (@pxref{Effort estimates}), the mode line displays the current
5373 clocking time against it@footnote{To add an effort estimate ``on the fly'',
5374 hook a function doing this to @code{org-clock-in-prepare-hook}.}  If the task
5375 is a repeating one (@pxref{Repeated tasks}), only the time since the last
5376 reset of the task @footnote{as recorded by the @code{LAST_REPEAT} property}
5377 will be shown.  More control over what time is shown can be exercised with
5378 the @code{CLOCK_MODELINE_TOTAL} property.  It may have the values
5379 @code{current} to show only the current clocking instance, @code{today} to
5380 show all time clocked on this tasks today (see also the variable
5381 @code{org-extend-today-until}), @code{all} to include all time, or
5382 @code{auto} which is the default@footnote{See also the variable
5383 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
5384 mode line entry will pop up a menu with clocking options.
5385 @kindex C-c C-x C-o
5386 @item C-c C-x C-o
5387 @vindex org-log-note-clock-out
5388 Stop the clock (clock-out).  This inserts another timestamp at the same
5389 location where the clock was last started.  It also directly computes
5390 the resulting time in inserts it after the time range as @samp{=>
5391 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
5392 possibility to record an additional note together with the clock-out
5393 timestamp@footnote{The corresponding in-buffer setting is:
5394 @code{#+STARTUP: lognoteclock-out}}.
5395 @kindex C-c C-x C-e
5396 @item C-c C-x C-e
5397 Update the effort estimate for the current clock task.
5398 @kindex C-c C-y
5399 @kindex C-c C-c
5400 @item C-c C-y @ @ @r{or}@ @ C-c C-c
5401 Recompute the time interval after changing one of the timestamps.  This
5402 is only necessary if you edit the timestamps directly.  If you change
5403 them with @kbd{S-@key{cursor}} keys, the update is automatic.
5404 @kindex C-c C-t
5405 @item C-c C-t
5406 Changing the TODO state of an item to DONE automatically stops the clock
5407 if it is running in this same item.
5408 @kindex C-c C-x C-x
5409 @item C-c C-x C-x
5410 Cancel the current clock.  This is useful if a clock was started by
5411 mistake, or if you ended up working on something else.
5412 @kindex C-c C-x C-j
5413 @item C-c C-x C-j
5414 Jump to the entry that contains the currently running clock.  With a
5415 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
5416 tasks.
5417 @kindex C-c C-x C-d
5418 @item C-c C-x C-d
5419 @vindex org-remove-highlights-with-change
5420 Display time summaries for each subtree in the current buffer.  This
5421 puts overlays at the end of each headline, showing the total time
5422 recorded under that heading, including the time of any subheadings. You
5423 can use visibility cycling to study the tree, but the overlays disappear
5424 when you change the buffer (see variable
5425 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
5426 @kindex C-c C-x C-r
5427 @item C-c C-x C-r
5428 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
5429 report as an Org-mode table into the current file.  When the cursor is
5430 at an existing clock table, just update it.  When called with a prefix
5431 argument, jump to the first clock report in the current document and
5432 update it.
5433 @cindex #+BEGIN, clocktable
5434 @example
5435 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
5436 #+END: clocktable
5437 @end example
5438 @noindent
5439 If such a block already exists at point, its content is replaced by the
5440 new table.  The @samp{BEGIN} line can specify options:
5441 @example
5442 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
5443 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
5444 :scope       @r{The scope to consider.  This can be any of the following:}
5445              nil        @r{the current buffer or narrowed region}
5446              file       @r{the full current buffer}
5447              subtree    @r{the subtree where the clocktable is located}
5448              tree@var{N}      @r{the surrounding level @var{N} tree, for example @code{tree3}}
5449              tree       @r{the surrounding level 1 tree}
5450              agenda     @r{all agenda files}
5451              ("file"..) @r{scan these files}
5452              file-with-archives    @r{current file and its archives}
5453              agenda-with-archives  @r{all agenda files, including archives}
5454 :block       @r{The time block to consider.  This block is specified either}
5455              @r{absolute, or relative to the current time and may be any of}
5456              @r{these formats:}
5457              2007-12-31    @r{New year eve 2007}
5458              2007-12       @r{December 2007}
5459              2007-W50      @r{ISO-week 50 in 2007}
5460              2007          @r{the year 2007}
5461              today, yesterday, today-@var{N}          @r{a relative day}
5462              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
5463              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
5464              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
5465              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
5466 :tstart      @r{A time string specifying when to start considering times.}
5467 :tend        @r{A time string specifying when to stop considering times.}
5468 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
5469              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
5470 :link        @r{Link the item headlines in the table to their origins.}
5471 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
5472              @r{As a special case, @samp{:formula %} adds a column with % time.}
5473              @r{If you do not specify a formula here, any existing formula.}
5474              @r{below the clock table will survive updates and be evaluated.}
5475 :timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
5476              @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
5477 @end example
5478 To get a clock summary of the current level 1 tree, for the current
5479 day, you could write
5480 @example
5481 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
5482 #+END: clocktable
5483 @end example
5484 @noindent
5485 and to use a specific time range you could write@footnote{Note that all
5486 parameters must be specified in a single line---the line is broken here
5487 only to fit it into the manual.}
5488 @example
5489 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
5490                     :tend "<2006-08-10 Thu 12:00>"
5491 #+END: clocktable
5492 @end example
5493 A summary of the current subtree with % times would be
5494 @example
5495 #+BEGIN: clocktable :scope subtree :link t :formula %
5496 #+END: clocktable
5497 @end example
5498 @kindex C-c C-c
5499 @item C-c C-c
5500 @kindex C-c C-x C-u
5501 @itemx C-c C-x C-u
5502 Update dynamic block at point.  The cursor needs to be in the
5503 @code{#+BEGIN} line of the dynamic block.
5504 @kindex C-u C-c C-x C-u
5505 @item C-u C-c C-x C-u
5506 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5507 you have several clock table blocks in a buffer.
5508 @kindex S-@key{left}
5509 @kindex S-@key{right}
5510 @item S-@key{left}
5511 @itemx S-@key{right}
5512 Shift the current @code{:block} interval and update the table.  The cursor
5513 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
5514 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
5515 @end table
5517 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
5518 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
5519 worked on or closed during a day.
5521 @node Effort estimates, Relative timer, Clocking work time, Dates and Times
5522 @section Effort estimates
5523 @cindex effort estimates
5525 @cindex property, Effort
5526 @vindex org-effort-property
5527 If you want to plan your work in a very detailed way, or if you need to
5528 produce offers with quotations of the estimated work effort, you may want to
5529 assign effort estimates to entries.  If you are also clocking your work, you
5530 may later want to compare the planned effort with the actual working time, a
5531 great way to improve planning estimates.  Effort estimates are stored in a
5532 special property @samp{Effort}@footnote{You may change the property being
5533 used with the variable @code{org-effort-property}.}.  You can set the effort
5534 for an entry with the following commands:
5536 @table @kbd
5537 @kindex C-c C-x e
5538 @item C-c C-x e
5539 Set the effort estimate for the current entry.  With a numeric prefix
5540 argument, set it to the NTH allowed value (see below).  This command is also
5541 accessible from the agenda with the @kbd{e} key.
5542 @kindex C-c C-x C-e
5543 @item C-c C-x C-e
5544 Modify the effort estimate of the item currently being clocked.
5545 @end table
5547 Clearly the best way to work with effort estimates is through column view
5548 (@pxref{Column view}).  You should start by setting up discrete values for
5549 effort estimates, and a @code{COLUMNS} format that displays these values
5550 together with clock sums (if you want to clock your time).  For a specific
5551 buffer you can use
5553 @example
5554 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
5555 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
5556 @end example
5558 @noindent
5559 @vindex org-global-properties
5560 @vindex org-columns-default-format
5561 or, even better, you can set up these values globally by customizing the
5562 variables @code{org-global-properties} and @code{org-columns-default-format}.
5563 In particular if you want to use this setup also in the agenda, a global
5564 setup may be advised.
5566 The way to assign estimates to individual items is then to switch to column
5567 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
5568 value.  The values you enter will immediately be summed up in the hierarchy.
5569 In the column next to it, any clocked time will be displayed.
5571 @vindex org-agenda-columns-add-appointments-to-effort-sum
5572 If you switch to column view in the daily/weekly agenda, the effort column
5573 will summarize the estimated work effort for each day@footnote{Please note
5574 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
5575 column view}).}, and you can use this to find space in your schedule.  To get
5576 an overview of the entire part of the day that is committed, you can set the
5577 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
5578 appointments on a day that take place over a specified time interval will
5579 then also be added to the load estimate of the day.
5581 Effort estimates can be used in secondary agenda filtering that is triggered
5582 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
5583 these estimates defined consistently, two or three key presses will narrow
5584 down the list to stuff that fits into an available time slot.
5586 @node Relative timer,  , Effort estimates, Dates and Times
5587 @section Taking notes with a relative timer
5588 @cindex relative timer
5590 When taking notes during, for example, a meeting or a video viewing, it can
5591 be useful to have access to times relative to a starting time.  Org provides
5592 such a relative timer and make it easy to create timed notes.
5594 @table @kbd
5595 @kindex C-c C-x .
5596 @item C-c C-x .
5597 Insert a relative time into the buffer.  The first time you use this, the
5598 timer will be started.  When called with a prefix argument, the timer is
5599 restarted.
5600 @kindex C-c C-x -
5601 @item C-c C-x -
5602 Insert a description list item with the current relative time.  With a prefix
5603 argument, first reset the timer to 0.
5604 @kindex M-@key{RET}
5605 @item M-@key{RET}
5606 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
5607 new timer items.
5608 @kindex C-c C-x ,
5609 @item C-c C-x ,
5610 Pause the timer, or continue it if it is already paused.
5611 @c removed the sentence because it is redundant to the following item
5612 @kindex C-u C-c C-x ,
5613 @item C-u C-c C-x ,
5614 Stop the timer.  After this, you can only start a new timer, not continue the
5615 old one.  This command also removes the timer from the mode line.
5616 @kindex C-c C-x 0
5617 @item C-c C-x 0
5618 Reset the timer without inserting anything into the buffer.  By default, the
5619 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
5620 specific starting offset.  The user is prompted for the offset, with a
5621 default taken from a timer string at point, if any, So this can be used to
5622 restart taking notes after a break in the process.  When called with a double
5623 prefix argument @kbd{C-c C-u}, change all timer strings in the active region
5624 by a certain amount.  This can be used to fix timer strings if the timer was
5625 not started at exactly the right moment.
5626 @end table
5628 @node Capture, Agenda Views, Dates and Times, Top
5629 @chapter Capture
5630 @cindex capture
5632 An important part of any organization system is the ability to quickly
5633 capture new ideas and tasks, and to associate reference material with them.
5634 Org uses the @file{remember.el} package to create tasks, and stores files
5635 related to a task (@i{attachments}) in a special directory.
5637 @menu
5638 * Remember::                    Capture new tasks/ideas with little interruption
5639 * Attachments::                 Add files to tasks.
5640 * RSS Feeds::                   Getting input from RSS feeds
5641 * Protocols::                   External (@eg Browser) access to Emacs and Org
5642 @end menu
5644 @node Remember, Attachments, Capture, Capture
5645 @section Remember
5646 @cindex @file{remember.el}
5648 The Remember package by John Wiegley lets you store quick notes with little
5649 interruption of your work flow.  It is an excellent way to add new notes and
5650 tasks to Org files.  The @code{remember.el} package is part of Emacs 23, not
5651 Emacs 22.  See @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for
5652 more information.
5654 Org significantly expands the possibilities of Remember: you may define
5655 templates for different note types, and associate target files and headlines
5656 with specific templates.  It also allows you to select the location where a
5657 note should be stored interactively, on the fly.
5659 @menu
5660 * Setting up Remember for Org:: Some code for .emacs to get things going
5661 * Remember templates::          Define the outline of different note types
5662 * Storing notes::               Directly get the note to where it belongs
5663 * Refiling notes::              Moving a note or task to a project
5664 @end menu
5666 @node Setting up Remember for Org, Remember templates, Remember, Remember
5667 @subsection Setting up Remember for Org
5669 The following customization will tell Remember to use Org files as
5670 target, and to create annotations compatible with Org links.
5672 @example
5673 (org-remember-insinuate)
5674 (setq org-directory "~/path/to/my/orgfiles/")
5675 (setq org-default-notes-file (concat org-directory "/notes.org"))
5676 (define-key global-map "\C-cr" 'org-remember)
5677 @end example
5679 @noindent
5680 The last line binds the command @code{org-remember} to a global
5681 key@footnote{Please select your own key, @kbd{C-c r} is only a
5682 suggestion.}.  @code{org-remember} basically just calls Remember,
5683 but it makes a few things easier: if there is an active region, it will
5684 automatically copy the region into the Remember buffer.  It also allows
5685 to jump to the buffer and location where Remember notes are being
5686 stored: just call @code{org-remember} with a prefix argument.  If you
5687 use two prefix arguments, Org jumps to the location where the last
5688 remember note was stored.
5690 The Remember buffer will actually use @code{org-mode} as its major mode, so
5691 that all editing features of Org mode are available.  In addition to this, a
5692 minor mode @code{org-remember-mode} is turned on, for the single purpose that
5693 you can use its keymap @code{org-remember-mode-map} to overwrite some of
5694 Org mode's key bindings.
5696 You can also call @code{org-remember} in a special way from the agenda,
5697 using the @kbd{k r} key combination.  With this access, any timestamps
5698 inserted by the selected Remember template (see below) will default to
5699 the cursor date in the agenda, rather than to the current date.
5701 @node Remember templates, Storing notes, Setting up Remember for Org, Remember
5702 @subsection Remember templates
5703 @cindex templates, for Remember
5705 In combination with Org, you can use templates to generate
5706 different types of Remember notes.  For example, if you would like
5707 to use one template to create general TODO entries, another one for
5708 journal entries, and a third one for collecting random ideas, you could
5709 use:
5711 @example
5712 (setq org-remember-templates
5713  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
5714    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
5715    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5716 @end example
5718 @vindex org-remember-default-headline
5719 @vindex org-directory
5720 @noindent In these entries, the first string is just a name, and the
5721 character specifies how to select the template.  It is useful if the
5722 character is also the first letter of the name.  The next string specifies
5723 the template.  Two more (optional) strings give the file in which, and the
5724 headline under which, the new note should be stored.  The file (if not present
5725 or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
5726 @code{org-remember-default-headline}.  If the file name is not an absolute
5727 path, it will be interpreted relative to @code{org-directory}.  The heading
5728 can also be the symbols @code{top} or @code{bottom} to send notes as level 1
5729 entries to the beginning or end of the file, respectively.
5731 An optional sixth element specifies the contexts in which the user can select
5732 the template.  This element can be a list of major modes or a function.
5733 @code{org-remember} will first check whether the function returns @code{t} or
5734 if we are in any of the listed major modes, and exclude templates for which
5735 this condition is not fulfilled.  Templates that do not specify this element
5736 at all, or that use @code{nil} or @code{t} as a value will always be
5737 selectable.
5739 So for example:
5741 @example
5742 (setq org-remember-templates
5743  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
5744    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
5745    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5746 @end example
5748 @noindent
5749 The first template will only be available when invoking @code{org-remember}
5750 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
5751 available when the function @code{my-check} returns @code{t}.  The third
5752 template will be proposed in any context.
5754 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
5755 something, Org will prompt for a key to select the template (if you have
5756 more than one template) and then prepare the buffer like
5757 @example
5758 * TODO
5759   [[file:@var{link to where you called remember}]]
5760 @end example
5762 @noindent
5763 During expansion of the template, special @kbd{%}-escapes@footnote{If you
5764 need one of these sequences literally, escape the @kbd{%} with a backslash.}
5765 allow dynamic insertion of content:
5766 @example
5767 %^@{@var{prompt}@}  @r{prompt the user for a string and replace this sequence with it.}
5768             @r{You may specify a default value and a completion table with}
5769             @r{%^@{prompt|default|completion2|completion3...@}}
5770             @r{The arrow keys access a prompt-specific history.}
5771 %a          @r{annotation, normally the link created with @code{org-store-link}}
5772 %A          @r{like @code{%a}, but prompt for the description part}
5773 %i          @r{initial content, the region when remember is called with C-u.}
5774             @r{The entire text will be indented like @code{%i} itself.}
5775 %t          @r{timestamp, date only}
5776 %T          @r{timestamp with date and time}
5777 %u, %U      @r{like the above, but inactive timestamps}
5778 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
5779             @r{You may define a prompt like @code{%^@{Birthday@}t}}
5780 %n          @r{user name (taken from @code{user-full-name})}
5781 %c          @r{Current kill ring head.}
5782 %x          @r{Content of the X clipboard.}
5783 %^C         @r{Interactive selection of which kill or clip to use.}
5784 %^L         @r{Like @code{%^C}, but insert as link.}
5785 %^g         @r{prompt for tags, with completion on tags in target file.}
5786 %k          @r{title of currently clocked task}
5787 %K          @r{link to currently clocked task}
5788 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
5789 %^@{@var{prop}@}p   @r{Prompt the user for a value for property @var{prop}}
5790 %:keyword   @r{specific information for certain link types, see below}
5791 %[@var{file}]     @r{insert the contents of the file given by @var{file}}
5792 %(@var{sexp})     @r{evaluate Elisp @var{sexp} and replace with the result}
5793 %!          @r{immediately store note after completing the template}
5794             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
5795 %&          @r{jump to target location immediately after storing note}
5796 @end example
5798 @noindent
5799 For specific link types, the following keywords will be
5800 defined@footnote{If you define your own link types (@pxref{Adding
5801 hyperlink types}), any property you store with
5802 @code{org-store-link-props} can be accessed in remember templates in a
5803 similar way.}:
5805 @vindex org-from-is-user-regexp
5806 @example
5807 Link type          |  Available keywords
5808 -------------------+----------------------------------------------
5809 bbdb               |  %:name %:company
5810 bbdb               |  %::server %:port %:nick
5811 vm, wl, mh, rmail  |  %:type %:subject %:message-id
5812                    |  %:from %:fromname %:fromaddress
5813                    |  %:to   %:toname   %:toaddress
5814                    |  %: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}.}}
5815 gnus               |  %:group, @r{for messages also all email fields}
5816 w3, w3m            |  %:url
5817 info               |  %:file %:node
5818 calendar           |  %:date"
5819 @end example
5821 @noindent
5822 To place the cursor after template expansion use:
5824 @example
5825 %?          @r{After completing the template, position cursor here.}
5826 @end example
5828 @noindent
5829 If you change your mind about which template to use, call
5830 @code{org-remember} in the remember buffer.  You may then select a new
5831 template that will be filled with the previous context information.
5833 @node Storing notes, Refiling notes, Remember templates, Remember
5834 @subsection Storing notes
5836 @vindex org-remember-clock-out-on-exit
5837 When you are finished preparing a note with Remember, you have to press
5838 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
5839 Remember buffer, you will first be asked if you want to clock out
5840 now@footnote{To avoid this query, configure the variable
5841 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
5842 will continue to run after the note was filed away.
5844 The handler will then store the note in the file and under the headline
5845 specified in the template, or it will use the default file and headline.
5846 The window configuration will be restored, sending you back to the working
5847 context before the call to Remember.  To re-use the location found
5848 during the last call to Remember, exit the Remember buffer with
5849 @kbd{C-0 C-c C-c}, @ie specify a zero prefix argument to @kbd{C-c C-c}.
5850 Another special case is @kbd{C-2 C-c C-c} which files the note as a child of
5851 the currently clocked item.
5853 @vindex org-remember-store-without-prompt
5854 If you want to store the note directly to a different place, use
5855 @kbd{C-1 C-c C-c} instead to exit Remember@footnote{Configure the
5856 variable @code{org-remember-store-without-prompt} to make this behavior
5857 the default.}.  The handler will then first prompt for a target file---if
5858 you press @key{RET}, the value specified for the template is used.
5859 Then the command offers the headings tree of the selected file, with the
5860 cursor position at the default headline (if you specified one in the
5861 template).  You can either immediately press @key{RET} to get the note
5862 placed there.  Or you can use the following keys to find a different
5863 location:
5864 @example
5865 @key{TAB}         @r{Cycle visibility.}
5866 @key{down} / @key{up}   @r{Next/previous visible headline.}
5867 n / p        @r{Next/previous visible headline.}
5868 f / b        @r{Next/previous headline same level.}
5869 u            @r{One level up.}
5870 @c 0-9          @r{Digit argument.}
5871 @end example
5872 @noindent
5873 Pressing @key{RET} or @key{left} or @key{right}
5874 then leads to the following result.
5876 @vindex org-reverse-note-order
5877 @multitable @columnfractions 0.2 0.15 0.65
5878 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
5879 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
5880 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
5881 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
5882 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
5883 @item                 @tab @tab depending on @code{org-reverse-note-order}.
5884 @item not on headline @tab @key{RET}
5885       @tab at cursor position, level taken from context.
5886 @end multitable
5888 Before inserting the text into a tree, the function ensures that the text has
5889 a headline, @ie a first line that starts with a @samp{*}.  If not, a
5890 headline is constructed from the current date.  If you have indented the text
5891 of the note below the headline, the indentation will be adapted if inserting
5892 the note into the tree requires demotion from level 1.
5894 @node Refiling notes,  , Storing notes, Remember
5895 @subsection Refiling notes
5896 @cindex refiling notes
5898 Remember is usually used to quickly capture notes and tasks into one or
5899 a few capture lists.  When reviewing the captured data, you may want to
5900 refile some of the entries into a different list, for example into a
5901 project.  Cutting, finding the right location, and then pasting the note
5902 is cumbersome.  To simplify this process, you can use the following
5903 special command:
5905 @table @kbd
5906 @kindex C-c C-w
5907 @item C-c C-w
5908 @vindex org-reverse-note-order
5909 @vindex org-refile-targets
5910 @vindex org-refile-use-outline-path
5911 @vindex org-outline-path-complete-in-steps
5912 @vindex org-refile-allow-creating-parent-nodes
5913 Refile the entry or region at point.  This command offers possible locations
5914 for refiling the entry and lets you select one with completion.  The item (or
5915 all items in the region) is filed below the target heading as a subitem.
5916 Depending on @code{org-reverse-note-order}, it will be either the first or
5917 last subitem.@*
5918 By default, all level 1 headlines in the current buffer are considered to be
5919 targets, but you can have more complex definitions across a number of files.
5920 See the variable @code{org-refile-targets} for details.  If you would like to
5921 select a location via a file-path-like completion along the outline path, see
5922 the variables @code{org-refile-use-outline-path} and
5923 @code{org-outline-path-complete-in-steps}.  If you would like to be able to
5924 create new nodes as new parents for for refiling on the fly, check the
5925 variable @code{org-refile-allow-creating-parent-nodes}.
5926 @kindex C-u C-c C-w
5927 @item C-u C-c C-w
5928 Use the refile interface to jump to a heading.
5929 @kindex C-u C-u C-c C-w
5930 @item C-u C-u C-c C-w
5931 Jump to the location where @code{org-refile} last moved a tree to.
5932 @end table
5935 @node Attachments, RSS Feeds, Remember, Capture
5936 @section Attachments
5937 @cindex attachments
5939 @vindex org-attach-directory
5940 It is often useful to associate reference material with an outline node/task.
5941 Small chunks of plain text can simply be stored in the subtree of a project.
5942 Hyperlinks (@pxref{Hyperlinks}) can be used to establish associations with
5943 files that live elsewhere on your computer or in the cloud, like emails or
5944 source code files belonging to a project.  Another method is @i{attachments},
5945 which are files located in a directory belonging to an outline node.  Org
5946 uses directories named by the unique ID of each entry.  These directories are
5947 located in the @file{data} directory which lives in the same directory where
5948 your Org file lives@footnote{If you move entries or Org files from one
5949 directory to another, you may want to configure @code{org-attach-directory}
5950 to contain an absolute path.}.  If you initialize this directory with
5951 @code{git init}, Org will automatically commit changes when it sees them.
5952 The attachment system has been contributed to Org by John Wiegley.
5954 In cases where it seems better to do so, you can also attach a directory of your
5955 choice to an entry.  You can also make children inherit the attachment
5956 directory from a parent, so that an entire subtree uses the same attached
5957 directory.
5959 @noindent The following commands deal with attachments.
5961 @table @kbd
5963 @kindex C-c C-a
5964 @item C-c C-a
5965 The dispatcher for commands related to the attachment system.  After these
5966 keys, a list of commands is displayed and you need to press an additional key
5967 to select a command:
5969 @table @kbd
5970 @kindex C-c C-a a
5971 @item a
5972 @vindex org-attach-method
5973 Select a file and move it into the task's attachment directory.  The file
5974 will be copied, moved, or linked, depending on @code{org-attach-method}.
5975 Note that hard links are not supported on all systems.
5977 @kindex C-c C-a c
5978 @kindex C-c C-a m
5979 @kindex C-c C-a l
5980 @item c/m/l
5981 Attach a file using the copy/move/link method.
5982 Note that hard links are not supported on all systems.
5984 @kindex C-c C-a n
5985 @item n
5986 Create a new attachment as an Emacs buffer.
5988 @kindex C-c C-a z
5989 @item z
5990 Synchronize the current task with its attachment directory, in case you added
5991 attachments yourself.
5993 @kindex C-c C-a o
5994 @item o
5995 @vindex org-file-apps
5996 Open current task's attachment.  If there are more than one, prompt for a
5997 file name first.  Opening will follow the rules set by @code{org-file-apps}.
5998 For more details, see the information on following hyperlinks
5999 (@pxref{Handling links}).
6001 @kindex C-c C-a O
6002 @item O
6003 Also open the attachment, but force opening the file in Emacs.
6005 @kindex C-c C-a f
6006 @item f
6007 Open the current task's attachment directory.
6009 @kindex C-c C-a F
6010 @item F
6011 Also open the directory, but force using @command{dired} in Emacs.
6013 @kindex C-c C-a d
6014 @item d
6015 Select and delete a single attachment.
6017 @kindex C-c C-a D
6018 @item D
6019 Delete all of a task's attachments.  A safer way is to open the directory in
6020 @command{dired} and delete from there.
6022 @kindex C-c C-a s
6023 @item C-c C-a s
6024 @cindex property, ATTACH_DIR
6025 Set a specific directory as the entry's attachment directory.  This works by
6026 putting the directory path into the @code{ATTACH_DIR} property.
6028 @kindex C-c C-a i
6029 @item C-c C-a i
6030 @cindex property, ATTACH_DIR_INHERIT
6031 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
6032 same directory for attachments as the parent does.
6033 @end table
6034 @end table
6036 @node RSS Feeds, Protocols, Attachments, Capture
6037 @section RSS feeds
6038 @cindex RSS feeds
6040 Org has the capability to add and change entries based on information found in
6041 RSS feeds.  You could use this to make a task out of each new podcast in a
6042 podcast feed.  Or you could use a phone-based note-creating service on the
6043 web to import tasks into Org.  To access feeds, you need to configure the
6044 variable @code{org-feed-alist}.  The docstring of this variable has detailed
6045 information.  Here is just an example:
6047 @example
6048 (setq org-feed-alist
6049       '(("ReQall" "http://www.reqall.com/user/feeds/rss/a1b2c3....."
6050          "~/org/feeds.org" "ReQall Entries")
6051 @end example
6052 @noindent
6053 will configure that new items from the feed provided by @file{reqall.com}
6054 will result in new entries in the file @file{~/org/feeds.org} under the
6055 heading @samp{ReQall Entries}, whenever the following command is used:
6057 @table @kbd
6058 @kindex C-c C-x g
6059 @item C-c C-x g
6060 Collect items from the feeds configured in @code{org-feed-alist} and act upon
6061 them.
6062 @kindex C-c C-x G
6063 @item C-c C-x G
6064 Prompt for a feed name and go to the inbox configured for this feed.
6065 @end table
6067 Under the same headline, Org will create a drawer @samp{FEEDSTATUS} in which
6068 it will store information about the status of items in the feed, to avoid
6069 adding the same item several times.  You should add @samp{FEEDSTATUS} to the
6070 list of drawers in that file:
6072 @example
6073 #+DRAWERS: LOGBOOK PROPERTIES FEEDSTATUS
6074 @end example
6076 For more information, see @file{org-feed.el} and the docstring of
6077 @code{org-feed-alist}.
6079 @node Protocols,  , RSS Feeds, Capture
6080 @section Protocols for external access
6081 @cindex protocols, for external access
6082 @cindex emacsserver
6084 You can set up Org for handling protocol calls from outside applications that
6085 are passed to Emacs through the @file{emacsserver}.  For example, you can
6086 configure bookmarks in your web browser to send a link to the current page to
6087 Org and create a note from it using Remember (@pxref{Remember}).  Or you
6088 could create a bookmark that will tell Emacs to open the local source file of
6089 a remote website you are looking at with the browser.  See
6090 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
6091 documentation and setup instructions.
6094 @node Agenda Views, Embedded LaTeX, Capture, Top
6095 @chapter Agenda Views
6096 @cindex agenda views
6098 Due to the way Org works, TODO items, time-stamped items, and
6099 tagged headlines can be scattered throughout a file or even a number of
6100 files.  To get an overview of open action items, or of events that are
6101 important for a particular date, this information must be collected,
6102 sorted and displayed in an organized way.
6104 Org can select items based on various criteria and display them
6105 in a separate buffer.  Seven different view types are provided:
6107 @itemize @bullet
6108 @item
6109 an @emph{agenda} that is like a calendar and shows information
6110 for specific dates,
6111 @item
6112 a @emph{TODO list} that covers all unfinished
6113 action items,
6114 @item
6115 a @emph{match view}, showings headlines based on the tags, properties, and
6116 TODO state associated with them,
6117 @item
6118 a @emph{timeline view} that shows all events in a single Org file,
6119 in time-sorted view,
6120 @item
6121 a @emph{keyword search view} that shows all entries from multiple files
6122 that contain specified keywords,
6123 @item
6124 a @emph{stuck projects view} showing projects that currently don't move
6125 along, and
6126 @item
6127 @emph{custom views} that are special tag/keyword searches and
6128 combinations of different views.
6129 @end itemize
6131 @noindent
6132 The extracted information is displayed in a special @emph{agenda
6133 buffer}.  This buffer is read-only, but provides commands to visit the
6134 corresponding locations in the original Org files, and even to
6135 edit these files remotely.
6137 @vindex org-agenda-window-setup
6138 @vindex org-agenda-restore-windows-after-quit
6139 Two variables control how the agenda buffer is displayed and whether the
6140 window configuration is restored when the agenda exits:
6141 @code{org-agenda-window-setup} and
6142 @code{org-agenda-restore-windows-after-quit}.
6144 @menu
6145 * Agenda files::                Files being searched for agenda information
6146 * Agenda dispatcher::           Keyboard access to agenda views
6147 * Built-in agenda views::       What is available out of the box?
6148 * Presentation and sorting::    How agenda items are prepared for display
6149 * Agenda commands::             Remote editing of Org trees
6150 * Custom agenda views::         Defining special searches and views
6151 * Exporting Agenda Views::
6152 * Agenda column view::          Using column view for collected entries
6153 @end menu
6155 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
6156 @section Agenda files
6157 @cindex agenda files
6158 @cindex files for agenda
6160 @vindex org-agenda-files
6161 The information to be shown is normally collected from all @emph{agenda
6162 files}, the files listed in the variable
6163 @code{org-agenda-files}@footnote{If the value of that variable is not a
6164 list, but a single file name, then the list of agenda files will be
6165 maintained in that external file.}. If a directory is part of this list,
6166 all files with the extension @file{.org} in this directory will be part
6167 of the list.
6169 Thus, even if you only work with a single Org file, that file should
6170 be put into the list@footnote{When using the dispatcher, pressing
6171 @kbd{<} before selecting a command will actually limit the command to
6172 the current file, and ignore @code{org-agenda-files} until the next
6173 dispatcher command.}.  You can customize @code{org-agenda-files}, but
6174 the easiest way to maintain it is through the following commands
6176 @cindex files, adding to agenda list
6177 @table @kbd
6178 @kindex C-c [
6179 @item C-c [
6180 Add current file to the list of agenda files.  The file is added to
6181 the front of the list.  If it was already in the list, it is moved to
6182 the front.  With a prefix argument, file is added/moved to the end.
6183 @kindex C-c ]
6184 @item C-c ]
6185 Remove current file from the list of agenda files.
6186 @kindex C-,
6187 @kindex C-'
6188 @item C-,
6189 @itemx C-'
6190 Cycle through agenda file list, visiting one file after the other.
6191 @kindex M-x org-iswitchb
6192 @item M-x org-iswitchb
6193 Command to use an @code{iswitchb}-like interface to switch to and between Org
6194 buffers.
6195 @end table
6197 @noindent
6198 The Org menu contains the current list of files and can be used
6199 to visit any of them.
6201 If you would like to focus the agenda temporarily on a file not in
6202 this list, or on just one file in the list, or even on only a subtree in a
6203 file, then this can be done in different ways.  For a single agenda command,
6204 you may press @kbd{<} once or several times in the dispatcher
6205 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
6206 extended period, use the following commands:
6208 @table @kbd
6209 @kindex C-c C-x <
6210 @item C-c C-x <
6211 Permanently restrict the agenda to the current subtree.  When with a
6212 prefix argument, or with the cursor before the first headline in a file,
6213 the agenda scope is set to the entire file.  This restriction remains in
6214 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
6215 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
6216 agenda view, the new restriction takes effect immediately.
6217 @kindex C-c C-x >
6218 @item C-c C-x >
6219 Remove the permanent restriction created by @kbd{C-c C-x <}.
6220 @end table
6222 @noindent
6223 When working with @file{speedbar.el}, you can use the following commands in
6224 the Speedbar frame:
6225 @table @kbd
6226 @kindex <
6227 @item < @r{in the speedbar frame}
6228 Permanently restrict the agenda to the item---either an Org file or a subtree
6229 in such a file---at the cursor in the Speedbar frame.
6230 If there is a window displaying an agenda view, the new restriction takes
6231 effect immediately.
6232 @kindex >
6233 @item > @r{in the speedbar frame}
6234 Lift the restriction.
6235 @end table
6237 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
6238 @section The agenda dispatcher
6239 @cindex agenda dispatcher
6240 @cindex dispatching agenda commands
6241 The views are created through a dispatcher, which should be bound to a
6242 global key---for example @kbd{C-c a} (@pxref{Installation}).  In the
6243 following we will assume that @kbd{C-c a} is indeed how the dispatcher
6244 is accessed and list keyboard access to commands accordingly.  After
6245 pressing @kbd{C-c a}, an additional letter is required to execute a
6246 command.  The dispatcher offers the following default commands:
6247 @table @kbd
6248 @item a
6249 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
6250 @item t @r{/} T
6251 Create a list of all TODO items (@pxref{Global TODO list}).
6252 @item m @r{/} M
6253 Create a list of headlines matching a TAGS expression (@pxref{Matching
6254 tags and properties}).
6255 @item L
6256 Create the timeline view for the current buffer (@pxref{Timeline}).
6257 @item s
6258 Create a list of entries selected by a boolean expression of keywords
6259 and/or regular expressions that must or must not occur in the entry.
6260 @item /
6261 @vindex org-agenda-text-search-extra-files
6262 Search for a regular expression in all agenda files and additionally in
6263 the files listed in @code{org-agenda-text-search-extra-files}.  This
6264 uses the Emacs command @code{multi-occur}.  A prefix argument can be
6265 used to specify the number of context lines for each match, default is
6267 @item # @r{/} !
6268 Create a list of stuck projects (@pxref{Stuck projects}).
6269 @item <
6270 Restrict an agenda command to the current buffer@footnote{For backward
6271 compatibility, you can also press @kbd{1} to restrict to the current
6272 buffer.}.  After pressing @kbd{<}, you still need to press the character
6273 selecting the command.
6274 @item < <
6275 If there is an active region, restrict the following agenda command to
6276 the region.  Otherwise, restrict it to the current subtree@footnote{For
6277 backward compatibility, you can also press @kbd{0} to restrict to the
6278 current region/subtree.}.  After pressing @kbd{< <}, you still need to press the
6279 character selecting the command.
6280 @end table
6282 You can also define custom commands that will be accessible through the
6283 dispatcher, just like the default commands.  This includes the
6284 possibility to create extended agenda buffers that contain several
6285 blocks together, for example the weekly agenda, the global TODO list and
6286 a number of special tags matches.  @xref{Custom agenda views}.
6288 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
6289 @section The built-in agenda views
6291 In this section we describe the built-in views.
6293 @menu
6294 * Weekly/daily agenda::         The calendar page with current tasks
6295 * Global TODO list::            All unfinished action items
6296 * Matching tags and properties::  Structured information with fine-tuned search
6297 * Timeline::                    Time-sorted view for single file
6298 * Keyword search::              Finding entries by keyword
6299 * Stuck projects::              Find projects you need to review
6300 @end menu
6302 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
6303 @subsection The weekly/daily agenda
6304 @cindex agenda
6305 @cindex weekly agenda
6306 @cindex daily agenda
6308 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
6309 paper agenda, showing all the tasks for the current week or day.
6311 @table @kbd
6312 @cindex org-agenda, command
6313 @kindex C-c a a
6314 @item C-c a a
6315 @vindex org-agenda-ndays
6316 Compile an agenda for the current week from a list of Org files.  The agenda
6317 shows the entries for each day.  With a numeric prefix@footnote{For backward
6318 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
6319 listed before the agenda.  This feature is deprecated, use the dedicated TODO
6320 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
6321 C-c a a}) you may set the number of days to be displayed (see also the
6322 variable @code{org-agenda-ndays})
6323 @end table
6325 Remote editing from the agenda buffer means, for example, that you can
6326 change the dates of deadlines and appointments from the agenda buffer.
6327 The commands available in the Agenda buffer are listed in @ref{Agenda
6328 commands}.
6330 @subsubheading Calendar/Diary integration
6331 @cindex calendar integration
6332 @cindex diary integration
6334 Emacs contains the calendar and diary by Edward M. Reingold.  The
6335 calendar displays a three-month calendar with holidays from different
6336 countries and cultures.  The diary allows you to keep track of
6337 anniversaries, lunar phases, sunrise/set, recurrent appointments
6338 (weekly, monthly) and more.  In this way, it is quite complementary to
6339 Org.  It can be very useful to combine output from Org with
6340 the diary.
6342 In order to include entries from the Emacs diary into Org mode's
6343 agenda, you only need to customize the variable
6345 @lisp
6346 (setq org-agenda-include-diary t)
6347 @end lisp
6349 @noindent After that, everything will happen automatically.  All diary
6350 entries including holidays, anniversaries, etc., will be included in the
6351 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
6352 @key{RET} can be used from the agenda buffer to jump to the diary
6353 file in order to edit existing diary entries.  The @kbd{i} command to
6354 insert new entries for the current date works in the agenda buffer, as
6355 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
6356 Sunrise/Sunset times, show lunar phases and to convert to other
6357 calendars, respectively.  @kbd{c} can be used to switch back and forth
6358 between calendar and agenda.
6360 If you are using the diary only for sexp entries and holidays, it is
6361 faster to not use the above setting, but instead to copy or even move
6362 the entries into an Org file. Org mode evaluates diary-style sexp
6363 entries, and does it faster because there is no overhead for first
6364 creating the diary display.  Note that the sexp entries must start at
6365 the left margin, no whitespace is allowed before them.  For example,
6366 the following segment of an Org file will be processed and entries
6367 will be made in the agenda:
6369 @example
6370 * Birthdays and similar stuff
6371 #+CATEGORY: Holiday
6372 %%(org-calendar-holiday)   ; special function for holiday names
6373 #+CATEGORY: Ann
6374 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
6375 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
6376 @end example
6378 @subsubheading Anniversaries from BBDB
6379 @cindex BBDB, anniversaries
6380 @cindex anniversaries, from BBDB
6382 If you are using the Big Brothers Database to store your contacts, you will
6383 very likely prefer to store anniversaries in BBDB rather than in a
6384 separate Org or diary file.  Org supports this and will show BBDB
6385 anniversaries as part of the agenda.  All you need to do is to add the
6386 following to one your your agenda files:
6388 @example
6389 * Anniversaries
6390   :PROPERTIES:
6391   :CATEGORY: Anniv
6392   :END
6393 %%(org-bbdb-anniversaries)
6394 @end example
6396 You can then go ahead and define anniversaries for a BBDB record.  Basically,
6397 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
6398 record and then add the date in the format @code{YYYY-MM-DD}, followed by a
6399 space and the class of the anniversary (@samp{birthday} or @samp{wedding}, or
6400 a format string).  If you omit the class, it will default to @samp{birthday}.
6401 Here are a few examples, the header for the file @file{org-bbdb.el} contains
6402 more detailed information.
6404 @example
6405 1973-06-22
6406 1955-08-02 wedding
6407 2008-04-14 %s released version 6.01 of org-mode, %d years ago
6408 @end example
6410 After a change to BBDB, or for the first agenda display during an Emacs
6411 session, the agenda display will suffer a short delay as Org updates its
6412 hash with anniversaries.  However, from then on things will be very fast---much
6413 faster in fact than a long list of @samp{%%(diary-anniversary)} entries
6414 in an Org or Diary file.
6416 @subsubheading Appointment reminders
6417 @cindex @file{appt.el}
6418 @cindex appointment reminders
6420 Org can interact with Emacs appointments notification facility.  To add all
6421 the appointments of your agenda files, use the command
6422 @code{org-agenda-to-appt}.  This command also lets you filter through the
6423 list of your appointments and add only those belonging to a specific category
6424 or matching a regular expression. See the docstring for details.
6426 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
6427 @subsection The global TODO list
6428 @cindex global TODO list
6429 @cindex TODO list, global
6431 The global TODO list contains all unfinished TODO items formatted and
6432 collected into a single place.
6434 @table @kbd
6435 @kindex C-c a t
6436 @item C-c a t
6437 Show the global TODO list.  This collects the TODO items from all
6438 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
6439 @code{agenda-mode}, so there are commands to examine and manipulate
6440 the TODO entries directly from that buffer (@pxref{Agenda commands}).
6441 @kindex C-c a T
6442 @item C-c a T
6443 @cindex TODO keyword matching
6444 @vindex org-todo-keywords
6445 Like the above, but allows selection of a specific TODO keyword.  You
6446 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
6447 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
6448 specify several keywords by separating them with @samp{|} as the boolean OR
6449 operator.  With a numeric prefix, the nth keyword in
6450 @code{org-todo-keywords} is selected.
6451 @kindex r
6452 The @kbd{r} key in the agenda buffer regenerates it, and you can give
6453 a prefix argument to this command to change the selected TODO keyword,
6454 for example @kbd{3 r}.  If you often need a search for a specific
6455 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
6456 Matching specific TODO keywords can also be done as part of a tags
6457 search (@pxref{Tag searches}).
6458 @end table
6460 Remote editing of TODO items means that you can change the state of a
6461 TODO entry with a single key press.  The commands available in the
6462 TODO list are described in @ref{Agenda commands}.
6464 @cindex sublevels, inclusion into TODO list
6465 Normally the global TODO list simply shows all headlines with TODO
6466 keywords.  This list can become very long.  There are two ways to keep
6467 it more compact:
6468 @itemize @minus
6469 @item
6470 @vindex org-agenda-todo-ignore-scheduled
6471 @vindex org-agenda-todo-ignore-deadlines
6472 @vindex org-agenda-todo-ignore-with-date
6473 Some people view a TODO item that has been @emph{scheduled} for execution or
6474 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
6475 Configure the variables @code{org-agenda-todo-ignore-scheduled},
6476 @code{org-agenda-todo-ignore-deadlines}, and/or
6477 @code{org-agenda-todo-ignore-with-date} to exclude such items from the
6478 global TODO list.
6479 @item
6480 @vindex org-agenda-todo-list-sublevels
6481 TODO items may have sublevels to break up the task into subtasks.  In
6482 such cases it may be enough to list only the highest level TODO headline
6483 and omit the sublevels from the global list.  Configure the variable
6484 @code{org-agenda-todo-list-sublevels} to get this behavior.
6485 @end itemize
6487 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
6488 @subsection Matching tags and properties
6489 @cindex matching, of tags
6490 @cindex matching, of properties
6491 @cindex tags view
6492 @cindex match view
6494 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
6495 or have properties (@pxref{Properties and Columns}), you can select headlines
6496 based on this metadata and collect them into an agenda buffer.  The match
6497 syntax described here also applies when creating sparse trees with @kbd{C-c /
6500 @table @kbd
6501 @kindex C-c a m
6502 @item C-c a m
6503 Produce a list of all headlines that match a given set of tags.  The
6504 command prompts for a selection criterion, which is a boolean logic
6505 expression with tags, like @samp{+work+urgent-withboss} or
6506 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
6507 define a custom command for it (@pxref{Agenda dispatcher}).
6508 @kindex C-c a M
6509 @item C-c a M
6510 @vindex org-tags-match-list-sublevels
6511 @vindex org-agenda-tags-todo-honor-ignore-options
6512 Like @kbd{C-c a m}, but only select headlines that are also TODO items and
6513 force checking subitems (see variable @code{org-tags-match-list-sublevels}).
6514 To exclude scheduled/deadline items, see the variable
6515 @code{org-agenda-tags-todo-honor-ignore-options}.  Matching specific TODO
6516 keywords together with a tags match is also possible, see @ref{Tag searches}.
6517 @end table
6519 The commands available in the tags list are described in @ref{Agenda
6520 commands}.
6522 @subsubheading Match syntax
6524 @cindex Boolean logic, for tag/property searches
6525 A search string can use Boolean operators @samp{&} for AND and @samp{|} for
6526 OR.  @samp{&} binds more strongly than @samp{|}.  Parentheses are currently
6527 not implemented.  Each element in the search is either a tag, a regular
6528 expression matching tags, or an expression like @code{PROPERTY OPERATOR
6529 VALUE} with a comparison operator, accessing a property value.  Each element
6530 may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
6531 sugar for positive selection.  The AND operator @samp{&} is optional when
6532 @samp{+} or @samp{-} is present.  Here are some examples, using only tags.
6534 @table @samp
6535 @item +work-boss
6536 Select headlines tagged @samp{:work:}, but discard those also tagged
6537 @samp{:boss:}.
6538 @item work|laptop
6539 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
6540 @item work|laptop+night
6541 Like before, but require the @samp{:laptop:} lines to be tagged also
6542 @samp{:night:}.
6543 @end table
6545 @cindex regular expressions, with tags search
6546 Instead of a tag, you may also specify a regular expression enclosed in curly
6547 braces.  For example,
6548 @samp{work+@{^boss.*@}} matches headlines that contain the tag
6549 @samp{:work:} and any tag @i{starting} with @samp{boss}.
6551 @cindex TODO keyword matching, with tags search
6552 @cindex level, require for tags/property match
6553 @cindex category, require for tags/property match
6554 @vindex org-odd-levels-only
6555 You may also test for properties (@pxref{Properties and Columns}) at the same
6556 time as matching tags.  The properties may be real properties, or special
6557 properties that represent other metadata (@pxref{Special properties}).  For
6558 example, the ``property'' @code{TODO} represents the TODO keyword of the
6559 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
6560 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
6561 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
6562 DONE.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
6563 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
6565 Here are more examples:
6566 @table @samp
6567 @item work+TODO="WAITING"
6568 Select @samp{:work:}-tagged TODO lines with the specific TODO
6569 keyword @samp{WAITING}.
6570 @item work+TODO="WAITING"|home+TODO="WAITING"
6571 Waiting tasks both at work and at home.
6572 @end table
6574 When matching properties, a number of different operators can be used to test
6575 the value of a property.  Here is a complex example:
6577 @example
6578 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
6579          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
6580 @end example
6582 @noindent
6583 The type of comparison will depend on how the comparison value is written:
6584 @itemize @minus
6585 @item
6586 If the comparison value is a plain number, a numerical comparison is done,
6587 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
6588 @samp{>=}, and @samp{<>}.
6589 @item
6590 If the comparison value is enclosed in double-quotes,
6591 a string comparison is done, and the same operators are allowed.
6592 @item
6593 If the comparison value is enclosed in double-quotes @emph{and} angular
6594 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
6595 assumed to be date/time specifications in the standard Org way, and the
6596 comparison will be done accordingly.  Special values that will be recognized
6597 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
6598 @code{"<tomorrow>"} for these days at 0:00 hours, @ie without a time
6599 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
6600 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
6601 respectively, can be used.
6602 @item
6603 If the comparison value is enclosed
6604 in curly braces, a regexp match is performed, with @samp{=} meaning that the
6605 regexp matches the property value, and @samp{<>} meaning that it does not
6606 match.
6607 @end itemize
6609 So the search string in the example finds entries tagged @samp{:work:} but
6610 not @samp{:boss:}, which also have a priority value @samp{A}, a
6611 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
6612 property that is numerically smaller than 2, a @samp{:With:} property that is
6613 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
6614 on or after October 11, 2008.
6616 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
6617 other properties will slow down the search.  However, once you have paid the
6618 price by accessing one property, testing additional properties is cheap
6619 again.
6621 You can configure Org mode to use property inheritance during a search, but
6622 beware that this can slow down searches considerably.  See @ref{Property
6623 inheritance}, for details.
6625 For backward compatibility, and also for typing speed, there is also a
6626 different way to test TODO states in a search.  For this, terminate the
6627 tags/property part of the search string (which may include several terms
6628 connected with @samp{|}) with a @samp{/} and then specify a Boolean
6629 expression just for TODO keywords.  The syntax is then similar to that for
6630 tags, but should be applied with care: for example, a positive
6631 selection on several TODO keywords cannot meaningfully be combined with
6632 boolean AND.  However, @emph{negative selection} combined with AND can be
6633 meaningful.  To make sure that only lines are checked that actually have any
6634 TODO keyword (resulting in a speed-up), use @kbd{C-c a M}, or equivalently
6635 start the TODO part after the slash with @samp{!}.  Examples:
6637 @table @samp
6638 @item work/WAITING
6639 Same as @samp{work+TODO="WAITING"}
6640 @item work/!-WAITING-NEXT
6641 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
6642 nor @samp{NEXT}
6643 @item work/!+WAITING|+NEXT
6644 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
6645 @samp{NEXT}.
6646 @end table
6648 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
6649 @subsection Timeline for a single file
6650 @cindex timeline, single file
6651 @cindex time-sorted view
6653 The timeline summarizes all time-stamped items from a single Org mode
6654 file in a @emph{time-sorted view}.  The main purpose of this command is
6655 to give an overview over events in a project.
6657 @table @kbd
6658 @kindex C-c a L
6659 @item C-c a L
6660 Show a time-sorted view of the Org file, with all time-stamped items.
6661 When called with a @kbd{C-u} prefix, all unfinished TODO entries
6662 (scheduled or not) are also listed under the current date.
6663 @end table
6665 @noindent
6666 The commands available in the timeline buffer are listed in
6667 @ref{Agenda commands}.
6669 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
6670 @subsection Keyword search
6671 @cindex keyword search
6672 @cindex searching, for keywords
6674 This agenda view is a general text search facility for Org mode entries.
6675 It is particularly useful to find notes.
6677 @table @kbd
6678 @kindex C-c a s
6679 @item C-c a s
6680 This is a special search that lets you select entries by keywords or
6681 regular expression, using a boolean logic.  For example, the search
6682 string
6684 @example
6685 +computer +wifi -ethernet -@{8\.11[bg]@}
6686 @end example
6688 @noindent
6689 will search for note entries that contain the keywords @code{computer}
6690 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
6691 not matched by the regular expression @code{8\.11[bg]}, meaning to
6692 exclude both 8.11b and 8.11g.
6694 @vindex org-agenda-text-search-extra-files
6695 Note that in addition to the agenda files, this command will also search
6696 the files listed in @code{org-agenda-text-search-extra-files}.
6697 @end table
6699 @node Stuck projects,  , Keyword search, Built-in agenda views
6700 @subsection Stuck projects
6702 If you are following a system like David Allen's GTD to organize your
6703 work, one of the ``duties'' you have is a regular review to make sure
6704 that all projects move along.  A @emph{stuck} project is a project that
6705 has no defined next actions, so it will never show up in the TODO lists
6706 Org mode produces.  During the review, you need to identify such
6707 projects and define next actions for them.
6709 @table @kbd
6710 @kindex C-c a #
6711 @item C-c a #
6712 List projects that are stuck.
6713 @kindex C-c a !
6714 @item C-c a !
6715 @vindex org-stuck-projects
6716 Customize the variable @code{org-stuck-projects} to define what a stuck
6717 project is and how to find it.
6718 @end table
6720 You almost certainly will have to configure this view before it will
6721 work for you.  The built-in default assumes that all your projects are
6722 level-2 headlines, and that a project is not stuck if it has at least
6723 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
6725 Let's assume that you, in your own way of using Org mode, identify
6726 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
6727 indicate a project that should not be considered yet.  Let's further
6728 assume that the TODO keyword DONE marks finished projects, and that NEXT
6729 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
6730 is a next action even without the NEXT tag.  Finally, if the project
6731 contains the special word IGNORE anywhere, it should not be listed
6732 either.  In this case you would start by identifying eligible projects
6733 with a tags/todo match@footnote{@xref{Tag searches}.}
6734 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
6735 IGNORE in the subtree to identify projects that are not stuck.  The
6736 correct customization for this is
6738 @lisp
6739 (setq org-stuck-projects
6740       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
6741                                "\\<IGNORE\\>"))
6742 @end lisp
6744 Note that if a project is identified as non-stuck, the subtree of this entry
6745 will still be searched for stuck projects.
6747 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
6748 @section Presentation and sorting
6749 @cindex presentation, of agenda items
6751 @vindex org-agenda-prefix-format
6752 Before displaying items in an agenda view, Org mode visually prepares
6753 the items and sorts them.  Each item occupies a single line.  The line
6754 starts with a @emph{prefix} that contains the @emph{category}
6755 (@pxref{Categories}) of the item and other important information.  You can
6756 customize the prefix using the option @code{org-agenda-prefix-format}.
6757 The prefix is followed by a cleaned-up version of the outline headline
6758 associated with the item.
6760 @menu
6761 * Categories::                  Not all tasks are equal
6762 * Time-of-day specifications::  How the agenda knows the time
6763 * Sorting of agenda items::     The order of things
6764 @end menu
6766 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
6767 @subsection Categories
6769 @cindex category
6770 The category is a broad label assigned to each agenda item.  By default,
6771 the category is simply derived from the file name, but you can also
6772 specify it with a special line in the buffer, like this@footnote{For
6773 backward compatibility, the following also works: if there are several
6774 such lines in a file, each specifies the category for the text below it.
6775 The first category also applies to any text before the first CATEGORY
6776 line.  However, using this method is @emph{strongly} deprecated as it is
6777 incompatible with the outline structure of the document.  The correct
6778 method for setting multiple categories in a buffer is using a
6779 property.}:
6781 @example
6782 #+CATEGORY: Thesis
6783 @end example
6785 @noindent
6786 @cindex property, CATEGORY
6787 If you would like to have a special CATEGORY for a single entry or a
6788 (sub)tree, give the entry a @code{:CATEGORY:} property with the
6789 special category you want to apply as the value.
6791 @noindent
6792 The display in the agenda buffer looks best if the category is not
6793 longer than 10 characters.
6795 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
6796 @subsection Time-of-day specifications
6797 @cindex time-of-day specification
6799 Org mode checks each agenda item for a time-of-day specification.  The
6800 time can be part of the timestamp that triggered inclusion into the
6801 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
6802 ranges can be specified with two timestamps, like
6804 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
6806 In the headline of the entry itself, a time(range) may also appear as
6807 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
6808 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
6809 specifications in diary entries are recognized as well.
6811 For agenda display, Org mode extracts the time and displays it in a
6812 standard 24 hour format as part of the prefix.  The example times in
6813 the previous paragraphs would end up in the agenda like this:
6815 @example
6816     8:30-13:00 Arthur Dent lies in front of the bulldozer
6817    12:45...... Ford Prefect arrives and takes Arthur to the pub
6818    19:00...... The Vogon reads his poem
6819    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6820 @end example
6822 @cindex time grid
6823 If the agenda is in single-day mode, or for the display of today, the
6824 timed entries are embedded in a time grid, like
6826 @example
6827     8:00...... ------------------
6828     8:30-13:00 Arthur Dent lies in front of the bulldozer
6829    10:00...... ------------------
6830    12:00...... ------------------
6831    12:45...... Ford Prefect arrives and takes Arthur to the pub
6832    14:00...... ------------------
6833    16:00...... ------------------
6834    18:00...... ------------------
6835    19:00...... The Vogon reads his poem
6836    20:00...... ------------------
6837    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6838 @end example
6840 @vindex org-agenda-use-time-grid
6841 @vindex org-agenda-time-grid
6842 The time grid can be turned on and off with the variable
6843 @code{org-agenda-use-time-grid}, and can be configured with
6844 @code{org-agenda-time-grid}.
6846 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
6847 @subsection Sorting of agenda items
6848 @cindex sorting, of agenda items
6849 @cindex priorities, of agenda items
6850 Before being inserted into a view, the items are sorted.  How this is
6851 done depends on the type of view.
6852 @itemize @bullet
6853 @item
6854 @vindex org-agenda-files
6855 For the daily/weekly agenda, the items for each day are sorted.  The
6856 default order is to first collect all items containing an explicit
6857 time-of-day specification.  These entries will be shown at the beginning
6858 of the list, as a @emph{schedule} for the day.  After that, items remain
6859 grouped in categories, in the sequence given by @code{org-agenda-files}.
6860 Within each category, items are sorted by priority (@pxref{Priorities}),
6861 which is composed of the base priority (2000 for priority @samp{A}, 1000
6862 for @samp{B}, and 0 for @samp{C}), plus additional increments for
6863 overdue scheduled or deadline items.
6864 @item
6865 For the TODO list, items remain in the order of categories, but within
6866 each category, sorting takes place according to priority
6867 (@pxref{Priorities}).  The priority used for sorting derives from the
6868 priority cookie, with additions depending on how close an item is to its due
6869 or scheduled date.
6870 @item
6871 For tags matches, items are not sorted at all, but just appear in the
6872 sequence in which they are found in the agenda files.
6873 @end itemize
6875 @vindex org-agenda-sorting-strategy
6876 Sorting can be customized using the variable
6877 @code{org-agenda-sorting-strategy}, and may also include criteria based on
6878 the estimated effort of an entry (@pxref{Effort estimates}).
6880 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
6881 @section Commands in the agenda buffer
6882 @cindex commands, in agenda buffer
6884 Entries in the agenda buffer are linked back to the Org file or diary
6885 file where they originate.  You are not allowed to edit the agenda
6886 buffer itself, but commands are provided to show and jump to the
6887 original entry location, and to edit the Org files ``remotely'' from
6888 the agenda buffer.  In this way, all information is stored only once,
6889 removing the risk that your agenda and note files may diverge.
6891 Some commands can be executed with mouse clicks on agenda lines.  For
6892 the other commands, the cursor needs to be in the desired line.
6894 @table @kbd
6895 @tsubheading{Motion}
6896 @cindex motion commands in agenda
6897 @kindex n
6898 @item n
6899 Next line (same as @key{up} and @kbd{C-p}).
6900 @kindex p
6901 @item p
6902 Previous line (same as @key{down} and @kbd{C-n}).
6903 @tsubheading{View/Go to Org file}
6904 @kindex mouse-3
6905 @kindex @key{SPC}
6906 @item mouse-3
6907 @itemx @key{SPC}
6908 Display the original location of the item in another window.
6909 With prefix arg, make sure that the entire entry is made visible in the
6910 outline, not only the heading.
6912 @kindex L
6913 @item L
6914 Display original location and recenter that window.
6916 @kindex mouse-2
6917 @kindex mouse-1
6918 @kindex @key{TAB}
6919 @item mouse-2
6920 @itemx mouse-1
6921 @itemx @key{TAB}
6922 Go to the original location of the item in another window.  Under Emacs
6923 22, @kbd{mouse-1} will also works for this.
6925 @kindex @key{RET}
6926 @itemx @key{RET}
6927 Go to the original location of the item and delete other windows.
6929 @kindex F
6930 @item F
6931 @vindex org-agenda-start-with-follow-mode
6932 Toggle Follow mode.  In Follow mode, as you move the cursor through
6933 the agenda buffer, the other window always shows the corresponding
6934 location in the Org file.  The initial setting for this mode in new
6935 agenda buffers can be set with the variable
6936 @code{org-agenda-start-with-follow-mode}.
6938 @kindex C-c C-x b
6939 @item C-c C-x b
6940 Display the entire subtree of the current item in an indirect buffer.  With a
6941 numeric prefix argument N, go up to level N and then take that tree.  If N is
6942 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
6943 previously used indirect buffer.
6945 @kindex C-c C-o
6946 @item C-c C-o
6947 Follow a link in the entry.  This will offer a selection of any links in the
6948 text belonging to the referenced Org node.  If there is only one link, it
6949 will be followed without a selection prompt.
6951 @tsubheading{Change display}
6952 @cindex display changing, in agenda
6953 @kindex o
6954 @item o
6955 Delete other windows.
6957 @kindex v d
6958 @kindex d
6959 @kindex v w
6960 @kindex w
6961 @kindex v m
6962 @kindex v y
6963 @item v d @ @r{or short} @ d
6964 @itemx v w @ @r{or short} @ w
6965 @itemx v m
6966 @itemx v y
6967 Switch to day/week/month/year view.  When switching to day or week view,
6968 this setting becomes the default for subsequent agenda commands.  Since
6969 month and year views are slow to create, they do not become the default.
6970 A numeric prefix argument may be used to jump directly to a specific day
6971 of the year, ISO week, month, or year, respectively.  For example,
6972 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
6973 setting day, week, or month view, a year may be encoded in the prefix
6974 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
6975 2007.  If such a year specification has only one or two digits, it will
6976 be mapped to the interval 1938-2037.
6978 @kindex f
6979 @item f
6980 @vindex org-agenda-ndays
6981 Go forward in time to display the following @code{org-agenda-ndays} days.
6982 For example, if the display covers a week, switch to the following week.
6983 With prefix arg, go forward that many times @code{org-agenda-ndays} days.
6985 @kindex b
6986 @item b
6987 Go backward in time to display earlier dates.
6989 @kindex .
6990 @item .
6991 Go to today.
6993 @kindex j
6994 @item j
6995 Prompt for a date and go there.
6997 @kindex D
6998 @item D
6999 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
7001 @kindex v l
7002 @kindex l
7003 @item v l @ @r{or short} @ l
7004 @vindex org-log-done
7005 @vindex org-agenda-log-mode-items
7006 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
7007 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
7008 entries that have been clocked on that day.  You can configure the entry
7009 types that should be included in log mode using the variable
7010 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
7011 all possible logbook entries, including state changes.  When called with two
7012 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
7014 @kindex v [
7015 @kindex [
7016 @item v [ @ @r{or short} @ [
7017 Include inactive timestamps into the current view.  Only for weekly/daily
7018 agenda and timeline views.
7020 @kindex v a
7021 @kindex v A
7022 @item v a
7023 @itemx v A
7024 Toggle Archives mode.  In Archives mode, trees that are marked
7025 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
7026 capital @kbd{A}, even all archive files are included.  To exit archives mode,
7027 press @kbd{v a} again.
7029 @kindex v R
7030 @kindex R
7031 @item v R @ @r{or short} @ R
7032 @vindex org-agenda-start-with-clockreport-mode
7033 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
7034 always show a table with the clocked times for the timespan and file scope
7035 covered by the current agenda view.  The initial setting for this mode in new
7036 agenda buffers can be set with the variable
7037 @code{org-agenda-start-with-clockreport-mode}.
7039 @kindex v E
7040 @kindex E
7041 @item v E @ @r{or short} @ E
7042 @vindex org-agenda-start-with-entry-text-mode
7043 @vindex org-agenda-entry-text-maxlines
7044 Toggle entry text mode.  In entry text mode, a number of lines from the Org
7045 outline node referenced by an agenda line will be displayed below the line.
7046 The maximum number of lines is given by the variable
7047 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
7048 prefix argument will temporarily modify that number to the prefix value.
7050 @kindex G
7051 @item G
7052 @vindex org-agenda-use-time-grid
7053 @vindex org-agenda-time-grid
7054 Toggle the time grid on and off.  See also the variables
7055 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
7057 @kindex r
7058 @item r
7059 Recreate the agenda buffer, for example to reflect the changes after
7060 modification of the timestamps of items with @kbd{S-@key{left}} and
7061 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
7062 argument is interpreted to create a selective list for a specific TODO
7063 keyword.
7064 @kindex g
7065 @item g
7066 Same as @kbd{r}.
7068 @kindex s
7069 @kindex C-x C-s
7070 @item s
7071 @itemx C-x C-s
7072 Save all Org buffers in the current Emacs session, and also the locations of
7073 IDs.
7075 @kindex C-c C-x C-c
7076 @item C-c C-x C-c
7077 @vindex org-columns-default-format
7078 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
7079 view format is taken from the entry at point, or (if there is no entry at
7080 point), from the first entry in the agenda view.  So whatever the format for
7081 that entry would be in the original buffer (taken from a property, from a
7082 @code{#+COLUMNS} line, or from the default variable
7083 @code{org-columns-default-format}), will be used in the agenda.
7085 @kindex C-c C-x >
7086 @item C-c C-x >
7087 Remove the restriction lock on the agenda, if it is currently restricted to a
7088 file or subtree (@pxref{Agenda files}).
7090 @tsubheading{Secondary filtering and query editing}
7091 @cindex filtering, by tag and effort, in agenda
7092 @cindex tag filtering, in agenda
7093 @cindex effort filtering, in agenda
7094 @cindex query editing, in agenda
7096 @kindex /
7097 @item /
7098 @vindex org-agenda-filter-preset
7099 Filter the current agenda view with respect to a tag and/or effort estimates.
7100 The difference between this and a custom agenda command is that filtering is
7101 very fast, so that you can switch quickly between different filters without
7102 having to recreate the agenda@footnote{Custom commands can preset a filter by
7103 binding the variable @code{org-agenda-filter-preset} as an option.  This
7104 filter will then be applied to the view and persist as a basic filter through
7105 refreshes and more secondary filtering.}
7107 You will be prompted for a tag selection letter.  Pressing @key{TAB} at that
7108 prompt will offer use completion to select a tag (including any tags that do
7109 not have a selection character).  The command then hides all entries that do
7110 not contain or inherit this tag.  When called with prefix arg, remove the
7111 entries that @emph{do} have the tag.  A second @kbd{/} at the prompt will
7112 turn off the filter and unhide any hidden entries.  If the first key you
7113 press is either @kbd{+} or @kbd{-}, the previous filter will be narrowed by
7114 requiring or forbidding the selected additional tag.  Instead of pressing
7115 @kbd{+} or @kbd{-} after @kbd{/}, you can also immediately use the @kbd{\}
7116 command.
7118 @vindex org-sort-agenda-noeffort-is-high
7119 In order to filter for effort estimates, you should set-up allowed
7120 efforts globally, for example
7121 @lisp
7122 (setq org-global-properties
7123     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
7124 @end lisp
7125 You can then filter for an effort by first typing an operator, one of
7126 @kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
7127 estimate in your array of allowed values, where @kbd{0} means the 10th value.
7128 The filter will then restrict to entries with effort smaller-or-equal, equal,
7129 or larger-or-equal than the selected value.  If the digits 0-9 are not used
7130 as fast access keys to tags, you can also simply press the index digit
7131 directly without an operator.  In this case, @kbd{<} will be assumed.  For
7132 application of the operator, entries without a defined effort will be treated
7133 according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
7134 for tasks without effort definition, press @kbd{?} as the operator.
7136 @kindex \
7137 @item \
7138 Narrow the current agenda filter by an additional condition.  When called with
7139 prefix arg, remove the entries that @emph{do} have the tag, or that do match
7140 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
7141 @kbd{-} as the first key after the @kbd{/} command.
7143 @kindex [
7144 @kindex ]
7145 @kindex @{
7146 @kindex @}
7147 @item [ ] @{ @}
7148 @table @i
7149 @item @r{in} search view
7150 add new search words (@kbd{[} and @kbd{]}) or new regular expressions
7151 (@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
7152 add a positive search term prefixed by @samp{+}, indicating that this search
7153 term @i{must} occur/match in the entry.  The closing bracket/brace will add a
7154 negative search term which @i{must not} occur/match in the entry for it to be
7155 selected.
7156 @end table
7158 @tsubheading{Remote editing}
7159 @cindex remote editing, from agenda
7161 @item 0-9
7162 Digit argument.
7164 @cindex undoing remote-editing events
7165 @cindex remote editing, undo
7166 @kindex C-_
7167 @item C-_
7168 Undo a change due to a remote editing command.  The change is undone
7169 both in the agenda buffer and in the remote buffer.
7171 @kindex t
7172 @item t
7173 Change the TODO state of the item, both in the agenda and in the
7174 original org file.
7176 @kindex C-k
7177 @item C-k
7178 @vindex org-agenda-confirm-kill
7179 Delete the current agenda item along with the entire subtree belonging
7180 to it in the original Org file.  If the text to be deleted remotely
7181 is longer than one line, the kill needs to be confirmed by the user.  See
7182 variable @code{org-agenda-confirm-kill}.
7184 @kindex C-c C-w
7185 @item C-c C-w
7186 Refile the entry at point.
7188 @kindex a
7189 @item a
7190 Toggle the ARCHIVE tag for the current headline.
7192 @kindex A
7193 @item A
7194 Move the subtree corresponding to the current entry to its @emph{archive
7195 sibling}.
7197 @kindex $
7198 @item $
7199 Archive the subtree corresponding to the current headline.  This means the
7200 entry will be moved to the configured archive location, most likely a
7201 different file.
7203 @kindex T
7204 @item T
7205 @vindex org-agenda-show-inherited-tags
7206 Show all tags associated with the current item.  This is useful if you have
7207 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
7208 tags of a headline occasionally.
7210 @kindex :
7211 @item :
7212 Set tags for the current headline.  If there is an active region in the
7213 agenda, change a tag for all headings in the region.
7215 @kindex ,
7216 @item ,
7217 Set the priority for the current item.  Org mode prompts for the
7218 priority character. If you reply with @key{SPC}, the priority cookie
7219 is removed from the entry.
7221 @kindex P
7222 @item P
7223 Display weighted priority of current item.
7225 @kindex +
7226 @kindex S-@key{up}
7227 @item +
7228 @itemx S-@key{up}
7229 Increase the priority of the current item.  The priority is changed in
7230 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
7231 key for this.
7233 @kindex -
7234 @kindex S-@key{down}
7235 @item -
7236 @itemx S-@key{down}
7237 Decrease the priority of the current item.
7239 @kindex z
7240 @item z
7241 @vindex org-log-into-drawer
7242 Add a note to the entry.  This note will be recorded, and then files to the
7243 same location where state change notes are put.  Depending on
7244 @code{org-log-into-drawer}, this maybe inside a drawer.
7246 @kindex C-c C-a
7247 @item C-c C-a
7248 Dispatcher for all command related to attachments.
7250 @kindex C-c C-s
7251 @item C-c C-s
7252 Schedule this item
7254 @kindex C-c C-d
7255 @item C-c C-d
7256 Set a deadline for this item.
7258 @kindex k
7259 @item k
7260 Agenda actions, to set dates for selected items to the cursor date.
7261 This command also works in the calendar!  The command prompts for an
7262 additional key:
7263 @example
7264 m   @r{Mark the entry at point for action.  You can also make entries}
7265     @r{in Org files with @kbd{C-c C-x C-k}.}
7266 d   @r{Set the deadline of the marked entry to the date at point.}
7267 s   @r{Schedule the marked entry at the date at point.}
7268 r   @r{Call @code{org-remember} with the cursor date as default date.}
7269 @end example
7270 @noindent
7271 Press @kbd{r} afterward to refresh the agenda and see the effect of the
7272 command.
7274 @kindex S-@key{right}
7275 @item S-@key{right}
7276 Change the timestamp associated with the current line by one day into the
7277 future.  With a numeric prefix argument, change it by that many days.  For
7278 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  With a
7279 @kbd{C-u} prefix, change the time by one hour.  If you immediately repeat the
7280 command, it will continue to change hours even without the prefix arg.  With
7281 a double @kbd{C-u C-u} prefix, do the same for changing minutes.  The stamp
7282 is changed in the original Org file, but the change is not directly reflected
7283 in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
7285 @kindex S-@key{left}
7286 @item S-@key{left}
7287 Change the timestamp associated with the current line by one day
7288 into the past.
7290 @kindex >
7291 @item >
7292 Change the timestamp associated with the current line to today.
7293 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
7294 on my keyboard.
7296 @kindex I
7297 @item I
7298 Start the clock on the current item.  If a clock is running already, it
7299 is stopped first.
7301 @kindex O
7302 @item O
7303 Stop the previously started clock.
7305 @kindex X
7306 @item X
7307 Cancel the currently running clock.
7309 @kindex J
7310 @item J
7311 Jump to the running clock in another window.
7313 @tsubheading{Bulk remote editing selected entries}
7314 @cindex remote editing, bulk, from agenda
7316 @kindex m
7317 @item s
7318 Mark the entry at point for bulk action.
7320 @kindex u
7321 @item u
7322 Unmark entry for bulk action.
7324 @kindex U
7325 @item U
7326 Unmark all marked entries for bulk action.
7328 @kindex B
7329 @item B
7330 Bulk action: act on all marked entries in the agenda.  This will prompt for
7331 another key to select the action to be applied:
7332 @example
7333 r  @r{Prompt for a single refile target and move all entries.  The entries}
7334    @r{will no longer be in the agenda, refresh (@kbd{g}) to bring them back.}
7335 $  @r{Archive all selected entries.}
7336 A  @r{Archive entries by moving them to their respective archive siblings.}
7337 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
7338    @r{changes the state of all selected entries, bypassing blocking and}
7339    @r{suppressing logging notes (but not time stamps).}
7340 +  @r{Add a tag to all selected entries.}
7341 -  @r{Remove a tag from all selected entries.}
7342 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
7343    @r{by a fixed number of days, use something starting with double plus}
7344    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
7345 d  @r{Set deadline to a specific date.}
7346 @end example
7349 @tsubheading{Calendar commands}
7350 @cindex calendar commands, from agenda
7351 @kindex c
7352 @item c
7353 Open the Emacs calendar and move to the date at the agenda cursor.
7355 @item c
7356 When in the calendar, compute and show the Org mode agenda for the
7357 date at the cursor.
7359 @cindex diary entries, creating from agenda
7360 @kindex i
7361 @item i
7362 Insert a new entry into the diary.  Prompts for the type of entry
7363 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
7364 entry in the diary, just as @kbd{i d}, etc., would do in the calendar.
7365 The date is taken from the cursor position.
7367 @kindex M
7368 @item M
7369 Show the phases of the moon for the three months around current date.
7371 @kindex S
7372 @item S
7373 Show sunrise and sunset times.  The geographical location must be set
7374 with calendar variables, see the documentation for the Emacs calendar.
7376 @kindex C
7377 @item C
7378 Convert the date at cursor into many other cultural and historic
7379 calendars.
7381 @kindex H
7382 @item H
7383 Show holidays for three months around the cursor date.
7385 @item M-x org-export-icalendar-combine-agenda-files
7386 Export a single iCalendar file containing entries from all agenda files.
7387 This is a globally available command, and also available in the agenda menu.
7389 @tsubheading{Exporting to a file}
7390 @kindex C-x C-w
7391 @item C-x C-w
7392 @cindex exporting agenda views
7393 @cindex agenda views, exporting
7394 @vindex org-agenda-exporter-settings
7395 Write the agenda view to a file.  Depending on the extension of the selected
7396 file name, the view will be exported as HTML (extension @file{.html} or
7397 @file{.htm}), Postscript (extension @file{.ps}), PDF (extension @file{.pdf}),
7398 or plain text (any other extension).  When called with a @kbd{C-u} prefix
7399 argument, immediately open the newly created file.  Use the variable
7400 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
7401 for @file{htmlize} to be used during export.
7403 @tsubheading{Quit and Exit}
7404 @kindex q
7405 @item q
7406 Quit agenda, remove the agenda buffer.
7408 @kindex x
7409 @cindex agenda files, removing buffers
7410 @item x
7411 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
7412 for the compilation of the agenda.  Buffers created by the user to
7413 visit Org files will not be removed.
7414 @end table
7417 @node Custom agenda views, Exporting Agenda Views, Agenda commands, Agenda Views
7418 @section Custom agenda views
7419 @cindex custom agenda views
7420 @cindex agenda views, custom
7422 Custom agenda commands serve two purposes: to store and quickly access
7423 frequently used TODO and tags searches, and to create special composite
7424 agenda buffers.  Custom agenda commands will be accessible through the
7425 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
7427 @menu
7428 * Storing searches::            Type once, use often
7429 * Block agenda::                All the stuff you need in a single buffer
7430 * Setting Options::             Changing the rules
7431 @end menu
7433 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
7434 @subsection Storing searches
7436 The first application of custom searches is the definition of keyboard
7437 shortcuts for frequently used searches, either creating an agenda
7438 buffer, or a sparse tree (the latter covering of course only the current
7439 buffer).
7440 @kindex C-c a C
7441 @vindex org-agenda-custom-commands
7442 Custom commands are configured in the variable
7443 @code{org-agenda-custom-commands}.  You can customize this variable, for
7444 example by pressing @kbd{C-c a C}.  You can also directly set it with
7445 Emacs Lisp in @file{.emacs}.  The following example contains all valid
7446 search types:
7448 @lisp
7449 @group
7450 (setq org-agenda-custom-commands
7451       '(("w" todo "WAITING")
7452         ("W" todo-tree "WAITING")
7453         ("u" tags "+boss-urgent")
7454         ("v" tags-todo "+boss-urgent")
7455         ("U" tags-tree "+boss-urgent")
7456         ("f" occur-tree "\\<FIXME\\>")
7457         ("h" . "HOME+Name tags searches") ; description for "h" prefix
7458         ("hl" tags "+home+Lisa")
7459         ("hp" tags "+home+Peter")
7460         ("hk" tags "+home+Kim")))
7461 @end group
7462 @end lisp
7464 @noindent
7465 The initial string in each entry defines the keys you have to press
7466 after the dispatcher command @kbd{C-c a} in order to access the command.
7467 Usually this will be just a single character, but if you have many
7468 similar commands, you can also define two-letter combinations where the
7469 first character is the same in several combinations and serves as a
7470 prefix key@footnote{You can provide a description for a prefix key by
7471 inserting a cons cell with the prefix and the description.}.  The second
7472 parameter is the search type, followed by the string or regular
7473 expression to be used for the matching.  The example above will
7474 therefore define:
7476 @table @kbd
7477 @item C-c a w
7478 as a global search for TODO entries with @samp{WAITING} as the TODO
7479 keyword
7480 @item C-c a W
7481 as the same search, but only in the current buffer and displaying the
7482 results as a sparse tree
7483 @item C-c a u
7484 as a global tags search for headlines marked @samp{:boss:} but not
7485 @samp{:urgent:}
7486 @item C-c a v
7487 as the same search as @kbd{C-c a u}, but limiting the search to
7488 headlines that are also TODO items
7489 @item C-c a U
7490 as the same search as @kbd{C-c a u}, but only in the current buffer and
7491 displaying the result as a sparse tree
7492 @item C-c a f
7493 to create a sparse tree (again: current buffer only) with all entries
7494 containing the word @samp{FIXME}
7495 @item C-c a h
7496 as a prefix command for a HOME tags search where you have to press an
7497 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
7498 Peter, or Kim) as additional tag to match.
7499 @end table
7501 @node Block agenda, Setting Options, Storing searches, Custom agenda views
7502 @subsection Block agenda
7503 @cindex block agenda
7504 @cindex agenda, with block views
7506 Another possibility is the construction of agenda views that comprise
7507 the results of @emph{several} commands, each of which creates a block in
7508 the agenda buffer.  The available commands include @code{agenda} for the
7509 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
7510 for the global TODO list (as constructed with @kbd{C-c a t}), and the
7511 matching commands discussed above: @code{todo}, @code{tags}, and
7512 @code{tags-todo}.  Here are two examples:
7514 @lisp
7515 @group
7516 (setq org-agenda-custom-commands
7517       '(("h" "Agenda and Home-related tasks"
7518          ((agenda "")
7519           (tags-todo "home")
7520           (tags "garden")))
7521         ("o" "Agenda and Office-related tasks"
7522          ((agenda "")
7523           (tags-todo "work")
7524           (tags "office")))))
7525 @end group
7526 @end lisp
7528 @noindent
7529 This will define @kbd{C-c a h} to create a multi-block view for stuff
7530 you need to attend to at home.  The resulting agenda buffer will contain
7531 your agenda for the current week, all TODO items that carry the tag
7532 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
7533 command @kbd{C-c a o} provides a similar view for office tasks.
7535 @node Setting Options,  , Block agenda, Custom agenda views
7536 @subsection Setting options for custom commands
7537 @cindex options, for custom agenda views
7539 @vindex org-agenda-custom-commands
7540 Org mode contains a number of variables regulating agenda construction
7541 and display.  The global variables define the behavior for all agenda
7542 commands, including the custom commands.  However, if you want to change
7543 some settings just for a single custom view, you can do so.  Setting
7544 options requires inserting a list of variable names and values at the
7545 right spot in @code{org-agenda-custom-commands}.  For example:
7547 @lisp
7548 @group
7549 (setq org-agenda-custom-commands
7550       '(("w" todo "WAITING"
7551          ((org-agenda-sorting-strategy '(priority-down))
7552           (org-agenda-prefix-format "  Mixed: ")))
7553         ("U" tags-tree "+boss-urgent"
7554          ((org-show-following-heading nil)
7555           (org-show-hierarchy-above nil)))
7556         ("N" search ""
7557          ((org-agenda-files '("~org/notes.org"))
7558           (org-agenda-text-search-extra-files nil)))))
7559 @end group
7560 @end lisp
7562 @noindent
7563 Now the @kbd{C-c a w} command will sort the collected entries only by
7564 priority, and the prefix format is modified to just say @samp{  Mixed: }
7565 instead of giving the category of the entry.  The sparse tags tree of
7566 @kbd{C-c a U} will now turn out ultra-compact, because neither the
7567 headline hierarchy above the match, nor the headline following the match
7568 will be shown.  The command @kbd{C-c a N} will do a text search limited
7569 to only a single file.
7571 @vindex org-agenda-custom-commands
7572 For command sets creating a block agenda,
7573 @code{org-agenda-custom-commands} has two separate spots for setting
7574 options.  You can add options that should be valid for just a single
7575 command in the set, and options that should be valid for all commands in
7576 the set.  The former are just added to the command entry, the latter
7577 must come after the list of command entries.  Going back to the block
7578 agenda example (@pxref{Block agenda}), let's change the sorting strategy
7579 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
7580 the results for GARDEN tags query in the opposite order,
7581 @code{priority-up}.  This would look like this:
7583 @lisp
7584 @group
7585 (setq org-agenda-custom-commands
7586       '(("h" "Agenda and Home-related tasks"
7587          ((agenda)
7588           (tags-todo "home")
7589           (tags "garden"
7590                 ((org-agenda-sorting-strategy '(priority-up)))))
7591          ((org-agenda-sorting-strategy '(priority-down))))
7592         ("o" "Agenda and Office-related tasks"
7593          ((agenda)
7594           (tags-todo "work")
7595           (tags "office")))))
7596 @end group
7597 @end lisp
7599 As you see, the values and parentheses setting is a little complex.
7600 When in doubt, use the customize interface to set this variable---it
7601 fully supports its structure.  Just one caveat: when setting options in
7602 this interface, the @emph{values} are just Lisp expressions.  So if the
7603 value is a string, you need to add the double-quotes around the value
7604 yourself.
7607 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
7608 @section Exporting Agenda Views
7609 @cindex agenda views, exporting
7611 If you are away from your computer, it can be very useful to have a printed
7612 version of some agenda views to carry around.  Org mode can export custom
7613 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
7614 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
7615 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
7616 a PDF file with also create the postscript file.}, and iCalendar files.  If
7617 you want to do this only occasionally, use the command
7619 @table @kbd
7620 @kindex C-x C-w
7621 @item C-x C-w
7622 @cindex exporting agenda views
7623 @cindex agenda views, exporting
7624 @vindex org-agenda-exporter-settings
7625 Write the agenda view to a file.  Depending on the extension of the
7626 selected file name, the view will be exported as HTML (extension
7627 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
7628 iCalendar (extension @file{.ics}), or plain text (any other extension).
7629 Use the variable @code{org-agenda-exporter-settings} to
7630 set options for @file{ps-print} and for @file{htmlize} to be used during
7631 export, for example
7633 @vindex org-agenda-add-entry-text-maxlines
7634 @vindex htmlize-output-type
7635 @vindex ps-number-of-columns
7636 @vindex ps-landscape-mode
7637 @lisp
7638 (setq org-agenda-exporter-settings
7639       '((ps-number-of-columns 2)
7640         (ps-landscape-mode t)
7641         (org-agenda-add-entry-text-maxlines 5)
7642         (htmlize-output-type 'css)))
7643 @end lisp
7644 @end table
7646 If you need to export certain agenda views frequently, you can associate
7647 any custom agenda command with a list of output file names
7648 @footnote{If you want to store standard views like the weekly agenda
7649 or the global TODO list as well, you need to define custom commands for
7650 them in order to be able to specify file names.}.  Here is an example
7651 that first defines custom commands for the agenda and the global
7652 TODO list, together with a number of files to which to export them.
7653 Then we define two block agenda commands and specify file names for them
7654 as well.  File names can be relative to the current working directory,
7655 or absolute.
7657 @lisp
7658 @group
7659 (setq org-agenda-custom-commands
7660       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
7661         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
7662         ("h" "Agenda and Home-related tasks"
7663          ((agenda "")
7664           (tags-todo "home")
7665           (tags "garden"))
7666          nil
7667          ("~/views/home.html"))
7668         ("o" "Agenda and Office-related tasks"
7669          ((agenda)
7670           (tags-todo "work")
7671           (tags "office"))
7672          nil
7673          ("~/views/office.ps" "~/calendars/office.ics"))))
7674 @end group
7675 @end lisp
7677 The extension of the file name determines the type of export.  If it is
7678 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
7679 the buffer to HTML and save it to this file name.  If the extension is
7680 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
7681 Postscript output.  If the extension is @file{.ics}, iCalendar export is
7682 run export over all files that were used to construct the agenda, and
7683 limit the export to entries listed in the agenda.  Any other
7684 extension produces a plain ASCII file.
7686 The export files are @emph{not} created when you use one of those
7687 commands interactively because this might use too much overhead.
7688 Instead, there is a special command to produce @emph{all} specified
7689 files in one step:
7691 @table @kbd
7692 @kindex C-c a e
7693 @item C-c a e
7694 Export all agenda views that have export file names associated with
7695 them.
7696 @end table
7698 You can use the options section of the custom agenda commands to also
7699 set options for the export commands.  For example:
7701 @lisp
7702 (setq org-agenda-custom-commands
7703       '(("X" agenda ""
7704          ((ps-number-of-columns 2)
7705           (ps-landscape-mode t)
7706           (org-agenda-prefix-format " [ ] ")
7707           (org-agenda-with-colors nil)
7708           (org-agenda-remove-tags t))
7709          ("theagenda.ps"))))
7710 @end lisp
7712 @noindent
7713 This command sets two options for the Postscript exporter, to make it
7714 print in two columns in landscape format---the resulting page can be cut
7715 in two and then used in a paper agenda.  The remaining settings modify
7716 the agenda prefix to omit category and scheduling information, and
7717 instead include a checkbox to check off items.  We also remove the tags
7718 to make the lines compact, and we don't want to use colors for the
7719 black-and-white printer.  Settings specified in
7720 @code{org-agenda-exporter-settings} will also apply, but the settings
7721 in @code{org-agenda-custom-commands} take precedence.
7723 @noindent
7724 From the command line you may also use
7725 @example
7726 emacs -f org-batch-store-agenda-views -kill
7727 @end example
7728 @noindent
7729 or, if you need to modify some parameters@footnote{Quoting depends on the
7730 system you use, please check the FAQ for examples.}
7731 @example
7732 emacs -eval '(org-batch-store-agenda-views                      \
7733               org-agenda-ndays 30                               \
7734               org-agenda-start-day "2007-11-01"                 \
7735               org-agenda-include-diary nil                      \
7736               org-agenda-files (quote ("~/org/project.org")))'  \
7737       -kill
7738 @end example
7739 @noindent
7740 which will create the agenda views restricted to the file
7741 @file{~/org/project.org}, without diary entries and with a 30-day
7742 extent.
7744 You can also extract agenda information in a way that allows further
7745 processing by other programs.  See @ref{Extracting agenda information}, for
7746 more information.
7749 @node Agenda column view,  , Exporting Agenda Views, Agenda Views
7750 @section Using column view in the agenda
7751 @cindex column view, in agenda
7752 @cindex agenda, column view
7754 Column view (@pxref{Column view}) is normally used to view and edit
7755 properties embedded in the hierarchical structure of an Org file.  It can be
7756 quite useful to use column view also from the agenda, where entries are
7757 collected by certain criteria.
7759 @table @kbd
7760 @kindex C-c C-x C-c
7761 @item C-c C-x C-c
7762 Turn on column view in the agenda.
7763 @end table
7765 To understand how to use this properly, it is important to realize that the
7766 entries in the agenda are no longer in their proper outline environment.
7767 This causes the following issues:
7769 @enumerate
7770 @item
7771 @vindex org-columns-default-format
7772 @vindex org-overriding-columns-format
7773 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
7774 entries in the agenda are collected from different files, and different files
7775 may have different @code{COLUMNS} formats, this is a non-trivial problem.
7776 Org first checks if the variable @code{org-overriding-columns-format} is
7777 currently set, and if so, takes the format from there.  Otherwise it takes
7778 the format associated with the first item in the agenda, or, if that item
7779 does not have a specific format (defined in a property, or in its file), it
7780 uses @code{org-columns-default-format}.
7781 @item
7782 @cindex property, special, CLOCKSUM
7783 If any of the columns has a summary type defined (@pxref{Column attributes}),
7784 turning on column view in the agenda will visit all relevant agenda files and
7785 make sure that the computations of this property are up to date.  This is
7786 also true for the special @code{CLOCKSUM} property.  Org will then sum the
7787 values displayed in the agenda.  In the daily/weekly agenda, the sums will
7788 cover a single day, in all other views they cover the entire block.  It is
7789 vital to realize that the agenda may show the same entry @emph{twice} (for
7790 example as scheduled and as a deadline), and it may show two entries from the
7791 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
7792 cases, the summation in the agenda will lead to incorrect results because
7793 some values will count double.
7794 @item
7795 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
7796 the entire clocked time for this item.  So even in the daily/weekly agenda,
7797 the clocksum listed in column view may originate from times outside the
7798 current view.  This has the advantage that you can compare these values with
7799 a column listing the planned total effort for a task---one of the major
7800 applications for column view in the agenda.  If you want information about
7801 clocked time in the displayed period use clock table mode (press @kbd{R} in
7802 the agenda).
7803 @end enumerate
7806 @node Embedded LaTeX, Exporting, Agenda Views, Top
7807 @chapter Embedded La@TeX{}
7808 @cindex @TeX{} interpretation
7809 @cindex La@TeX{} interpretation
7811 Plain ASCII is normally sufficient for almost all note taking.  One
7812 exception, however, are scientific notes which need to be able to contain
7813 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
7814 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
7815 features described here as ``La@TeX{}'' are really from @TeX{}, but for
7816 simplicity I am blurring this distinction.}  is widely used to typeset
7817 scientific documents. Org mode supports embedding La@TeX{} code into its
7818 files, because many academics are used to reading La@TeX{} source code, and
7819 because it can be readily processed into images for HTML production.
7821 It is not necessary to mark La@TeX{} macros and code in any special way.
7822 If you observe a few conventions, Org mode knows how to find it and what
7823 to do with it.
7825 @menu
7826 * Math symbols::                @TeX{} macros for symbols and Greek letters
7827 * Subscripts and superscripts::  Simple syntax for raising/lowering text
7828 * LaTeX fragments::             Complex formulas made easy
7829 * Processing LaTeX fragments::  Previewing La@TeX{} processing
7830 * CDLaTeX mode::                Speed up entering of formulas
7831 @end menu
7833 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
7834 @section Math symbols
7835 @cindex math symbols
7836 @cindex @TeX{} macros
7838 You can use La@TeX{} macros to insert special symbols like @samp{\alpha} to
7839 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
7840 for these macros is available, just type @samp{\} and maybe a few letters,
7841 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike La@TeX{}
7842 code, Org mode allows these macros to be present without surrounding math
7843 delimiters, for example:
7845 @example
7846 Angles are written as Greek letters \alpha, \beta and \gamma.
7847 @end example
7848 @noindent
7849 During HTML export (@pxref{HTML export}), these symbols are translated
7850 into the proper syntax for HTML, for the above examples this is
7851 @samp{&alpha;} and @samp{&rarr;}, respectively.  If you need such a symbol
7852 inside a word, terminate it like this: @samp{\Aacute@{@}stor}.
7854 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
7855 @section Subscripts and superscripts
7856 @cindex subscript
7857 @cindex superscript
7859 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
7860 and subscripts.  Again, these can be used without embedding them in
7861 math-mode delimiters.  To increase the readability of ASCII text, it is
7862 not necessary (but OK) to surround multi-character sub- and superscripts
7863 with curly braces.  For example
7865 @example
7866 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
7867 the sun is R_@{sun@} = 6.96 x 10^8 m.
7868 @end example
7870 To avoid interpretation as raised or lowered text, you can quote
7871 @samp{^} and @samp{_} with a backslash: @samp{\^} and @samp{\_}.
7873 During HTML export (@pxref{HTML export}), subscript and superscripts
7874 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
7876 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
7877 @section La@TeX{} fragments
7878 @cindex La@TeX{} fragments
7880 @vindex org-format-latex-header
7881 With symbols, sub- and superscripts, HTML is pretty much at its end when
7882 it comes to representing mathematical formulas@footnote{Yes, there is
7883 MathML, but that is not yet fully supported by many browsers, and there
7884 is no decent converter for turning La@TeX{} or ASCII representations of
7885 formulas into MathML. So for the time being, converting formulas into
7886 images seems the way to go.}. More complex expressions need a dedicated
7887 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
7888 fragments. It provides commands to preview the typeset result of these
7889 fragments, and upon export to HTML, all fragments will be converted to
7890 images and inlined into the HTML document@footnote{The La@TeX{} export
7891 will not use images for displaying La@TeX{} fragments but include these
7892 fragments directly into the La@TeX{} code.}. For this to work you
7893 need to be on a system with a working La@TeX{} installation. You also
7894 need the @file{dvipng} program, available at
7895 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
7896 will be used when processing a fragment can be configured with the
7897 variable @code{org-format-latex-header}.
7899 La@TeX{} fragments don't need any special marking at all.  The following
7900 snippets will be identified as La@TeX{} source code:
7901 @itemize @bullet
7902 @item
7903 Environments of any kind.  The only requirement is that the
7904 @code{\begin} statement appears on a new line, preceded by only
7905 whitespace.
7906 @item
7907 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
7908 currency specifications, single @samp{$} characters are only recognized as
7909 math delimiters if the enclosed text contains at most two line breaks, is
7910 directly attached to the @samp{$} characters with no whitespace in between,
7911 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
7912 For the other delimiters, there is no such restriction, so when in doubt, use
7913 @samp{\(...\)} as inline math delimiters.
7914 @end itemize
7916 @noindent For example:
7918 @example
7919 \begin@{equation@}                          % arbitrary environments,
7920 x=\sqrt@{b@}                                % even tables, figures
7921 \end@{equation@}                            % etc
7923 If $a^2=b$ and \( b=2 \), then the solution must be
7924 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
7925 @end example
7927 @noindent
7928 @vindex org-format-latex-options
7929 If you need any of the delimiter ASCII sequences for other purposes, you
7930 can configure the option @code{org-format-latex-options} to deselect the
7931 ones you do not wish to have interpreted by the La@TeX{} converter.
7933 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
7934 @section Processing LaTeX fragments
7935 @cindex LaTeX fragments, preview
7937 La@TeX{} fragments can be processed to produce preview images of the
7938 typeset expressions:
7940 @table @kbd
7941 @kindex C-c C-x C-l
7942 @item C-c C-x C-l
7943 Produce a preview image of the La@TeX{} fragment at point and overlay it
7944 over the source code.  If there is no fragment at point, process all
7945 fragments in the current entry (between two headlines).  When called
7946 with a prefix argument, process the entire subtree.  When called with
7947 two prefix arguments, or when the cursor is before the first headline,
7948 process the entire buffer.
7949 @kindex C-c C-c
7950 @item C-c C-c
7951 Remove the overlay preview images.
7952 @end table
7954 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
7955 converted into images and inlined into the document if the following
7956 setting is active:
7958 @lisp
7959 (setq org-export-with-LaTeX-fragments t)
7960 @end lisp
7962 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
7963 @section Using CDLa@TeX{} to enter math
7964 @cindex CDLa@TeX{}
7966 CDLa@TeX{} mode is a minor mode that is normally used in combination with a
7967 major La@TeX{} mode like AUC@TeX{} in order to speed-up insertion of
7968 environments and math templates.  Inside Org mode, you can make use of
7969 some of the features of CDLa@TeX{} mode.  You need to install
7970 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
7971 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
7972 Don't use CDLa@TeX{} mode itself under Org mode, but use the light
7973 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
7974 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
7975 Org files with
7977 @lisp
7978 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
7979 @end lisp
7981 When this mode is enabled, the following features are present (for more
7982 details see the documentation of CDLa@TeX{} mode):
7983 @itemize @bullet
7984 @kindex C-c @{
7985 @item
7986 Environment templates can be inserted with @kbd{C-c @{}.
7987 @item
7988 @kindex @key{TAB}
7989 The @key{TAB} key will do template expansion if the cursor is inside a
7990 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
7991 inside such a fragment, see the documentation of the function
7992 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
7993 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
7994 correctly inside the first brace.  Another @key{TAB} will get you into
7995 the second brace.  Even outside fragments, @key{TAB} will expand
7996 environment abbreviations at the beginning of a line.  For example, if
7997 you write @samp{equ} at the beginning of a line and press @key{TAB},
7998 this abbreviation will be expanded to an @code{equation} environment.
7999 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
8000 @item
8001 @kindex _
8002 @kindex ^
8003 @vindex cdlatex-simplify-sub-super-scripts
8004 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
8005 characters together with a pair of braces.  If you use @key{TAB} to move
8006 out of the braces, and if the braces surround only a single character or
8007 macro, they are removed again (depending on the variable
8008 @code{cdlatex-simplify-sub-super-scripts}).
8009 @item
8010 @kindex `
8011 Pressing the backquote @kbd{`} followed by a character inserts math
8012 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
8013 after the backquote, a help window will pop up.
8014 @item
8015 @kindex '
8016 Pressing the single-quote @kbd{'} followed by another character modifies
8017 the symbol before point with an accent or a font.  If you wait more than
8018 1.5 seconds after the backquote, a help window will pop up.  Character
8019 modification will work only inside La@TeX{} fragments, outside the quote
8020 is normal.
8021 @end itemize
8023 @node Exporting, Publishing, Embedded LaTeX, Top
8024 @chapter Exporting
8025 @cindex exporting
8027 Org-mode documents can be exported into a variety of other formats.  For
8028 printing and sharing of notes, ASCII export produces a readable and simple
8029 version of an Org file.  HTML export allows you to publish a notes file on
8030 the web, while the XOXO format provides a solid base for exchange with a
8031 broad range of other applications. La@TeX{} export lets you use Org mode and
8032 its structured editing functions to easily create La@TeX{} files.  DocBook
8033 export makes it possible to convert Org files to many other formats using
8034 DocBook tools.  To incorporate entries with associated times like deadlines
8035 or appointments into a desktop calendar program like iCal, Org mode can also
8036 produce extracts in the iCalendar format.  Currently Org mode only supports
8037 export, not import of these different formats.
8039 Org supports export of selected regions when @code{transient-mark-mode} is
8040 enabled (default in Emacs 23).
8042 @menu
8043 * Markup rules::                Which structures are recognized?
8044 * Selective export::            Using tags to select and exclude trees
8045 * Export options::              Per-file export settings
8046 * The export dispatcher::       How to access exporter commands
8047 * ASCII export::                Exporting to plain ASCII
8048 * HTML export::                 Exporting to HTML
8049 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
8050 * DocBook export::              Exporting to DocBook
8051 * XOXO export::                 Exporting to XOXO
8052 * iCalendar export::            Exporting in iCalendar format
8053 @end menu
8055 @node Markup rules, Selective export, Exporting, Exporting
8056 @section Markup rules
8058 When exporting Org-mode documents, the exporter tries to reflect the
8059 structure of the document as accurately as possible in the backend.  Since
8060 export targets like HTML, La@TeX{}, or DocBook allow much richer formatting,
8061 Org mode has rules on how to prepare text for rich export.  This section
8062 summarizes the markup rules used in an Org-mode buffer.
8064 @menu
8065 * Document title::              How the document title is determined
8066 * Headings and sections::       The main structure of the exported document
8067 * Table of contents::           If, where, how to create a table of contents
8068 * Initial text::                Text before the first headline
8069 * Lists::                       Plain lists are exported
8070 * Paragraphs::                  What determines beginning and ending
8071 * Literal examples::            Source code and other examples
8072 * Include files::               Include the contents of a file during export
8073 * Tables exported::             Tables are exported richly
8074 * Inlined images::              How to inline images during export
8075 * Footnote markup::             ASCII representation of footnotes
8076 * Emphasis and monospace::      To bold or not to bold
8077 * TeX macros and LaTeX fragments::  Create special, rich export.
8078 * Horizontal rules::            A line across the page
8079 * Comment lines::               Some lines will not be exported
8080 * Macro replacement::           Global replacement of place holders
8081 @end menu
8083 @node Document title, Headings and sections, Markup rules, Markup rules
8084 @subheading Document title
8085 @cindex document title, markup rules
8087 @noindent
8088 The title of the exported document is taken from the special line
8090 @cindex #+TITLE
8091 @example
8092 #+TITLE: This is the title of the document
8093 @end example
8095 @noindent
8096 If this line does not exist, the title is derived from the first non-empty,
8097 non-comment line in the buffer.  If no such line exists, or if you have
8098 turned off exporting of the text before the first headline (see below), the
8099 title will be the file name without extension.
8101 @cindex property, EXPORT_TITLE
8102 If you are exporting only a subtree by marking is as the region, the heading
8103 of the subtree will become the title of the document.  If the subtree has a
8104 property @code{EXPORT_TITLE}, that will take precedence.
8106 @node Headings and sections, Table of contents, Document title, Markup rules
8107 @subheading Headings and sections
8108 @cindex headings and sections, markup rules
8110 @vindex org-headline-levels
8111 The outline structure of the document as described in @ref{Document
8112 Structure}, forms the basis for defining sections of the exported document.
8113 However, since the outline structure is also used for (for example) lists of
8114 tasks, only the first three outline levels will be used as headings.  Deeper
8115 levels will become itemized lists.  You can change the location of this
8116 switch globally by setting the variable @code{org-headline-levels}, or on a
8117 per-file basis with a line
8119 @cindex #+OPTIONS
8120 @example
8121 #+OPTIONS: H:4
8122 @end example
8124 @node Table of contents, Initial text, Headings and sections, Markup rules
8125 @subheading Table of contents
8126 @cindex table of contents, markup rules
8128 @vindex org-export-with-toc
8129 The table of contents is normally inserted directly before the first headline
8130 of the file.  If you would like to get it to a different location, insert the
8131 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
8132 location.  The depth of the table of contents is by default the same as the
8133 number of headline levels, but you can choose a smaller number, or turn off
8134 the table of contents entirely, by configuring the variable
8135 @code{org-export-with-toc}, or on a per-file basis with a line like
8137 @example
8138 #+OPTIONS: toc:2          (only to two levels in TOC)
8139 #+OPTIONS: toc:nil        (no TOC at all)
8140 @end example
8142 @node Initial text, Lists, Table of contents, Markup rules
8143 @subheading Text before the first headline
8144 @cindex text before first headline, markup rules
8145 @cindex #+TEXT
8147 Org mode normally exports the text before the first headline, and even uses
8148 the first line as the document title.  The text will be fully marked up.  If
8149 you need to include literal HTML, La@TeX{}, or DocBook code, use the special
8150 constructs described below in the sections for the individual exporters.
8152 @vindex org-export-skip-text-before-1st-heading
8153 Some people like to use the space before the first headline for setup and
8154 internal links and therefore would like to control the exported text before
8155 the first headline in a different way.  You can do so by setting the variable
8156 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
8157 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
8159 @noindent
8160 If you still want to have some text before the first headline, use the
8161 @code{#+TEXT} construct:
8163 @example
8164 #+OPTIONS: skip:t
8165 #+TEXT: This text will go before the *first* headline.
8166 #+TEXT: [TABLE-OF-CONTENTS]
8167 #+TEXT: This goes between the table of contents and the first headline
8168 @end example
8170 @node Lists, Paragraphs, Initial text, Markup rules
8171 @subheading Lists
8172 @cindex lists, markup rules
8174 Plain lists as described in @ref{Plain lists}, are translated to the backend's
8175 syntax for such lists.  Most backends support unordered, ordered, and
8176 description lists.
8178 @node Paragraphs, Literal examples, Lists, Markup rules
8179 @subheading Paragraphs, line breaks, and quoting
8180 @cindex paragraphs, markup rules
8182 Paragraphs are separated by at least one empty line.  If you need to enforce
8183 a line break within a paragraph, use @samp{\\} at the end of a line.
8185 To keep the line breaks in a region, but otherwise use normal formatting, you
8186 can use this construct, which can also be used to format poetry.
8188 @cindex #+BEGIN_VERSE
8189 @example
8190 #+BEGIN_VERSE
8191  Great clouds overhead
8192  Tiny black birds rise and fall
8193  Snow covers Emacs
8195      -- AlexSchroeder
8196 #+END_VERSE
8197 @end example
8199 When quoting a passage from another document, it is customary to format this
8200 as a paragraph that is indented on both the left and the right margin.  You
8201 can include quotations in Org-mode documents like this:
8203 @cindex #+BEGIN_QUOTE
8204 @example
8205 #+BEGIN_QUOTE
8206 Everything should be made as simple as possible,
8207 but not any simpler -- Albert Einstein
8208 #+END_QUOTE
8209 @end example
8211 If you would like to center some text, do it like this:
8212 @cindex #+BEGIN_CENTER
8213 @example
8214 #+BEGIN_CENTER
8215 Everything should be made as simple as possible, \\
8216 but not any simpler
8217 #+END_CENTER
8218 @end example
8220 @node Literal examples, Include files, Paragraphs, Markup rules
8221 @subheading Literal examples
8222 @cindex literal examples, markup rules
8223 @cindex code line references, markup rules
8225 You can include literal examples that should not be subjected to
8226 markup.  Such examples will be typeset in monospace, so this is well suited
8227 for source code and similar examples.
8228 @cindex #+BEGIN_EXAMPLE
8230 @example
8231 #+BEGIN_EXAMPLE
8232 Some example from a text file.
8233 #+END_EXAMPLE
8234 @end example
8236 Note that such blocks may be @i{indented} in order to align nicely with
8237 indented text and in particular with plain list structure (@pxref{Plain
8238 lists}).  For simplicity when using small examples, you can also start the
8239 example lines with a colon followed by a space.  There may also be additional
8240 whitespace before the colon:
8242 @example
8243 Here is an example
8244    : Some example from a text file.
8245 @end example
8247 @cindex formatting source code, markup rules
8248 If the example is source code from a programming language, or any other text
8249 that can be marked up by font-lock in Emacs, you can ask for the example to
8250 look like the fontified Emacs buffer@footnote{Currently this works for the
8251 HTML backend, and requires the @file{htmlize.el} package version 1.34 or
8252 later.  It also works for LaTeX with the listings package, if you turn on the
8253 option @code{org-export-latex-listings} and make sure that the listings
8254 package is included by the LaTeX header.}.  This is done with the @samp{src}
8255 block, where you also need to specify the name of the major mode that should
8256 be used to fontify the example:
8257 @cindex #+BEGIN_SRC
8259 @example
8260 #+BEGIN_SRC emacs-lisp
8261 (defun org-xor (a b)
8262    "Exclusive or."
8263    (if a (not b) b))
8264 #+END_SRC
8265 @end example
8267 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
8268 switch to the end of the @code{BEGIN} line, to get the lines of the example
8269 numbered.  If you use a @code{+n} switch, the numbering from the previous
8270 numbered snippet will be continued in the current one.  In literal examples,
8271 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
8272 targets for special hyperlinks like @code{[[(name)]]} (@ie the reference name
8273 enclosed in single parenthesis).  In HTML, hovering the mouse over such a
8274 link will remote-highlight the corresponding code line, which is kind of
8275 cool.
8277 You can also add a @code{-r} switch which @i{removes} the labels from the
8278 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
8279 labels in the source code while using line numbers for the links, which might
8280 be useful to explain those in an org-mode example code.}.  With the @code{-n}
8281 switch, links to these references will be labeled by the line numbers from
8282 the code listing, otherwise links will use the labels with no parentheses.
8283 Here is an example:
8285 @example
8286 #+BEGIN_SRC emacs-lisp -n -r
8287 (save-excursion                  (ref:sc)
8288    (goto-char (point-min))       (ref:jump)
8289 #+END_SRC
8290 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
8291 jumps to point-min.
8292 @end example
8294 @vindex org-coderef-label-format
8295 If the syntax for the label format conflicts with the language syntax, use a
8296 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
8297 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
8299 HTML export also allows examples to be published as text areas, @xref{Text
8300 areas in HTML export}.
8302 @table @kbd
8303 @kindex C-c '
8304 @item C-c '
8305 Edit the source code example at point in its native mode.  This works by
8306 switching to a temporary buffer with the source code.  You need to exit by
8307 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}
8308 or @samp{#} will get a comma prepended, to keep them from being interpreted
8309 by Org as outline nodes or special comments.  These commas will be striped
8310 for editing with @kbd{C-c '}, and also for export.}, the edited version will
8311 then replace the old version in the Org buffer.  Fixed-width regions
8312 (where each line starts with a colon followed by a space) will be edited
8313 using @code{artist-mode}@footnote{You may select a different-mode with the
8314 variable @code{org-edit-fixed-width-region-mode}.} to allow creating ASCII
8315 drawings easily.  Using this command in an empty line will create a new
8316 fixed-width region.
8317 @kindex C-c l
8318 @item C-c l
8319 Calling @code{org-store-link} while editing a source code example in a
8320 temporary buffer created with @kbd{C-c '} will prompt for a label, make sure
8321 that it is unique in the current buffer, and insert it with the proper
8322 formatting like @samp{(ref:label)} at the end of the current line.  Then the
8323 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
8324 @end table
8327 @node Include files, Tables exported, Literal examples, Markup rules
8328 @subheading Include files
8329 @cindex include files, markup rules
8331 During export, you can include the content of another file.  For example, to
8332 include your @file{.emacs} file, you could use:
8333 @cindex #+INCLUDE
8335 @example
8336 #+INCLUDE: "~/.emacs" src emacs-lisp
8337 @end example
8338 @noindent
8339 The optional second and third parameter are the markup (e.g. @samp{quote},
8340 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
8341 language for formatting the contents.  The markup is optional, if it is not
8342 given, the text will be assumed to be in Org mode format and will be
8343 processed normally.  The include line will also allow additional keyword
8344 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
8345 first line and for each following line, as well as any options accepted by
8346 the selected markup.  For example, to include a file as an item, use
8348 @example
8349 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
8350 @end example
8352 @table @kbd
8353 @kindex C-c '
8354 @item C-c '
8355 Visit the include file at point.
8356 @end table
8358 @node Tables exported, Inlined images, Include files, Markup rules
8359 @subheading Tables
8360 @cindex tables, markup rules
8362 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
8363 the @file{table.el} package will be exported properly.  For Org mode tables,
8364 the lines before the first horizontal separator line will become table header
8365 lines.  You can use the following lines somewhere before the table to assign
8366 a caption and a label for cross references:
8368 @example
8369 #+CAPTION: This is the caption for the next table (or link)
8370 #+LABEL:   tbl:basic-data
8371 @end example
8373 @node Inlined images, Footnote markup, Tables exported, Markup rules
8374 @subheading Inlined Images
8375 @cindex inlined images, markup rules
8377 Some backends (HTML, La@TeX{}, and DocBook) allow you to directly include images
8378 into the exported document.  Org does this, if a link to an image files does
8379 not have a description part, for example @code{[[./img/a.jpg]]}.  If you wish
8380 to define a caption for the image and maybe a label for internal cross
8381 references, you can use (before, but close to the link)
8383 @example
8384 #+CAPTION: This is the caption for the next figure link (or table)
8385 #+LABEL:   fig:SED-HR4049
8386 @end example
8388 You may also define additional attributes for the figure.  As this is
8389 backend-specific, see the sections about the individual backends for more
8390 information.
8392 @node Footnote markup, Emphasis and monospace, Inlined images, Markup rules
8393 @subheading Footnote markup
8394 @cindex footnotes, markup rules
8395 @cindex @file{footnote.el}
8397 Footnotes defined in the way described in @ref{Footnotes}, will be exported by
8398 all backends.  Org allows multiple references to the same note, and
8399 different backends support this to varying degrees.
8401 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnote markup, Markup rules
8402 @subheading Emphasis and monospace
8404 @cindex underlined text, markup rules
8405 @cindex bold text, markup rules
8406 @cindex italic text, markup rules
8407 @cindex verbatim text, markup rules
8408 @cindex code text, markup rules
8409 @cindex strike-through text, markup rules
8410 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
8411 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
8412 in the code and verbatim string is not processed for Org-mode specific
8413 syntax, it is exported verbatim.
8415 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
8416 @subheading @TeX{} macros and La@TeX{} fragments
8417 @cindex La@TeX{} fragments, markup rules
8418 @cindex @TeX{} macros, markup rules
8419 @cindex HTML entities
8420 @cindex La@TeX{} entities
8422 @vindex org-html-entities
8423 A @TeX{}-like syntax is used to specify special characters.  Where possible,
8424 these will be transformed into the native format of the exporter backend.
8425 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
8426 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
8427 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
8428 This applies for a large number of entities, with names taken from both HTML
8429 and La@TeX{}, see the variable @code{org-html-entities} for the complete
8430 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
8431 after having typed the backslash and optionally a few characters
8432 (@pxref{Completion}).
8434 La@TeX{} fragments are converted into images for HTML export, and they are
8435 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
8437 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
8438 @samp{...} are all converted into special commands creating hyphens of
8439 different lengths or a compact set of dots.
8441 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
8442 @subheading  Horizontal rules
8443 @cindex horizontal rules, markup rules
8444 A line consisting of only dashes, and at least 5 of them, will be
8445 exported as a horizontal line (@samp{<hr/>} in HTML).
8447 @node Comment lines, Macro replacement, Horizontal rules, Markup rules
8448 @subheading Comment lines
8449 @cindex comment lines
8450 @cindex exporting, not
8451 @cindex #+BEGIN_COMMENT
8453 Lines starting with @samp{#} in column zero are treated as comments and will
8454 never be exported.  Also entire subtrees starting with the word
8455 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
8456 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
8458 @table @kbd
8459 @kindex C-c ;
8460 @item C-c ;
8461 Toggle the COMMENT keyword at the beginning of an entry.
8462 @end table
8464 @node Macro replacement,  , Comment lines, Markup rules
8465 @subheading Macro replacement
8466 @cindex macro replacement, during export
8467 @cindex #+MACRO
8469 You can define text snippets with
8471 @example
8472 #+MACRO: name   replacement text $1, $2 are arguments
8473 @end example
8475 @noindent which can be referenced anywhere in the document (even in
8476 code examples) with @code{@{@{@{name(arg1,arg2)@}@}@}}.  In addition to
8477 defined macros, @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc.,
8478 will reference information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and
8479 similar lines.  Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
8480 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
8481 and to the modification time of the file being exported, respectively.
8482 @var{FORMAT} should be a format string understood by
8483 @code{format-time-string}.
8485 @node Selective export, Export options, Markup rules, Exporting
8486 @section Selective export
8487 @cindex export, selective by tags
8489 @vindex org-export-select-tags
8490 @vindex org-export-exclude-tags
8491 You may use tags to select the parts of a document that should be exported,
8492 or to exclude parts from export.  This behavior is governed by two variables:
8493 @code{org-export-select-tags} and @code{org-export-exclude-tags}.
8495 Org first checks if any of the @emph{select} tags is present in the buffer.
8496 If yes, all trees that do not carry one of these tags will be excluded.  If a
8497 selected tree is a subtree, the heading hierarchy above it will also be
8498 selected for export, but not the text below those headings.
8500 @noindent
8501 If none of the select tags is found, the whole buffer will be selected for
8502 export.
8504 @noindent
8505 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
8506 be removed from the export buffer.
8508 @node Export options, The export dispatcher, Selective export, Exporting
8509 @section Export options
8510 @cindex options, for export
8512 @cindex completion, of option keywords
8513 The exporter recognizes special lines in the buffer which provide
8514 additional information.  These lines may be put anywhere in the file.
8515 The whole set of lines can be inserted into the buffer with @kbd{C-c
8516 C-e t}.  For individual lines, a good way to make sure the keyword is
8517 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
8518 (@pxref{Completion}).   For a summary of other in-buffer settings not
8519 specifically related to export, see @ref{In-buffer settings}.
8520 In particular, note that you can place commonly-used (export) options in
8521 a separate file which can be included using @code{#+SETUPFILE}.
8523 @table @kbd
8524 @kindex C-c C-e t
8525 @item C-c C-e t
8526 Insert template with export options, see example below.
8527 @end table
8529 @cindex #+TITLE
8530 @cindex #+AUTHOR
8531 @cindex #+DATE
8532 @cindex #+EMAIL
8533 @cindex #+DESCRIPTION
8534 @cindex #+KEYWORDS
8535 @cindex #+LANGUAGE
8536 @cindex #+TEXT
8537 @cindex #+OPTIONS
8538 @cindex #+BIND
8539 @cindex #+LINK_UP
8540 @cindex #+LINK_HOME
8541 @cindex #+EXPORT_SELECT_TAGS
8542 @cindex #+EXPORT_EXCLUDE_TAGS
8543 @cindex #+LATEX_HEADER
8544 @vindex user-full-name
8545 @vindex user-mail-address
8546 @vindex org-export-default-language
8547 @example
8548 #+TITLE:       the title to be shown (default is the buffer name)
8549 #+AUTHOR:      the author (default taken from @code{user-full-name})
8550 #+DATE:        a date, fixed, of a format string for @code{format-time-string}
8551 #+EMAIL:       his/her email address (default from @code{user-mail-address})
8552 #+DESCRIPTION: the page description, @eg for the XHTML meta tag
8553 #+KEYWORDS:    the page keywords, @eg for the XHTML meta tag
8554 #+LANGUAGE:    language for HTML, @eg @samp{en} (@code{org-export-default-language})
8555 #+TEXT:        Some descriptive text to be inserted at the beginning.
8556 #+TEXT:        Several lines may be given.
8557 #+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
8558 #+BIND:        lisp-var lisp-val, e.g.: org-export-latex-low-levels itemize
8559                @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
8560 #+LINK_UP:     the ``up'' link of an exported page
8561 #+LINK_HOME:   the ``home'' link of an exported page
8562 #+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
8563 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
8564 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
8565 @end example
8567 @noindent
8568 The OPTIONS line is a compact@footnote{If you want to configure many options
8569 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
8570 you can:
8571 @cindex headline levels
8572 @cindex section-numbers
8573 @cindex table of contents
8574 @cindex line-break preservation
8575 @cindex quoted HTML tags
8576 @cindex fixed-width sections
8577 @cindex tables
8578 @cindex @TeX{}-like syntax for sub- and superscripts
8579 @cindex footnotes
8580 @cindex special strings
8581 @cindex emphasized text
8582 @cindex @TeX{} macros
8583 @cindex La@TeX{} fragments
8584 @cindex author info, in export
8585 @cindex time info, in export
8586 @example
8587 H:         @r{set the number of headline levels for export}
8588 num:       @r{turn on/off section-numbers}
8589 toc:       @r{turn on/off table of contents, or set level limit (integer)}
8590 \n:        @r{turn on/off line-break-preservation}
8591 @@:         @r{turn on/off quoted HTML tags}
8592 ::         @r{turn on/off fixed-width sections}
8593 |:         @r{turn on/off tables}
8594 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
8595            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
8596            @r{the simple @code{a_b} will be left as it is.}
8597 -:         @r{turn on/off conversion of special strings.}
8598 f:         @r{turn on/off footnotes like this[1].}
8599 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
8600 pri:       @r{turn on/off priority cookies}
8601 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
8602 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
8603 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
8604 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
8605 LaTeX:     @r{turn on/off La@TeX{} fragments}
8606 skip:      @r{turn on/off skipping the text before the first heading}
8607 author:    @r{turn on/off inclusion of author name/email into exported file}
8608 creator:   @r{turn on/off inclusion of creator info into exported file}
8609 timestamp: @r{turn on/off inclusion creation time into exported file}
8610 d:         @r{turn on/off inclusion of drawers}
8611 @end example
8612 @noindent
8613 These options take effect in both the HTML and La@TeX{} export, except
8614 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
8615 @code{nil} for the La@TeX{} export.
8617 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
8618 calling an export command, the subtree can overrule some of the file's export
8619 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
8620 @code{EXPORT_TEXT}, @code{EXPORT_AUTHOR}, @code{EXPORT_DATE}, and
8621 @code{EXPORT_OPTIONS}.
8623 @node The export dispatcher, ASCII export, Export options, Exporting
8624 @section The export dispatcher
8625 @cindex dispatcher, for export commands
8627 All export commands can be reached using the export dispatcher, which is a
8628 prefix key that prompts for an additional key specifying the command.
8629 Normally the entire file is exported, but if there is an active region that
8630 contains one outline tree, the first heading is used as document title and
8631 the subtrees are exported.
8633 @table @kbd
8634 @kindex C-c C-e
8635 @item C-c C-e
8636 @vindex org-export-run-in-background
8637 Dispatcher for export and publishing commands.  Displays a help-window
8638 listing the additional key(s) needed to launch an export or publishing
8639 command.  The prefix arg is passed through to the exporter.  A double prefix
8640 @kbd{C-u C-u} causes most commands to be executed in the background, in a
8641 separate Emacs process@footnote{To make this behavior the default, customize
8642 the variable @code{org-export-run-in-background}.}.
8643 @kindex C-c C-e v
8644 @item C-c C-e v
8645 Like @kbd{C-c C-e}, but only export the text that is currently visible
8646 (@ie not hidden by outline visibility).
8647 @kindex C-u C-u C-c C-e
8648 @item C-u C-u C-c C-e
8649 @vindex org-export-run-in-background
8650 Call an the exporter, but reverse the setting of
8651 @code{org-export-run-in-background}, @ie request background processing if
8652 not set, or force processing in the current Emacs process if set.
8653 @end table
8655 @node ASCII export, HTML export, The export dispatcher, Exporting
8656 @section ASCII export
8657 @cindex ASCII export
8659 ASCII export produces a simple and very readable version of an Org-mode
8660 file.
8662 @cindex region, active
8663 @cindex active region
8664 @cindex transient-mark-mode
8665 @table @kbd
8666 @kindex C-c C-e a
8667 @item C-c C-e a
8668 @cindex property, EXPORT_FILE_NAME
8669 Export as ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
8670 will be @file{myfile.txt}.  The file will be overwritten without
8671 warning.  If there is an active region@footnote{This requires
8672 @code{transient-mark-mode} be turned on.}, only the region will be
8673 exported. If the selected region is a single tree@footnote{To select the
8674 current subtree, use @kbd{C-c @@}.}, the tree head will
8675 become the document title.  If the tree head entry has or inherits an
8676 @code{EXPORT_FILE_NAME} property, that name will be used for the
8677 export.
8678 @kindex C-c C-e A
8679 @item C-c C-e A
8680 Export to a temporary buffer, do not create a file.
8681 @kindex C-c C-e v a
8682 @item C-c C-e v a
8683 Export only the visible part of the document.
8684 @end table
8686 @cindex headline levels, for exporting
8687 In the exported version, the first 3 outline levels will become
8688 headlines, defining a general document structure.  Additional levels
8689 will be exported as itemized lists.  If you want that transition to occur
8690 at a different level, specify it with a prefix argument.  For example,
8692 @example
8693 @kbd{C-1 C-c C-e a}
8694 @end example
8696 @noindent
8697 creates only top level headlines and does the rest as items.  When
8698 headlines are converted to items, the indentation of the text following
8699 the headline is changed to fit nicely under the item.  This is done with
8700 the assumption that the first body line indicates the base indentation of
8701 the body text.  Any indentation larger than this is adjusted to preserve
8702 the layout relative to the first line.  Should there be lines with less
8703 indentation than the first, these are left alone.
8705 @vindex org-export-ascii-links-to-notes
8706 Links will be exported in a footnote-like style, with the descriptive part in
8707 the text and the link in a note before the next heading.  See the variable
8708 @code{org-export-ascii-links-to-notes} for details and other options.
8710 @node HTML export, LaTeX and PDF export, ASCII export, Exporting
8711 @section HTML export
8712 @cindex HTML export
8714 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
8715 HTML formatting, in ways similar to John Gruber's @emph{markdown}
8716 language, but with additional support for tables.
8718 @menu
8719 * HTML Export commands::        How to invoke HTML export
8720 * Quoting HTML tags::           Using direct HTML in Org mode
8721 * Links::                       Transformation of links for HTML
8722 * Tables in HTML export::       How to modify the formatting of tables
8723 * Images in HTML export::       How to insert figures into HTML output
8724 * Text areas in HTML export::   An alternative way to show an example
8725 * CSS support::                 Changing the appearance of the output
8726 * Javascript support::          Info and Folding in a web browser
8727 @end menu
8729 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
8730 @subsection HTML export commands
8732 @cindex region, active
8733 @cindex active region
8734 @cindex transient-mark-mode
8735 @table @kbd
8736 @kindex C-c C-e h
8737 @item C-c C-e h
8738 @cindex property, EXPORT_FILE_NAME
8739 Export as HTML file @file{myfile.html}.  For an Org file @file{myfile.org},
8740 the ASCII file will be @file{myfile.html}.  The file will be overwritten
8741 without warning.  If there is an active region@footnote{This requires
8742 @code{transient-mark-mode} be turned on.}, only the region will be
8743 exported. If the selected region is a single tree@footnote{To select the
8744 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
8745 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
8746 property, that name will be used for the export.
8747 @kindex C-c C-e b
8748 @item C-c C-e b
8749 Export as HTML file and immediately open it with a browser.
8750 @kindex C-c C-e H
8751 @item C-c C-e H
8752 Export to a temporary buffer, do not create a file.
8753 @kindex C-c C-e R
8754 @item C-c C-e R
8755 Export the active region to a temporary buffer.  With a prefix argument, do
8756 not produce the file header and footer, but just the plain HTML section for
8757 the region.  This is good for cut-and-paste operations.
8758 @kindex C-c C-e v h
8759 @kindex C-c C-e v b
8760 @kindex C-c C-e v H
8761 @kindex C-c C-e v R
8762 @item C-c C-e v h
8763 @item C-c C-e v b
8764 @item C-c C-e v H
8765 @item C-c C-e v R
8766 Export only the visible part of the document.
8767 @item M-x org-export-region-as-html
8768 Convert the region to HTML under the assumption that it was Org-mode
8769 syntax before.  This is a global command that can be invoked in any
8770 buffer.
8771 @item M-x org-replace-region-by-HTML
8772 Replace the active region (assumed to be in Org-mode syntax) by HTML
8773 code.
8774 @end table
8776 @cindex headline levels, for exporting
8777 In the exported version, the first 3 outline levels will become headlines,
8778 defining a general document structure.  Additional levels will be exported as
8779 itemized lists.  If you want that transition to occur at a different level,
8780 specify it with a numeric prefix argument.  For example,
8782 @example
8783 @kbd{C-2 C-c C-e b}
8784 @end example
8786 @noindent
8787 creates two levels of headings and does the rest as items.
8789 @node Quoting HTML tags, Links, HTML Export commands, HTML export
8790 @subsection Quoting HTML tags
8792 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
8793 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
8794 which should be interpreted as such, mark them with @samp{@@} as in
8795 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
8796 simple tags.  For more extensive HTML that should be copied verbatim to
8797 the exported file use either
8799 @cindex #+HTML
8800 @cindex #+BEGIN_HTML
8801 @example
8802 #+HTML: Literal HTML code for export
8803 @end example
8805 @noindent or
8806 @cindex #+BEGIN_HTML
8808 @example
8809 #+BEGIN_HTML
8810 All lines between these markers are exported literally
8811 #+END_HTML
8812 @end example
8815 @node Links, Tables in HTML export, Quoting HTML tags, HTML export
8816 @subsection Links
8818 @cindex links, in HTML export
8819 @cindex internal links, in HTML export
8820 @cindex external links, in HTML export
8821 Internal links (@pxref{Internal links}) will continue to work in HTML.  This
8822 includes automatic links created by radio targets (@pxref{Radio
8823 targets}).  Links to external files will still work if the target file is on
8824 the same @i{relative} path as the published Org file.  Links to other
8825 @file{.org} files will be translated into HTML links under the assumption
8826 that an HTML version also exists of the linked file, at the same relative
8827 path.  @samp{id:} links can then be used to jump to specific entries across
8828 files.  For information related to linking files while publishing them to a
8829 publishing directory see @ref{Publishing links}.
8831 If you want to specify attributes for links, you can do so using a special
8832 @code{#+ATTR_HTML} line to define attributes that will be added to the
8833 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
8834 and @code{style} attributes for a link:
8836 @cindex #+ATTR_HTML
8837 @example
8838 #+ATTR_HTML: title="The Org-mode homepage" style="color:red;"
8839 [[http://orgmode.org]]
8840 @end example
8842 @node Tables in HTML export, Images in HTML export, Links, HTML export
8843 @subsection Tables
8844 @cindex tables, in HTML
8845 @vindex org-export-html-table-tag
8847 Org-mode tables are exported to HTML using the table tag defined in
8848 @code{org-export-html-table-tag}.  The default setting makes tables without
8849 cell borders and frame.  If you would like to change this for individual
8850 tables, place somthing like the following before the table:
8852 @cindex #+CAPTION
8853 @example
8854 #+CAPTION: This is a table with lines around and between cells
8855 #+ATTR_HTML: border="2" rules="all" frame="all"
8856 @end example
8858 @node Images in HTML export, Text areas in HTML export, Tables in HTML export, HTML export
8859 @subsection Images
8861 @cindex images, inline in HTML
8862 @cindex inlining images in HTML
8863 @vindex org-export-html-inline-images
8864 HTML export can inline images given as links in the Org file, and
8865 it can make an image the clickable part of a link.  By
8866 default@footnote{But see the variable
8867 @code{org-export-html-inline-images}.}, images are inlined if a link does
8868 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
8869 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
8870 @samp{the image} that points to the image.  If the description part
8871 itself is a @code{file:} link or a @code{http:} URL pointing to an
8872 image, this image will be inlined and activated so that clicking on the
8873 image will activate the link.  For example, to include a thumbnail that
8874 will link to a high resolution version of the image, you could use:
8876 @example
8877 [[file:highres.jpg][file:thumb.jpg]]
8878 @end example
8880 If you need to add attributes to an inlines image, use a @code{#+ATTR_HTML},
8881 for example:
8883 @cindex #+CAPTION
8884 @example
8885 #+CAPTION: A black cat stalking a spider
8886 #+ATTR_HTML: alt="cat/spider image" title="one second before action"
8887 [[./img/a.jpg]]
8888 @end example
8890 @noindent
8891 and you could use @code{http} addresses just as well.
8893 @node Text areas in HTML export, CSS support, Images in HTML export, HTML export
8894 @subsection Text areas
8896 @cindex text areas, in HTML
8897 An alternative way to publish literal code examples in HTML is to use text
8898 areas, where the example can even be edited before pasting it into an
8899 application.  It is triggered by a @code{-t} switch at an @code{example} or
8900 @code{src} block.  Using this switch disables any options for syntax and
8901 label highlighting, and line numbering, which may be present.  You may also
8902 use @code{-h} and @code{-w} switches to specify the height and width of the
8903 text area, which default to the number of lines in the example, and 80,
8904 respectively.  For example
8906 @example
8907 #+BEGIN_EXAMPLE -t -w 40
8908 (defun org-xor (a b)
8909    "Exclusive or."
8910    (if a (not b) b))
8911 #+END_EXAMPLE
8912 @end example
8915 @node CSS support, Javascript support, Text areas in HTML export, HTML export
8916 @subsection CSS support
8917 @cindex CSS, for HTML export
8918 @cindex HTML export, CSS
8920 @vindex org-export-html-todo-kwd-class-prefix
8921 @vindex org-export-html-tag-class-prefix
8922 You can also give style information for the exported file.  The HTML exporter
8923 assigns the following special CSS classes@footnote{If the classes on TODO
8924 keywords and tags lead to conflicts, use the variables
8925 @code{org-export-html-todo-kwd-class-prefix} and
8926 @code{org-export-html-tag-class-prefix} to make them unique.} to appropriate
8927 parts of the document---your style specifications may change these, in
8928 addition to any of the standard classes like for headlines, tables, etc.
8929 @example
8930 p.author            @r{author information, including email}
8931 p.date              @r{publishing date}
8932 p.creator           @r{creator info, about org-mode version}
8933 .title              @r{document title}
8934 .todo               @r{TODO keywords, all not-done states}
8935 .done               @r{the DONE keywords, all stated the count as done}
8936 .WAITING            @r{each TODO keyword also uses a class named after itself}
8937 .timestamp          @r{timestamp}
8938 .timestamp-kwd      @r{keyword associated with a timestamp, like SCHEDULED}
8939 .timestamp-wrapper  @r{span around keyword plus timestamp}
8940 .tag                @r{tag in a headline}
8941 ._HOME              @r{each tag uses itself as a class, "@@" replaced by "_"}
8942 .target             @r{target for links}
8943 .linenr             @r{the line number in a code example}
8944 .code-highlighted   @r{for highlighting referenced code lines}
8945 div.outline-N       @r{div for outline level N (headline plus text))}
8946 div.outline-text-N  @r{extra div for text at outline level N}
8947 .section-number-N   @r{section number in headlines, different for each level}
8948 div.figure          @r{how to format an inlined image}
8949 pre.src             @r{formatted source code}
8950 pre.example         @r{normal example}
8951 p.verse             @r{verse paragraph}
8952 div.footnotes       @r{footnote section headline}
8953 p.footnote          @r{footnote definition paragraph, containing a footnote}
8954 .footref            @r{a footnote reference number (always a <sup>)}
8955 .footnum            @r{footnote number in footnote definition (always <sup>)}
8956 @end example
8958 @vindex org-export-html-style-default
8959 @vindex org-export-html-style-include-default
8960 @vindex org-export-html-style
8961 @vindex org-export-html-extra
8962 @vindex org-export-html-style-default
8963 Each exported file contains a compact default style that defines these
8964 classes in a basic way@footnote{This style is defined in the constant
8965 @code{org-export-html-style-default}, which you should not modify.  To turn
8966 inclusion of these defaults off, customize
8967 @code{org-export-html-style-include-default}}.  You may overwrite these
8968 settings, or add to them by using the variables @code{org-export-html-style}
8969 (for Org-wide settings) and @code{org-export-html-style-extra} (for more
8970 granular settings, like file-local settings).  To set the latter variable
8971 individually for each file, you can use
8973 @cindex #+STYLE
8974 @example
8975 #+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
8976 @end example
8978 @noindent
8979 For longer style definitions, you can use several such lines.  You could also
8980 directly write a @code{<style>} @code{</style>} section in this way, without
8981 referring to an external file.
8983 @c FIXME: More about header and footer styles
8984 @c FIXME: Talk about links and targets.
8986 @node Javascript support,  , CSS support, HTML export
8987 @subsection Javascript supported display of web pages
8989 @cindex Rose, Sebastian
8990 Sebastian Rose has written a JavaScript program especially designed to
8991 enhance the web viewing experience of HTML files created with Org.  This
8992 program allows you to view large files in two different ways.  The first one
8993 is an @emph{Info}-like mode where each section is displayed separately and
8994 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
8995 as well, press @kbd{?} for an overview of the available keys).  The second
8996 view type is a @emph{folding} view much like Org provides inside Emacs.  The
8997 script is available at @url{http://orgmode.org/org-info.js} and you can find
8998 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
8999 We host the script at our site, but if you use it a lot, you might
9000 not want to be dependent on @url{orgmode.org} and prefer to install a local
9001 copy on your own web server.
9003 To use the script, you need to make sure that the @file{org-jsinfo.el} module
9004 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
9005 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
9006 this is indeed the case.  All it then takes to make use of the program is
9007 adding a single line to the Org file:
9009 @cindex #+INFOJS_OPT
9010 @example
9011 #+INFOJS_OPT: view:info toc:nil
9012 @end example
9014 @noindent
9015 If this line is found, the HTML header will automatically contain the code
9016 needed to invoke the script.  Using the line above, you can set the following
9017 viewing options:
9019 @example
9020 path:    @r{The path to the script.  The default is to grab the script from}
9021          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
9022          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
9023 view:    @r{Initial view when website is first shown.  Possible values are:}
9024          info      @r{Info-like interface with one section per page.}
9025          overview  @r{Folding interface, initially showing only top-level.}
9026          content   @r{Folding interface, starting with all headlines visible.}
9027          showall   @r{Folding interface, all headlines and text visible.}
9028 sdepth:  @r{Maximum headline level that will still become an independent}
9029          @r{section for info and folding modes.  The default is taken from}
9030          @r{@code{org-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
9031          @r{If this is smaller than in @code{org-headline-levels}, each}
9032          @r{info/folding section can still contain child headlines.}
9033 toc:     @r{Should the table of content @emph{initially} be visible?}
9034          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
9035 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
9036          @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
9037 ftoc:    @r{Does the css of the page specify a fixed position for the "toc"?}
9038          @r{If yes, the toc will never be displayed as a section.}
9039 ltoc:    @r{Should there be short contents (children) in each section?}
9040          @r{Make this @code{above} if the section should be above initial text.}
9041 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
9042          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
9043 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
9044          @r{default), only one such button will be present.}
9045 @end example
9046 @noindent
9047 @vindex org-infojs-options
9048 @vindex org-export-html-use-infojs
9049 You can choose default values for these options by customizing the variable
9050 @code{org-infojs-options}.  If you always want to apply the script to your
9051 pages, configure the variable @code{org-export-html-use-infojs}.
9053 @node LaTeX and PDF export, DocBook export, HTML export, Exporting
9054 @section La@TeX{} and PDF export
9055 @cindex La@TeX{} export
9056 @cindex PDF export
9057 @cindex Guerry, Bastian
9059 Org mode contains a La@TeX{} exporter written by Bastien Guerry.  With
9060 further processing, this backend is also used to produce PDF output.  Since
9061 the La@TeX{} output uses @file{hyperref} to implement links and cross
9062 references, the PDF output file will be fully linked.
9064 @menu
9065 * LaTeX/PDF export commands::   Which key invokes which commands
9066 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
9067 * Sectioning structure::        Changing sectioning in La@TeX{} output
9068 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
9069 * Images in LaTeX export::      How to insert figures into La@TeX{} output
9070 @end menu
9072 @node LaTeX/PDF export commands, Quoting LaTeX code, LaTeX and PDF export, LaTeX and PDF export
9073 @subsection La@TeX{} export commands
9075 @cindex region, active
9076 @cindex active region
9077 @cindex transient-mark-mode
9078 @table @kbd
9079 @kindex C-c C-e l
9080 @item C-c C-e l
9081 @cindex property EXPORT_FILE_NAME
9082 Export as La@TeX{} file @file{myfile.tex}.  For an Org file
9083 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
9084 be overwritten without warning.  If there is an active region@footnote{This
9085 requires @code{transient-mark-mode} be turned on.}, only the region will be
9086 exported. If the selected region is a single tree@footnote{To select the
9087 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9088 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
9089 property, that name will be used for the export.
9090 @kindex C-c C-e L
9091 @item C-c C-e L
9092 Export to a temporary buffer, do not create a file.
9093 @kindex C-c C-e v l
9094 @kindex C-c C-e v L
9095 @item C-c C-e v l
9096 @item C-c C-e v L
9097 Export only the visible part of the document.
9098 @item M-x org-export-region-as-latex
9099 Convert the region to La@TeX{} under the assumption that it was Org mode
9100 syntax before.  This is a global command that can be invoked in any
9101 buffer.
9102 @item M-x org-replace-region-by-latex
9103 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
9104 code.
9105 @kindex C-c C-e p
9106 @item C-c C-e p
9107 Export as La@TeX{} and then process to PDF.
9108 @kindex C-c C-e d
9109 @item C-c C-e d
9110 Export as La@TeX{} and then process to PDF, then open the resulting PDF file.
9111 @end table
9113 @cindex headline levels, for exporting
9114 @vindex org-latex-low-levels
9115 In the exported version, the first 3 outline levels will become
9116 headlines, defining a general document structure.  Additional levels
9117 will be exported as description lists.  The exporter can ignore them or
9118 convert them to a custom string depending on
9119 @code{org-latex-low-levels}.
9121 If you want that transition to occur at a different level, specify it
9122 with a numeric prefix argument. For example,
9124 @example
9125 @kbd{C-2 C-c C-e l}
9126 @end example
9128 @noindent
9129 creates two levels of headings and does the rest as items.
9131 @node Quoting LaTeX code, Sectioning structure, LaTeX/PDF export commands, LaTeX and PDF export
9132 @subsection Quoting La@TeX{} code
9134 Embedded La@TeX{} as described in @ref{Embedded LaTeX}, will be correctly
9135 inserted into the La@TeX{} file.  This includes simple macros like
9136 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
9137 you can add special code that should only be present in La@TeX{} export with
9138 the following constructs:
9140 @cindex #+LaTeX
9141 @cindex #+BEGIN_LaTeX
9142 @example
9143 #+LaTeX: Literal LaTeX code for export
9144 @end example
9146 @noindent or
9147 @cindex #+BEGIN_LaTeX
9149 @example
9150 #+BEGIN_LaTeX
9151 All lines between these markers are exported literally
9152 #+END_LaTeX
9153 @end example
9155 @node  Sectioning structure, Tables in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
9156 @subsection Sectioning structure
9157 @cindex La@TeX{} class
9158 @cindex La@TeX{} sectioning structure
9160 By default, the La@TeX{} output uses the class @code{article}.
9162 @vindex org-export-latex-default-class
9163 @vindex org-export-latex-classes
9164 @cindex #+LATEX_HEADER
9165 @cindex #+LATEX_CLASS
9166 @cindex property, LATEX_CLASS
9167 You can change this globally by setting a different value for
9168 @code{org-export-latex-default-class} or locally by adding an option like
9169 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
9170 property that applies when exporting a region containing only this (sub)tree.
9171 The class should be listed in @code{org-export-latex-classes}, where you can
9172 also define the sectioning structure for each class, as well as defining
9173 additional classes.  You can also use @code{#+LATEX_HEADER:
9174 \usepackage@{xyz@}} to add lines to the header.
9176 @node Tables in LaTeX export, Images in LaTeX export, Sectioning structure, LaTeX and PDF export
9177 @subsection Tables in La@TeX{} export
9178 @cindex tables, in La@TeX{} export
9180 For La@TeX{} export of a table, you can specify a label and a caption
9181 (@pxref{Markup rules}).  You can also use the @code{ATTR_LaTeX} line to
9182 request a longtable environment for the table, so that it may span several
9183 pages.  Finally, you can set the alignment string:
9185 @cindex #+CAPTION
9186 @cindex #+LABEL
9187 @cindex #+ATTR_LaTeX
9188 @example
9189 #+CAPTION: A long table
9190 #+LABEL: tbl:long
9191 #+ATTR_LaTeX: longtable align=l|lp@{3cm@}r|l
9192 | ..... | ..... |
9193 | ..... | ..... |
9194 @end example
9197 @node Images in LaTeX export,  , Tables in LaTeX export, LaTeX and PDF export
9198 @subsection Images in La@TeX{} export
9199 @cindex images, inline in La@TeX{}
9200 @cindex inlining images in La@TeX{}
9202 Images that are linked to without a description part in the link, like
9203 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
9204 output files resulting from La@TeX{} output.  Org will use an
9205 @code{\includegraphics} macro to insert the image.  If you have specified a
9206 caption and/or a label as described in @ref{Markup rules}, the figure will
9207 be wrapped into a @code{figure} environment and thus become a floating
9208 element.  Finally, you can use an @code{#+ATTR_LaTeX:} line to specify the
9209 options that can be used in the optional argument of the
9210 @code{\includegraphics} macro.
9212 @cindex #+CAPTION
9213 @cindex #+LABEL
9214 @cindex #+ATTR_LaTeX
9215 @example
9216 #+CAPTION:    The black-body emission of the disk around HR 4049
9217 #+LABEL:      fig:SED-HR4049
9218 #+ATTR_LaTeX: width=5cm,angle=90
9219 [[./img/sed-hr4049.pdf]]
9220 @end example
9222 @vindex org-export-latex-inline-image-extensions
9223 If you need references to a label created in this way, write
9224 @samp{\ref@{fig:SED-HR4049@}} just like in La@TeX{}.  The default settings will
9225 recognize files types that can be included as images during processing by
9226 @command{pdflatex} (@file{png}, @file{jpg}, and @file{pdf} files).  If you process your
9227 files in a different way, you may need to customize the variable
9228 @code{org-export-latex-inline-image-extensions}.
9230 @node DocBook export, XOXO export, LaTeX and PDF export, Exporting
9231 @section DocBook export
9232 @cindex DocBook export
9233 @cindex PDF export
9234 @cindex Cui, Baoqui
9236 Org contains a DocBook exporter written by Baoqiu Cui.  Once an Org file is
9237 exported to DocBook format, it can be further processed to produce other
9238 formats, including PDF, HTML, man pages, etc., using many available DocBook
9239 tools and stylesheets.
9241 Currently DocBook exporter only supports DocBook V5.0.
9243 @menu
9244 * DocBook export commands::     How to invoke DocBook export
9245 * Quoting DocBook code::        Incorporating DocBook code in Org files
9246 * Recursive sections::          Recursive sections in DocBook
9247 * Tables in DocBook export::    Tables are exported as HTML tables
9248 * Images in DocBook export::    How to insert figures into DocBook output
9249 * Special characters::          How to handle special characters
9250 @end menu
9252 @node DocBook export commands, Quoting DocBook code, DocBook export, DocBook export
9253 @subsection DocBook export commands
9255 @cindex region, active
9256 @cindex active region
9257 @cindex transient-mark-mode
9258 @table @kbd
9259 @kindex C-c C-e D
9260 @item C-c C-e D
9261 @cindex property EXPORT_FILE_NAME
9262 Export as DocBook file.  For an Org file, @file{myfile.org}, the DocBook XML
9263 file will be @file{myfile.xml}.  The file will be overwritten without
9264 warning.  If there is an active region@footnote{This requires
9265 @code{transient-mark-mode} to be turned on}, only the region will be
9266 exported.  If the selected region is a single tree@footnote{To select the
9267 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9268 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
9269 property, that name will be used for the export.
9270 @kindex C-c C-e V
9271 @item C-c C-e V
9272 Export as DocBook file, process to PDF, then open the resulting PDF file.
9274 @vindex org-export-docbook-xslt-proc-command
9275 @vindex org-export-docbook-xsl-fo-proc-command
9276 Note that, in order to produce PDF output based on exported DocBook file, you
9277 need to have XSLT processor and XSL-FO processor software installed on your
9278 system.  Check variables @code{org-export-docbook-xslt-proc-command} and
9279 @code{org-export-docbook-xsl-fo-proc-command}.
9281 @kindex C-c C-e v D
9282 @item C-c C-e v D
9283 Export only the visible part of the document.
9284 @end table
9286 @node Quoting DocBook code, Recursive sections, DocBook export commands, DocBook export
9287 @subsection Quoting DocBook code
9289 You can quote DocBook code in Org files and copy it verbatim into exported
9290 DocBook file with the following constructs:
9292 @cindex #+DOCBOOK
9293 @cindex #+BEGIN_DOCBOOK
9294 @example
9295 #+DOCBOOK: Literal DocBook code for export
9296 @end example
9298 @noindent or
9299 @cindex #+BEGIN_DOCBOOK
9301 @example
9302 #+BEGIN_DOCBOOK
9303 All lines between these markers are exported by DocBook exporter
9304 literally.
9305 #+END_DOCBOOK
9306 @end example
9308 For example, you can use the following lines to include a DocBook warning
9309 admonition.  As to what this warning says, you should pay attention to the
9310 document context when quoting DocBook code in Org files.  You may make
9311 exported DocBook XML files invalid by not quoting DocBook code correctly.
9313 @example
9314 #+BEGIN_DOCBOOK
9315 <warning>
9316   <para>You should know what you are doing when quoting DocBook XML code
9317   in your Org file.  Invalid DocBook XML file may be generated by
9318   DocBook exporter if you are not careful!</para>
9319 </warning>
9320 #+END_DOCBOOK
9321 @end example
9323 @node Recursive sections, Tables in DocBook export, Quoting DocBook code, DocBook export
9324 @subsection Recursive sections
9325 @cindex DocBook recursive sections
9327 DocBook exporter exports Org files as articles using the @code{article}
9328 element in DocBook.  Recursive sections, @ie @code{section} elements, are
9329 used in exported articles.  Top level headlines in Org files are exported as
9330 top level sections, and lower level headlines are exported as nested
9331 sections.  The entire structure of Org files will be exported completely, no
9332 matter how many nested levels of headlines there are.
9334 Using recursive sections makes it easy to port and reuse exported DocBook
9335 code in other DocBook document types like @code{book} or @code{set}.
9337 @node Tables in DocBook export, Images in DocBook export, Recursive sections, DocBook export
9338 @subsection Tables in DocBook export
9339 @cindex tables, in DocBook export
9341 Tables in Org files are exported as HTML tables, which have been supported since
9342 DocBook V4.3.
9344 If a table does not have a caption, an informal table is generated using the
9345 @code{informaltable} element; otherwise, a formal table will be generated
9346 using the @code{table} element.
9348 @node Images in DocBook export, Special characters, Tables in DocBook export, DocBook export
9349 @subsection Images in DocBook export
9350 @cindex images, inline in DocBook
9351 @cindex inlining images in DocBook
9353 Images that are linked to without a description part in the link, like
9354 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]}, will be exported to DocBook
9355 using @code{mediaobject} elements.  Each @code{mediaobject} element contains
9356 an @code{imageobject} that wraps an @code{imagedata} element.  If you have
9357 specified a caption for an image as described in @ref{Markup rules}, a
9358 @code{caption} element will be added in @code{mediaobject}.  If a label is
9359 also specified, it will be exported as an @code{xml:id} attribute of the
9360 @code{mediaobject} element.
9362 @vindex org-export-docbook-default-image-attributes
9363 Image attributes supported by the @code{imagedata} element, like @code{align}
9364 or @code{width}, can be specified in two ways: you can either customize
9365 variable @code{org-export-docbook-default-image-attributes} or use the
9366 @code{#+ATTR_DOCBOOK:} line.  Attributes specified in variable
9367 @code{org-export-docbook-default-image-attributes} are applied to all inline
9368 images in the Org file to be exported (unless they are overwritten by image
9369 attributes specified in @code{#+ATTR_DOCBOOK:} lines).
9371 The @code{#+ATTR_DOCBOOK:} line can be used to specify additional image
9372 attributes or overwrite default image attributes for individual images.  If
9373 the same attribute appears in both the @code{#+ATTR_DOCBOOK:} line and
9374 variable @code{org-export-docbook-default-image-attributes}, the former
9375 overwrites the latter.  Here is an example about how image attributes can be
9376 set:
9378 @cindex #+CAPTION
9379 @cindex #+LABEL
9380 @cindex #+ATTR_DOCBOOK
9381 @example
9382 #+CAPTION:    The logo of Org mode
9383 #+LABEL:      unicorn-svg
9384 #+ATTR_DOCBOOK: scalefit="1" width="100%" depth="100%"
9385 [[./img/org-mode-unicorn.svg]]
9386 @end example
9388 @vindex org-export-docbook-inline-image-extensions
9389 By default, DocBook exporter recognizes the following image file types:
9390 @file{jpeg}, @file{jpg}, @file{png}, @file{gif}, and @file{svg}.  You can
9391 customize variable @code{org-export-docbook-inline-image-extensions} to add
9392 more types to this list as long as DocBook supports them.
9394 @node Special characters,  , Images in DocBook export, DocBook export
9395 @subsection Special characters in DocBook export
9396 @cindex Special characters in DocBook export
9398 @vindex org-export-docbook-doctype
9399 @vindex org-html-entities
9400 Special characters that are written in @TeX{}-like syntax, such as @code{\alpha},
9401 @code{\Gamma}, and @code{\Zeta}, are supported by DocBook exporter.  These
9402 characters are rewritten to XML entities, like @code{&alpha;},
9403 @code{&Gamma;}, and @code{&Zeta;}, based on the list saved in variable
9404 @code{org-html-entities}.  As long as the generated DocBook file includes the
9405 corresponding entities, these special characters are recognized.
9407 You can customize variable @code{org-export-docbook-doctype} to include the
9408 entities you need.  For example, you can set variable
9409 @code{org-export-docbook-doctype} to the following value to recognize all
9410 special characters included in XHTML entities:
9412 @example
9413 "<!DOCTYPE article [
9414 <!ENTITY % xhtml1-symbol PUBLIC
9415 \"-//W3C//ENTITIES Symbol for HTML//EN//XML\"
9416 \"http://www.w3.org/2003/entities/2007/xhtml1-symbol.ent\"
9418 %xhtml1-symbol;
9421 @end example
9423 @node XOXO export, iCalendar export, DocBook export, Exporting
9424 @section XOXO export
9425 @cindex XOXO export
9427 Org mode contains an exporter that produces XOXO-style output.
9428 Currently, this exporter only handles the general outline structure and
9429 does not interpret any additional Org-mode features.
9431 @table @kbd
9432 @kindex C-c C-e x
9433 @item C-c C-e x
9434 Export as XOXO file @file{myfile.html}.
9435 @kindex C-c C-e v
9436 @item C-c C-e v x
9437 Export only the visible part of the document.
9438 @end table
9440 @node iCalendar export,  , XOXO export, Exporting
9441 @section iCalendar export
9442 @cindex iCalendar export
9444 @vindex org-icalendar-include-todo
9445 @vindex org-icalendar-use-deadline
9446 @vindex org-icalendar-use-scheduled
9447 @vindex org-icalendar-categories
9448 Some people use Org mode for keeping track of projects, but still prefer a
9449 standard calendar application for anniversaries and appointments.  In this
9450 case it can be useful to show deadlines and other time-stamped items in Org
9451 files in the calendar application.  Org mode can export calendar information
9452 in the standard iCalendar format.  If you also want to have TODO entries
9453 included in the export, configure the variable
9454 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
9455 and TODO items as VTODO.  It will also create events from deadlines that are
9456 in non-TODO items.  Deadlines and scheduling dates in TODO items will be used
9457 to set the start and due dates for the TODO entry@footnote{See the variables
9458 @code{org-icalendar-use-deadline} and @code{org-icalendar-use-scheduled}.}.
9459 As categories, it will use the tags locally defined in the heading, and the
9460 file/tree category@footnote{To add inherited tags or the TODO state,
9461 configure the variable @code{org-icalendar-categories}.}.
9463 @vindex org-icalendar-store-UID
9464 @cindex property, ID
9465 The iCalendar standard requires each entry to have a globally unique
9466 identifier (UID).  Org creates these identifiers during export.  If you set
9467 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
9468 @code{:ID:} property of the entry and re-used next time you report this
9469 entry.  Since a single entry can give rise to multiple iCalendar entries (as
9470 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
9471 prefixes to the UID, depending on what triggered the inclusion of the entry.
9472 In this way the UID remains unique, but a synchronization program can still
9473 figure out from which entry all the different instances originate.
9475 @table @kbd
9476 @kindex C-c C-e i
9477 @item C-c C-e i
9478 Create iCalendar entries for the current file and store them in the same
9479 directory, using a file extension @file{.ics}.
9480 @kindex C-c C-e I
9481 @item C-c C-e I
9482 @vindex org-agenda-files
9483 Like @kbd{C-c C-e i}, but do this for all files in
9484 @code{org-agenda-files}.  For each of these files, a separate iCalendar
9485 file will be written.
9486 @kindex C-c C-e c
9487 @item C-c C-e c
9488 @vindex org-combined-agenda-icalendar-file
9489 Create a single large iCalendar file from all files in
9490 @code{org-agenda-files} and write it to the file given by
9491 @code{org-combined-agenda-icalendar-file}.
9492 @end table
9494 @vindex org-use-property-inheritance
9495 @vindex org-icalendar-include-body
9496 @cindex property, SUMMARY
9497 @cindex property, DESCRIPTION
9498 @cindex property, LOCATION
9499 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
9500 property can be inherited from higher in the hierarchy if you configure
9501 @code{org-use-property-inheritance} accordingly.} properties if the selected
9502 entries have them.  If not, the summary will be derived from the headline,
9503 and the description from the body (limited to
9504 @code{org-icalendar-include-body} characters).
9506 How this calendar is best read and updated, depends on the application
9507 you are using.  The FAQ covers this issue.
9509 @node Publishing, Miscellaneous, Exporting, Top
9510 @chapter Publishing
9511 @cindex publishing
9512 @cindex O'Toole, David
9514 Org includes a publishing management system that allows you to configure
9515 automatic HTML conversion of @emph{projects} composed of interlinked org
9516 files.  You can also configure Org to automatically upload your exported HTML
9517 pages and related attachments, such as images and source code files, to a web
9518 server.
9520 You can also use Org to convert files into PDF, or even combine HTML and PDF
9521 conversion so that files are available in both formats on the server.
9523 Publishing has been contributed to Org by David O'Toole.
9525 @menu
9526 * Configuration::               Defining projects
9527 * Uploading files::             How to get files up on the server
9528 * Sample configuration::        Example projects
9529 * Triggering publication::      Publication commands
9530 @end menu
9532 @node Configuration, Uploading files, Publishing, Publishing
9533 @section Configuration
9535 Publishing needs significant configuration to specify files, destination
9536 and many other properties of a project.
9538 @menu
9539 * Project alist::               The central configuration variable
9540 * Sources and destinations::    From here to there
9541 * Selecting files::             What files are part of the project?
9542 * Publishing action::           Setting the function doing the publishing
9543 * Publishing options::          Tweaking HTML export
9544 * Publishing links::            Which links keep working after publishing?
9545 * Project page index::          Publishing a list of project files
9546 @end menu
9548 @node Project alist, Sources and destinations, Configuration, Configuration
9549 @subsection The variable @code{org-publish-project-alist}
9550 @cindex org-publish-project-alist
9551 @cindex projects, for publishing
9553 @vindex org-publish-project-alist
9554 Publishing is configured almost entirely through setting the value of one
9555 variable, called @code{org-publish-project-alist}.  Each element of the list
9556 configures one project, and may be in one of the two following forms:
9558 @lisp
9559    ("project-name" :property value :property value ...)
9560 @r{or}
9561    ("project-name" :components ("project-name" "project-name" ...))
9563 @end lisp
9565 In both cases, projects are configured by specifying property values.  A
9566 project defines the set of files that will be published, as well as the
9567 publishing configuration to use when publishing those files.  When a project
9568 takes the second form listed above, the individual members of the
9569 @code{:components} property are taken to be sub-projects, which group
9570 together files requiring different publishing options.  When you publish such
9571 a ``meta-project'', all the components will also be published, in the
9572 sequence given.
9574 @node Sources and destinations, Selecting files, Project alist, Configuration
9575 @subsection Sources and destinations for files
9576 @cindex directories, for publishing
9578 Most properties are optional, but some should always be set.  In
9579 particular, Org needs to know where to look for source files,
9580 and where to put published files.
9582 @multitable @columnfractions 0.3 0.7
9583 @item @code{:base-directory}
9584 @tab Directory containing publishing source files
9585 @item @code{:publishing-directory}
9586 @tab Directory where output files will be published.  You can directly
9587 publish to a webserver using a file name syntax appropriate for
9588 the Emacs @file{tramp} package.  Or you can publish to a local directory and
9589 use external tools to upload your website (@pxref{Uploading files}).
9590 @item @code{:preparation-function}
9591 @tab Function called before starting the publishing process, for example, to
9592 run @code{make} for updating files to be published.
9593 @item @code{:completion-function}
9594 @tab Function called after finishing the publishing process, for example, to
9595 change permissions of the resulting files.
9596 @end multitable
9597 @noindent
9599 @node Selecting files, Publishing action, Sources and destinations, Configuration
9600 @subsection Selecting files
9601 @cindex files, selecting for publishing
9603 By default, all files with extension @file{.org} in the base directory
9604 are considered part of the project.  This can be modified by setting the
9605 properties
9606 @multitable @columnfractions 0.25 0.75
9607 @item @code{:base-extension}
9608 @tab Extension (without the dot!) of source files.  This actually is a
9609 regular expression.  Set this to the symbol @code{any} if you want to get all
9610 files in @code{:base-directory}, even without extension.
9612 @item @code{:exclude}
9613 @tab Regular expression to match file names that should not be
9614 published, even though they have been selected on the basis of their
9615 extension.
9617 @item @code{:include}
9618 @tab List of files to be included regardless of @code{:base-extension}
9619 and @code{:exclude}.
9620 @end multitable
9622 @node Publishing action, Publishing options, Selecting files, Configuration
9623 @subsection Publishing action
9624 @cindex action, for publishing
9626 Publishing means that a file is copied to the destination directory and
9627 possibly transformed in the process.  The default transformation is to export
9628 Org files as HTML files, and this is done by the function
9629 @code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
9630 export}).  But you also can publish your content as PDF files using
9631 @code{org-publish-org-to-pdf}.  If you want to publish the Org file itself,
9632 but with @i{archived}, @i{commented}, and @i{tag-excluded} trees removed, use
9633 @code{org-publish-org-to-org} and set the parameters @code{:plain-source}
9634 and/or @code{:htmlized-source}.  This will produce @file{file.org} and
9635 @file{file.org.html} in the publishing
9636 directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
9637 source and publishing directories are equal.  Note that with this kind of
9638 setup, you need to add @code{:exclude "-source\\.org"} to the project
9639 definition in @code{org-publish-project-alist} to avoid that the published
9640 source files will be considered as new org files the next time the project is
9641 published.}.  Other files like images only
9642 need to be copied to the publishing destination, for this you may use
9643 @code{org-publish-attachment}.  For non-Org files, you always need to
9644 specify the publishing function:
9646 @multitable @columnfractions 0.3 0.7
9647 @item @code{:publishing-function}
9648 @tab Function executing the publication of a file.  This may also be a
9649 list of functions, which will all be called in turn.
9650 @item @code{:plain-source}
9651 @tab Non-nil means, publish plain source.
9652 @item @code{:htmlized-source}
9653 @tab Non-nil means, publish htmlized source.
9654 @end multitable
9656 The function must accept two arguments: a property list containing at least a
9657 @code{:publishing-directory} property, and the name of the file to be
9658 published.  It should take the specified file, make the necessary
9659 transformation (if any) and place the result into the destination folder.
9661 @node Publishing options, Publishing links, Publishing action, Configuration
9662 @subsection Options for the HTML/La@TeX{} exporters
9663 @cindex options, for publishing
9665 The property list can be used to set many export options for the HTML
9666 and La@TeX{} exporters.  In most cases, these properties correspond to user
9667 variables in Org.  The table below lists these properties along
9668 with the variable they belong to.  See the documentation string for the
9669 respective variable for details.
9671 @vindex org-export-html-link-up
9672 @vindex org-export-html-link-home
9673 @vindex org-export-default-language
9674 @vindex org-display-custom-times
9675 @vindex org-export-headline-levels
9676 @vindex org-export-with-section-numbers
9677 @vindex org-export-section-number-format
9678 @vindex org-export-with-toc
9679 @vindex org-export-preserve-breaks
9680 @vindex org-export-with-archived-trees
9681 @vindex org-export-with-emphasize
9682 @vindex org-export-with-sub-superscripts
9683 @vindex org-export-with-special-strings
9684 @vindex org-export-with-footnotes
9685 @vindex org-export-with-drawers
9686 @vindex org-export-with-tags
9687 @vindex org-export-with-todo-keywords
9688 @vindex org-export-with-priority
9689 @vindex org-export-with-TeX-macros
9690 @vindex org-export-with-LaTeX-fragments
9691 @vindex org-export-skip-text-before-1st-heading
9692 @vindex org-export-with-fixed-width
9693 @vindex org-export-with-timestamps
9694 @vindex org-export-author-info
9695 @vindex org-export-creator-info
9696 @vindex org-export-with-tables
9697 @vindex org-export-highlight-first-table-line
9698 @vindex org-export-html-style-include-default
9699 @vindex org-export-html-style
9700 @vindex org-export-html-style-extra
9701 @vindex org-export-html-link-org-files-as-html
9702 @vindex org-export-html-inline-images
9703 @vindex org-export-html-extension
9704 @vindex org-export-html-table-tag
9705 @vindex org-export-html-expand
9706 @vindex org-export-html-with-timestamp
9707 @vindex org-export-publishing-directory
9708 @vindex org-export-html-preamble
9709 @vindex org-export-html-postamble
9710 @vindex org-export-html-auto-preamble
9711 @vindex org-export-html-auto-postamble
9712 @vindex user-full-name
9713 @vindex user-mail-address
9714 @vindex org-export-select-tags
9715 @vindex org-export-exclude-tags
9717 @multitable @columnfractions 0.32 0.68
9718 @item @code{:link-up}               @tab @code{org-export-html-link-up}
9719 @item @code{:link-home}             @tab @code{org-export-html-link-home}
9720 @item @code{:language}              @tab @code{org-export-default-language}
9721 @item @code{:customtime}            @tab @code{org-display-custom-times}
9722 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
9723 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
9724 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
9725 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
9726 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
9727 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
9728 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
9729 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
9730 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
9731 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
9732 @item @code{:drawers}               @tab @code{org-export-with-drawers}
9733 @item @code{:tags}                  @tab @code{org-export-with-tags}
9734 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
9735 @item @code{:priority}              @tab @code{org-export-with-priority}
9736 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
9737 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
9738 @item @code{:latex-listings}        @tab @code{org-export-latex-listings}
9739 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
9740 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
9741 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
9742 @item @code{:author-info}           @tab @code{org-export-author-info}
9743 @item @code{:creator-info}          @tab @code{org-export-creator-info}
9744 @item @code{:tables}                @tab @code{org-export-with-tables}
9745 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
9746 @item @code{:style-include-default} @tab @code{org-export-html-style-include-default}
9747 @item @code{:style}                 @tab @code{org-export-html-style}
9748 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
9749 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
9750 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
9751 @item @code{:html-extension}        @tab @code{org-export-html-extension}
9752 @item @code{:xml-declaration}       @tab @code{org-export-html-xml-declaration}
9753 @item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
9754 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
9755 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
9756 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
9757 @item @code{:preamble}              @tab @code{org-export-html-preamble}
9758 @item @code{:postamble}             @tab @code{org-export-html-postamble}
9759 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
9760 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
9761 @item @code{:author}                @tab @code{user-full-name}
9762 @item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
9763 @item @code{:select-tags}           @tab @code{org-export-select-tags}
9764 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
9765 @item @code{:latex-image-options}   @tab @code{org-export-latex-image-default-option}
9766 @end multitable
9768 Most of the @code{org-export-with-*} variables have the same effect in
9769 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
9770 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
9771 La@TeX{} export.
9773 @vindex org-publish-project-alist
9774 When a property is given a value in @code{org-publish-project-alist},
9775 its setting overrides the value of the corresponding user variable (if
9776 any) during publishing.  Options set within a file (@pxref{Export
9777 options}), however, override everything.
9779 @node Publishing links, Project page index, Publishing options, Configuration
9780 @subsection Links between published files
9781 @cindex links, publishing
9783 To create a link from one Org file to another, you would use
9784 something like @samp{[[file:foo.org][The foo]]} or simply
9785 @samp{file:foo.org.} (@pxref{Hyperlinks}).  When published, this link
9786 becomes a link to @file{foo.html}.  In this way, you can interlink the
9787 pages of your "org web" project and the links will work as expected when
9788 you publish them to HTML.  If you also publish the Org source file and want
9789 to link to that, use an @code{http:} link instead of a @code{file:} link,
9790 because @code{file:} links are converted to link to the corresponding
9791 @file{html} file.
9793 You may also link to related files, such as images. Provided you are careful
9794 with relative file names, and provided you have also configured Org to upload
9795 the related files, these links will work too. See @ref{Complex example}, for
9796 an example of this usage.
9798 Sometimes an Org file to be published may contain links that are
9799 only valid in your production environment, but not in the publishing
9800 location.  In this case, use the property
9802 @multitable @columnfractions 0.4 0.6
9803 @item @code{:link-validation-function}
9804 @tab Function to validate links
9805 @end multitable
9807 @noindent
9808 to define a function for checking link validity.  This function must
9809 accept two arguments, the file name and a directory relative to which
9810 the file name is interpreted in the production environment.  If this
9811 function returns @code{nil}, then the HTML generator will only insert a
9812 description into the HTML file, but no link.  One option for this
9813 function is @code{org-publish-validate-link} which checks if the given
9814 file is part of any project in @code{org-publish-project-alist}.
9816 @node Project page index,  , Publishing links, Configuration
9817 @subsection Project page index
9818 @cindex index, of published pages
9820 The following properties may be used to control publishing of an
9821 index of files or a summary page for a given project.
9823 @multitable @columnfractions 0.25 0.75
9824 @item @code{:auto-index}
9825 @tab When non-nil, publish an index during @code{org-publish-current-project}
9826 or @code{org-publish-all}.
9828 @item @code{:index-filename}
9829 @tab Filename for output of index. Defaults to @file{sitemap.org} (which
9830 becomes @file{sitemap.html}).
9832 @item @code{:index-title}
9833 @tab Title of index page. Defaults to name of file.
9835 @item @code{:index-function}
9836 @tab Plug-in function to use for generation of index.
9837 Defaults to @code{org-publish-org-index}, which generates a plain list
9838 of links to all files in the project.
9839 @end multitable
9841 @node Uploading files, Sample configuration, Configuration, Publishing
9842 @section Uploading files
9843 @cindex rsync
9844 @cindex unison
9846 For those people already utilizing third party sync tools such as
9847 @command{rsync} or @command{unison}, it might be preferable not to use the built in
9848 @i{remote} publishing facilities of Org mode which rely heavily on
9849 Tramp.  Tramp, while very useful and powerful, tends not to be
9850 so efficient for multiple file transfer and has been known to cause problems
9851 under heavy usage.
9853 Specialized synchronization utilities offer several advantages.  In addition
9854 to timestamp comparison, they also do content and permissions/attribute
9855 checks.  For this reason you might prefer to publish your web to a local
9856 directory (possibly even @i{in place} with your Org files) and then use
9857 @file{unison} or @file{rsync} to do the synchronization with the remote host.
9859 Since Unison (for example) can be configured as to which files to transfer to
9860 a certain remote destination, it can greatly simplify the project publishing
9861 definition.  Simply keep all files in the correct location, process your Org
9862 files with @code{org-publish} and let the synchronization tool do the rest.
9863 You do not need, in this scenario, to include attachments such as @file{jpg},
9864 @file{css} or @file{gif} files in the project definition since the 3rd party
9865 tool syncs them.
9867 Publishing to a local directory is also much faster than to a remote one, so
9868 that you can afford more easily to republish entire projects.  If you set
9869 @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the main
9870 benefit of re-including any changed external files such as source example
9871 files you might include with @code{#+INCLUDE}.  The timestamp mechanism in
9872 Org is not smart enough to detect if included files have been modified.
9874 @node Sample configuration, Triggering publication, Uploading files, Publishing
9875 @section Sample configuration
9877 Below we provide two example configurations.  The first one is a simple
9878 project publishing only a set of Org files.  The second example is
9879 more complex, with a multi-component project.
9881 @menu
9882 * Simple example::              One-component publishing
9883 * Complex example::             A multi-component publishing example
9884 @end menu
9886 @node Simple example, Complex example, Sample configuration, Sample configuration
9887 @subsection Example: simple publishing configuration
9889 This example publishes a set of Org files to the @file{public_html}
9890 directory on the local machine.
9892 @lisp
9893 (setq org-publish-project-alist
9894       '(("org"
9895          :base-directory "~/org/"
9896          :publishing-directory "~/public_html"
9897          :section-numbers nil
9898          :table-of-contents nil
9899          :style "<link rel=\"stylesheet\"
9900                 href=\"../other/mystyle.css\"
9901                 type=\"text/css\"/>")))
9902 @end lisp
9904 @node Complex example,  , Simple example, Sample configuration
9905 @subsection Example: complex publishing configuration
9907 This more complicated example publishes an entire website, including
9908 Org files converted to HTML, image files, Emacs Lisp source code, and
9909 style sheets. The publishing directory is remote and private files are
9910 excluded.
9912 To ensure that links are preserved, care should be taken to replicate
9913 your directory structure on the web server, and to use relative file
9914 paths. For example, if your Org files are kept in @file{~/org} and your
9915 publishable images in @file{~/images}, you'd link to an image with
9917 @example
9918 file:../images/myimage.png
9919 @end example
9921 On the web server, the relative path to the image should be the
9922 same. You can accomplish this by setting up an "images" folder in the
9923 right place on the web server, and publishing images to it.
9925 @lisp
9926 (setq org-publish-project-alist
9927       '(("orgfiles"
9928           :base-directory "~/org/"
9929           :base-extension "org"
9930           :publishing-directory "/ssh:user@@host:~/html/notebook/"
9931           :publishing-function org-publish-org-to-html
9932           :exclude "PrivatePage.org"   ;; regexp
9933           :headline-levels 3
9934           :section-numbers nil
9935           :table-of-contents nil
9936           :style "<link rel=\"stylesheet\"
9937                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
9938           :auto-preamble t
9939           :auto-postamble nil)
9941          ("images"
9942           :base-directory "~/images/"
9943           :base-extension "jpg\\|gif\\|png"
9944           :publishing-directory "/ssh:user@@host:~/html/images/"
9945           :publishing-function org-publish-attachment)
9947          ("other"
9948           :base-directory "~/other/"
9949           :base-extension "css\\|el"
9950           :publishing-directory "/ssh:user@@host:~/html/other/"
9951           :publishing-function org-publish-attachment)
9952          ("website" :components ("orgfiles" "images" "other"))))
9953 @end lisp
9955 @node Triggering publication,  , Sample configuration, Publishing
9956 @section Triggering publication
9958 Once properly configured, Org can publish with the following commands:
9960 @table @kbd
9961 @kindex C-c C-e C
9962 @item C-c C-e C
9963 Prompt for a specific project and publish all files that belong to it.
9964 @kindex C-c C-e P
9965 @item C-c C-e P
9966 Publish the project containing the current file.
9967 @kindex C-c C-e F
9968 @item C-c C-e F
9969 Publish only the current file.
9970 @kindex C-c C-e E
9971 @item C-c C-e E
9972 Publish every project.
9973 @end table
9975 @vindex org-publish-use-timestamps-flag
9976 Org uses timestamps to track when a file has changed. The above functions
9977 normally only publish changed files. You can override this and force
9978 publishing of all files by giving a prefix argument to any of the commands
9979 above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
9980 This may be necessary in particular if files include other files via
9981 @code{#+SETUPFILE:} or @code{#+INCLUDE:}.
9983 @node Miscellaneous, Hacking, Publishing, Top
9984 @chapter Miscellaneous
9986 @menu
9987 * Completion::                  M-TAB knows what you need
9988 * Customization::               Adapting Org to your taste
9989 * In-buffer settings::          Overview of the #+KEYWORDS
9990 * The very busy C-c C-c key::   When in doubt, press C-c C-c
9991 * Clean view::                  Getting rid of leading stars in the outline
9992 * TTY keys::                    Using Org on a tty
9993 * Interaction::                 Other Emacs packages
9994 @end menu
9997 @node Completion, Customization, Miscellaneous, Miscellaneous
9998 @section Completion
9999 @cindex completion, of @TeX{} symbols
10000 @cindex completion, of TODO keywords
10001 @cindex completion, of dictionary words
10002 @cindex completion, of option keywords
10003 @cindex completion, of tags
10004 @cindex completion, of property keys
10005 @cindex completion, of link abbreviations
10006 @cindex @TeX{} symbol completion
10007 @cindex TODO keywords completion
10008 @cindex dictionary word completion
10009 @cindex option keyword completion
10010 @cindex tag completion
10011 @cindex link abbreviations, completion of
10013 Emacs would not be Emacs without completion, and Org-mode uses it whenever it
10014 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
10015 some of the completion prompts, you can specify your preferece by setting at
10016 most one of the variables @code{org-completion-use-iswitchb}
10017 @code{org-completion-use-ido}.
10019 Org supports in-buffer completion.  This type of completion does
10020 not make use of the minibuffer.  You simply type a few letters into
10021 the buffer and use the key to complete text right there.
10023 @table @kbd
10024 @kindex M-@key{TAB}
10025 @item M-@key{TAB}
10026 Complete word at point
10027 @itemize @bullet
10028 @item
10029 At the beginning of a headline, complete TODO keywords.
10030 @item
10031 After @samp{\}, complete @TeX{} symbols supported by the exporter.
10032 @item
10033 After @samp{*}, complete headlines in the current buffer so that they
10034 can be used in search links like @samp{[[*find this headline]]}.
10035 @item
10036 After @samp{:} in a headline, complete tags.  The list of tags is taken
10037 from the variable @code{org-tag-alist} (possibly set through the
10038 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
10039 dynamically from all tags used in the current buffer.
10040 @item
10041 After @samp{:} and not in a headline, complete property keys.  The list
10042 of keys is constructed dynamically from all keys used in the current
10043 buffer.
10044 @item
10045 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
10046 @item
10047 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
10048 @samp{OPTIONS} which set file-specific options for Org mode.  When the
10049 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
10050 will insert example settings for this keyword.
10051 @item
10052 In the line after @samp{#+STARTUP: }, complete startup keywords,
10053 @ie valid keys for this line.
10054 @item
10055 Elsewhere, complete dictionary words using Ispell.
10056 @end itemize
10057 @end table
10059 @node Customization, In-buffer settings, Completion, Miscellaneous
10060 @section Customization
10061 @cindex customization
10062 @cindex options, for customization
10063 @cindex variables, for customization
10065 There are more than 180 variables that can be used to customize
10066 Org.  For the sake of compactness of the manual, I am not
10067 describing the variables here.  A structured overview of customization
10068 variables is available with @kbd{M-x org-customize}.  Or select
10069 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
10070 settings can also be activated on a per-file basis, by putting special
10071 lines into the buffer (@pxref{In-buffer settings}).
10073 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
10074 @section Summary of in-buffer settings
10075 @cindex in-buffer settings
10076 @cindex special keywords
10078 Org mode uses special lines in the buffer to define settings on a
10079 per-file basis.  These lines start with a @samp{#+} followed by a
10080 keyword, a colon, and then individual words defining a setting.  Several
10081 setting words can be in the same line, but you can also have multiple
10082 lines for the keyword.  While these settings are described throughout
10083 the manual, here is a summary.  After changing any of those lines in the
10084 buffer, press @kbd{C-c C-c} with the cursor still in the line to
10085 activate the changes immediately.  Otherwise they become effective only
10086 when the file is visited again in a new Emacs session.
10088 @vindex org-archive-location
10089 @table @kbd
10090 @item #+ARCHIVE: %s_done::
10091 This line sets the archive location for the agenda file.  It applies for
10092 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
10093 of the file.  The first such line also applies to any entries before it.
10094 The corresponding variable is @code{org-archive-location}.
10095 @item #+CATEGORY:
10096 This line sets the category for the agenda file.  The category applies
10097 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
10098 end of the file.  The first such line also applies to any entries before it.
10099 @item #+COLUMNS: %25ITEM .....
10100 @cindex property, COLUMNS
10101 Set the default format for columns view.  This format applies when
10102 columns view is invoked in locations where no @code{COLUMNS} property
10103 applies.
10104 @item #+CONSTANTS: name1=value1 ...
10105 @vindex org-table-formula-constants
10106 @vindex org-table-formula
10107 Set file-local values for constants to be used in table formulas.  This
10108 line set the local variable @code{org-table-formula-constants-local}.
10109 The global version of this variable is
10110 @code{org-table-formula-constants}.
10111 @item #+FILETAGS: :tag1:tag2:tag3:
10112 Set tags that can be inherited by any entry in the file, including the
10113 top-level entries.
10114 @item #+DRAWERS: NAME1 .....
10115 @vindex org-drawers
10116 Set the file-local set of drawers.  The corresponding global variable is
10117 @code{org-drawers}.
10118 @item #+LINK:  linkword replace
10119 @vindex org-link-abbrev-alist
10120 These lines (several are allowed) specify link abbreviations.
10121 @xref{Link abbreviations}.  The corresponding variable is
10122 @code{org-link-abbrev-alist}.
10123 @item #+PRIORITIES: highest lowest default
10124 @vindex org-highest-priority
10125 @vindex org-lowest-priority
10126 @vindex org-default-priority
10127 This line sets the limits and the default for the priorities.  All three
10128 must be either letters A-Z or numbers 0-9.  The highest priority must
10129 have a lower ASCII number that the lowest priority.
10130 @item #+PROPERTY: Property_Name Value
10131 This line sets a default inheritance value for entries in the current
10132 buffer, most useful for specifying the allowed values of a property.
10133 @cindex #+SETUPFILE
10134 @item #+SETUPFILE: file
10135 This line defines a file that holds more in-buffer setup.  Normally this is
10136 entirely ignored.  Only when the buffer is parsed for option-setting lines
10137 (@ie when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
10138 settings line, or when exporting), then the contents of this file are parsed
10139 as if they had been included in the buffer.  In particular, the file can be
10140 any other Org mode file with internal setup.  You can visit the file the
10141 cursor is in the line with @kbd{C-c '}.
10142 @item #+STARTUP:
10143 @cindex #+STARTUP:
10144 This line sets options to be used at startup of Org mode, when an
10145 Org file is being visited.
10147 The first set of options deals with the initial visibility of the outline
10148 tree.  The corresponding variable for global default settings is
10149 @code{org-startup-folded}, with a default value @code{t}, which means
10150 @code{overview}.
10151 @vindex org-startup-folded
10152 @cindex @code{overview}, STARTUP keyword
10153 @cindex @code{content}, STARTUP keyword
10154 @cindex @code{showall}, STARTUP keyword
10155 @example
10156 overview   @r{top-level headlines only}
10157 content    @r{all headlines}
10158 showall    @r{no folding at all, show everything}
10159 @end example
10161 @vindex org-startup-indented
10162 @cindex @code{indent}, STARTUP keyword
10163 @cindex @code{noindent}, STARTUP keyword
10164 Dynamic virtual indentation is controlled by the variable
10165 @code{org-startup-indented}@footnote{Emacs 23 and Org-mode 6.29 are required}
10166 @example
10167 indent     @r{start with @code{org-indent-mode} turned on}
10168 noindent   @r{start with @code{org-indent-mode} turned off}
10169 @end example
10171 @vindex org-startup-align-all-tables
10172 Then there are options for aligning tables upon visiting a file.  This
10173 is useful in files containing narrowed table columns.  The corresponding
10174 variable is @code{org-startup-align-all-tables}, with a default value
10175 @code{nil}.
10176 @cindex @code{align}, STARTUP keyword
10177 @cindex @code{noalign}, STARTUP keyword
10178 @example
10179 align      @r{align all tables}
10180 noalign    @r{don't align tables on startup}
10181 @end example
10182 @vindex org-log-done
10183 @vindex org-log-note-clock-out
10184 @vindex org-log-repeat
10185 Logging the closing and reopening of TODO items and clock intervals can be
10186 configured using these options (see variables @code{org-log-done},
10187 @code{org-log-note-clock-out} and @code{org-log-repeat})
10188 @cindex @code{logdone}, STARTUP keyword
10189 @cindex @code{lognotedone}, STARTUP keyword
10190 @cindex @code{nologdone}, STARTUP keyword
10191 @cindex @code{lognoteclock-out}, STARTUP keyword
10192 @cindex @code{nolognoteclock-out}, STARTUP keyword
10193 @cindex @code{logrepeat}, STARTUP keyword
10194 @cindex @code{lognoterepeat}, STARTUP keyword
10195 @cindex @code{nologrepeat}, STARTUP keyword
10196 @example
10197 logdone            @r{record a timestamp when an item is marked DONE}
10198 lognotedone        @r{record timestamp and a note when DONE}
10199 nologdone          @r{don't record when items are marked DONE}
10200 logrepeat          @r{record a time when reinstating a repeating item}
10201 lognoterepeat      @r{record a note when reinstating a repeating item}
10202 nologrepeat        @r{do not record when reinstating repeating item}
10203 lognoteclock-out   @r{record a note when clocking out}
10204 nolognoteclock-out @r{don't record a note when clocking out}
10205 @end example
10206 @vindex org-hide-leading-stars
10207 @vindex org-odd-levels-only
10208 Here are the options for hiding leading stars in outline headings, and for
10209 indenting outlines.  The corresponding variables are
10210 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
10211 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
10212 @cindex @code{hidestars}, STARTUP keyword
10213 @cindex @code{showstars}, STARTUP keyword
10214 @cindex @code{odd}, STARTUP keyword
10215 @cindex @code{even}, STARTUP keyword
10216 @example
10217 hidestars  @r{make all but one of the stars starting a headline invisible.}
10218 showstars  @r{show all stars starting a headline}
10219 indent     @r{virtual indentation according to outline level}
10220 noindent   @r{no virtual indentation according to outline level}
10221 odd        @r{allow only odd outline levels (1,3,...)}
10222 oddeven    @r{allow all outline levels}
10223 @end example
10224 @vindex org-put-time-stamp-overlays
10225 @vindex org-time-stamp-overlay-formats
10226 To turn on custom format overlays over timestamps (variables
10227 @code{org-put-time-stamp-overlays} and
10228 @code{org-time-stamp-overlay-formats}), use
10229 @cindex @code{customtime}, STARTUP keyword
10230 @example
10231 customtime @r{overlay custom time format}
10232 @end example
10233 @vindex constants-unit-system
10234 The following options influence the table spreadsheet (variable
10235 @code{constants-unit-system}).
10236 @cindex @code{constcgs}, STARTUP keyword
10237 @cindex @code{constSI}, STARTUP keyword
10238 @example
10239 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
10240 constSI    @r{@file{constants.el} should use the SI unit system}
10241 @end example
10242 @vindex org-footnote-define-inline
10243 @vindex org-footnote-auto-label
10244 @vindex org-footnote-auto-adjust
10245 To influence footnote settings, use the following keywords.  The
10246 corresponding variables are @code{org-footnote-define-inline},
10247 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
10248 @cindex @code{fninline}, STARTUP keyword
10249 @cindex @code{nofninline}, STARTUP keyword
10250 @cindex @code{fnlocal}, STARTUP keyword
10251 @cindex @code{fnprompt}, STARTUP keyword
10252 @cindex @code{fnauto}, STARTUP keyword
10253 @cindex @code{fnconfirm}, STARTUP keyword
10254 @cindex @code{fnplain}, STARTUP keyword
10255 @cindex @code{fnadjust}, STARTUP keyword
10256 @cindex @code{nofnadjust}, STARTUP keyword
10257 @example
10258 fninline    @r{define footnotes inline}
10259 fnnoinline  @r{define footnotes in separate section}
10260 fnlocal     @r{define footnotes near first reference, but not inline}
10261 fnprompt    @r{prompt for footnote labels}
10262 fnauto      @r{create [fn:1]-like labels automatically (default)}
10263 fnconfirm   @r{offer automatic label for editing or confirmation}
10264 fnplain     @r{create [1]-like labels automatically}
10265 fnadjust    @r{automatically renumber and sort footnotes}
10266 nofnadjust  @r{do not renumber and sort automatically}
10267 @end example
10268 @cindex org-hide-block-startup
10269 To hide blocks on startup, use these keywords. The corresponding variable is
10270 @code{org-hide-block-startup}.
10271 @cindex @code{hideblocks}, STARTUP keyword
10272 @cindex @code{nohideblocks}, STARTUP keyword
10273 @example
10274 hideblocks   @r{Hide all begin/end blocks on startup}
10275 nohideblocks @r{Do not hide blocks on startup}
10276 @end example
10277 @item #+TAGS:  TAG1(c1) TAG2(c2)
10278 @vindex org-tag-alist
10279 These lines (several such lines are allowed) specify the valid tags in
10280 this file, and (potentially) the corresponding @emph{fast tag selection}
10281 keys.  The corresponding variable is @code{org-tag-alist}.
10282 @item #+TBLFM:
10283 This line contains the formulas for the table directly above the line.
10284 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
10285 @itemx #+OPTIONS:, #+BIND:
10286 @itemx #+DESCRIPTION:, #+KEYWORDS:
10287 @itemx #+LATEX_HEADER:, #+STYLE:, #+LINK_UP:, #+LINK_HOME:,
10288 @itemx #+EXPORT_SELECT_TAGS:, #+EXPORT_EXCLUDE_TAGS:
10289 These lines provide settings for exporting files.  For more details see
10290 @ref{Export options}.
10291 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
10292 @vindex org-todo-keywords
10293 These lines set the TODO keywords and their interpretation in the
10294 current file.  The corresponding variable is @code{org-todo-keywords}.
10295 @end table
10297 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
10298 @section The very busy C-c C-c key
10299 @kindex C-c C-c
10300 @cindex C-c C-c, overview
10302 The key @kbd{C-c C-c} has many purposes in Org, which are all
10303 mentioned scattered throughout this manual.  One specific function of
10304 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
10305 other circumstances it means something like @emph{``Hey Org, look
10306 here and update according to what you see here''}.  Here is a summary of
10307 what this means in different contexts.
10309 @itemize @minus
10310 @item
10311 If there are highlights in the buffer from the creation of a sparse
10312 tree, or from clock display, remove these highlights.
10313 @item
10314 If the cursor is in one of the special @code{#+KEYWORD} lines, this
10315 triggers scanning the buffer for these lines and updating the
10316 information.
10317 @item
10318 If the cursor is inside a table, realign the table.  This command
10319 works even if the automatic table editor has been turned off.
10320 @item
10321 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
10322 the entire table.
10323 @item
10324 If the cursor is inside a table created by the @file{table.el} package,
10325 activate that table.
10326 @item
10327 If the current buffer is a Remember buffer, close the note and file it.
10328 With a prefix argument, file it, without further interaction, to the
10329 default location.
10330 @item
10331 If the cursor is on a @code{<<<target>>>}, update radio targets and
10332 corresponding links in this buffer.
10333 @item
10334 If the cursor is in a property line or at the start or end of a property
10335 drawer, offer property commands.
10336 @item
10337 If the cursor is at a footnote reference, go to the corresponding
10338 definition, and vice versa.
10339 @item
10340 If the cursor is on a statistics cookie, update it.
10341 @item
10342 If the cursor is in a plain list item with a checkbox, toggle the status
10343 of the checkbox.
10344 @item
10345 If the cursor is on a numbered item in a plain list, renumber the
10346 ordered list.
10347 @item
10348 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
10349 block is updated.
10350 @end itemize
10352 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
10353 @section A cleaner outline view
10354 @cindex hiding leading stars
10355 @cindex dynamic indentation
10356 @cindex odd-levels-only outlines
10357 @cindex clean outline view
10359 Some people find it noisy and distracting that the Org headlines start with a
10360 potentially large number of stars, and that text below the headlines is not
10361 indented.  While this is no problem when writing a @emph{book-like} document
10362 where the outline headings are really section headings, in a more
10363 @emph{list-oriented} outline, indented structure is a lot cleaner:
10365 @example
10366 @group
10367 * Top level headline             |    * Top level headline
10368 ** Second level                  |      * Second level
10369 *** 3rd level                    |        * 3rd level
10370 some text                        |          some text
10371 *** 3rd level                    |        * 3rd level
10372 more text                        |          more text
10373 * Another top level headline     |    * Another top level headline
10374 @end group
10375 @end example
10377 @noindent
10378 If you are using at least Emacs 23.1.50.3 and version 6.29 of Org, this kind
10379 of view can be achieved dynamically at display time using
10380 @code{org-indent-mode}.  In this minor mode, all lines are prefixed for
10381 display with the necessary amount of space.  Also headlines are prefixed with
10382 additional stars, so that the amount of indentation shifts by
10383 two@footnote{See the variable @code{org-indent-indentation-per-level}.}
10384 spaces per level.  All headline stars but the last one are made invisible
10385 using the @code{org-hide} face@footnote{Turning on @code{org-indent-mode}
10386 sets @code{org-hide-leading-stars} to @code{t} and
10387 @code{org-adapt-indentation} to @code{nil}.} - see below under @samp{2.} for
10388 more information on how this works.  You can turn on @code{org-indent-mode}
10389 for all files by customizing the variable @code{org-startup-indented}, or you
10390 can turn it on for individual files using
10392 @example
10393 #+STARTUP: indent
10394 @end example
10396 If you want a similar effect in earlier version of Emacs and/or Org, or if
10397 you want the indentation to be hard space characters so that the plain text
10398 file looks as similar as possible to the Emacs display, Org supports you in
10399 the following way:
10401 @enumerate
10402 @item
10403 @emph{Indentation of text below headlines}@*
10404 You may indent text below each headline to make the left boundary line up
10405 with the headline, like
10407 @example
10408 *** 3rd level
10409     more text, now indented
10410 @end example
10412 @vindex org-adapt-indentation
10413 Org supports this with paragraph filling, line wrapping, and structure
10414 editing@footnote{See also the variable @code{org-adapt-indentation}.},
10415 preserving or adapting the indentation as appropriate.
10417 @item
10418 @vindex org-hide-leading-stars
10419 @emph{Hiding leading stars}@* You can modify the display in such a way that
10420 all leading stars become invisible.  To do this in a global way, configure
10421 the variable @code{org-hide-leading-stars} or change this on a per-file basis
10422 with
10424 @example
10425 #+STARTUP: hidestars
10426 #+STARTUP: showstars
10427 @end example
10429 With hidden stars, the tree becomes:
10431 @example
10432 @group
10433 * Top level headline
10434  * Second level
10435   * 3rd level
10436   ...
10437 @end group
10438 @end example
10440 @noindent
10441 @vindex org-hide @r{(face)}
10442 The leading stars are not truly replaced by whitespace, they are only
10443 fontified with the face @code{org-hide} that uses the background color as
10444 font color.  If you are not using either white or black background, you may
10445 have to customize this face to get the wanted effect.  Another possibility is
10446 to set this font such that the extra stars are @i{almost} invisible, for
10447 example using the color @code{grey90} on a white background.
10449 @item
10450 @vindex org-odd-levels-only
10451 Things become cleaner still if you skip all the even levels and use only odd
10452 levels 1, 3, 5..., effectively adding two stars to go from one outline level
10453 to the next@footnote{When you need to specify a level for a property search
10454 or refile targets, @samp{LEVEL=2} will correspond to 3 stars, etc@.}.  In this
10455 way we get the outline view shown at the beginning of this section.  In order
10456 to make the structure editing and export commands handle this convention
10457 correctly, configure the variable @code{org-odd-levels-only}, or set this on
10458 a per-file basis with one of the following lines:
10460 @example
10461 #+STARTUP: odd
10462 #+STARTUP: oddeven
10463 @end example
10465 You can convert an Org file from single-star-per-level to the
10466 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
10467 RET} in that file.  The reverse operation is @kbd{M-x
10468 org-convert-to-oddeven-levels}.
10469 @end enumerate
10471 @node TTY keys, Interaction, Clean view, Miscellaneous
10472 @section Using Org on a tty
10473 @cindex tty key bindings
10475 Because Org contains a large number of commands, by default many of
10476 Org's core commands are bound to keys that are generally not
10477 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
10478 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
10479 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
10480 these commands on a tty when special keys are unavailable, the following
10481 alternative bindings can be used.  The tty bindings below will likely be
10482 more cumbersome; you may find for some of the bindings below that a
10483 customized workaround suits you better.  For example, changing a timestamp
10484 is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
10485 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
10487 @multitable @columnfractions 0.15 0.2 0.2
10488 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
10489 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
10490 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
10491 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
10492 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
10493 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
10494 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
10495 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
10496 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
10497 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
10498 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
10499 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
10500 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
10501 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
10502 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
10503 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
10504 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
10505 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
10506 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
10507 @end multitable
10510 @node Interaction,  , TTY keys, Miscellaneous
10511 @section Interaction with other packages
10512 @cindex packages, interaction with other
10513 Org lives in the world of GNU Emacs and interacts in various ways
10514 with other code out there.
10516 @menu
10517 * Cooperation::                 Packages Org cooperates with
10518 * Conflicts::                   Packages that lead to conflicts
10519 @end menu
10521 @node Cooperation, Conflicts, Interaction, Interaction
10522 @subsection Packages that Org cooperates with
10524 @table @asis
10525 @cindex @file{calc.el}
10526 @cindex Gillespie, Dave
10527 @item @file{calc.el} by Dave Gillespie
10528 Org uses the Calc package for implementing spreadsheet
10529 functionality in its tables (@pxref{The spreadsheet}).  Org
10530 checks for the availability of Calc by looking for the function
10531 @code{calc-eval} which will have been autoloaded during setup if Calc has
10532 been installed properly.  As of Emacs 22, Calc is part of the Emacs
10533 distribution.  Another possibility for interaction between the two
10534 packages is using Calc for embedded calculations. @xref{Embedded Mode,
10535 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
10536 @item @file{constants.el} by Carsten Dominik
10537 @cindex @file{constants.el}
10538 @cindex Dominik, Carsten
10539 @vindex org-table-formula-constants
10540 In a table formula (@pxref{The spreadsheet}), it is possible to use
10541 names for natural constants or units.  Instead of defining your own
10542 constants in the variable @code{org-table-formula-constants}, install
10543 the @file{constants} package which defines a large number of constants
10544 and units, and lets you use unit prefixes like @samp{M} for
10545 @samp{Mega}, etc@.  You will need version 2.0 of this package, available
10546 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
10547 the function @code{constants-get}, which has to be autoloaded in your
10548 setup.  See the installation instructions in the file
10549 @file{constants.el}.
10550 @item @file{cdlatex.el} by Carsten Dominik
10551 @cindex @file{cdlatex.el}
10552 @cindex Dominik, Carsten
10553 Org mode can make use of the CDLa@TeX{} package to efficiently enter
10554 La@TeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
10555 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
10556 @cindex @file{imenu.el}
10557 Imenu allows menu access to an index of items in a file.  Org mode
10558 supports Imenu---all you need to do to get the index is the following:
10559 @lisp
10560 (add-hook 'org-mode-hook
10561           (lambda () (imenu-add-to-menubar "Imenu")))
10562 @end lisp
10563 @vindex org-imenu-depth
10564 By default the index is two levels deep---you can modify the depth using
10565 the option @code{org-imenu-depth}.
10566 @item @file{remember.el} by John Wiegley
10567 @cindex @file{remember.el}
10568 @cindex Wiegley, John
10569 Org cooperates with remember, see @ref{Remember}.
10570 @file{Remember.el} is not part of Emacs, find it on the web.
10571 @item @file{speedbar.el} by Eric M. Ludlam
10572 @cindex @file{speedbar.el}
10573 @cindex Ludlam, Eric M.
10574 Speedbar is a package that creates a special frame displaying files and
10575 index items in files.  Org mode supports Speedbar and allows you to
10576 drill into Org files directly from the Speedbar.  It also allows you to
10577 restrict the scope of agenda commands to a file or a subtree by using
10578 the command @kbd{<} in the Speedbar frame.
10579 @cindex @file{table.el}
10580 @item @file{table.el} by Takaaki Ota
10581 @kindex C-c C-c
10582 @cindex table editor, @file{table.el}
10583 @cindex @file{table.el}
10584 @cindex Ota, Takaaki
10586 Complex ASCII tables with automatic line wrapping, column- and
10587 row-spanning, and alignment can be created using the Emacs table
10588 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
10589 and also part of Emacs 22).
10590 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
10591 will call @command{table-recognize-table} and move the cursor into the
10592 table.  Inside a table, the keymap of Org mode is inactive.  In order
10593 to execute Org mode-related commands, leave the table.
10595 @table @kbd
10596 @kindex C-c C-c
10597 @item C-c C-c
10598 Recognize @file{table.el} table.  Works when the cursor is in a
10599 table.el table.
10601 @kindex C-c ~
10602 @item C-c ~
10603 Insert a @file{table.el} table.  If there is already a table at point, this
10604 command converts it between the @file{table.el} format and the Org-mode
10605 format.  See the documentation string of the command
10606 @code{org-convert-table} for the restrictions under which this is
10607 possible.
10608 @end table
10609 @file{table.el} is part of Emacs 22.
10610 @item @file{footnote.el} by Steven L. Baur
10611 @cindex @file{footnote.el}
10612 @cindex Baur, Steven L.
10613 Org mode recognizes numerical footnotes as provided by this package.
10614 However, Org mode also has its own footnote support (@pxref{Footnotes}),
10615 which makes using @file{footnote.el} unnecessary.
10616 @end table
10618 @node Conflicts,  , Cooperation, Interaction
10619 @subsection Packages that lead to conflicts with Org mode
10621 @table @asis
10623 @cindex @code{shift-selection-mode}
10624 @vindex org-support-shift-select
10625 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
10626 cursor motions combined with the shift key should start or enlarge regions.
10627 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
10628 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
10629 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
10630 special contexts don't do anything, but you can customize the variable
10631 @code{org-support-shift-select}.  Org mode then tries to accommodate shift
10632 selection by (i) using it outside of the special contexts where special
10633 commands apply, and by (ii) extending an existing active region even if the
10634 cursor moves across a special context.
10636 @item @file{CUA.el} by Kim. F. Storm
10637 @cindex @file{CUA.el}
10638 @cindex Storm, Kim. F.
10639 @vindex org-replace-disputed-keys
10640 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
10641 (as well as @code{pc-select-mode} and @code{s-region-mode}) to select and extend the
10642 region.  In fact, Emacs 23 has this built-in in the form of
10643 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
10644 23, you probably don't want to use another package for this purpose.  However,
10645 if you prefer to leave these keys to a different package while working in
10646 Org mode, configure the variable @code{org-replace-disputed-keys}.  When set,
10647 Org will move the following key bindings in Org files, and in the agenda
10648 buffer (but not during date selection).
10650 @example
10651 S-UP      ->  M-p             S-DOWN     ->  M-n
10652 S-LEFT    ->  M--             S-RIGHT    ->  M-+
10653 C-S-LEFT  ->  M-S--           C-S-RIGHT  ->  M-S-+
10654 @end example
10656 @vindex org-disputed-keys
10657 Yes, these are unfortunately more difficult to remember.  If you want
10658 to have other replacement keys, look at the variable
10659 @code{org-disputed-keys}.
10661 @item @file{yasnippet.el}
10662 @cindex @file{yasnippet.el}
10663 The way Org-mode binds the TAB key (binding to @code{[tab]} instead of
10664 @code{"\t"}) overrules yasnippets' access to this key.  The following code
10665 fixed this problem:
10667 @lisp
10668 (add-hook 'org-mode-hook
10669           (lambda ()
10670             (org-set-local 'yas/trigger-key [tab])
10671             (define-key yas/keymap [tab] 'yas/next-field-group)))
10672 @end lisp
10674 @item @file{windmove.el} by Hovav Shacham
10675 @cindex @file{windmove.el}
10676 This package also uses the @kbd{S-<cursor>} keys, so everything written
10677 in the paragraph above about CUA mode also applies here.
10679 @end table
10681 @node Hacking, History and Acknowledgments, Miscellaneous, Top
10682 @appendix Hacking
10683 @cindex hacking
10685 This appendix covers some aspects where users can extend the functionality of
10686 Org.
10688 @menu
10689 * Hooks::                       Who to reach into Org's internals
10690 * Add-on packages::             Available extensions
10691 * Adding hyperlink types::      New custom link types
10692 * Context-sensitive commands::  How to add functionality to such commands
10693 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
10694 * Dynamic blocks::              Automatically filled blocks
10695 * Special agenda views::        Customized views
10696 * Extracting agenda information::  Postprocessing of agenda information
10697 * Using the property API::      Writing programs that use entry properties
10698 * Using the mapping API::       Mapping over all or selected entries
10699 @end menu
10701 @node Hooks, Add-on packages, Hacking, Hacking
10702 @section Hooks
10703 @cindex hooks
10705 Org has a large number of hook variables that can be used to add
10706 functionality.  This appendix about hacking is going to illustrate the
10707 use of some of them.  A complete list of all hooks with documentation is
10708 maintained by the Worg project and can be found at
10709 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
10711 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
10712 @section Add-on packages
10713 @cindex add-on packages
10715 A large number of add-on packages have been written by various authors.
10716 These packages are not part of Emacs, but they are distributed as contributed
10717 packages with the separate release available at the Org mode home page at
10718 @uref{http://orgmode.org}.  The list of contributed packages, along with
10719 documentation about each package, is maintained by the Worg project at
10720 @uref{http://orgmode.org/worg/org-contrib/}.
10724 @node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
10725 @section Adding hyperlink types
10726 @cindex hyperlinks, adding new types
10728 Org has a large number of hyperlink types built-in
10729 (@pxref{Hyperlinks}).  If you would like to add new link types, Org
10730 provides an interface for doing so.  Let's look at an example file,
10731 @file{org-man.el}, that will add support for creating links like
10732 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
10733 Emacs:
10735 @lisp
10736 ;;; org-man.el - Support for links to manpages in Org
10738 (require 'org)
10740 (org-add-link-type "man" 'org-man-open)
10741 (add-hook 'org-store-link-functions 'org-man-store-link)
10743 (defcustom org-man-command 'man
10744   "The Emacs command to be used to display a man page."
10745   :group 'org-link
10746   :type '(choice (const man) (const woman)))
10748 (defun org-man-open (path)
10749   "Visit the manpage on PATH.
10750 PATH should be a topic that can be thrown at the man command."
10751   (funcall org-man-command path))
10753 (defun org-man-store-link ()
10754   "Store a link to a manpage."
10755   (when (memq major-mode '(Man-mode woman-mode))
10756     ;; This is a man page, we do make this link
10757     (let* ((page (org-man-get-page-name))
10758            (link (concat "man:" page))
10759            (description (format "Manpage for %s" page)))
10760       (org-store-link-props
10761        :type "man"
10762        :link link
10763        :description description))))
10765 (defun org-man-get-page-name ()
10766   "Extract the page name from the buffer name."
10767   ;; This works for both `Man-mode' and `woman-mode'.
10768   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
10769       (match-string 1 (buffer-name))
10770     (error "Cannot create link to this man page")))
10772 (provide 'org-man)
10774 ;;; org-man.el ends here
10775 @end lisp
10777 @noindent
10778 You would activate this new link type in @file{.emacs} with
10780 @lisp
10781 (require 'org-man)
10782 @end lisp
10784 @noindent
10785 Let's go through the file and see what it does.
10786 @enumerate
10787 @item
10788 It does @code{(require 'org)} to make sure that @file{org.el} has been
10789 loaded.
10790 @item
10791 The next line calls @code{org-add-link-type} to define a new link type
10792 with prefix @samp{man}.  The call also contains the name of a function
10793 that will be called to follow such a link.
10794 @item
10795 @vindex org-store-link-functions
10796 The next line adds a function to @code{org-store-link-functions}, in
10797 order to allow the command @kbd{C-c l} to record a useful link in a
10798 buffer displaying a man page.
10799 @end enumerate
10801 The rest of the file defines the necessary variables and functions.
10802 First there is a customization variable that determines which Emacs
10803 command should be used to display man pages.  There are two options,
10804 @code{man} and @code{woman}.  Then the function to follow a link is
10805 defined.  It gets the link path as an argument---in this case the link
10806 path is just a topic for the manual command.  The function calls the
10807 value of @code{org-man-command} to display the man page.
10809 Finally the function @code{org-man-store-link} is defined.  When you try
10810 to store a link with @kbd{C-c l}, this function will be called to
10811 try to make a link.  The function must first decide if it is supposed to
10812 create the link for this buffer type; we do this by checking the value
10813 of the variable @code{major-mode}.  If not, the function must exit and
10814 return the value @code{nil}.  If yes, the link is created by getting the
10815 manual topic from the buffer name and prefixing it with the string
10816 @samp{man:}.  Then it must call the command @code{org-store-link-props}
10817 and set the @code{:type} and @code{:link} properties.  Optionally you
10818 can also set the @code{:description} property to provide a default for
10819 the link description when the link is later inserted into an Org
10820 buffer with @kbd{C-c C-l}.
10822 When is makes sense for your new link type, you may also define a function
10823 @code{org-PREFIX-complete-link} that implements special (@eg completion)
10824 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
10825 not accept any arguments, and return the full link with prefix.
10827 @node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
10828 @section Context-sensitive commands
10829 @cindex context-sensitive commands, hooks
10830 @cindex add-ons, context-sensitive commands
10831 @vindex org-ctrl-c-ctrl-c-hook
10833 Org has several commands that act differently depending on context.  The most
10834 important example it the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
10835 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
10837 Add-ons can tap into this functionality by providing a function that detects
10838 special context for that add-on and executes functionality appropriate for
10839 the context.  Here is an example from Dan Davison's @file{org-R.el} which
10840 allows you to evaluate commands based on the @file{R} programming language.  For
10841 this package, special contexts are lines that start with @code{#+R:} or
10842 @code{#+RR:}.
10844 @lisp
10845 (defun org-R-apply-maybe ()
10846   "Detect if this is context for org-R and execute R commands."
10847   (if (save-excursion
10848         (beginning-of-line 1)
10849         (looking-at "#\\+RR?:"))
10850       (progn (call-interactively 'org-R-apply)
10851              t) ;; to signal that we took action
10852     nil)) ;; to signal that we did not
10854 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
10855 @end lisp
10857 The function first checks if the cursor is in such a line.  If that is the
10858 case, @code{org-R-apply} is called and the function returns @code{t} to
10859 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
10860 contexts.  If the function finds it should do nothing locally, it returns @code{nil} so that other, similar functions can have a try.
10863 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
10864 @section Tables and lists in arbitrary syntax
10865 @cindex tables, in other modes
10866 @cindex lists, in other modes
10867 @cindex Orgtbl mode
10869 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
10870 frequent feature request has been to make it work with native tables in
10871 specific languages, for example La@TeX{}.  However, this is extremely
10872 hard to do in a general way, would lead to a customization nightmare,
10873 and would take away much of the simplicity of the Orgtbl-mode table
10874 editor.
10877 This appendix describes a different approach.  We keep the Orgtbl mode
10878 table in its native format (the @i{source table}), and use a custom
10879 function to @i{translate} the table to the correct syntax, and to
10880 @i{install} it in the right location (the @i{target table}).  This puts
10881 the burden of writing conversion functions on the user, but it allows
10882 for a very flexible system.
10884 Bastien added the ability to do the same with lists.  You can use Org's
10885 facilities to edit and structure lists by turning @code{orgstruct-mode}
10886 on, then locally exporting such lists in another format (HTML, La@TeX{}
10887 or Texinfo.)
10890 @menu
10891 * Radio tables::                Sending and receiving radio tables
10892 * A LaTeX example::             Step by step, almost a tutorial
10893 * Translator functions::        Copy and modify
10894 * Radio lists::                 Doing the same for lists
10895 @end menu
10897 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
10898 @subsection Radio tables
10899 @cindex radio tables
10901 To define the location of the target table, you first need to create two
10902 lines that are comments in the current mode, but contain magic words for
10903 Orgtbl mode to find.  Orgtbl mode will insert the translated table
10904 between these lines, replacing whatever was there before.  For example:
10906 @example
10907 /* BEGIN RECEIVE ORGTBL table_name */
10908 /* END RECEIVE ORGTBL table_name */
10909 @end example
10911 @noindent
10912 Just above the source table, we put a special line that tells
10913 Orgtbl mode how to translate this table and where to install it.  For
10914 example:
10915 @cindex #+ORGTBL
10916 @example
10917 #+ORGTBL: SEND table_name translation_function arguments....
10918 @end example
10920 @noindent
10921 @code{table_name} is the reference name for the table that is also used
10922 in the receiver lines. @code{translation_function} is the Lisp function
10923 that does the translation.  Furthermore, the line can contain a list of
10924 arguments (alternating key and value) at the end.  The arguments will be
10925 passed as a property list to the translation function for
10926 interpretation.  A few standard parameters are already recognized and
10927 acted upon before the translation function is called:
10929 @table @code
10930 @item :skip N
10931 Skip the first N lines of the table.  Hlines do count as separate lines for
10932 this parameter!
10934 @item :skipcols (n1 n2 ...)
10935 List of columns that should be skipped.  If the table has a column with
10936 calculation marks, that column is automatically discarded as well.
10937 Please note that the translator function sees the table @emph{after} the
10938 removal of these columns, the function never knows that there have been
10939 additional columns.
10940 @end table
10942 @noindent
10943 The one problem remaining is how to keep the source table in the buffer
10944 without disturbing the normal workings of the file, for example during
10945 compilation of a C file or processing of a La@TeX{} file.  There are a
10946 number of different solutions:
10948 @itemize @bullet
10949 @item
10950 The table could be placed in a block comment if that is supported by the
10951 language.  For example, in C mode you could wrap the table between
10952 @samp{/*} and @samp{*/} lines.
10953 @item
10954 Sometimes it is possible to put the table after some kind of @i{END}
10955 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
10956 in La@TeX{}.
10957 @item
10958 You can just comment the table line-by-line whenever you want to process
10959 the file, and uncomment it whenever you need to edit the table.  This
10960 only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment}
10961 makes this comment-toggling very easy, in particular if you bind it to a
10962 key.
10963 @end itemize
10965 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
10966 @subsection A La@TeX{} example of radio tables
10967 @cindex La@TeX{}, and Orgtbl mode
10969 The best way to wrap the source table in La@TeX{} is to use the
10970 @code{comment} environment provided by @file{comment.sty}.  It has to be
10971 activated by placing @code{\usepackage@{comment@}} into the document
10972 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
10973 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
10974 variable @code{orgtbl-radio-tables} to install templates for other
10975 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
10976 be prompted for a table name, let's say we use @samp{salesfigures}.  You
10977 will then get the following template:
10979 @cindex #+ORGTBL, SEND
10980 @example
10981 % BEGIN RECEIVE ORGTBL salesfigures
10982 % END RECEIVE ORGTBL salesfigures
10983 \begin@{comment@}
10984 #+ORGTBL: SEND salesfigures orgtbl-to-latex
10985 | | |
10986 \end@{comment@}
10987 @end example
10989 @noindent
10990 @vindex La@TeX{}-verbatim-environments
10991 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
10992 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
10993 into the receiver location with name @code{salesfigures}.  You may now
10994 fill in the table, feel free to use the spreadsheet features@footnote{If
10995 the @samp{#+TBLFM} line contains an odd number of dollar characters,
10996 this may cause problems with font-lock in La@TeX{} mode.  As shown in the
10997 example you can fix this by adding an extra line inside the
10998 @code{comment} environment that is used to balance the dollar
10999 expressions.  If you are using AUC@TeX{} with the font-latex library, a
11000 much better solution is to add the @code{comment} environment to the
11001 variable @code{LaTeX-verbatim-environments}.}:
11003 @example
11004 % BEGIN RECEIVE ORGTBL salesfigures
11005 % END RECEIVE ORGTBL salesfigures
11006 \begin@{comment@}
11007 #+ORGTBL: SEND salesfigures orgtbl-to-latex
11008 | Month | Days | Nr sold | per day |
11009 |-------+------+---------+---------|
11010 | Jan   |   23 |      55 |     2.4 |
11011 | Feb   |   21 |      16 |     0.8 |
11012 | March |   22 |     278 |    12.6 |
11013 #+TBLFM: $4=$3/$2;%.1f
11014 % $ (optional extra dollar to keep font-lock happy, see footnote)
11015 \end@{comment@}
11016 @end example
11018 @noindent
11019 When you are done, press @kbd{C-c C-c} in the table to get the converted
11020 table inserted between the two marker lines.
11022 Now let's assume you want to make the table header by hand, because you
11023 want to control how columns are aligned, etc@.  In this case we make sure
11024 that the table translator skips the first 2 lines of the source
11025 table, and tell the command to work as a @i{splice}, @ie to not produce
11026 header and footer commands of the target table:
11028 @example
11029 \begin@{tabular@}@{lrrr@}
11030 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
11031 % BEGIN RECEIVE ORGTBL salesfigures
11032 % END RECEIVE ORGTBL salesfigures
11033 \end@{tabular@}
11035 \begin@{comment@}
11036 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
11037 | Month | Days | Nr sold | per day |
11038 |-------+------+---------+---------|
11039 | Jan   |   23 |      55 |     2.4 |
11040 | Feb   |   21 |      16 |     0.8 |
11041 | March |   22 |     278 |    12.6 |
11042 #+TBLFM: $4=$3/$2;%.1f
11043 \end@{comment@}
11044 @end example
11046 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
11047 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
11048 and marks horizontal lines with @code{\hline}.  Furthermore, it
11049 interprets the following parameters (see also @pxref{Translator functions}):
11051 @table @code
11052 @item :splice nil/t
11053 When set to t, return only table body lines, don't wrap them into a
11054 tabular environment.  Default is nil.
11056 @item :fmt fmt
11057 A format to be used to wrap each field, it should contain @code{%s} for the
11058 original field value.  For example, to wrap each field value in dollars,
11059 you could use @code{:fmt "$%s$"}.  This may also be a property list with
11060 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
11061 A function of one argument can be used in place of the strings; the
11062 function must return a formatted string.
11064 @item :efmt efmt
11065 Use this format to print numbers with exponentials.  The format should
11066 have @code{%s} twice for inserting mantissa and exponent, for example
11067 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
11068 may also be a property list with column numbers and formats, for example
11069 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
11070 @code{efmt} has been applied to a value, @code{fmt} will also be
11071 applied.  Similar to @code{fmt}, functions of two arguments can be
11072 supplied instead of strings.
11073 @end table
11075 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
11076 @subsection Translator functions
11077 @cindex HTML, and Orgtbl mode
11078 @cindex translator function
11080 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
11081 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
11082 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
11083 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
11084 code that produces tables during HTML export.}, these all use a generic
11085 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
11086 itself is a very short function that computes the column definitions for the
11087 @code{tabular} environment, defines a few field and line separators and then
11088 hands processing over to the generic translator.  Here is the entire code:
11090 @lisp
11091 @group
11092 (defun orgtbl-to-latex (table params)
11093   "Convert the Orgtbl mode TABLE to LaTeX."
11094   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
11095                                org-table-last-alignment ""))
11096          (params2
11097           (list
11098            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
11099            :tend "\\end@{tabular@}"
11100            :lstart "" :lend " \\\\" :sep " & "
11101            :efmt "%s\\,(%s)" :hline "\\hline")))
11102     (orgtbl-to-generic table (org-combine-plists params2 params))))
11103 @end group
11104 @end lisp
11106 As you can see, the properties passed into the function (variable
11107 @var{PARAMS}) are combined with the ones newly defined in the function
11108 (variable @var{PARAMS2}).  The ones passed into the function (@ie the
11109 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
11110 would like to use the La@TeX{} translator, but wanted the line endings to
11111 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
11112 overrule the default with
11114 @example
11115 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
11116 @end example
11118 For a new language, you can either write your own converter function in
11119 analogy with the La@TeX{} translator, or you can use the generic function
11120 directly.  For example, if you have a language where a table is started
11121 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
11122 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
11123 separator is a TAB, you could call the generic translator like this (on
11124 a single line!):
11126 @example
11127 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
11128                               :lstart "!BL! " :lend " !EL!" :sep "\t"
11129 @end example
11131 @noindent
11132 Please check the documentation string of the function
11133 @code{orgtbl-to-generic} for a full list of parameters understood by
11134 that function, and remember that you can pass each of them into
11135 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
11136 using the generic function.
11138 Of course you can also write a completely new function doing complicated
11139 things the generic translator cannot do.  A translator function takes
11140 two arguments.  The first argument is the table, a list of lines, each
11141 line either the symbol @code{hline} or a list of fields.  The second
11142 argument is the property list containing all parameters specified in the
11143 @samp{#+ORGTBL: SEND} line.  The function must return a single string
11144 containing the formatted table.  If you write a generally useful
11145 translator, please post it on @email{emacs-orgmode@@gnu.org} so that
11146 others can benefit from your work.
11148 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
11149 @subsection Radio lists
11150 @cindex radio lists
11151 @cindex org-list-insert-radio-list
11153 Sending and receiving radio lists works exactly the same way than sending and
11154 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
11155 insert radio lists templates in HTML, La@TeX{} and Texinfo modes by calling
11156 @code{org-list-insert-radio-list}.
11158 Here are the differences with radio tables:
11160 @itemize @minus
11161 @item
11162 Use @code{ORGLST} instead of @code{ORGTBL}.
11163 @item
11164 The available translation functions for radio lists don't take
11165 parameters.
11166 @item
11167 @kbd{C-c C-c} will work when pressed on the first item of the list.
11168 @end itemize
11170 Here is a La@TeX{} example.  Let's say that you have this in your
11171 La@TeX{} file:
11173 @cindex #+ORGLIST
11174 @example
11175 % BEGIN RECEIVE ORGLST to-buy
11176 % END RECEIVE ORGLST to-buy
11177 \begin@{comment@}
11178 #+ORGLIST: SEND to-buy orgtbl-to-latex
11179 - a new house
11180 - a new computer
11181   + a new keyboard
11182   + a new mouse
11183 - a new life
11184 \end@{comment@}
11185 @end example
11187 Pressing `C-c C-c' on @code{a new house} and will insert the converted
11188 La@TeX{} list between the two marker lines.
11190 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
11191 @section Dynamic blocks
11192 @cindex dynamic blocks
11194 Org documents can contain @emph{dynamic blocks}.  These are
11195 specially marked regions that are updated by some user-written function.
11196 A good example for such a block is the clock table inserted by the
11197 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
11199 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
11200 to the block and can also specify parameters for the function producing
11201 the content of the block.
11203 #+BEGIN:dynamic block
11204 @example
11205 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
11207 #+END:
11208 @end example
11210 Dynamic blocks are updated with the following commands
11212 @table @kbd
11213 @kindex C-c C-x C-u
11214 @item C-c C-x C-u
11215 Update dynamic block at point.
11216 @kindex C-u C-c C-x C-u
11217 @item C-u C-c C-x C-u
11218 Update all dynamic blocks in the current file.
11219 @end table
11221 Updating a dynamic block means to remove all the text between BEGIN and
11222 END, parse the BEGIN line for parameters and then call the specific
11223 writer function for this block to insert the new content.  If you want
11224 to use the original content in the writer function, you can use the
11225 extra parameter @code{:content}.
11227 For a block with name @code{myblock}, the writer function is
11228 @code{org-dblock-write:myblock} with as only parameter a property list
11229 with the parameters given in the begin line.  Here is a trivial example
11230 of a block that keeps track of when the block update function was last
11231 run:
11233 @example
11234 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
11236 #+END:
11237 @end example
11239 @noindent
11240 The corresponding block writer function could look like this:
11242 @lisp
11243 (defun org-dblock-write:block-update-time (params)
11244    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
11245      (insert "Last block update at: "
11246              (format-time-string fmt (current-time)))))
11247 @end lisp
11249 If you want to make sure that all dynamic blocks are always up-to-date,
11250 you could add the function @code{org-update-all-dblocks} to a hook, for
11251 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
11252 written in a way such that it does nothing in buffers that are not in
11253 @code{org-mode}.
11255 @node Special agenda views, Extracting agenda information, Dynamic blocks, Hacking
11256 @section Special agenda views
11257 @cindex agenda views, user-defined
11259 Org provides a special hook that can be used to narrow down the
11260 selection made by any of the agenda views.  You may specify a function
11261 that is used at each match to verify if the match should indeed be part
11262 of the agenda view, and if not, how much should be skipped.
11264 Let's say you want to produce a list of projects that contain a WAITING
11265 tag anywhere in the project tree.  Let's further assume that you have
11266 marked all tree headings that define a project with the TODO keyword
11267 PROJECT.  In this case you would run a TODO search for the keyword
11268 PROJECT, but skip the match unless there is a WAITING tag anywhere in
11269 the subtree belonging to the project line.
11271 To achieve this, you must write a function that searches the subtree for
11272 the tag.  If the tag is found, the function must return @code{nil} to
11273 indicate that this match should not be skipped.  If there is no such
11274 tag, return the location of the end of the subtree, to indicate that
11275 search should continue from there.
11277 @lisp
11278 (defun my-skip-unless-waiting ()
11279   "Skip trees that are not waiting"
11280   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
11281     (if (re-search-forward ":waiting:" subtree-end t)
11282         nil          ; tag found, do not skip
11283       subtree-end))) ; tag not found, continue after end of subtree
11284 @end lisp
11286 Now you may use this function in an agenda custom command, for example
11287 like this:
11289 @lisp
11290 (org-add-agenda-custom-command
11291  '("b" todo "PROJECT"
11292    ((org-agenda-skip-function 'my-skip-unless-waiting)
11293     (org-agenda-overriding-header "Projects waiting for something: "))))
11294 @end lisp
11296 @vindex org-agenda-overriding-header
11297 Note that this also binds @code{org-agenda-overriding-header} to get a
11298 meaningful header in the agenda view.
11300 @vindex org-odd-levels-only
11301 @vindex org-agenda-skip-function
11302 A general way to create custom searches is to base them on a search for
11303 entries with a certain level limit.  If you want to study all entries with
11304 your custom search function, simply do a search for
11305 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
11306 level number corresponds to order in the hierarchy, not to the number of
11307 stars.}, and then use @code{org-agenda-skip-function} to select the entries
11308 you really want to have.
11310 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
11311 particular, you may use the functions @code{org-agenda-skip-entry-if}
11312 and @code{org-agenda-skip-subtree-if} in this form, for example:
11314 @table @code
11315 @item '(org-agenda-skip-entry-if 'scheduled)
11316 Skip current entry if it has been scheduled.
11317 @item '(org-agenda-skip-entry-if 'notscheduled)
11318 Skip current entry if it has not been scheduled.
11319 @item '(org-agenda-skip-entry-if 'deadline)
11320 Skip current entry if it has a deadline.
11321 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
11322 Skip current entry if it has a deadline, or if it is scheduled.
11323 @item '(org-agenda-skip-entry-if 'timestamp)
11324 Skip current entry if it has any timestamp, may also be deadline or scheduled.
11325 @item '(org-agenda-skip-entry 'regexp "regular expression")
11326 Skip current entry if the regular expression matches in the entry.
11327 @item '(org-agenda-skip-entry 'notregexp "regular expression")
11328 Skip current entry unless the regular expression matches.
11329 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
11330 Same as above, but check and skip the entire subtree.
11331 @end table
11333 Therefore we could also have written the search for WAITING projects
11334 like this, even without defining a special function:
11336 @lisp
11337 (org-add-agenda-custom-command
11338  '("b" todo "PROJECT"
11339    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
11340                                 'regexp ":waiting:"))
11341     (org-agenda-overriding-header "Projects waiting for something: "))))
11342 @end lisp
11344 @node Extracting agenda information, Using the property API, Special agenda views, Hacking
11345 @section Extracting agenda information
11346 @cindex agenda, pipe
11347 @cindex Scripts, for agenda processing
11349 @vindex org-agenda-custom-commands
11350 Org provides commands to access agenda information for the command
11351 line in Emacs batch mode.  This extracted information can be sent
11352 directly to a printer, or it can be read by a program that does further
11353 processing of the data.  The first of these commands is the function
11354 @code{org-batch-agenda}, that produces an agenda view and sends it as
11355 ASCII text to STDOUT.  The command takes a single string as parameter.
11356 If the string has length 1, it is used as a key to one of the commands
11357 you have configured in @code{org-agenda-custom-commands}, basically any
11358 key you can use after @kbd{C-c a}.  For example, to directly print the
11359 current TODO list, you could use
11361 @example
11362 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
11363 @end example
11365 If the parameter is a string with 2 or more characters, it is used as a
11366 tags/TODO match string.  For example, to print your local shopping list
11367 (all items with the tag @samp{shop}, but excluding the tag
11368 @samp{NewYork}), you could use
11370 @example
11371 emacs -batch -l ~/.emacs                                      \
11372       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
11373 @end example
11375 @noindent
11376 You may also modify parameters on the fly like this:
11378 @example
11379 emacs -batch -l ~/.emacs                                      \
11380    -eval '(org-batch-agenda "a"                               \
11381             org-agenda-ndays 30                               \
11382             org-agenda-include-diary nil                      \
11383             org-agenda-files (quote ("~/org/project.org")))'  \
11384    | lpr
11385 @end example
11387 @noindent
11388 which will produce a 30-day agenda, fully restricted to the Org file
11389 @file{~/org/projects.org}, not even including the diary.
11391 If you want to process the agenda data in more sophisticated ways, you
11392 can use the command @code{org-batch-agenda-csv} to get a comma-separated
11393 list of values for each agenda item.  Each line in the output will
11394 contain a number of fields separated by commas.  The fields in a line
11395 are:
11397 @example
11398 category     @r{The category of the item}
11399 head         @r{The headline, without TODO keyword, TAGS and PRIORITY}
11400 type         @r{The type of the agenda entry, can be}
11401                 todo               @r{selected in TODO match}
11402                 tagsmatch          @r{selected in tags match}
11403                 diary              @r{imported from diary}
11404                 deadline           @r{a deadline}
11405                 scheduled          @r{scheduled}
11406                 timestamp          @r{appointment, selected by timestamp}
11407                 closed             @r{entry was closed on date}
11408                 upcoming-deadline  @r{warning about nearing deadline}
11409                 past-scheduled     @r{forwarded scheduled item}
11410                 block              @r{entry has date block including date}
11411 todo         @r{The TODO keyword, if any}
11412 tags         @r{All tags including inherited ones, separated by colons}
11413 date         @r{The relevant date, like 2007-2-14}
11414 time         @r{The time, like 15:00-16:50}
11415 extra        @r{String with extra planning info}
11416 priority-l   @r{The priority letter if any was given}
11417 priority-n   @r{The computed numerical priority}
11418 @end example
11420 @noindent
11421 Time and date will only be given if a timestamp (or deadline/scheduled)
11422 led to the selection of the item.
11424 A CSV list like this is very easy to use in a post-processing script.
11425 For example, here is a Perl program that gets the TODO list from
11426 Emacs/Org and prints all the items, preceded by a checkbox:
11428 @example
11429 #!/usr/bin/perl
11431 # define the Emacs command to run
11432 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
11434 # run it and capture the output
11435 $agenda = qx@{$cmd 2>/dev/null@};
11437 # loop over all lines
11438 foreach $line (split(/\n/,$agenda)) @{
11439   # get the individual values
11440   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
11441    $priority_l,$priority_n) = split(/,/,$line);
11442   # process and print
11443   print "[ ] $head\n";
11445 @end example
11460 @node Using the property API, Using the mapping API, Extracting agenda information, Hacking
11461 @section Using the property API
11462 @cindex API, for properties
11463 @cindex properties, API
11465 Here is a description of the functions that can be used to work with
11466 properties.
11468 @defun org-entry-properties &optional pom which
11469 Get all properties of the entry at point-or-marker POM.@*
11470 This includes the TODO keyword, the tags, time strings for deadline,
11471 scheduled, and clocking, and any additional properties defined in the
11472 entry.  The return value is an alist, keys may occur multiple times
11473 if the property key was used several times.@*
11474 POM may also be nil, in which case the current entry is used.
11475 If WHICH is nil or `all', get all properties.  If WHICH is
11476 `special' or `standard', only get that subclass.
11477 @end defun
11478 @vindex org-use-property-inheritance
11479 @defun org-entry-get pom property &optional inherit
11480 Get value of PROPERTY for entry at point-or-marker POM.  By default,
11481 this only looks at properties defined locally in the entry.  If INHERIT
11482 is non-nil and the entry does not have the property, then also check
11483 higher levels of the hierarchy.  If INHERIT is the symbol
11484 @code{selective}, use inheritance if and only if the setting of
11485 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
11486 @end defun
11488 @defun org-entry-delete pom property
11489 Delete the property PROPERTY from entry at point-or-marker POM.
11490 @end defun
11492 @defun org-entry-put pom property value
11493 Set PROPERTY to VALUE for entry at point-or-marker POM.
11494 @end defun
11496 @defun org-buffer-property-keys &optional include-specials
11497 Get all property keys in the current buffer.
11498 @end defun
11500 @defun org-insert-property-drawer
11501 Insert a property drawer at point.
11502 @end defun
11504 @defun org-entry-put-multivalued-property pom property &rest values
11505 Set PROPERTY at point-or-marker POM to VALUES.  VALUES should be a list of
11506 strings.  They will be concatenated, with spaces as separators.
11507 @end defun
11509 @defun org-entry-get-multivalued-property pom property
11510 Treat the value of the property PROPERTY as a whitespace-separated list of
11511 values and return the values as a list of strings.
11512 @end defun
11514 @defun org-entry-add-to-multivalued-property pom property value
11515 Treat the value of the property PROPERTY as a whitespace-separated list of
11516 values and make sure that VALUE is in this list.
11517 @end defun
11519 @defun org-entry-remove-from-multivalued-property pom property value
11520 Treat the value of the property PROPERTY as a whitespace-separated list of
11521 values and make sure that VALUE is @emph{not} in this list.
11522 @end defun
11524 @defun org-entry-member-in-multivalued-property pom property value
11525 Treat the value of the property PROPERTY as a whitespace-separated list of
11526 values and check if VALUE is in this list.
11527 @end defun
11529 @node Using the mapping API,  , Using the property API, Hacking
11530 @section Using the mapping API
11531 @cindex API, for mapping
11532 @cindex mapping entries, API
11534 Org has sophisticated mapping capabilities to find all entries satisfying
11535 certain criteria.  Internally, this functionality is used to produce agenda
11536 views, but there is also an API that can be used to execute arbitrary
11537 functions for each or selected entries.  The main entry point for this API
11540 @defun org-map-entries func &optional match scope &rest skip
11541 Call FUNC at each headline selected by MATCH in SCOPE.
11543 FUNC is a function or a Lisp form.  The function will be called without
11544 arguments, with the cursor positioned at the beginning of the headline.
11545 The return values of all calls to the function will be collected and
11546 returned as a list.
11548 The call to FUNC will be wrapped into a save-excursion form, so FUNC
11549 does not need to preserve point.  After evaluation, the cursor will be
11550 moved to the end of the line (presumably of the headline of the
11551 processed entry) and search continues from there.  Under some
11552 circumstances, this may not produce the wanted results.  For example,
11553 if you have removed (@eg archived) the current (sub)tree it could
11554 mean that the next entry will be skipped entirely.  In such cases, you
11555 can specify the position from where search should continue by making
11556 FUNC set the variable `org-map-continue-from' to the desired buffer
11557 position.
11559 MATCH is a tags/property/todo match as it is used in the agenda match view.
11560 Only headlines that are matched by this query will be considered during
11561 the iteration.  When MATCH is nil or t, all headlines will be
11562 visited by the iteration.
11564 SCOPE determines the scope of this command.  It can be any of:
11566 @example
11567 nil     @r{the current buffer, respecting the restriction if any}
11568 tree    @r{the subtree started with the entry at point}
11569 file    @r{the current buffer, without restriction}
11570 file-with-archives
11571         @r{the current buffer, and any archives associated with it}
11572 agenda  @r{all agenda files}
11573 agenda-with-archives
11574         @r{all agenda files with any archive files associated with them}
11575 (file1 file2 ...)
11576         @r{if this is a list, all files in the list will be scanned}
11577 @end example
11578 @noindent
11579 The remaining args are treated as settings for the skipping facilities of
11580 the scanner.  The following items can be given here:
11582 @vindex org-agenda-skip-function
11583 @example
11584 archive   @r{skip trees with the archive tag}
11585 comment   @r{skip trees with the COMMENT keyword}
11586 function or Lisp form
11587           @r{will be used as value for @code{org-agenda-skip-function},}
11588           @r{so whenever the function returns t, FUNC}
11589           @r{will not be called for that entry and search will}
11590           @r{continue from the point where the function leaves it}
11591 @end example
11592 @end defun
11594 The function given to that mapping routine can really do anything you like.
11595 It can use the property API (@pxref{Using the property API}) to gather more
11596 information about the entry, or in order to change metadata in the entry.
11597 Here are a couple of functions that might be handy:
11599 @defun org-todo &optional arg
11600 Change the TODO state of the entry, see the docstring of the functions for
11601 the many possible values for the argument ARG.
11602 @end defun
11604 @defun org-priority &optional action
11605 Change the priority of the entry, see the docstring of this function for the
11606 possible values for ACTION.
11607 @end defun
11609 @defun org-toggle-tag tag &optional onoff
11610 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
11611 or @code{off} will not toggle tag, but ensure that it is either on or off.
11612 @end defun
11614 @defun org-promote
11615 Promote the current entry.
11616 @end defun
11618 @defun org-demote
11619 Demote the current entry.
11620 @end defun
11622 Here is a simple example that will turn all entries in the current file with
11623 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
11624 Entries in comment trees and in archive trees will be ignored.
11626 @lisp
11627 (org-map-entries
11628    '(org-todo "UPCOMING")
11629    "+TOMORROW" 'file 'archive 'comment)
11630 @end lisp
11632 The following example counts the number of entries with TODO keyword
11633 @code{WAITING}, in all agenda files.
11635 @lisp
11636 (length (org-map-entries t "/+WAITING" 'agenda))
11637 @end lisp
11639 @node History and Acknowledgments, Main Index, Hacking, Top
11640 @appendix History and Acknowledgments
11641 @cindex acknowledgments
11642 @cindex history
11643 @cindex thanks
11645 Org was born in 2003, out of frustration over the user interface
11646 of the Emacs Outline mode.  I was trying to organize my notes and
11647 projects, and using Emacs seemed to be the natural way to go.  However,
11648 having to remember eleven different commands with two or three keys per
11649 command, only to hide and show parts of the outline tree, that seemed
11650 entirely unacceptable to me.  Also, when using outlines to take notes, I
11651 constantly wanted to restructure the tree, organizing it parallel to my
11652 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
11653 editing} were originally implemented in the package
11654 @file{outline-magic.el}, but quickly moved to the more general
11655 @file{org.el}.  As this environment became comfortable for project
11656 planning, the next step was adding @emph{TODO entries}, basic
11657 @emph{timestamps}, and @emph{table support}.  These areas highlighted the two main
11658 goals that Org still has today: to be a new, outline-based,
11659 plain text mode with innovative and intuitive editing features, and to
11660 incorporate project planning functionality directly into a notes file.
11662 A special thanks goes to @i{Bastien Guerry} who has not only written a large
11663 number of extensions to Org (most of them integrated into the core by now),
11664 but who has also helped in the development and maintenance of Org so much that he
11665 should be considered the main co-contributor to this package.
11667 Since the first release, literally thousands of emails to me or to
11668 @email{emacs-orgmode@@gnu.org} have provided a constant stream of bug
11669 reports, feedback, new ideas, and sometimes patches and add-on code.
11670 Many thanks to everyone who has helped to improve this package.  I am
11671 trying to keep here a list of the people who had significant influence
11672 in shaping one or more aspects of Org.  The list may not be
11673 complete, if I have forgotten someone, please accept my apologies and
11674 let me know.
11676 @itemize @bullet
11678 @item
11679 @i{Russel Adams} came up with the idea for drawers.
11680 @item
11681 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
11682 @item
11683 @i{Christophe Bataillon} created the great unicorn logo that we use on the
11684 Org-mode website.
11685 @item
11686 @i{Alex Bochannek} provided a patch for rounding timestamps.
11687 @item
11688 @i{Brad Bozarth} showed how to pull RSS feed data into Org-mode files.
11689 @item
11690 @i{Tom Breton} wrote @file{org-choose.el}.
11691 @item
11692 @i{Charles Cave}'s suggestion sparked the implementation of templates
11693 for Remember.
11694 @item
11695 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
11696 specified time.
11697 @item
11698 @i{Gregory Chernov} patched support for Lisp forms into table
11699 calculations and improved XEmacs compatibility, in particular by porting
11700 @file{nouline.el} to XEmacs.
11701 @item
11702 @i{Sacha Chua} suggested copying some linking code from Planner.
11703 @item
11704 @i{Baoqiu Cui} contributed the DocBook exporter.
11705 @item
11706 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
11707 came up with the idea of properties, and that there should be an API for
11708 them.
11709 @item
11710 @i{Nick Dokos} tracked down several nasty bugs.
11711 @item
11712 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
11713 inspired some of the early development, including HTML export.  He also
11714 asked for a way to narrow wide table columns.
11715 @item
11716 @i{Christian Egli} converted the documentation into Texinfo format,
11717 patched CSS formatting into the HTML exporter, and inspired the agenda.
11718 @item
11719 @i{David Emery} provided a patch for custom CSS support in exported
11720 HTML agendas.
11721 @item
11722 @i{Nic Ferrier} contributed mailcap and XOXO support.
11723 @item
11724 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
11725 @item
11726 @i{John Foerch} figured out how to make incremental search show context
11727 around a match in a hidden outline tree.
11728 @item
11729 @i{Niels Giesen} had the idea to automatically archive DONE trees.
11730 @item
11731 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
11732 has been prolific with patches, ideas, and bug reports.
11733 @item
11734 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
11735 @item
11736 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
11737 task state change logging, and the clocktable.  His clear explanations have
11738 been critical when we started to adopt the Git version control system.
11739 @item
11740 @i{Manuel Hermenegildo} has contributed various ideas, small fixes and
11741 patches.
11742 @item
11743 @i{Phil Jackson} wrote @file{org-irc.el}.
11744 @item
11745 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
11746 folded entries, and column view for properties.
11747 @item
11748 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
11749 @item
11750 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
11751 provided frequent feedback and some patches.
11752 @item
11753 @i{Matt Lundin} has proposed last-row references for table formulas and named
11754 invisible anchors.  He has also worked a lot on the FAQ.
11755 @item
11756 @i{Jason F. McBrayer} suggested agenda export to CSV format.
11757 @item
11758 @i{Max Mikhanosha} came up with the idea of refiling.
11759 @item
11760 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
11761 basis.
11762 @item
11763 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
11764 happy.
11765 @item
11766 @i{Rick Moynihan} proposed allowing multiple TODO sequences in a file
11767 and being able to quickly restrict the agenda to a subtree.
11768 @item
11769 @i{Todd Neal} provided patches for links to Info files and Elisp forms.
11770 @item
11771 @i{Greg Newman} refreshed the unicorn logo into its current form.
11772 @item
11773 @i{Tim O'Callaghan} suggested in-file links, search options for general
11774 file links, and TAGS.
11775 @item
11776 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
11777 into Japanese.
11778 @item
11779 @i{Oliver Oppitz} suggested multi-state TODO items.
11780 @item
11781 @i{Scott Otterson} sparked the introduction of descriptive text for
11782 links, among other things.
11783 @item
11784 @i{Pete Phillips} helped during the development of the TAGS feature, and
11785 provided frequent feedback.
11786 @item
11787 @i{Martin Pohlack} provided the code snippet to bundle character insertion
11788 into bundles of 20 for undo.
11789 @item
11790 @i{T.V. Raman} reported bugs and suggested improvements.
11791 @item
11792 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
11793 control.
11794 @item
11795 @i{Paul Rivier} provided the basic implementation of named footnotes.
11796 @item
11797 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
11798 @item
11799 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
11800 webpages derived from Org using an Info-like or a folding interface with
11801 single-key navigation.
11802 @item
11803 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
11804 conflict with @file{allout.el}.
11805 @item
11806 @i{Jason Riedy} generalized the send-receive mechanism for Orgtbl tables with
11807 extensive patches.
11808 @item
11809 @i{Philip Rooke} created the Org reference card, provided lots
11810 of feedback, developed and applied standards to the Org documentation.
11811 @item
11812 @i{Christian Schlauer} proposed angular brackets around links, among
11813 other things.
11814 @item
11815 @i{Eric Schulte} wrote @file{org-plot.el} and contributed various patches,
11816 small features and modules.
11817 @item
11818 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
11819 @file{organizer-mode.el}.
11820 @item
11821 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
11822 examples, and remote highlighting for referenced code lines.
11823 @item
11824 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
11825 now packaged into Org's @file{contrib} directory.
11826 @item
11827 @i{Daniel Sinder} came up with the idea of internal archiving by locking
11828 subtrees.
11829 @item
11830 @i{Dale Smith} proposed link abbreviations.
11831 @item
11832 @i{James TD Smith} has contributed a large number of patches for useful
11833 tweaks and features.
11834 @item
11835 @i{Adam Spiers} asked for global linking commands, inspired the link
11836 extension system, added support for mairix, and proposed the mapping API.
11837 @item
11838 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
11839 with links transformation to Org syntax.
11840 @item
11841 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
11842 chapter about publishing.
11843 @item
11844 @i{J@"urgen Vollmer} contributed code generating the table of contents
11845 in HTML output.
11846 @item
11847 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
11848 keyword.
11849 @item
11850 @i{David Wainberg} suggested archiving, and improvements to the linking
11851 system.
11852 @item
11853 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
11854 @file{muse.el}, which have some overlap with Org.  Initially the development
11855 of Org was fully independent because I was not aware of the existence of
11856 these packages.  But with time I have occasionally looked at John's code and
11857 learned a lot from it.  John has also contributed a number of great ideas and
11858 patches directly to Org, including the attachment system
11859 (@file{org-attach.el}), integration with Apple Mail
11860 (@file{org-mac-message.el}), and hierarchical dependencies of TODO items.
11861 @item
11862 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
11863 linking to Gnus.
11864 @item
11865 @i{Roland Winkler} requested additional key bindings to make Org
11866 work on a tty.
11867 @item
11868 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
11869 and contributed various ideas and code snippets.
11870 @end itemize
11873 @node Main Index, Key Index, History and Acknowledgments, Top
11874 @unnumbered Concept Index
11876 @printindex cp
11878 @node Key Index, Variable Index, Main Index, Top
11879 @unnumbered Key Index
11881 @printindex ky
11883 @node Variable Index,  , Key Index, Top
11884 @unnumbered Variable Index
11886 This is not a complete index of variables and faces, only the ones that are
11887 mentioned in the manual.  For a more complete list, use @kbd{M-x
11888 org-customize @key{RET}} and then klick yourself through the tree.
11890 @printindex vr
11892 @bye
11894 @ignore
11895         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
11896 @end ignore
11898 @c Local variables:
11899 @c ispell-local-dictionary: "en_US-w_accents"
11900 @c ispell-local-pdict: "./.aspell.org.pws"
11901 @c fill-column: 77
11902 @c End: