disable VC for batch evaluation
[org-mode.git] / doc / org.texi
blob2ebc4086f6564a56b0a76da071c506f4514294f9
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @include org-version.inc
8 @c Use proper quote and backtick for code sections in PDF output
9 @c Cf. Texinfo manual 14.2
10 @set txicodequoteundirected
11 @set txicodequotebacktick
13 @c Version and Contact Info
14 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
15 @set AUTHOR Carsten Dominik
16 @set MAINTAINER Bastien Guerry
17 @set MAINTAINEREMAIL @email{bzg at gnu dot org}
18 @set MAINTAINERCONTACT @uref{mailto:bzg at gnu dot org,contact the maintainer}
19 @c %**end of header
20 @finalout
23 @c -----------------------------------------------------------------------------
25 @c Macro definitions for commands and keys
26 @c =======================================
28 @c The behavior of the key/command macros will depend on the flag cmdnames
29 @c When set, commands names are shown.  When clear, they are not shown.
31 @set cmdnames
33 @c Below we define the following macros for Org key tables:
35 @c orgkey{key}                        A key item
36 @c orgcmd{key,cmd}                    Key with command name
37 @c xorgcmd{key,cmd}                   Key with command name as @itemx
38 @c orgcmdnki{key,cmd}                 Like orgcmd, but do not index the key
39 @c orgcmdtkc{text,key,cmd}            Like orgcmd,special text instead of key
40 @c orgcmdkkc{key1,key2,cmd}           Two keys with one command name, use "or"
41 @c orgcmdkxkc{key1,key2,cmd}          Two keys with one command name, but
42 @c                                    different functions, so format as @itemx
43 @c orgcmdkskc{key1,key2,cmd}          Same as orgcmdkkc, but use "or short"
44 @c xorgcmdkskc{key1,key2,cmd}         Same as previous, but use @itemx
45 @c orgcmdkkcc{key1,key2,cmd1,cmd2}    Two keys and two commands
47 @c a key but no command
48 @c    Inserts:    @item key
49 @macro orgkey{key}
50 @kindex \key\
51 @item @kbd{\key\}
52 @end macro
54 @macro xorgkey{key}
55 @kindex \key\
56 @itemx @kbd{\key\}
57 @end macro
59 @c one key with a command
60 @c   Inserts:    @item KEY               COMMAND
61 @macro orgcmd{key,command}
62 @ifset cmdnames
63 @kindex \key\
64 @findex \command\
65 @iftex
66 @item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
67 @end iftex
68 @ifnottex
69 @item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
70 @end ifnottex
71 @end ifset
72 @ifclear cmdnames
73 @kindex \key\
74 @item @kbd{\key\}
75 @end ifclear
76 @end macro
78 @c One key with one command, formatted using @itemx
79 @c   Inserts:    @itemx KEY               COMMAND
80 @macro xorgcmd{key,command}
81 @ifset cmdnames
82 @kindex \key\
83 @findex \command\
84 @iftex
85 @itemx @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
86 @end iftex
87 @ifnottex
88 @itemx @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
89 @end ifnottex
90 @end ifset
91 @ifclear cmdnames
92 @kindex \key\
93 @itemx @kbd{\key\}
94 @end ifclear
95 @end macro
97 @c one key with a command, bit do not index the key
98 @c   Inserts:    @item KEY               COMMAND
99 @macro orgcmdnki{key,command}
100 @ifset cmdnames
101 @findex \command\
102 @iftex
103 @item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
104 @end iftex
105 @ifnottex
106 @item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
107 @end ifnottex
108 @end ifset
109 @ifclear cmdnames
110 @item @kbd{\key\}
111 @end ifclear
112 @end macro
114 @c one key with a command, and special text to replace key in item
115 @c   Inserts:    @item TEXT                    COMMAND
116 @macro orgcmdtkc{text,key,command}
117 @ifset cmdnames
118 @kindex \key\
119 @findex \command\
120 @iftex
121 @item @kbd{\text\} @hskip 0pt plus 1filll @code{\command\}
122 @end iftex
123 @ifnottex
124 @item @kbd{\text\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
125 @end ifnottex
126 @end ifset
127 @ifclear cmdnames
128 @kindex \key\
129 @item @kbd{\text\}
130 @end ifclear
131 @end macro
133 @c two keys with one command
134 @c   Inserts:    @item KEY1 or KEY2            COMMAND
135 @macro orgcmdkkc{key1,key2,command}
136 @ifset cmdnames
137 @kindex \key1\
138 @kindex \key2\
139 @findex \command\
140 @iftex
141 @item @kbd{\key1\} @ @r{or} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
142 @end iftex
143 @ifnottex
144 @item @kbd{\key1\} @ @r{or} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
145 @end ifnottex
146 @end ifset
147 @ifclear cmdnames
148 @kindex \key1\
149 @kindex \key2\
150 @item @kbd{\key1\} @ @r{or} @ @kbd{\key2\}
151 @end ifclear
152 @end macro
154 @c Two keys with one command name, but different functions, so format as
155 @c @itemx
156 @c   Inserts:    @item KEY1
157 @c               @itemx KEY2                COMMAND
158 @macro orgcmdkxkc{key1,key2,command}
159 @ifset cmdnames
160 @kindex \key1\
161 @kindex \key2\
162 @findex \command\
163 @iftex
164 @item @kbd{\key1\}
165 @itemx @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
166 @end iftex
167 @ifnottex
168 @item @kbd{\key1\}
169 @itemx @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
170 @end ifnottex
171 @end ifset
172 @ifclear cmdnames
173 @kindex \key1\
174 @kindex \key2\
175 @item @kbd{\key1\}
176 @itemx @kbd{\key2\}
177 @end ifclear
178 @end macro
180 @c Same as previous, but use "or short"
181 @c   Inserts:    @item KEY1 or short KEY2            COMMAND
182 @macro orgcmdkskc{key1,key2,command}
183 @ifset cmdnames
184 @kindex \key1\
185 @kindex \key2\
186 @findex \command\
187 @iftex
188 @item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
189 @end iftex
190 @ifnottex
191 @item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
192 @end ifnottex
193 @end ifset
194 @ifclear cmdnames
195 @kindex \key1\
196 @kindex \key2\
197 @item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\}
198 @end ifclear
199 @end macro
201 @c Same as previous, but use @itemx
202 @c   Inserts:    @itemx KEY1 or short KEY2            COMMAND
203 @macro xorgcmdkskc{key1,key2,command}
204 @ifset cmdnames
205 @kindex \key1\
206 @kindex \key2\
207 @findex \command\
208 @iftex
209 @itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
210 @end iftex
211 @ifnottex
212 @itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
213 @end ifnottex
214 @end ifset
215 @ifclear cmdnames
216 @kindex \key1\
217 @kindex \key2\
218 @itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\}
219 @end ifclear
220 @end macro
222 @c two keys with two commands
223 @c   Inserts:    @item KEY1                        COMMAND1
224 @c               @itemx KEY2                       COMMAND2
225 @macro orgcmdkkcc{key1,key2,command1,command2}
226 @ifset cmdnames
227 @kindex \key1\
228 @kindex \key2\
229 @findex \command1\
230 @findex \command2\
231 @iftex
232 @item @kbd{\key1\} @hskip 0pt plus 1filll @code{\command1\}
233 @itemx @kbd{\key2\} @hskip 0pt plus 1filll @code{\command2\}
234 @end iftex
235 @ifnottex
236 @item @kbd{\key1\} @tie{}@tie{}@tie{}@tie{}(@code{\command1\})
237 @itemx @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command2\})
238 @end ifnottex
239 @end ifset
240 @ifclear cmdnames
241 @kindex \key1\
242 @kindex \key2\
243 @item @kbd{\key1\}
244 @itemx @kbd{\key2\}
245 @end ifclear
246 @end macro
247 @c -----------------------------------------------------------------------------
249 @iftex
250 @c @hyphenation{time-stamp time-stamps time-stamp-ing time-stamp-ed}
251 @end iftex
253 @c Subheadings inside a table.
254 @macro tsubheading{text}
255 @ifinfo
256 @subsubheading \text\
257 @end ifinfo
258 @ifnotinfo
259 @item @b{\text\}
260 @end ifnotinfo
261 @end macro
263 @copying
264 This manual is for Org version @value{VERSION}.
266 Copyright @copyright{} 2004--2013 Free Software Foundation, Inc.
268 @quotation
269 Permission is granted to copy, distribute and/or modify this document
270 under the terms of the GNU Free Documentation License, Version 1.3 or
271 any later version published by the Free Software Foundation; with no
272 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
273 and with the Back-Cover Texts as in (a) below.  A copy of the license
274 is included in the section entitled ``GNU Free Documentation License.''
276 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
277 modify this GNU manual.''
278 @end quotation
279 @end copying
281 @dircategory Emacs editing modes
282 @direntry
283 * Org Mode: (org).      Outline-based notes management and organizer
284 @end direntry
286 @titlepage
287 @title The Org Manual
289 @subtitle Release @value{VERSION}
290 @author by Carsten Dominik
291 with contributions by David O'Toole, Bastien Guerry, Philip Rooke, Dan Davison, Eric Schulte, Thomas Dye and Jambunathan K.
293 @c The following two commands start the copyright page.
294 @page
295 @vskip 0pt plus 1filll
296 @insertcopying
297 @end titlepage
299 @c Output the table of contents at the beginning.
300 @contents
302 @ifnottex
303 @c FIXME These hand-written next,prev,up node pointers make editing a lot
304 @c harder.  There should be no need for them, makeinfo can do it
305 @c automatically for any document with a normal structure.
306 @node Top, Introduction, (dir), (dir)
307 @top Org Mode Manual
309 @insertcopying
310 @end ifnottex
312 @menu
313 * Introduction::                Getting started
314 * Document Structure::          A tree works like your brain
315 * Tables::                      Pure magic for quick formatting
316 * Hyperlinks::                  Notes in context
317 * TODO Items::                  Every tree branch can be a TODO item
318 * Tags::                        Tagging headlines and matching sets of tags
319 * Properties and Columns::      Storing information about an entry
320 * Dates and Times::             Making items useful for planning
321 * Capture - Refile - Archive::  The ins and outs for projects
322 * Agenda Views::                Collecting information into views
323 * Markup::                      Prepare text for rich export
324 * Exporting::                   Sharing and publishing notes
325 * Publishing::                  Create a web site of linked Org files
326 * Working With Source Code::    Export, evaluate, and tangle code blocks
327 * Miscellaneous::               All the rest which did not fit elsewhere
328 * Hacking::                     How to hack your way around
329 * MobileOrg::                   Viewing and capture on a mobile device
330 * History and Acknowledgments::  How Org came into being
331 * GNU Free Documentation License::  The license for this documentation.
332 * Main Index::                  An index of Org's concepts and features
333 * Key Index::                   Key bindings and where they are described
334 * Command and Function Index::  Command names and some internal functions
335 * Variable Index::              Variables mentioned in the manual
337 @detailmenu
338  --- The Detailed Node Listing ---
340 Introduction
342 * Summary::                     Brief summary of what Org does
343 * Installation::                Installing Org
344 * Activation::                  How to activate Org for certain buffers
345 * Feedback::                    Bug reports, ideas, patches etc.
346 * Conventions::                 Typesetting conventions in the manual
348 Document structure
350 * Outlines::                    Org is based on Outline mode
351 * Headlines::                   How to typeset Org tree headlines
352 * Visibility cycling::          Show and hide, much simplified
353 * Motion::                      Jumping to other headlines
354 * Structure editing::           Changing sequence and level of headlines
355 * Sparse trees::                Matches embedded in context
356 * Plain lists::                 Additional structure within an entry
357 * Drawers::                     Tucking stuff away
358 * Blocks::                      Folding blocks
359 * Footnotes::                   How footnotes are defined in Org's syntax
360 * Orgstruct mode::              Structure editing outside Org
361 * Org syntax::                  Formal description of Org's syntax
363 Visibility cycling
365 * Global and local cycling::    Cycling through various visibility states
366 * Initial visibility::          Setting the initial visibility state
367 * Catching invisible edits::    Preventing mistakes when editing invisible parts
369 Global and local cycling
371 * Initial visibility::          Setting the initial visibility state
372 * Catching invisible edits::    Preventing mistakes when editing invisible parts
374 Tables
376 * Built-in table editor::       Simple tables
377 * Column width and alignment::  Overrule the automatic settings
378 * Column groups::               Grouping to trigger vertical lines
379 * Orgtbl mode::                 The table editor as minor mode
380 * The spreadsheet::             The table editor has spreadsheet capabilities
381 * Org-Plot::                    Plotting from org tables
383 The spreadsheet
385 * References::                  How to refer to another field or range
386 * Formula syntax for Calc::     Using Calc to compute stuff
387 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
388 * Durations and time values::   How to compute durations and time values
389 * Field and range formulas::    Formula for specific (ranges of) fields
390 * Column formulas::             Formulas valid for an entire column
391 * Lookup functions::            Lookup functions for searching tables
392 * Editing and debugging formulas::  Fixing formulas
393 * Updating the table::          Recomputing all dependent fields
394 * Advanced features::           Field and column names, parameters and automatic recalc
396 Hyperlinks
398 * Link format::                 How links in Org are formatted
399 * Internal links::              Links to other places in the current file
400 * External links::              URL-like links to the world
401 * Handling links::              Creating, inserting and following
402 * Using links outside Org::     Linking from my C source code?
403 * Link abbreviations::          Shortcuts for writing complex links
404 * Search options::              Linking to a specific location
405 * Custom searches::             When the default search is not enough
407 Internal links
409 * Radio targets::               Make targets trigger links in plain text
411 TODO items
413 * TODO basics::                 Marking and displaying TODO entries
414 * TODO extensions::             Workflow and assignments
415 * Progress logging::            Dates and notes for progress
416 * Priorities::                  Some things are more important than others
417 * Breaking down tasks::         Splitting a task into manageable pieces
418 * Checkboxes::                  Tick-off lists
420 Extended use of TODO keywords
422 * Workflow states::             From TODO to DONE in steps
423 * TODO types::                  I do this, Fred does the rest
424 * Multiple sets in one file::   Mixing it all, and still finding your way
425 * Fast access to TODO states::  Single letter selection of a state
426 * Per-file keywords::           Different files, different requirements
427 * Faces for TODO keywords::     Highlighting states
428 * TODO dependencies::           When one task needs to wait for others
430 Progress logging
432 * Closing items::               When was this entry marked DONE?
433 * Tracking TODO state changes::  When did the status change?
434 * Tracking your habits::        How consistent have you been?
436 Tags
438 * Tag inheritance::             Tags use the tree structure of the outline
439 * Setting tags::                How to assign tags to a headline
440 * Tag searches::                Searching for combinations of tags
442 Properties and columns
444 * Property syntax::             How properties are spelled out
445 * Special properties::          Access to other Org mode features
446 * Property searches::           Matching property values
447 * Property inheritance::        Passing values down the tree
448 * Column view::                 Tabular viewing and editing
449 * Property API::                Properties for Lisp programmers
451 Column view
453 * Defining columns::            The COLUMNS format property
454 * Using column view::           How to create and use column view
455 * Capturing column view::       A dynamic block for column view
457 Defining columns
459 * Scope of column definitions::  Where defined, where valid?
460 * Column attributes::           Appearance and content of a column
462 Dates and times
464 * Timestamps::                  Assigning a time to a tree entry
465 * Creating timestamps::         Commands which insert timestamps
466 * Deadlines and scheduling::    Planning your work
467 * Clocking work time::          Tracking how long you spend on a task
468 * Effort estimates::            Planning work effort in advance
469 * Relative timer::              Notes with a running timer
470 * Countdown timer::             Starting a countdown timer for a task
472 Creating timestamps
474 * The date/time prompt::        How Org mode helps you entering date and time
475 * Custom time format::          Making dates look different
477 Deadlines and scheduling
479 * Inserting deadline/schedule::  Planning items
480 * Repeated tasks::              Items that show up again and again
482 Clocking work time
484 * Clocking commands::           Starting and stopping a clock
485 * The clock table::             Detailed reports
486 * Resolving idle time::         Resolving time when you've been idle
488 Capture - Refile - Archive
490 * Capture::                     Capturing new stuff
491 * Attachments::                 Add files to tasks
492 * RSS Feeds::                   Getting input from RSS feeds
493 * Protocols::                   External (e.g., Browser) access to Emacs and Org
494 * Refile and copy::             Moving/copying a tree from one place to another
495 * Archiving::                   What to do with finished projects
497 Capture
499 * Setting up capture::          Where notes will be stored
500 * Using capture::               Commands to invoke and terminate capture
501 * Capture templates::           Define the outline of different note types
503 Capture templates
505 * Template elements::           What is needed for a complete template entry
506 * Template expansion::          Filling in information about time and context
507 * Templates in contexts::       Only show a template in a specific context
509 Archiving
511 * Moving subtrees::             Moving a tree to an archive file
512 * Internal archiving::          Switch off a tree but keep it in the file
514 Agenda views
516 * Agenda files::                Files being searched for agenda information
517 * Agenda dispatcher::           Keyboard access to agenda views
518 * Built-in agenda views::       What is available out of the box?
519 * Presentation and sorting::    How agenda items are prepared for display
520 * Agenda commands::             Remote editing of Org trees
521 * Custom agenda views::         Defining special searches and views
522 * Exporting Agenda Views::      Writing a view to a file
523 * Agenda column view::          Using column view for collected entries
525 The built-in agenda views
527 * Weekly/daily agenda::         The calendar page with current tasks
528 * Global TODO list::            All unfinished action items
529 * Matching tags and properties::  Structured information with fine-tuned search
530 * Timeline::                    Time-sorted view for single file
531 * Search view::                 Find entries by searching for text
532 * Stuck projects::              Find projects you need to review
534 Presentation and sorting
536 * Categories::                  Not all tasks are equal
537 * Time-of-day specifications::  How the agenda knows the time
538 * Sorting of agenda items::     The order of things
540 Custom agenda views
542 * Storing searches::            Type once, use often
543 * Block agenda::                All the stuff you need in a single buffer
544 * Setting Options::             Changing the rules
546 Markup for rich export
548 * Structural markup elements::  The basic structure as seen by the exporter
549 * Images and tables::           Tables and Images will be included
550 * Literal examples::            Source code examples with special formatting
551 * Include files::               Include additional files into a document
552 * Index entries::               Making an index
553 * Macro replacement::           Use macros to create complex output
554 * Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
556 Structural markup elements
558 * Document title::              Where the title is taken from
559 * Headings and sections::       The document structure as seen by the exporter
560 * Table of contents::           The if and where of the table of contents
561 * Lists::                       Lists
562 * Paragraphs::                  Paragraphs
563 * Footnote markup::             Footnotes
564 * Emphasis and monospace::      Bold, italic, etc.
565 * Horizontal rules::            Make a line
566 * Comment lines::               What will *not* be exported
568 Embedded @LaTeX{}
570 * Special symbols::             Greek letters and other symbols
571 * Subscripts and superscripts::  Simple syntax for raising/lowering text
572 * @LaTeX{} fragments::          Complex formulas made easy
573 * Previewing @LaTeX{} fragments::  What will this snippet look like?
574 * CDLaTeX mode::                Speed up entering of formulas
576 Exporting
578 * Selective export::            Using tags to select and exclude trees
579 * Export options::              Per-file export settings
580 * The export dispatcher::       How to access exporter commands
581 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
582 * HTML export::                 Exporting to HTML
583 * @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
584 * OpenDocument Text export::    Exporting to OpenDocument Text
585 * iCalendar export::            Exporting in iCalendar format
587 HTML export
589 * HTML Export commands::        How to invoke HTML export
590 * HTML preamble and postamble::  How to insert a preamble and a postamble
591 * Quoting HTML tags::           Using direct HTML in Org mode
592 * Links in HTML export::        How links will be interpreted and formatted
593 * Tables in HTML export::       How to modify the formatting of tables
594 * Images in HTML export::       How to insert figures into HTML output
595 * Math formatting in HTML export::  Beautiful math also on the web
596 * Text areas in HTML export::   An alternative way to show an example
597 * CSS support::                 Changing the appearance of the output
598 * JavaScript support::          Info and Folding in a web browser
600 @LaTeX{} and PDF export
602 * @LaTeX{}/PDF export commands::
603 * Header and sectioning::       Setting up the export file structure
604 * Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
605 * Tables in @LaTeX{} export::   Options for exporting tables to @LaTeX{}
606 * Images in @LaTeX{} export::   How to insert figures into @LaTeX{} output
607 * Beamer class export::         Turning the file into a presentation
609 OpenDocument Text export
611 * Pre-requisites for ODT export::  What packages ODT exporter relies on
612 * ODT export commands::         How to invoke ODT export
613 * Extending ODT export::        How to produce @samp{doc}, @samp{pdf} files
614 * Applying custom styles::      How to apply custom styles to the output
615 * Links in ODT export::         How links will be interpreted and formatted
616 * Tables in ODT export::        How Tables are exported
617 * Images in ODT export::        How to insert images
618 * Math formatting in ODT export::  How @LaTeX{} fragments are formatted
619 * Labels and captions in ODT export::  How captions are rendered
620 * Literal examples in ODT export::  How source and example blocks are formatted
621 * Advanced topics in ODT export::  Read this if you are a power user
623 Math formatting in ODT export
625 * Working with @LaTeX{} math snippets::  How to embed @LaTeX{} math fragments
626 * Working with MathML or OpenDocument formula files::  How to embed equations in native format
628 Advanced topics in ODT export
630 * Configuring a document converter::  How to register a document converter
631 * Working with OpenDocument style files::  Explore the internals
632 * Creating one-off styles::     How to produce custom highlighting etc
633 * Customizing tables in ODT export::  How to define and use Table templates
634 * Validating OpenDocument XML::  How to debug corrupt OpenDocument files
636 Publishing
638 * Configuration::               Defining projects
639 * Uploading files::             How to get files up on the server
640 * Sample configuration::        Example projects
641 * Triggering publication::      Publication commands
643 Configuration
645 * Project alist::               The central configuration variable
646 * Sources and destinations::    From here to there
647 * Selecting files::             What files are part of the project?
648 * Publishing action::           Setting the function doing the publishing
649 * Publishing options::          Tweaking HTML/@LaTeX{} export
650 * Publishing links::            Which links keep working after publishing?
651 * Sitemap::                     Generating a list of all pages
652 * Generating an index::         An index that reaches across pages
654 Sample configuration
656 * Simple example::              One-component publishing
657 * Complex example::             A multi-component publishing example
659 Working with source code
661 * Structure of code blocks::    Code block syntax described
662 * Editing source code::         Language major-mode editing
663 * Exporting code blocks::       Export contents and/or results
664 * Extracting source code::      Create pure source code files
665 * Evaluating code blocks::      Place results of evaluation in the Org mode buffer
666 * Library of Babel::            Use and contribute to a library of useful code blocks
667 * Languages::                   List of supported code block languages
668 * Header arguments::            Configure code block functionality
669 * Results of evaluation::       How evaluation results are handled
670 * Noweb reference syntax::      Literate programming in Org mode
671 * Key bindings and useful functions::  Work quickly with code blocks
672 * Batch execution::             Call functions from the command line
674 Header arguments
676 * Using header arguments::      Different ways to set header arguments
677 * Specific header arguments::   List of header arguments
679 Using header arguments
681 * System-wide header arguments::  Set global default values
682 * Language-specific header arguments::  Set default values by language
683 * Buffer-wide header arguments::  Set default values for a specific buffer
684 * Header arguments in Org mode properties::  Set default values for a buffer or heading
685 * Code block specific header arguments::  The most common way to set values
686 * Header arguments in function calls::  The most specific level
688 Specific header arguments
690 * var::                         Pass arguments to code blocks
691 * results::                     Specify the type of results and how they will
692                                 be collected and handled
693 * file::                        Specify a path for file output
694 * file-desc::                   Specify a description for file results
695 * dir::                         Specify the default (possibly remote)
696                                 directory for code block execution
697 * exports::                     Export code and/or results
698 * tangle::                      Toggle tangling and specify file name
699 * mkdirp::                      Toggle creation of parent directories of target
700                                 files during tangling
701 * comments::                    Toggle insertion of comments in tangled
702                                 code files
703 * padline::                     Control insertion of padding lines in tangled
704                                 code files
705 * no-expand::                   Turn off variable assignment and noweb
706                                 expansion during tangling
707 * session::                     Preserve the state of code evaluation
708 * noweb::                       Toggle expansion of noweb references
709 * noweb-ref::                   Specify block's noweb reference resolution target
710 * noweb-sep::                   String used to separate noweb references
711 * cache::                       Avoid re-evaluating unchanged code blocks
712 * sep::                         Delimiter for writing tabular results outside Org
713 * hlines::                      Handle horizontal lines in tables
714 * colnames::                    Handle column names in tables
715 * rownames::                    Handle row names in tables
716 * shebang::                     Make tangled files executable
717 * eval::                        Limit evaluation of specific code blocks
718 * wrap::                        Mark source block evaluation results
720 Miscellaneous
722 * Completion::                  M-TAB knows what you need
723 * Easy Templates::              Quick insertion of structural elements
724 * Speed keys::                  Electric commands at the beginning of a headline
725 * Code evaluation security::    Org mode files evaluate inline code
726 * Customization::               Adapting Org to your taste
727 * In-buffer settings::          Overview of the #+KEYWORDS
728 * The very busy C-c C-c key::   When in doubt, press C-c C-c
729 * Clean view::                  Getting rid of leading stars in the outline
730 * TTY keys::                    Using Org on a tty
731 * Interaction::                 Other Emacs packages
732 * org-crypt.el::                Encrypting Org files
734 Interaction with other packages
736 * Cooperation::                 Packages Org cooperates with
737 * Conflicts::                   Packages that lead to conflicts
739 Hacking
741 * Hooks::                       How to reach into Org's internals
742 * Add-on packages::             Available extensions
743 * Adding hyperlink types::      New custom link types
744 * Context-sensitive commands::  How to add functionality to such commands
745 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
746 * Dynamic blocks::              Automatically filled blocks
747 * Special agenda views::        Customized views
748 * Speeding up your agendas::    Tips on how to speed up your agendas
749 * Extracting agenda information::  Postprocessing of agenda information
750 * Using the property API::      Writing programs that use entry properties
751 * Using the mapping API::       Mapping over all or selected entries
753 Tables and lists in arbitrary syntax
755 * Radio tables::                Sending and receiving radio tables
756 * A @LaTeX{} example::          Step by step, almost a tutorial
757 * Translator functions::        Copy and modify
758 * Radio lists::                 Doing the same for lists
760 MobileOrg
762 * Setting up the staging area::  Where to interact with the mobile device
763 * Pushing to MobileOrg::        Uploading Org files and agendas
764 * Pulling from MobileOrg::      Integrating captured and flagged items
766 @end detailmenu
767 @end menu
769 @node Introduction, Document Structure, Top, Top
770 @chapter Introduction
771 @cindex introduction
773 @menu
774 * Summary::                     Brief summary of what Org does
775 * Installation::                Installing Org
776 * Activation::                  How to activate Org for certain buffers
777 * Feedback::                    Bug reports, ideas, patches etc.
778 * Conventions::                 Typesetting conventions in the manual
779 @end menu
781 @node Summary, Installation, Introduction, Introduction
782 @section Summary
783 @cindex summary
785 Org is a mode for keeping notes, maintaining TODO lists, and doing
786 project planning with a fast and effective plain-text system.
788 Org develops organizational tasks around NOTES files that contain
789 lists or information about projects as plain text.  Org is
790 implemented on top of Outline mode, which makes it possible to keep the
791 content of large files well structured.  Visibility cycling and
792 structure editing help to work with the tree.  Tables are easily created
793 with a built-in table editor.  Org supports TODO items, deadlines,
794 timestamps, and scheduling.  It dynamically compiles entries into an
795 agenda that utilizes and smoothly integrates much of the Emacs calendar
796 and diary.  Plain text URL-like links connect to websites, emails,
797 Usenet messages, BBDB entries, and any files related to the projects.
798 For printing and sharing notes, an Org file can be exported as a
799 structured ASCII file, as HTML, or (TODO and agenda items only) as an
800 iCalendar file.  It can also serve as a publishing tool for a set of
801 linked web pages.
803 As a project planning environment, Org works by adding metadata to outline
804 nodes.  Based on this data, specific entries can be extracted in queries and
805 create dynamic @i{agenda views}.
807 Org mode contains the Org Babel environment which allows you to work with
808 embedded source code blocks in a file, to facilitate code evaluation,
809 documentation, and literate programming techniques.
811 Org's automatic, context-sensitive table editor with spreadsheet
812 capabilities can be integrated into any major mode by activating the
813 minor Orgtbl mode.  Using a translation step, it can be used to maintain
814 tables in arbitrary file types, for example in @LaTeX{}.  The structure
815 editing and list creation capabilities can be used outside Org with
816 the minor Orgstruct mode.
818 Org keeps simple things simple.  When first fired up, it should
819 feel like a straightforward, easy to use outliner.  Complexity is not
820 imposed, but a large amount of functionality is available when you need
821 it.  Org is a toolbox and can be used in different ways and for different
822 ends, for example:
824 @example
825 @r{@bullet{} an outline extension with visibility cycling and structure editing}
826 @r{@bullet{} an ASCII system and table editor for taking structured notes}
827 @r{@bullet{} a TODO list editor}
828 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
829 @pindex GTD, Getting Things Done
830 @r{@bullet{} an environment in which to implement David Allen's GTD system}
831 @r{@bullet{} a simple hypertext system, with HTML and @LaTeX{} export}
832 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
833 @r{@bullet{} an environment for literate programming}
834 @end example
836 @cindex FAQ
837 There is a website for Org which provides links to the newest
838 version of Org, as well as additional information, frequently asked
839 questions (FAQ), links to tutorials, etc.  This page is located at
840 @uref{http://orgmode.org}.
842 @cindex print edition
843 The version 7.3 of this manual is available as a
844 @uref{http://www.network-theory.co.uk/org/manual/, paperback book from Network
845 Theory Ltd.}
847 @page
850 @node Installation, Activation, Summary, Introduction
851 @section Installation
852 @cindex installation
853 @cindex XEmacs
855 Org is part of recent distributions of GNU Emacs, so you normally don't need
856 to install it.  If, for one reason or another, you want to install Org on top
857 of this pre-packaged version, there are three ways to do it:
859 @itemize @bullet
860 @item By using Emacs package system.
861 @item By downloading Org as an archive.
862 @item By using Org's git repository.
863 @end itemize
865 We @b{strongly recommend} to stick to a single installation method.
867 @subsubheading Using Emacs packaging system
869 Recent Emacs distributions include a packaging system which lets you install
870 Elisp libraries.  You can install Org with @kbd{M-x package-install RET org}.
871 You need to do this in a session where no @code{.org} file has been visited.
872 Then, to make sure your Org configuration is taken into account, initialize
873 the package system with @code{(package-initialize)} in your @file{.emacs}
874 before setting any Org option.  If you want to use Org's package repository,
875 check out the @uref{http://orgmode.org/elpa.html, Org ELPA page}.
877 @subsubheading Downloading Org as an archive
879 You can download Org latest release from @uref{http://orgmode.org/, Org's
880 website}.  In this case, make sure you set the load-path correctly in your
881 @file{.emacs}:
883 @example
884 (add-to-list 'load-path "~/path/to/orgdir/lisp")
885 @end example
887 The downloaded archive contains contributed libraries that are not included
888 in Emacs.  If you want to use them, add the @file{contrib} directory to your
889 load-path:
891 @example
892 (add-to-list 'load-path "~/path/to/orgdir/contrib/lisp" t)
893 @end example
895 Optionally, you can compile the files and/or install them in your system.
896 Run @code{make help} to list compilation and installation options.
898 @subsubheading Using Org's git repository
900 You can clone Org's repository and install Org like this:
902 @example
903 $ cd ~/src/
904 $ git clone git://orgmode.org/org-mode.git
905 $ make autoloads
906 @end example
908 Note that in this case, @code{make autoloads} is mandatory: it defines Org's
909 version in @file{org-version.el} and Org's autoloads in
910 @file{org-loaddefs.el}.
912 Remember to add the correct load-path as described in the method above.
914 You can also compile with @code{make}, generate the documentation with
915 @code{make doc}, create a local configuration with @code{make config} and
916 install Org with @code{make install}.  Please run @code{make help} to get
917 the list of compilation/installation options.
919 For more detailed explanations on Org's build system, please check the Org
920 Build System page on @uref{http://orgmode.org/worg/dev/org-build-system.html,
921 Worg}.
923 @node Activation, Feedback, Installation, Introduction
924 @section Activation
925 @cindex activation
926 @cindex autoload
927 @cindex ELPA
928 @cindex global key bindings
929 @cindex key bindings, global
930 @findex org-agenda
931 @findex org-capture
932 @findex org-store-link
933 @findex org-iswitchb
935 Since Emacs 22.2, files with the @file{.org} extension use Org mode by
936 default.  If you are using an earlier version of Emacs, add this line to your
937 @file{.emacs} file:
939 @lisp
940 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
941 @end lisp
943 Org mode buffers need font-lock to be turned on: this is the default in
944 Emacs@footnote{If you don't use font-lock globally, turn it on in Org buffer
945 with @code{(add-hook 'org-mode-hook 'turn-on-font-lock)}}.
947 There are compatibility issues between Org mode and some other Elisp
948 packages, please take the time to check the list (@pxref{Conflicts}).
950 The four Org commands @command{org-store-link}, @command{org-capture},
951 @command{org-agenda}, and @command{org-iswitchb} should be accessible through
952 global keys (i.e., anywhere in Emacs, not just in Org buffers).  Here are
953 suggested bindings for these keys, please modify the keys to your own
954 liking.
955 @lisp
956 (global-set-key "\C-cl" 'org-store-link)
957 (global-set-key "\C-cc" 'org-capture)
958 (global-set-key "\C-ca" 'org-agenda)
959 (global-set-key "\C-cb" 'org-iswitchb)
960 @end lisp
962 @cindex Org mode, turning on
963 With this setup, all files with extension @samp{.org} will be put
964 into Org mode.  As an alternative, make the first line of a file look
965 like this:
967 @example
968 MY PROJECTS    -*- mode: org; -*-
969 @end example
971 @vindex org-insert-mode-line-in-empty-file
972 @noindent which will select Org mode for this buffer no matter what
973 the file's name is.  See also the variable
974 @code{org-insert-mode-line-in-empty-file}.
976 Many commands in Org work on the region if the region is @i{active}.  To make
977 use of this, you need to have @code{transient-mark-mode}
978 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
979 in Emacs 22 you need to do this yourself with
980 @lisp
981 (transient-mark-mode 1)
982 @end lisp
983 @noindent If you do not like @code{transient-mark-mode}, you can create an
984 active region by using the mouse to select a region, or pressing
985 @kbd{C-@key{SPC}} twice before moving the cursor.
987 @node Feedback, Conventions, Activation, Introduction
988 @section Feedback
989 @cindex feedback
990 @cindex bug reports
991 @cindex maintainer
992 @cindex author
994 If you find problems with Org, or if you have questions, remarks, or ideas
995 about it, please mail to the Org mailing list @email{emacs-orgmode@@gnu.org}.
996 If you are not a member of the mailing list, your mail will be passed to the
997 list after a moderator has approved it@footnote{Please consider subscribing
998 to the mailing list, in order to minimize the work the mailing list
999 moderators have to do.}.
1001 For bug reports, please first try to reproduce the bug with the latest
1002 version of Org available---if you are running an outdated version, it is
1003 quite possible that the bug has been fixed already.  If the bug persists,
1004 prepare a report and provide as much information as possible, including the
1005 version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
1006 (@kbd{M-x org-version @key{RET}}), as well as the Org related setup in
1007 @file{.emacs}.  The easiest way to do this is to use the command
1008 @example
1009 @kbd{M-x org-submit-bug-report}
1010 @end example
1011 @noindent which will put all this information into an Emacs mail buffer so
1012 that you only need to add your description.  If you re not sending the Email
1013 from within Emacs, please copy and paste the content into your Email program.
1015 Sometimes you might face a problem due to an error in your Emacs or Org mode
1016 setup.  Before reporting a bug, it is very helpful to start Emacs with minimal
1017 customizations and reproduce the problem.  Doing so often helps you determine
1018 if the problem is with your customization or with Org mode itself.  You can
1019 start a typical minimal session with a command like the example below.
1021 @example
1022 $ emacs -Q -l /path/to/minimal-org.el
1023 @end example
1025 However if you are using Org mode as distributed with Emacs, a minimal setup
1026 is not necessary.  In that case it is sufficient to start Emacs as
1027 @code{emacs -Q}.  The @code{minimal-org.el} setup file can have contents as
1028 shown below.
1030 @example
1031 ;;; Minimal setup to load latest `org-mode'
1033 ;; activate debugging
1034 (setq debug-on-error t
1035       debug-on-signal nil
1036       debug-on-quit nil)
1038 ;; add latest org-mode to load path
1039 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
1040 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
1041 @end example
1043 If an error occurs, a backtrace can be very useful (see below on how to
1044 create one).  Often a small example file helps, along with clear information
1045 about:
1047 @enumerate
1048 @item What exactly did you do?
1049 @item What did you expect to happen?
1050 @item What happened instead?
1051 @end enumerate
1052 @noindent Thank you for helping to improve this program.
1054 @subsubheading How to create a useful backtrace
1056 @cindex backtrace of an error
1057 If working with Org produces an error with a message you don't
1058 understand, you may have hit a bug.  The best way to report this is by
1059 providing, in addition to what was mentioned above, a @emph{backtrace}.
1060 This is information from the built-in debugger about where and how the
1061 error occurred.  Here is how to produce a useful backtrace:
1063 @enumerate
1064 @item
1065 Reload uncompiled versions of all Org mode Lisp files.  The backtrace
1066 contains much more information if it is produced with uncompiled code.
1067 To do this, use
1068 @example
1069 C-u M-x org-reload RET
1070 @end example
1071 @noindent
1072 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
1073 menu.
1074 @item
1075 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
1076 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
1077 @item
1078 Do whatever you have to do to hit the error.  Don't forget to
1079 document the steps you take.
1080 @item
1081 When you hit the error, a @file{*Backtrace*} buffer will appear on the
1082 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
1083 attach it to your bug report.
1084 @end enumerate
1086 @node Conventions,  , Feedback, Introduction
1087 @section Typesetting conventions used in this manual
1089 @subsubheading TODO keywords, tags, properties, etc.
1091 Org mainly uses three types of keywords: TODO keywords, tags and property
1092 names.  In this manual we use the following conventions:
1094 @table @code
1095 @item TODO
1096 @itemx WAITING
1097 TODO keywords are written with all capitals, even if they are
1098 user-defined.
1099 @item boss
1100 @itemx ARCHIVE
1101 User-defined tags are written in lowercase; built-in tags with special
1102 meaning are written with all capitals.
1103 @item Release
1104 @itemx PRIORITY
1105 User-defined properties are capitalized; built-in properties with
1106 special meaning are written with all capitals.
1107 @end table
1109 Moreover, Org uses @i{option keywords} (like @code{#+TITLE} to set the title)
1110 and @i{environment keywords} (like @code{#+BEGIN_HTML} to start a @code{HTML}
1111 environment).  They are written in uppercase in the manual to enhance its
1112 readability, but you can use lowercase in your Org files@footnote{Easy
1113 templates insert lowercase keywords and Babel dynamically inserts
1114 @code{#+results}.}
1116 @subsubheading Keybindings and commands
1117 @kindex C-c a
1118 @findex org-agenda
1119 @kindex C-c c
1120 @findex org-capture
1122 The manual suggests two global keybindings: @kbd{C-c a} for @code{org-agenda}
1123 and @kbd{C-c c} for @code{org-capture}.  These are only suggestions, but the
1124 rest of the manual assumes that you are using these keybindings.
1126 Also, the manual lists both the keys and the corresponding commands for
1127 accessing a functionality.  Org mode often uses the same key for different
1128 functions, depending on context.  The command that is bound to such keys has
1129 a generic name, like @code{org-metaright}.  In the manual we will, wherever
1130 possible, give the function that is internally called by the generic command.
1131 For example, in the chapter on document structure, @kbd{M-@key{right}} will
1132 be listed to call @code{org-do-demote}, while in the chapter on tables, it
1133 will be listed to call @code{org-table-move-column-right}.  If you prefer,
1134 you can compile the manual without the command names by unsetting the flag
1135 @code{cmdnames} in @file{org.texi}.
1137 @node Document Structure, Tables, Introduction, Top
1138 @chapter Document structure
1139 @cindex document structure
1140 @cindex structure of document
1142 Org is based on Outline mode and provides flexible commands to
1143 edit the structure of the document.
1145 @menu
1146 * Outlines::                    Org is based on Outline mode
1147 * Headlines::                   How to typeset Org tree headlines
1148 * Visibility cycling::          Show and hide, much simplified
1149 * Motion::                      Jumping to other headlines
1150 * Structure editing::           Changing sequence and level of headlines
1151 * Sparse trees::                Matches embedded in context
1152 * Plain lists::                 Additional structure within an entry
1153 * Drawers::                     Tucking stuff away
1154 * Blocks::                      Folding blocks
1155 * Footnotes::                   How footnotes are defined in Org's syntax
1156 * Orgstruct mode::              Structure editing outside Org
1157 * Org syntax::                  Formal description of Org's syntax
1158 @end menu
1160 @node Outlines, Headlines, Document Structure, Document Structure
1161 @section Outlines
1162 @cindex outlines
1163 @cindex Outline mode
1165 Org is implemented on top of Outline mode.  Outlines allow a
1166 document to be organized in a hierarchical structure, which (at least
1167 for me) is the best representation of notes and thoughts.  An overview
1168 of this structure is achieved by folding (hiding) large parts of the
1169 document to show only the general document structure and the parts
1170 currently being worked on.  Org greatly simplifies the use of
1171 outlines by compressing the entire show/hide functionality into a single
1172 command, @command{org-cycle}, which is bound to the @key{TAB} key.
1174 @node Headlines, Visibility cycling, Outlines, Document Structure
1175 @section Headlines
1176 @cindex headlines
1177 @cindex outline tree
1178 @vindex org-special-ctrl-a/e
1179 @vindex org-special-ctrl-k
1180 @vindex org-ctrl-k-protect-subtree
1182 Headlines define the structure of an outline tree.  The headlines in Org
1183 start with one or more stars, on the left margin@footnote{See the variables
1184 @code{org-special-ctrl-a/e}, @code{org-special-ctrl-k}, and
1185 @code{org-ctrl-k-protect-subtree} to configure special behavior of @kbd{C-a},
1186 @kbd{C-e}, and @kbd{C-k} in headlines.} @footnote{Clocking only works with
1187 headings indented less then 30 stars.}.  For example:
1189 @example
1190 * Top level headline
1191 ** Second level
1192 *** 3rd level
1193     some text
1194 *** 3rd level
1195     more text
1197 * Another top level headline
1198 @end example
1200 @noindent Some people find the many stars too noisy and would prefer an
1201 outline that has whitespace followed by a single star as headline
1202 starters.  @ref{Clean view}, describes a setup to realize this.
1204 @vindex org-cycle-separator-lines
1205 An empty line after the end of a subtree is considered part of it and
1206 will be hidden when the subtree is folded.  However, if you leave at
1207 least two empty lines, one empty line will remain visible after folding
1208 the subtree, in order to structure the collapsed view.  See the
1209 variable @code{org-cycle-separator-lines} to modify this behavior.
1211 @node Visibility cycling, Motion, Headlines, Document Structure
1212 @section Visibility cycling
1213 @cindex cycling, visibility
1214 @cindex visibility cycling
1215 @cindex trees, visibility
1216 @cindex show hidden text
1217 @cindex hide text
1219 @menu
1220 * Global and local cycling::    Cycling through various visibility states
1221 * Initial visibility::          Setting the initial visibility state
1222 * Catching invisible edits::    Preventing mistakes when editing invisible parts
1223 @end menu
1225 @node Global and local cycling, Initial visibility, Visibility cycling, Visibility cycling
1226 @subsection Global and local cycling
1228 Outlines make it possible to hide parts of the text in the buffer.
1229 Org uses just two commands, bound to @key{TAB} and
1230 @kbd{S-@key{TAB}} to change the visibility in the buffer.
1232 @cindex subtree visibility states
1233 @cindex subtree cycling
1234 @cindex folded, subtree visibility state
1235 @cindex children, subtree visibility state
1236 @cindex subtree, subtree visibility state
1237 @table @asis
1238 @orgcmd{@key{TAB},org-cycle}
1239 @emph{Subtree cycling}: Rotate current subtree among the states
1241 @example
1242 ,-> FOLDED -> CHILDREN -> SUBTREE --.
1243 '-----------------------------------'
1244 @end example
1246 @vindex org-cycle-emulate-tab
1247 @vindex org-cycle-global-at-bob
1248 The cursor must be on a headline for this to work@footnote{see, however,
1249 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
1250 beginning of the buffer and the first line is not a headline, then
1251 @key{TAB} actually runs global cycling (see below)@footnote{see the
1252 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
1253 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
1255 @cindex global visibility states
1256 @cindex global cycling
1257 @cindex overview, global visibility state
1258 @cindex contents, global visibility state
1259 @cindex show all, global visibility state
1260 @orgcmd{S-@key{TAB},org-global-cycle}
1261 @itemx C-u @key{TAB}
1262 @emph{Global cycling}: Rotate the entire buffer among the states
1264 @example
1265 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
1266 '--------------------------------------'
1267 @end example
1269 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
1270 CONTENTS view up to headlines of level N will be shown.  Note that inside
1271 tables, @kbd{S-@key{TAB}} jumps to the previous field.
1273 @cindex show all, command
1274 @orgcmd{C-u C-u C-u @key{TAB},show-all}
1275 Show all, including drawers.
1276 @cindex revealing context
1277 @orgcmd{C-c C-r,org-reveal}
1278 Reveal context around point, showing the current entry, the following heading
1279 and the hierarchy above.  Useful for working near a location that has been
1280 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
1281 (@pxref{Agenda commands}).  With a prefix argument show, on each
1282 level, all sibling headings.  With a double prefix argument, also show the
1283 entire subtree of the parent.
1284 @cindex show branches, command
1285 @orgcmd{C-c C-k,show-branches}
1286 Expose all the headings of the subtree, CONTENT view for just one subtree.
1287 @cindex show children, command
1288 @orgcmd{C-c @key{TAB},show-children}
1289 Expose all direct children of the subtree.  With a numeric prefix argument N,
1290 expose all children down to level N@.
1291 @orgcmd{C-c C-x b,org-tree-to-indirect-buffer}
1292 Show the current subtree in an indirect buffer@footnote{The indirect
1293 buffer
1294 @ifinfo
1295 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
1296 @end ifinfo
1297 @ifnotinfo
1298 (see the Emacs manual for more information about indirect buffers)
1299 @end ifnotinfo
1300 will contain the entire buffer, but will be narrowed to the current
1301 tree.  Editing the indirect buffer will also change the original buffer,
1302 but without affecting visibility in that buffer.}.  With a numeric
1303 prefix argument N, go up to level N and then take that tree.  If N is
1304 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
1305 the previously used indirect buffer.
1306 @orgcmd{C-c C-x v,org-copy-visible}
1307 Copy the @i{visible} text in the region into the kill ring.
1308 @end table
1310 @menu
1311 * Initial visibility::          Setting the initial visibility state
1312 * Catching invisible edits::    Preventing mistakes when editing invisible parts
1313 @end menu
1315 @node Initial visibility, Catching invisible edits, Global and local cycling, Visibility cycling
1316 @subsection Initial visibility
1318 @cindex visibility, initialize
1319 @vindex org-startup-folded
1320 @vindex org-agenda-inhibit-startup
1321 @cindex @code{overview}, STARTUP keyword
1322 @cindex @code{content}, STARTUP keyword
1323 @cindex @code{showall}, STARTUP keyword
1324 @cindex @code{showeverything}, STARTUP keyword
1326 When Emacs first visits an Org file, the global state is set to OVERVIEW,
1327 i.e., only the top level headlines are visible@footnote{When
1328 @code{org-agenda-inhibit-startup} is non-nil, Org will not honor the default
1329 visibility state when first opening a file for the agenda (@pxref{Speeding up
1330 your agendas}).}  This can be configured through the variable
1331 @code{org-startup-folded}, or on a per-file basis by adding one of the
1332 following lines anywhere in the buffer:
1334 @example
1335 #+STARTUP: overview
1336 #+STARTUP: content
1337 #+STARTUP: showall
1338 #+STARTUP: showeverything
1339 @end example
1341 The startup visibility options are ignored when the file is open for the
1342 first time during the agenda generation: if you want the agenda to honor
1343 the startup visibility, set @code{org-agenda-inhibit-startup} to nil.
1345 @cindex property, VISIBILITY
1346 @noindent
1347 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
1348 and Columns}) will get their visibility adapted accordingly.  Allowed values
1349 for this property are @code{folded}, @code{children}, @code{content}, and
1350 @code{all}.
1352 @table @asis
1353 @orgcmd{C-u C-u @key{TAB},org-set-startup-visibility}
1354 Switch back to the startup visibility of the buffer, i.e., whatever is
1355 requested by startup options and @samp{VISIBILITY} properties in individual
1356 entries.
1357 @end table
1359 @node Catching invisible edits,  , Initial visibility, Visibility cycling
1360 @subsection Catching invisible edits
1362 @vindex org-catch-invisible-edits
1363 @cindex edits, catching invisible
1364 Sometimes you may inadvertantly edit an invisible part of the buffer and be
1365 confused on what as been edited and how to undo the mistake.  Setting
1366 @code{org-catch-invisible-edits} to non-nil will help prevent this.  See the
1367 docstring of this option on how Org should catch invisible edits and process
1368 them.
1370 @node Motion, Structure editing, Visibility cycling, Document Structure
1371 @section Motion
1372 @cindex motion, between headlines
1373 @cindex jumping, to headlines
1374 @cindex headline navigation
1375 The following commands jump to other headlines in the buffer.
1377 @table @asis
1378 @orgcmd{C-c C-n,outline-next-visible-heading}
1379 Next heading.
1380 @orgcmd{C-c C-p,outline-previous-visible-heading}
1381 Previous heading.
1382 @orgcmd{C-c C-f,org-forward-same-level}
1383 Next heading same level.
1384 @orgcmd{C-c C-b,org-backward-same-level}
1385 Previous heading same level.
1386 @orgcmd{C-c C-u,outline-up-heading}
1387 Backward to higher level heading.
1388 @orgcmd{C-c C-j,org-goto}
1389 Jump to a different place without changing the current outline
1390 visibility.  Shows the document structure in a temporary buffer, where
1391 you can use the following keys to find your destination:
1392 @vindex org-goto-auto-isearch
1393 @example
1394 @key{TAB}         @r{Cycle visibility.}
1395 @key{down} / @key{up}   @r{Next/previous visible headline.}
1396 @key{RET}         @r{Select this location.}
1397 @kbd{/}           @r{Do a Sparse-tree search}
1398 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
1399 n / p        @r{Next/previous visible headline.}
1400 f / b        @r{Next/previous headline same level.}
1401 u            @r{One level up.}
1402 0-9          @r{Digit argument.}
1403 q            @r{Quit}
1404 @end example
1405 @vindex org-goto-interface
1406 @noindent
1407 See also the variable @code{org-goto-interface}.
1408 @end table
1410 @node Structure editing, Sparse trees, Motion, Document Structure
1411 @section Structure editing
1412 @cindex structure editing
1413 @cindex headline, promotion and demotion
1414 @cindex promotion, of subtrees
1415 @cindex demotion, of subtrees
1416 @cindex subtree, cut and paste
1417 @cindex pasting, of subtrees
1418 @cindex cutting, of subtrees
1419 @cindex copying, of subtrees
1420 @cindex sorting, of subtrees
1421 @cindex subtrees, cut and paste
1423 @table @asis
1424 @orgcmd{M-@key{RET},org-insert-heading}
1425 @vindex org-M-RET-may-split-line
1426 Insert a new heading/item with the same level than the one at point.
1427 If the cursor is in a plain list item, a new item is created
1428 (@pxref{Plain lists}).  To prevent this behavior in lists, call the
1429 command with a prefix argument.  When this command is used in the
1430 middle of a line, the line is split and the rest of the line becomes
1431 the new item or headline@footnote{If you do not want the line to be
1432 split, customize the variable @code{org-M-RET-may-split-line}.}.  If
1433 the command is used at the @emph{beginning} of a headline, the new
1434 headline is created before the current line.  If the command is used
1435 at the @emph{end} of a folded subtree (i.e., behind the ellipses at
1436 the end of a headline), then a headline like the current one will be
1437 inserted after the end of the subtree.  Calling this command with
1438 @kbd{C-u C-u} will inconditionnally respect the headline's content and
1439 create a new item at the end of the parent subtree.
1440 @orgcmd{C-@key{RET},org-insert-heading-respect-content}
1441 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
1442 current heading, the new heading is placed after the body instead of before
1443 it.  This command works from anywhere in the entry.
1444 @orgcmd{M-S-@key{RET},org-insert-todo-heading}
1445 @vindex org-treat-insert-todo-heading-as-state-change
1446 Insert new TODO entry with same level as current heading.  See also the
1447 variable @code{org-treat-insert-todo-heading-as-state-change}.
1448 @orgcmd{C-S-@key{RET},org-insert-todo-heading-respect-content}
1449 Insert new TODO entry with same level as current heading.  Like
1450 @kbd{C-@key{RET}}, the new headline will be inserted after the current
1451 subtree.
1452 @orgcmd{@key{TAB},org-cycle}
1453 In a new entry with no text yet, the first @key{TAB} demotes the entry to
1454 become a child of the previous one.  The next @key{TAB} makes it a parent,
1455 and so on, all the way to top level.  Yet another @key{TAB}, and you are back
1456 to the initial level.
1457 @orgcmd{M-@key{left},org-do-promote}
1458 Promote current heading by one level.
1459 @orgcmd{M-@key{right},org-do-demote}
1460 Demote current heading by one level.
1461 @orgcmd{M-S-@key{left},org-promote-subtree}
1462 Promote the current subtree by one level.
1463 @orgcmd{M-S-@key{right},org-demote-subtree}
1464 Demote the current subtree by one level.
1465 @orgcmd{M-S-@key{up},org-move-subtree-up}
1466 Move subtree up (swap with previous subtree of same
1467 level).
1468 @orgcmd{M-S-@key{down},org-move-subtree-down}
1469 Move subtree down (swap with next subtree of same level).
1470 @orgcmd{M-h,org-mark-element}
1471 Mark the element at point.  Hitting repeatedly will mark subsequent elements
1472 of the one just marked.  E.g., hitting @key{M-h} on a paragraph will mark it,
1473 hitting @key{M-h} immediately again will mark the next one.
1474 @orgcmd{C-c @@,org-mark-subtree}
1475 Mark the subtree at point.  Hitting repeatedly will mark subsequent subtrees
1476 of the same level than the marked subtree.
1477 @orgcmd{C-c C-x C-w,org-cut-subtree}
1478 Kill subtree, i.e., remove it from buffer but save in kill ring.
1479 With a numeric prefix argument N, kill N sequential subtrees.
1480 @orgcmd{C-c C-x M-w,org-copy-subtree}
1481 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
1482 sequential subtrees.
1483 @orgcmd{C-c C-x C-y,org-paste-subtree}
1484 Yank subtree from kill ring.  This does modify the level of the subtree to
1485 make sure the tree fits in nicely at the yank position.  The yank level can
1486 also be specified with a numeric prefix argument, or by yanking after a
1487 headline marker like @samp{****}.
1488 @orgcmd{C-y,org-yank}
1489 @vindex org-yank-adjusted-subtrees
1490 @vindex org-yank-folded-subtrees
1491 Depending on the variables @code{org-yank-adjusted-subtrees} and
1492 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
1493 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
1494 C-x C-y}.  With the default settings, no level adjustment will take place,
1495 but the yanked tree will be folded unless doing so would swallow text
1496 previously visible.  Any prefix argument to this command will force a normal
1497 @code{yank} to be executed, with the prefix passed along.  A good way to
1498 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
1499 yank, it will yank previous kill items plainly, without adjustment and
1500 folding.
1501 @orgcmd{C-c C-x c,org-clone-subtree-with-time-shift}
1502 Clone a subtree by making a number of sibling copies of it.  You will be
1503 prompted for the number of copies to make, and you can also specify if any
1504 timestamps in the entry should be shifted.  This can be useful, for example,
1505 to create a number of tasks related to a series of lectures to prepare.  For
1506 more details, see the docstring of the command
1507 @code{org-clone-subtree-with-time-shift}.
1508 @orgcmd{C-c C-w,org-refile}
1509 Refile entry or region to a different location.  @xref{Refile and copy}.
1510 @orgcmd{C-c ^,org-sort}
1511 Sort same-level entries.  When there is an active region, all entries in the
1512 region will be sorted.  Otherwise the children of the current headline are
1513 sorted.  The command prompts for the sorting method, which can be
1514 alphabetically, numerically, by time (first timestamp with active preferred,
1515 creation time, scheduled time, deadline time), by priority, by TODO keyword
1516 (in the sequence the keywords have been defined in the setup) or by the value
1517 of a property.  Reverse sorting is possible as well.  You can also supply
1518 your own function to extract the sorting key.  With a @kbd{C-u} prefix,
1519 sorting will be case-sensitive.
1520 @orgcmd{C-x n s,org-narrow-to-subtree}
1521 Narrow buffer to current subtree.
1522 @orgcmd{C-x n b,org-narrow-to-block}
1523 Narrow buffer to current block.
1524 @orgcmd{C-x n w,widen}
1525 Widen buffer to remove narrowing.
1526 @orgcmd{C-c *,org-toggle-heading}
1527 Turn a normal line or plain list item into a headline (so that it becomes a
1528 subheading at its location).  Also turn a headline into a normal line by
1529 removing the stars.  If there is an active region, turn all lines in the
1530 region into headlines.  If the first line in the region was an item, turn
1531 only the item lines into headlines.  Finally, if the first line is a
1532 headline, remove the stars from all headlines in the region.
1533 @end table
1535 @cindex region, active
1536 @cindex active region
1537 @cindex transient mark mode
1538 When there is an active region (Transient Mark mode), promotion and
1539 demotion work on all headlines in the region.  To select a region of
1540 headlines, it is best to place both point and mark at the beginning of a
1541 line, mark at the beginning of the first headline, and point at the line
1542 just after the last headline to change.  Note that when the cursor is
1543 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1544 functionality.
1547 @node Sparse trees, Plain lists, Structure editing, Document Structure
1548 @section Sparse trees
1549 @cindex sparse trees
1550 @cindex trees, sparse
1551 @cindex folding, sparse trees
1552 @cindex occur, command
1554 @vindex org-show-hierarchy-above
1555 @vindex org-show-following-heading
1556 @vindex org-show-siblings
1557 @vindex org-show-entry-below
1558 An important feature of Org mode is the ability to construct @emph{sparse
1559 trees} for selected information in an outline tree, so that the entire
1560 document is folded as much as possible, but the selected information is made
1561 visible along with the headline structure above it@footnote{See also the
1562 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1563 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1564 control on how much context is shown around each match.}.  Just try it out
1565 and you will see immediately how it works.
1567 Org mode contains several commands creating such trees, all these
1568 commands can be accessed through a dispatcher:
1570 @table @asis
1571 @orgcmd{C-c /,org-sparse-tree}
1572 This prompts for an extra key to select a sparse-tree creating command.
1573 @orgcmd{C-c / r,org-occur}
1574 @vindex org-remove-highlights-with-change
1575 Prompts for a regexp and shows a sparse tree with all matches.  If
1576 the match is in a headline, the headline is made visible.  If the match is in
1577 the body of an entry, headline and body are made visible.  In order to
1578 provide minimal context, also the full hierarchy of headlines above the match
1579 is shown, as well as the headline following the match.  Each match is also
1580 highlighted; the highlights disappear when the buffer is changed by an
1581 editing command@footnote{This depends on the option
1582 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1583 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1584 so several calls to this command can be stacked.
1585 @orgcmdkkc{M-g n,M-g M-n,next-error}
1586 Jump to the next sparse tree match in this buffer.
1587 @orgcmdkkc{M-g p,M-g M-p,previous-error}
1588 Jump to the previous sparse tree match in this buffer.
1589 @end table
1592 @noindent
1593 @vindex org-agenda-custom-commands
1594 For frequently used sparse trees of specific search strings, you can
1595 use the variable @code{org-agenda-custom-commands} to define fast
1596 keyboard access to specific sparse trees.  These commands will then be
1597 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1598 For example:
1600 @lisp
1601 (setq org-agenda-custom-commands
1602       '(("f" occur-tree "FIXME")))
1603 @end lisp
1605 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1606 a sparse tree matching the string @samp{FIXME}.
1608 The other sparse tree commands select headings based on TODO keywords,
1609 tags, or properties and will be discussed later in this manual.
1611 @kindex C-c C-e v
1612 @cindex printing sparse trees
1613 @cindex visible text, printing
1614 To print a sparse tree, you can use the Emacs command
1615 @code{ps-print-buffer-with-faces} which does not print invisible parts
1616 of the document @footnote{This does not work under XEmacs, because
1617 XEmacs uses selective display for outlining, not text properties.}.
1618 Or you can use the command @kbd{C-c C-e v} to export only the visible
1619 part of the document and print the resulting file.
1621 @node Plain lists, Drawers, Sparse trees, Document Structure
1622 @section Plain lists
1623 @cindex plain lists
1624 @cindex lists, plain
1625 @cindex lists, ordered
1626 @cindex ordered lists
1628 Within an entry of the outline tree, hand-formatted lists can provide
1629 additional structure.  They also provide a way to create lists of checkboxes
1630 (@pxref{Checkboxes}).  Org supports editing such lists, and every exporter
1631 (@pxref{Exporting}) can parse and format them.
1633 Org knows ordered lists, unordered lists, and description lists.
1634 @itemize @bullet
1635 @item
1636 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1637 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1638 they will be seen as top-level headlines.  Also, when you are hiding leading
1639 stars to get a clean outline view, plain list items starting with a star may
1640 be hard to distinguish from true headlines.  In short: even though @samp{*}
1641 is supported, it may be better to not use it for plain list items.}  as
1642 bullets.
1643 @item
1644 @vindex org-plain-list-ordered-item-terminator
1645 @vindex org-alphabetical-lists
1646 @emph{Ordered} list items start with a numeral followed by either a period or
1647 a right parenthesis@footnote{You can filter out any of them by configuring
1648 @code{org-plain-list-ordered-item-terminator}.}, such as @samp{1.} or
1649 @samp{1)}@footnote{You can also get @samp{a.}, @samp{A.}, @samp{a)} and
1650 @samp{A)} by configuring @code{org-alphabetical-lists}.  To minimize
1651 confusion with normal text, those are limited to one character only.  Beyond
1652 that limit, bullets will automatically fallback to numbers.}.  If you want a
1653 list to start with a different value (e.g., 20), start the text of the item
1654 with @code{[@@20]}@footnote{If there's a checkbox in the item, the cookie
1655 must be put @emph{before} the checkbox.  If you have activated alphabetical
1656 lists, you can also use counters like @code{[@@b]}.}.  Those constructs can
1657 be used in any item of the list in order to enforce a particular numbering.
1658 @item
1659 @emph{Description} list items are unordered list items, and contain the
1660 separator @samp{ :: } to distinguish the description @emph{term} from the
1661 description.
1662 @end itemize
1664 Items belonging to the same list must have the same indentation on the first
1665 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1666 2--digit numbers must be written left-aligned with the other numbers in the
1667 list.  An item ends before the next line that is less or equally indented
1668 than its bullet/number.
1670 @vindex org-empty-line-terminates-plain-lists
1671 A list ends whenever every item has ended, which means before any line less
1672 or equally indented than items at top level.  It also ends before two blank
1673 lines@footnote{See also @code{org-empty-line-terminates-plain-lists}.}.  In
1674 that case, all items are closed.  Here is an example:
1676 @example
1677 @group
1678 ** Lord of the Rings
1679    My favorite scenes are (in this order)
1680    1. The attack of the Rohirrim
1681    2. Eowyn's fight with the witch king
1682       + this was already my favorite scene in the book
1683       + I really like Miranda Otto.
1684    3. Peter Jackson being shot by Legolas
1685       - on DVD only
1686       He makes a really funny face when it happens.
1687    But in the end, no individual scenes matter but the film as a whole.
1688    Important actors in this film are:
1689    - @b{Elijah Wood} :: He plays Frodo
1690    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1691      him very well from his role as Mikey Walsh in @i{The Goonies}.
1692 @end group
1693 @end example
1695 Org supports these lists by tuning filling and wrapping commands to deal with
1696 them correctly@footnote{Org only changes the filling settings for Emacs.  For
1697 XEmacs, you should use Kyle E. Jones' @file{filladapt.el}.  To turn this on,
1698 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
1699 properly (@pxref{Exporting}).  Since indentation is what governs the
1700 structure of these lists, many structural constructs like @code{#+BEGIN_...}
1701 blocks can be indented to signal that they belong to a particular item.
1703 @vindex org-list-demote-modify-bullet
1704 @vindex org-list-indent-offset
1705 If you find that using a different bullet for a sub-list (than that used for
1706 the current list-level) improves readability, customize the variable
1707 @code{org-list-demote-modify-bullet}.  To get a greater difference of
1708 indentation between items and theirs sub-items, customize
1709 @code{org-list-indent-offset}.
1711 @vindex org-list-automatic-rules
1712 The following commands act on items when the cursor is in the first line of
1713 an item (the line with the bullet or number).  Some of them imply the
1714 application of automatic rules to keep list structure intact.  If some of
1715 these actions get in your way, configure @code{org-list-automatic-rules}
1716 to disable them individually.
1718 @table @asis
1719 @orgcmd{@key{TAB},org-cycle}
1720 @cindex cycling, in plain lists
1721 @vindex org-cycle-include-plain-lists
1722 Items can be folded just like headline levels.  Normally this works only if
1723 the cursor is on a plain list item.  For more details, see the variable
1724 @code{org-cycle-include-plain-lists}.  If this variable is set to
1725 @code{integrate}, plain list items will be treated like low-level
1726 headlines.  The level of an item is then given by the indentation of the
1727 bullet/number.  Items are always subordinate to real headlines, however; the
1728 hierarchies remain completely separated.  In a new item with no text yet, the
1729 first @key{TAB} demotes the item to become a child of the previous
1730 one.  Subsequent @key{TAB}s move the item to meaningful levels in the list
1731 and eventually get it back to its initial position.
1732 @orgcmd{M-@key{RET},org-insert-heading}
1733 @vindex org-M-RET-may-split-line
1734 @vindex org-list-automatic-rules
1735 Insert new item at current level.  With a prefix argument, force a new
1736 heading (@pxref{Structure editing}).  If this command is used in the middle
1737 of an item, that item is @emph{split} in two, and the second part becomes the
1738 new item@footnote{If you do not want the item to be split, customize the
1739 variable @code{org-M-RET-may-split-line}.}.  If this command is executed
1740 @emph{before item's body}, the new item is created @emph{before} the current
1741 one.
1742 @end table
1744 @table @kbd
1745 @kindex M-S-@key{RET}
1746 @item M-S-RET
1747 Insert a new item with a checkbox (@pxref{Checkboxes}).
1748 @kindex S-@key{down}
1749 @item S-up
1750 @itemx S-down
1751 @cindex shift-selection-mode
1752 @vindex org-support-shift-select
1753 @vindex org-list-use-circular-motion
1754 Jump to the previous/next item in the current list@footnote{If you want to
1755 cycle around items that way, you may customize
1756 @code{org-list-use-circular-motion}.}, but only if
1757 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1758 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1759 similar effect.
1760 @kindex M-@key{up}
1761 @kindex M-@key{down}
1762 @item M-up
1763 @itemx M-down
1764 Move the item including subitems up/down@footnote{See
1765 @code{org-liste-use-circular-motion} for a cyclic behavior.} (swap with
1766 previous/next item of same indentation).  If the list is ordered, renumbering
1767 is automatic.
1768 @kindex M-@key{left}
1769 @kindex M-@key{right}
1770 @item M-left
1771 @itemx M-right
1772 Decrease/increase the indentation of an item, leaving children alone.
1773 @kindex M-S-@key{left}
1774 @kindex M-S-@key{right}
1775 @item M-S-left
1776 @itemx M-S-right
1777 Decrease/increase the indentation of the item, including subitems.
1778 Initially, the item tree is selected based on current indentation.  When
1779 these commands are executed several times in direct succession, the initially
1780 selected region is used, even if the new indentation would imply a different
1781 hierarchy.  To use the new hierarchy, break the command chain with a cursor
1782 motion or so.
1784 As a special case, using this command on the very first item of a list will
1785 move the whole list.  This behavior can be disabled by configuring
1786 @code{org-list-automatic-rules}.  The global indentation of a list has no
1787 influence on the text @emph{after} the list.
1788 @kindex C-c C-c
1789 @item C-c C-c
1790 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1791 state of the checkbox.  In any case, verify bullets and indentation
1792 consistency in the whole list.
1793 @kindex C-c -
1794 @vindex org-plain-list-ordered-item-terminator
1795 @item C-c -
1796 Cycle the entire list level through the different itemize/enumerate bullets
1797 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}) or a subset of them,
1798 depending on @code{org-plain-list-ordered-item-terminator}, the type of list,
1799 and its indentation.  With a numeric prefix argument N, select the Nth bullet
1800 from this list.  If there is an active region when calling this, selected
1801 text will be changed into an item.  With a prefix argument, all lines will be
1802 converted to list items.  If the first line already was a list item, any item
1803 marker will be removed from the list.  Finally, even without an active
1804 region, a normal line will be converted into a list item.
1805 @kindex C-c *
1806 @item C-c *
1807 Turn a plain list item into a headline (so that it becomes a subheading at
1808 its location).  @xref{Structure editing}, for a detailed explanation.
1809 @kindex C-c C-*
1810 @item C-c C-*
1811 Turn the whole plain list into a subtree of the current heading.  Checkboxes
1812 (@pxref{Checkboxes}) will become TODO (resp. DONE) keywords when unchecked
1813 (resp. checked).
1814 @kindex S-@key{left}
1815 @kindex S-@key{right}
1816 @item S-left/right
1817 @vindex org-support-shift-select
1818 This command also cycles bullet styles when the cursor in on the bullet or
1819 anywhere in an item line, details depending on
1820 @code{org-support-shift-select}.
1821 @kindex C-c ^
1822 @item C-c ^
1823 Sort the plain list.  You will be prompted for the sorting method:
1824 numerically, alphabetically, by time, or by custom function.
1825 @end table
1827 @node Drawers, Blocks, Plain lists, Document Structure
1828 @section Drawers
1829 @cindex drawers
1830 @cindex #+DRAWERS
1831 @cindex visibility cycling, drawers
1833 @vindex org-drawers
1834 @cindex org-insert-drawer
1835 @kindex C-c C-x d
1836 Sometimes you want to keep information associated with an entry, but you
1837 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1838 Drawers need to be configured with the variable
1839 @code{org-drawers}@footnote{You can define additional drawers on a
1840 per-file basis with a line like @code{#+DRAWERS: HIDDEN STATE}}.  Drawers
1841 look like this:
1843 @example
1844 ** This is a headline
1845    Still outside the drawer
1846    :DRAWERNAME:
1847    This is inside the drawer.
1848    :END:
1849    After the drawer.
1850 @end example
1852 You can interactively insert drawers at point by calling
1853 @code{org-insert-drawer}, which is bound to @key{C-c C-x d}.  With an active
1854 region, this command will put the region inside the drawer.  With a prefix
1855 argument, this command calls @code{org-insert-property-drawer} and add a
1856 property drawer right below the current headline.  Completion over drawer
1857 keywords is also possible using @key{M-TAB}.
1859 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1860 show the entry, but keep the drawer collapsed to a single line.  In order to
1861 look inside the drawer, you need to move the cursor to the drawer line and
1862 press @key{TAB} there.  Org mode uses the @code{PROPERTIES} drawer for
1863 storing properties (@pxref{Properties and Columns}), and you can also arrange
1864 for state change notes (@pxref{Tracking TODO state changes}) and clock times
1865 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.  If you
1866 want to store a quick note in the LOGBOOK drawer, in a similar way to state changes, use
1868 @table @kbd
1869 @kindex C-c C-z
1870 @item C-c C-z
1871 Add a time-stamped note to the LOGBOOK drawer.
1872 @end table
1874 @node Blocks, Footnotes, Drawers, Document Structure
1875 @section Blocks
1877 @vindex org-hide-block-startup
1878 @cindex blocks, folding
1879 Org mode uses begin...end blocks for various purposes from including source
1880 code examples (@pxref{Literal examples}) to capturing time logging
1881 information (@pxref{Clocking work time}).  These blocks can be folded and
1882 unfolded by pressing TAB in the begin line.  You can also get all blocks
1883 folded at startup by configuring the variable @code{org-hide-block-startup}
1884 or on a per-file basis by using
1886 @cindex @code{hideblocks}, STARTUP keyword
1887 @cindex @code{nohideblocks}, STARTUP keyword
1888 @example
1889 #+STARTUP: hideblocks
1890 #+STARTUP: nohideblocks
1891 @end example
1893 @node Footnotes, Orgstruct mode, Blocks, Document Structure
1894 @section Footnotes
1895 @cindex footnotes
1897 Org mode supports the creation of footnotes.  In contrast to the
1898 @file{footnote.el} package, Org mode's footnotes are designed for work on
1899 a larger document, not only for one-off documents like emails.
1901 A footnote is started by a footnote marker in square brackets in column 0, no
1902 indentation allowed.  It ends at the next footnote definition, headline, or
1903 after two consecutive empty lines.  The footnote reference is simply the
1904 marker in square brackets, inside text.  For example:
1906 @example
1907 The Org homepage[fn:1] now looks a lot better than it used to.
1909 [fn:1] The link is: http://orgmode.org
1910 @end example
1912 Org mode extends the number-based syntax to @emph{named} footnotes and
1913 optional inline definition.  Using plain numbers as markers (as
1914 @file{footnote.el} does) is supported for backward compatibility, but not
1915 encouraged because of possible conflicts with @LaTeX{} snippets (@pxref{Embedded
1916 @LaTeX{}}).  Here are the valid references:
1918 @table @code
1919 @item [1]
1920 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
1921 recommended because something like @samp{[1]} could easily be part of a code
1922 snippet.
1923 @item [fn:name]
1924 A named footnote reference, where @code{name} is a unique label word, or, for
1925 simplicity of automatic creation, a number.
1926 @item [fn:: This is the inline definition of this footnote]
1927 A @LaTeX{}-like anonymous footnote where the definition is given directly at the
1928 reference point.
1929 @item [fn:name: a definition]
1930 An inline definition of a footnote, which also specifies a name for the note.
1931 Since Org allows multiple references to the same note, you can then use
1932 @code{[fn:name]} to create additional references.
1933 @end table
1935 @vindex org-footnote-auto-label
1936 Footnote labels can be created automatically, or you can create names yourself.
1937 This is handled by the variable @code{org-footnote-auto-label} and its
1938 corresponding @code{#+STARTUP} keywords.  See the docstring of that variable
1939 for details.
1941 @noindent The following command handles footnotes:
1943 @table @kbd
1944 @kindex C-c C-x f
1945 @item C-c C-x f
1946 The footnote action command.
1948 When the cursor is on a footnote reference, jump to the definition.  When it
1949 is at a definition, jump to the (first) reference.
1951 @vindex org-footnote-define-inline
1952 @vindex org-footnote-section
1953 @vindex org-footnote-auto-adjust
1954 Otherwise, create a new footnote.  Depending on the variable
1955 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1956 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1957 definition will be placed right into the text as part of the reference, or
1958 separately into the location determined by the variable
1959 @code{org-footnote-section}.
1961 When this command is called with a prefix argument, a menu of additional
1962 options is offered:
1963 @example
1964 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1965     @r{Org makes no effort to sort footnote definitions into a particular}
1966     @r{sequence.  If you want them sorted, use this command, which will}
1967     @r{also move entries according to @code{org-footnote-section}.  Automatic}
1968     @r{sorting after each insertion/deletion can be configured using the}
1969     @r{variable @code{org-footnote-auto-adjust}.}
1970 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
1971     @r{after each insertion/deletion can be configured using the variable}
1972     @r{@code{org-footnote-auto-adjust}.}
1973 S   @r{Short for first @code{r}, then @code{s} action.}
1974 n   @r{Normalize the footnotes by collecting all definitions (including}
1975     @r{inline definitions) into a special section, and then numbering them}
1976     @r{in sequence.  The references will then also be numbers.  This is}
1977     @r{meant to be the final step before finishing a document (e.g., sending}
1978     @r{off an email).  The exporters do this automatically, and so could}
1979     @r{something like @code{message-send-hook}.}
1980 d   @r{Delete the footnote at point, and all definitions of and references}
1981     @r{to it.}
1982 @end example
1983 Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
1984 corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
1985 renumbering and sorting footnotes can be automatic after each insertion or
1986 deletion.
1988 @kindex C-c C-c
1989 @item C-c C-c
1990 If the cursor is on a footnote reference, jump to the definition.  If it is a
1991 the definition, jump back to the reference.  When called at a footnote
1992 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1993 @kindex C-c C-o
1994 @kindex mouse-1
1995 @kindex mouse-2
1996 @item C-c C-o  @r{or} mouse-1/2
1997 Footnote labels are also links to the corresponding definition/reference, and
1998 you can use the usual commands to follow these links.
1999 @end table
2001 @node Orgstruct mode, Org syntax, Footnotes, Document Structure
2002 @section The Orgstruct minor mode
2003 @cindex Orgstruct mode
2004 @cindex minor mode for structure editing
2006 If you like the intuitive way the Org mode structure editing and list
2007 formatting works, you might want to use these commands in other modes like
2008 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
2009 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
2010 turn it on by default, for example in Message mode, with one of:
2012 @lisp
2013 (add-hook 'message-mode-hook 'turn-on-orgstruct)
2014 (add-hook 'message-mode-hook 'turn-on-orgstruct++)
2015 @end lisp
2017 When this mode is active and the cursor is on a line that looks to Org like a
2018 headline or the first line of a list item, most structure editing commands
2019 will work, even if the same keys normally have different functionality in the
2020 major mode you are using.  If the cursor is not in one of those special
2021 lines, Orgstruct mode lurks silently in the shadows.
2023 When you use @code{orgstruct++-mode}, Org will also export indentation and
2024 autofill settings into that mode, and detect item context after the first
2025 line of an item.
2027 @vindex orgstruct-heading-prefix-regexp
2028 You can also use Org structure editing to fold and unfold headlines in
2029 @emph{any} file, provided you defined @var{orgstruct-heading-prefix-regexp}:
2030 the regular expression must match the local prefix to use before Org's
2031 headlines.  For example, if you set this variable to @code{"^;; "} in Emacs
2032 Lisp files, you will be able to fold and unfold headlines in Emacs Lisp
2033 commented lines.  Some commands like @code{org-demote} are disabled when the
2034 prefix is set, but folding/unfolding will work correctly.
2036 @node Org syntax,  , Orgstruct mode, Document Structure
2037 @section Org syntax
2038 @cindex Org syntax
2040 A reference document providing a formal description of Org's syntax is
2041 available as @uref{http://orgmode.org/worg/dev/org-syntax.html, a draft on
2042 Worg}, written and maintained by Nicolas Goaziou.  It defines Org's core
2043 internal concepts such as @code{headlines}, @code{sections}, @code{affiliated
2044 keywords}, @code{(greater) elements} and @code{objects}.  Each part of an Org
2045 file falls into one of the categories above.
2047 To explore the abstract structure of an Org buffer, run this in a buffer:
2049 @lisp
2050 M-: (org-element-parse-buffer) RET
2051 @end lisp
2053 It will output a list containing the buffer's content represented as an
2054 abstract structure.  The export engine relies on the information stored in
2055 this list.  Most interactive commands (e.g., for structure editing) also
2056 rely on the syntactic meaning of the surrounding context.
2058 @node Tables, Hyperlinks, Document Structure, Top
2059 @chapter Tables
2060 @cindex tables
2061 @cindex editing tables
2063 Org comes with a fast and intuitive table editor.  Spreadsheet-like
2064 calculations are supported using the Emacs @file{calc} package
2065 (@pxref{Top, Calc, , calc, Gnu Emacs Calculator Manual}).
2067 @menu
2068 * Built-in table editor::       Simple tables
2069 * Column width and alignment::  Overrule the automatic settings
2070 * Column groups::               Grouping to trigger vertical lines
2071 * Orgtbl mode::                 The table editor as minor mode
2072 * The spreadsheet::             The table editor has spreadsheet capabilities
2073 * Org-Plot::                    Plotting from org tables
2074 @end menu
2076 @node Built-in table editor, Column width and alignment, Tables, Tables
2077 @section The built-in table editor
2078 @cindex table editor, built-in
2080 Org makes it easy to format tables in plain ASCII@.  Any line with @samp{|} as
2081 the first non-whitespace character is considered part of a table.  @samp{|}
2082 is also the column separator@footnote{To insert a vertical bar into a table
2083 field, use @code{\vert} or, inside a word @code{abc\vert@{@}def}.}.  A table
2084 might look like this:
2086 @example
2087 | Name  | Phone | Age |
2088 |-------+-------+-----|
2089 | Peter |  1234 |  17 |
2090 | Anna  |  4321 |  25 |
2091 @end example
2093 A table is re-aligned automatically each time you press @key{TAB} or
2094 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
2095 the next field (@key{RET} to the next row) and creates new table rows
2096 at the end of the table or before horizontal lines.  The indentation
2097 of the table is set by the first line.  Any line starting with
2098 @samp{|-} is considered as a horizontal separator line and will be
2099 expanded on the next re-align to span the whole table width.  So, to
2100 create the above table, you would only type
2102 @example
2103 |Name|Phone|Age|
2105 @end example
2107 @noindent and then press @key{TAB} to align the table and start filling in
2108 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
2109 @kbd{C-c @key{RET}}.
2111 @vindex org-enable-table-editor
2112 @vindex org-table-auto-blank-field
2113 When typing text into a field, Org treats @key{DEL},
2114 @key{Backspace}, and all character keys in a special way, so that
2115 inserting and deleting avoids shifting other fields.  Also, when
2116 typing @emph{immediately after the cursor was moved into a new field
2117 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
2118 field is automatically made blank.  If this behavior is too
2119 unpredictable for you, configure the variables
2120 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
2122 @table @kbd
2123 @tsubheading{Creation and conversion}
2124 @orgcmd{C-c |,org-table-create-or-convert-from-region}
2125 Convert the active region to table.  If every line contains at least one
2126 TAB character, the function assumes that the material is tab separated.
2127 If every line contains a comma, comma-separated values (CSV) are assumed.
2128 If not, lines are split at whitespace into fields.  You can use a prefix
2129 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
2130 C-u} forces TAB, and a numeric argument N indicates that at least N
2131 consecutive spaces, or alternatively a TAB will be the separator.
2133 If there is no active region, this command creates an empty Org
2134 table.  But it is easier just to start typing, like
2135 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
2137 @tsubheading{Re-aligning and field motion}
2138 @orgcmd{C-c C-c,org-table-align}
2139 Re-align the table and don't move to another field.
2141 @orgcmd{<TAB>,org-table-next-field}
2142 Re-align the table, move to the next field.  Creates a new row if
2143 necessary.
2145 @orgcmd{S-@key{TAB},org-table-previous-field}
2146 Re-align, move to previous field.
2148 @orgcmd{@key{RET},org-table-next-row}
2149 Re-align the table and move down to next row.  Creates a new row if
2150 necessary.  At the beginning or end of a line, @key{RET} still does
2151 NEWLINE, so it can be used to split a table.
2153 @orgcmd{M-a,org-table-beginning-of-field}
2154 Move to beginning of the current table field, or on to the previous field.
2155 @orgcmd{M-e,org-table-end-of-field}
2156 Move to end of the current table field, or on to the next field.
2158 @tsubheading{Column and row editing}
2159 @orgcmdkkcc{M-@key{left},M-@key{right},org-table-move-column-left,org-table-move-column-right}
2160 Move the current column left/right.
2162 @orgcmd{M-S-@key{left},org-table-delete-column}
2163 Kill the current column.
2165 @orgcmd{M-S-@key{right},org-table-insert-column}
2166 Insert a new column to the left of the cursor position.
2168 @orgcmdkkcc{M-@key{up},M-@key{down},org-table-move-row-up,org-table-move-row-down}
2169 Move the current row up/down.
2171 @orgcmd{M-S-@key{up},org-table-kill-row}
2172 Kill the current row or horizontal line.
2174 @orgcmd{M-S-@key{down},org-table-insert-row}
2175 Insert a new row above the current row.  With a prefix argument, the line is
2176 created below the current one.
2178 @orgcmd{C-c -,org-table-insert-hline}
2179 Insert a horizontal line below current row.  With a prefix argument, the line
2180 is created above the current line.
2182 @orgcmd{C-c @key{RET},org-table-hline-and-move}
2183 Insert a horizontal line below current row, and move the cursor into the row
2184 below that line.
2186 @orgcmd{C-c ^,org-table-sort-lines}
2187 Sort the table lines in the region.  The position of point indicates the
2188 column to be used for sorting, and the range of lines is the range
2189 between the nearest horizontal separator lines, or the entire table.  If
2190 point is before the first column, you will be prompted for the sorting
2191 column.  If there is an active region, the mark specifies the first line
2192 and the sorting column, while point should be in the last line to be
2193 included into the sorting.  The command prompts for the sorting type
2194 (alphabetically, numerically, or by time).  When called with a prefix
2195 argument, alphabetic sorting will be case-sensitive.
2197 @tsubheading{Regions}
2198 @orgcmd{C-c C-x M-w,org-table-copy-region}
2199 Copy a rectangular region from a table to a special clipboard.  Point and
2200 mark determine edge fields of the rectangle.  If there is no active region,
2201 copy just the current field.  The process ignores horizontal separator lines.
2203 @orgcmd{C-c C-x C-w,org-table-cut-region}
2204 Copy a rectangular region from a table to a special clipboard, and
2205 blank all fields in the rectangle.  So this is the ``cut'' operation.
2207 @orgcmd{C-c C-x C-y,org-table-paste-rectangle}
2208 Paste a rectangular region into a table.
2209 The upper left corner ends up in the current field.  All involved fields
2210 will be overwritten.  If the rectangle does not fit into the present table,
2211 the table is enlarged as needed.  The process ignores horizontal separator
2212 lines.
2214 @orgcmd{M-@key{RET},org-table-wrap-region}
2215 Split the current field at the cursor position and move the rest to the line
2216 below.  If there is an active region, and both point and mark are in the same
2217 column, the text in the column is wrapped to minimum width for the given
2218 number of lines.  A numeric prefix argument may be used to change the number
2219 of desired lines.  If there is no region, but you specify a prefix argument,
2220 the current field is made blank, and the content is appended to the field
2221 above.
2223 @tsubheading{Calculations}
2224 @cindex formula, in tables
2225 @cindex calculations, in tables
2226 @cindex region, active
2227 @cindex active region
2228 @cindex transient mark mode
2229 @orgcmd{C-c +,org-table-sum}
2230 Sum the numbers in the current column, or in the rectangle defined by
2231 the active region.  The result is shown in the echo area and can
2232 be inserted with @kbd{C-y}.
2234 @orgcmd{S-@key{RET},org-table-copy-down}
2235 @vindex org-table-copy-increment
2236 When current field is empty, copy from first non-empty field above.  When not
2237 empty, copy current field down to next row and move cursor along with it.
2238 Depending on the variable @code{org-table-copy-increment}, integer field
2239 values will be incremented during copy.  Integers that are too large will not
2240 be incremented.  Also, a @code{0} prefix argument temporarily disables the
2241 increment.  This key is also used by shift-selection and related modes
2242 (@pxref{Conflicts}).
2244 @tsubheading{Miscellaneous}
2245 @orgcmd{C-c `,org-table-edit-field}
2246 Edit the current field in a separate window.  This is useful for fields that
2247 are not fully visible (@pxref{Column width and alignment}).  When called with
2248 a @kbd{C-u} prefix, just make the full field visible, so that it can be
2249 edited in place.  When called with two @kbd{C-u} prefixes, make the editor
2250 window follow the cursor through the table and always show the current
2251 field.  The follow mode exits automatically when the cursor leaves the table,
2252 or when you repeat this command with @kbd{C-u C-u C-c `}.
2254 @item M-x org-table-import
2255 Import a file as a table.  The table should be TAB or whitespace
2256 separated.  Use, for example, to import a spreadsheet table or data
2257 from a database, because these programs generally can write
2258 TAB-separated text files.  This command works by inserting the file into
2259 the buffer and then converting the region to a table.  Any prefix
2260 argument is passed on to the converter, which uses it to determine the
2261 separator.
2262 @orgcmd{C-c |,org-table-create-or-convert-from-region}
2263 Tables can also be imported by pasting tabular text into the Org
2264 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
2265 @kbd{C-c |} command (see above under @i{Creation and conversion}).
2267 @item M-x org-table-export
2268 @findex org-table-export
2269 @vindex org-table-export-default-format
2270 Export the table, by default as a TAB-separated file.  Use for data
2271 exchange with, for example, spreadsheet or database programs.  The format
2272 used to export the file can be configured in the variable
2273 @code{org-table-export-default-format}.  You may also use properties
2274 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
2275 name and the format for table export in a subtree.  Org supports quite
2276 general formats for exported tables.  The exporter format is the same as the
2277 format used by Orgtbl radio tables, see @ref{Translator functions}, for a
2278 detailed description.
2279 @end table
2281 If you don't like the automatic table editor because it gets in your
2282 way on lines which you would like to start with @samp{|}, you can turn
2283 it off with
2285 @lisp
2286 (setq org-enable-table-editor nil)
2287 @end lisp
2289 @noindent Then the only table command that still works is
2290 @kbd{C-c C-c} to do a manual re-align.
2292 @node Column width and alignment, Column groups, Built-in table editor, Tables
2293 @section Column width and alignment
2294 @cindex narrow columns in tables
2295 @cindex alignment in tables
2297 The width of columns is automatically determined by the table editor.  And
2298 also the alignment of a column is determined automatically from the fraction
2299 of number-like versus non-number fields in the column.
2301 Sometimes a single field or a few fields need to carry more text, leading to
2302 inconveniently wide columns.  Or maybe you want to make a table with several
2303 columns having a fixed width, regardless of content.  To set@footnote{This
2304 feature does not work on XEmacs.} the width of a column, one field anywhere
2305 in the column may contain just the string @samp{<N>} where @samp{N} is an
2306 integer specifying the width of the column in characters.  The next re-align
2307 will then set the width of this column to this value.
2309 @example
2310 @group
2311 |---+------------------------------|               |---+--------|
2312 |   |                              |               |   | <6>    |
2313 | 1 | one                          |               | 1 | one    |
2314 | 2 | two                          |     ----\     | 2 | two    |
2315 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
2316 | 4 | four                         |               | 4 | four   |
2317 |---+------------------------------|               |---+--------|
2318 @end group
2319 @end example
2321 @noindent
2322 Fields that are wider become clipped and end in the string @samp{=>}.
2323 Note that the full text is still in the buffer but is hidden.
2324 To see the full text, hold the mouse over the field---a tool-tip window
2325 will show the full content.  To edit such a field, use the command
2326 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
2327 open a new window with the full field.  Edit it and finish with @kbd{C-c
2328 C-c}.
2330 @vindex org-startup-align-all-tables
2331 When visiting a file containing a table with narrowed columns, the
2332 necessary character hiding has not yet happened, and the table needs to
2333 be aligned before it looks nice.  Setting the option
2334 @code{org-startup-align-all-tables} will realign all tables in a file
2335 upon visiting, but also slow down startup.  You can also set this option
2336 on a per-file basis with:
2338 @example
2339 #+STARTUP: align
2340 #+STARTUP: noalign
2341 @end example
2343 If you would like to overrule the automatic alignment of number-rich columns
2344 to the right and of string-rich column to the left, you can use @samp{<r>},
2345 @samp{<c>}@footnote{Centering does not work inside Emacs, but it does have an
2346 effect when exporting to HTML.} or @samp{<l>} in a similar fashion.  You may
2347 also combine alignment and field width like this: @samp{<r10>}.
2349 Lines which only contain these formatting cookies will be removed
2350 automatically when exporting the document.
2352 @node Column groups, Orgtbl mode, Column width and alignment, Tables
2353 @section Column groups
2354 @cindex grouping columns in tables
2356 When Org exports tables, it does so by default without vertical
2357 lines because that is visually more satisfying in general.  Occasionally
2358 however, vertical lines can be useful to structure a table into groups
2359 of columns, much like horizontal lines can do for groups of rows.  In
2360 order to specify column groups, you can use a special row where the
2361 first field contains only @samp{/}.  The further fields can either
2362 contain @samp{<} to indicate that this column should start a group,
2363 @samp{>} to indicate the end of a column, or @samp{<>} (no space between @samp{<}
2364 and @samp{>}) to make a column
2365 a group of its own.  Boundaries between column groups will upon export be
2366 marked with vertical lines.  Here is an example:
2368 @example
2369 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2370 |---+-----+-----+-----+---------+------------|
2371 | / |   < |     |   > |       < |          > |
2372 | 1 |   1 |   1 |   1 |       1 |          1 |
2373 | 2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
2374 | 3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
2375 |---+-----+-----+-----+---------+------------|
2376 #+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
2377 @end example
2379 It is also sufficient to just insert the column group starters after
2380 every vertical line you would like to have:
2382 @example
2383 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2384 |----+-----+-----+-----+---------+------------|
2385 | /  | <   |     |     | <       |            |
2386 @end example
2388 @node Orgtbl mode, The spreadsheet, Column groups, Tables
2389 @section The Orgtbl minor mode
2390 @cindex Orgtbl mode
2391 @cindex minor mode for tables
2393 If you like the intuitive way the Org table editor works, you
2394 might also want to use it in other modes like Text mode or Mail mode.
2395 The minor mode Orgtbl mode makes this possible.  You can always toggle
2396 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
2397 example in Message mode, use
2399 @lisp
2400 (add-hook 'message-mode-hook 'turn-on-orgtbl)
2401 @end lisp
2403 Furthermore, with some special setup, it is possible to maintain tables
2404 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
2405 construct @LaTeX{} tables with the underlying ease and power of
2406 Orgtbl mode, including spreadsheet capabilities.  For details, see
2407 @ref{Tables in arbitrary syntax}.
2409 @node The spreadsheet, Org-Plot, Orgtbl mode, Tables
2410 @section The spreadsheet
2411 @cindex calculations, in tables
2412 @cindex spreadsheet capabilities
2413 @cindex @file{calc} package
2415 The table editor makes use of the Emacs @file{calc} package to implement
2416 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
2417 derive fields from other fields.  While fully featured, Org's implementation
2418 is not identical to other spreadsheets.  For example, Org knows the concept
2419 of a @emph{column formula} that will be applied to all non-header fields in a
2420 column without having to copy the formula to each relevant field.  There is
2421 also a formula debugger, and a formula editor with features for highlighting
2422 fields in the table corresponding to the references at the point in the
2423 formula, moving these references by arrow keys
2425 @menu
2426 * References::                  How to refer to another field or range
2427 * Formula syntax for Calc::     Using Calc to compute stuff
2428 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
2429 * Durations and time values::   How to compute durations and time values
2430 * Field and range formulas::    Formula for specific (ranges of) fields
2431 * Column formulas::             Formulas valid for an entire column
2432 * Lookup functions::            Lookup functions for searching tables
2433 * Editing and debugging formulas::  Fixing formulas
2434 * Updating the table::          Recomputing all dependent fields
2435 * Advanced features::           Field and column names, parameters and automatic recalc
2436 @end menu
2438 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
2439 @subsection References
2440 @cindex references
2442 To compute fields in the table from other fields, formulas must
2443 reference other fields or ranges.  In Org, fields can be referenced
2444 by name, by absolute coordinates, and by relative coordinates.  To find
2445 out what the coordinates of a field are, press @kbd{C-c ?} in that
2446 field, or press @kbd{C-c @}} to toggle the display of a grid.
2448 @subsubheading Field references
2449 @cindex field references
2450 @cindex references, to fields
2452 Formulas can reference the value of another field in two ways.  Like in
2453 any other spreadsheet, you may reference fields with a letter/number
2454 combination like @code{B3}, meaning the 2nd field in the 3rd row.
2455 @vindex org-table-use-standard-references
2456 However, Org prefers@footnote{Org will understand references typed by the
2457 user as @samp{B4}, but it will not use this syntax when offering a formula
2458 for editing.  You can customize this behavior using the variable
2459 @code{org-table-use-standard-references}.}  to use another, more general
2460 representation that looks like this:
2461 @example
2462 @@@var{row}$@var{column}
2463 @end example
2465 Column specifications can be absolute like @code{$1},
2466 @code{$2},...@code{$@var{N}}, or relative to the current column (i.e., the
2467 column of the field which is being computed) like @code{$+1} or @code{$-2}.
2468 @code{$<} and @code{$>} are immutable references to the first and last
2469 column, respectively, and you can use @code{$>>>} to indicate the third
2470 column from the right.
2472 The row specification only counts data lines and ignores horizontal separator
2473 lines (hlines).  Like with columns, you can use absolute row numbers
2474 @code{@@1}, @code{@@2},...@code{@@@var{N}}, and row numbers relative to the
2475 current row like @code{@@+3} or @code{@@-1}.  @code{@@<} and @code{@@>} are
2476 immutable references the first and last@footnote{For backward compatibility
2477 you can also use special names like @code{$LR5} and @code{$LR12} to refer in
2478 a stable way to the 5th and 12th field in the last row of the table.
2479 However, this syntax is deprecated, it should not be used for new documents.
2480 Use @code{@@>$} instead.} row in the table, respectively.  You may also
2481 specify the row relative to one of the hlines: @code{@@I} refers to the first
2482 hline, @code{@@II} to the second, etc.  @code{@@-I} refers to the first such
2483 line above the current line, @code{@@+I} to the first such line below the
2484 current line.  You can also write @code{@@III+2} which is the second data line
2485 after the third hline in the table.
2487 @code{@@0} and @code{$0} refer to the current row and column, respectively,
2488 i.e., to the row/column for the field being computed.  Also, if you omit
2489 either the column or the row part of the reference, the current row/column is
2490 implied.
2492 Org's references with @emph{unsigned} numbers are fixed references
2493 in the sense that if you use the same reference in the formula for two
2494 different fields, the same field will be referenced each time.
2495 Org's references with @emph{signed} numbers are floating
2496 references because the same reference operator can reference different
2497 fields depending on the field being calculated by the formula.
2499 Here are a few examples:
2501 @example
2502 @@2$3      @r{2nd row, 3rd column (same as @code{C2})}
2503 $5        @r{column 5 in the current row (same as @code{E&})}
2504 @@2        @r{current column, row 2}
2505 @@-1$-3    @r{the field one row up, three columns to the left}
2506 @@-I$2     @r{field just under hline above current row, column 2}
2507 @@>$5      @r{field in the last row, in column 5}
2508 @end example
2510 @subsubheading Range references
2511 @cindex range references
2512 @cindex references, to ranges
2514 You may reference a rectangular range of fields by specifying two field
2515 references connected by two dots @samp{..}.  If both fields are in the
2516 current row, you may simply use @samp{$2..$7}, but if at least one field
2517 is in a different row, you need to use the general @code{@@row$column}
2518 format at least for the first field (i.e the reference must start with
2519 @samp{@@} in order to be interpreted correctly).  Examples:
2521 @example
2522 $1..$3        @r{first three fields in the current row}
2523 $P..$Q        @r{range, using column names (see under Advanced)}
2524 $<<<..$>>     @r{start in third column, continue to the one but last}
2525 @@2$1..@@4$3    @r{6 fields between these two fields (same as @code{A2..C4})}
2526 @@-1$-2..@@-1   @r{3 fields in the row above, starting from 2 columns on the left}
2527 @@I..II        @r{between first and second hline, short for @code{@@I..@@II}}
2528 @end example
2530 @noindent Range references return a vector of values that can be fed
2531 into Calc vector functions.  Empty fields in ranges are normally
2532 suppressed, so that the vector contains only the non-empty fields (but
2533 see the @samp{E} mode switch below).  If there are no non-empty fields,
2534 @samp{[0]} is returned to avoid syntax errors in formulas.
2536 @subsubheading Field coordinates in formulas
2537 @cindex field coordinates
2538 @cindex coordinates, of field
2539 @cindex row, of field coordinates
2540 @cindex column, of field coordinates
2542 For Calc formulas and Lisp formulas @code{@@#} and @code{$#} can be used to
2543 get the row or column number of the field where the formula result goes.
2544 The traditional Lisp formula equivalents are @code{org-table-current-dline}
2545 and @code{org-table-current-column}.  Examples:
2547 @example
2548 if(@@# % 2, $#, string(""))   @r{column number on odd lines only}
2549 $3 = remote(FOO, @@@@#$2)      @r{copy column 2 from table FOO into}
2550                              @r{column 3 of the current table}
2551 @end example
2553 @noindent For the second example, table FOO must have at least as many rows
2554 as the current table.  Note that this is inefficient@footnote{The computation time scales as
2555 O(N^2) because table FOO is parsed for each field to be copied.} for large
2556 number of rows.
2558 @subsubheading Named references
2559 @cindex named references
2560 @cindex references, named
2561 @cindex name, of column or field
2562 @cindex constants, in calculations
2563 @cindex #+CONSTANTS
2565 @vindex org-table-formula-constants
2566 @samp{$name} is interpreted as the name of a column, parameter or
2567 constant.  Constants are defined globally through the variable
2568 @code{org-table-formula-constants}, and locally (for the file) through a
2569 line like
2571 @example
2572 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2573 @end example
2575 @noindent
2576 @vindex constants-unit-system
2577 @pindex constants.el
2578 Also properties (@pxref{Properties and Columns}) can be used as
2579 constants in table formulas: for a property @samp{:Xyz:} use the name
2580 @samp{$PROP_Xyz}, and the property will be searched in the current
2581 outline entry and in the hierarchy above it.  If you have the
2582 @file{constants.el} package, it will also be used to resolve constants,
2583 including natural constants like @samp{$h} for Planck's constant, and
2584 units like @samp{$km} for kilometers@footnote{@file{constants.el} can
2585 supply the values of constants in two different unit systems, @code{SI}
2586 and @code{cgs}.  Which one is used depends on the value of the variable
2587 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2588 @code{constSI} and @code{constcgs} to set this value for the current
2589 buffer.}.  Column names and parameters can be specified in special table
2590 lines.  These are described below, see @ref{Advanced features}.  All
2591 names must start with a letter, and further consist of letters and
2592 numbers.
2594 @subsubheading Remote references
2595 @cindex remote references
2596 @cindex references, remote
2597 @cindex references, to a different table
2598 @cindex name, of column or field
2599 @cindex constants, in calculations
2600 @cindex #+TBLNAME
2602 You may also reference constants, fields and ranges from a different table,
2603 either in the current file or even in a different file.  The syntax is
2605 @example
2606 remote(NAME-OR-ID,REF)
2607 @end example
2609 @noindent
2610 where NAME can be the name of a table in the current file as set by a
2611 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2612 entry, even in a different file, and the reference then refers to the first
2613 table in that entry.  REF is an absolute field or range reference as
2614 described above for example @code{@@3$3} or @code{$somename}, valid in the
2615 referenced table.
2617 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2618 @subsection Formula syntax for Calc
2619 @cindex formula syntax, Calc
2620 @cindex syntax, of formulas
2622 A formula can be any algebraic expression understood by the Emacs
2623 @file{Calc} package.  @b{Note that @file{calc} has the
2624 non-standard convention that @samp{/} has lower precedence than
2625 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2626 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2627 Your Programs, calc-eval, Calling Calc from Your Lisp Programs, calc, GNU
2628 Emacs Calc Manual}),
2629 variable substitution takes place according to the rules described above.
2630 @cindex vectors, in table calculations
2631 The range vectors can be directly fed into the Calc vector functions
2632 like @samp{vmean} and @samp{vsum}.
2634 @cindex format specifier
2635 @cindex mode, for @file{calc}
2636 @vindex org-calc-default-modes
2637 A formula can contain an optional mode string after a semicolon.  This
2638 string consists of flags to influence Calc and other modes during
2639 execution.  By default, Org uses the standard Calc modes (precision
2640 12, angular units degrees, fraction and symbolic modes off).  The display
2641 format, however, has been changed to @code{(float 8)} to keep tables
2642 compact.  The default settings can be configured using the variable
2643 @code{org-calc-default-modes}.
2645 @example
2646 p20           @r{set the internal Calc calculation precision to 20 digits}
2647 n3 s3 e2 f4   @r{Normal, scientific, engineering, or fixed}
2648               @r{format of the result of Calc passed back to Org.}
2649               @r{Calc formatting is unlimited in precision as}
2650               @r{long as the Calc calculation precision is greater.}
2651 D R           @r{angle modes: degrees, radians}
2652 F S           @r{fraction and symbolic modes}
2653 E             @r{keep empty fields in ranges and use nan (not a number)}
2654               @r{in Calc formulas for empty fields in range references and}
2655               @r{for empty field references; else suppress empty fields in}
2656               @r{range references and use 0 for empty field references, see}
2657               @r{also the notes for `Range references' in @pxref{References}}
2658 N             @r{interpret all fields as numbers, use 0 for non-numbers;}
2659               @r{N has higher precedence than E (for the value of the field)}
2660 L             @r{literal, for Lisp formulas only}
2661 @end example
2663 @noindent
2664 Unless you use large integer numbers or high-precision-calculation
2665 and -display for floating point numbers you may alternatively provide a
2666 @code{printf} format specifier to reformat the Calc result after it has been
2667 passed back to Org instead of letting Calc already do the
2668 formatting@footnote{The @code{printf} reformatting is limited in precision
2669 because the value passed to it is converted into an @code{integer} or
2670 @code{double}.  The @code{integer} is limited in size by truncating the
2671 signed value to 32 bits.  The @code{double} is limited in precision to 64
2672 bits overall which leaves approximately 16 significant decimal digits.}.
2673 A few examples:
2675 @example
2676 $1+$2                @r{Sum of first and second field}
2677 $1+$2;%.2f           @r{Same, format result to two decimals}
2678 exp($2)+exp($1)      @r{Math functions can be used}
2679 $0;%.1f              @r{Reformat current cell to 1 decimal}
2680 ($3-32)*5/9          @r{Degrees F -> C conversion}
2681 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2682 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2683 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2684 vmean($2..$7)        @r{Compute column range mean, suppress empty fields}
2685 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2686 taylor($3,x=7,2)     @r{Taylor series of $3, at x=7, second degree}
2687 @end example
2689 Calc also contains a complete set of logical operations.  For example
2691 @example
2692 if($1 < 20, teen, string(""))
2693                      @r{"teen" if age $1 is less than 20, else empty}
2694 if("$1" = "nan" || "$2" = "nan", string(""), $1 + $2); E
2695                      @r{sum of first two columns unless one or both empty}
2696 @end example
2698 Note that you can also use two org-specific flags @code{T} and @code{t} for
2699 durations computations @ref{Durations and time values}.
2701 You can add your own Calc functions defined in Emacs Lisp with @code{defmath}
2702 and use them in formula syntax for Calc.
2704 @node Formula syntax for Lisp, Durations and time values, Formula syntax for Calc, The spreadsheet
2705 @subsection Emacs Lisp forms as formulas
2706 @cindex Lisp forms, as table formulas
2708 It is also possible to write a formula in Emacs Lisp.  This can be useful
2709 for string manipulation and control structures, if Calc's functionality is
2710 not enough.
2712 If a formula starts with a single-quote followed by an opening parenthesis,
2713 then it is evaluated as a Lisp form.  The evaluation should return either a
2714 string or a number.  Just as with @file{calc} formulas, you can specify modes
2715 and a printf format after a semicolon.
2717 With Emacs Lisp forms, you need to be conscious about the way field
2718 references are interpolated into the form.  By default, a reference will be
2719 interpolated as a Lisp string (in double-quotes) containing the field.  If
2720 you provide the @samp{N} mode switch, all referenced elements will be numbers
2721 (non-number fields will be zero) and interpolated as Lisp numbers, without
2722 quotes.  If you provide the @samp{L} flag, all fields will be interpolated
2723 literally, without quotes.  I.e., if you want a reference to be interpreted
2724 as a string by the Lisp form, enclose the reference operator itself in
2725 double-quotes, like @code{"$3"}.  Ranges are inserted as space-separated
2726 fields, so you can embed them in list or vector syntax.
2728 Here are a few examples---note how the @samp{N} mode is used when we do
2729 computations in Lisp:
2731 @example
2732 @r{Swap the first two characters of the content of column 1}
2733   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2734 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2735   '(+ $1 $2);N
2736 @r{Compute the sum of columns 1--4, like Calc's @code{vsum($1..$4)}}
2737   '(apply '+ '($1..$4));N
2738 @end example
2740 @node Durations and time values, Field and range formulas, Formula syntax for Lisp, The spreadsheet
2741 @subsection Durations and time values
2742 @cindex Duration, computing
2743 @cindex Time, computing
2744 @vindex org-table-duration-custom-format
2746 If you want to compute time values use the @code{T} flag, either in Calc
2747 formulas or Elisp formulas:
2749 @example
2750 @group
2751   |  Task 1 |   Task 2 |    Total |
2752   |---------+----------+----------|
2753   |    2:12 |     1:47 | 03:59:00 |
2754   | 3:02:20 | -2:07:00 |     0.92 |
2755   #+TBLFM: @@2$3=$1+$2;T::@@3$3=$1+$2;t
2756 @end group
2757 @end example
2759 Input duration values must be of the form @code{[HH:MM[:SS]}, where seconds
2760 are optional.  With the @code{T} flag, computed durations will be displayed
2761 as @code{HH:MM:SS} (see the first formula above).  With the @code{t} flag,
2762 computed durations will be displayed according to the value of the variable
2763 @code{org-table-duration-custom-format}, which defaults to @code{'hours} and
2764 will display the result as a fraction of hours (see the second formula in the
2765 example above).
2767 Negative duration values can be manipulated as well, and integers will be
2768 considered as seconds in addition and subtraction.
2770 @node Field and range formulas, Column formulas, Durations and time values, The spreadsheet
2771 @subsection Field and range formulas
2772 @cindex field formula
2773 @cindex range formula
2774 @cindex formula, for individual table field
2775 @cindex formula, for range of fields
2777 To assign a formula to a particular field, type it directly into the field,
2778 preceded by @samp{:=}, for example @samp{:=vsum(@@II..III)}.  When you press
2779 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2780 the formula will be stored as the formula for this field, evaluated, and the
2781 current field will be replaced with the result.
2783 @cindex #+TBLFM
2784 Formulas are stored in a special line starting with @samp{#+TBLFM:} directly
2785 below the table.  If you type the equation in the 4th field of the 3rd data
2786 line in the table, the formula will look like @samp{@@3$4=$1+$2}.  When
2787 inserting/deleting/swapping column and rows with the appropriate commands,
2788 @i{absolute references} (but not relative ones) in stored formulas are
2789 modified in order to still reference the same field.  To avoid this from
2790 happening, in particular in range references, anchor ranges at the table
2791 borders (using @code{@@<}, @code{@@>}, @code{$<}, @code{$>}), or at hlines
2792 using the @code{@@I} notation.  Automatic adaptation of field references does
2793 of course not happen if you edit the table structure with normal editing
2794 commands---then you must fix the equations yourself.
2796 Instead of typing an equation into the field, you may also use the following
2797 command
2799 @table @kbd
2800 @orgcmd{C-u C-c =,org-table-eval-formula}
2801 Install a new formula for the current field.  The command prompts for a
2802 formula with default taken from the @samp{#+TBLFM:} line, applies
2803 it to the current field, and stores it.
2804 @end table
2806 The left-hand side of a formula can also be a special expression in order to
2807 assign the formula to a number of different fields.  There is no keyboard
2808 shortcut to enter such range formulas.  To add them, use the formula editor
2809 (@pxref{Editing and debugging formulas}) or edit the @code{#+TBLFM:} line
2810 directly.
2812 @table @code
2813 @item $2=
2814 Column formula, valid for the entire column.  This is so common that Org
2815 treats these formulas in a special way, see @ref{Column formulas}.
2816 @item @@3=
2817 Row formula, applies to all fields in the specified row.  @code{@@>=} means
2818 the last row.
2819 @item @@1$2..@@4$3=
2820 Range formula, applies to all fields in the given rectangular range.  This
2821 can also be used to assign a formula to some but not all fields in a row.
2822 @item $name=
2823 Named field, see @ref{Advanced features}.
2824 @end table
2826 @node Column formulas, Lookup functions, Field and range formulas, The spreadsheet
2827 @subsection Column formulas
2828 @cindex column formula
2829 @cindex formula, for table column
2831 When you assign a formula to a simple column reference like @code{$3=}, the
2832 same formula will be used in all fields of that column, with the following
2833 very convenient exceptions: (i) If the table contains horizontal separator
2834 hlines with rows above and below, everything before the first such hline is
2835 considered part of the table @emph{header} and will not be modified by column
2836 formulas.  Therefore a header is mandatory when you use column formulas and
2837 want to add hlines to group rows, like for example to separate a total row at
2838 the bottom from the summand rows above.  (ii) Fields that already get a value
2839 from a field/range formula will be left alone by column formulas.  These
2840 conditions make column formulas very easy to use.
2842 To assign a formula to a column, type it directly into any field in the
2843 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2844 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2845 the formula will be stored as the formula for the current column, evaluated
2846 and the current field replaced with the result.  If the field contains only
2847 @samp{=}, the previously stored formula for this column is used.  For each
2848 column, Org will only remember the most recently used formula.  In the
2849 @samp{#+TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The
2850 left-hand side of a column formula can not be the name of column, it must be
2851 the numeric column reference or @code{$>}.
2853 Instead of typing an equation into the field, you may also use the
2854 following command:
2856 @table @kbd
2857 @orgcmd{C-c =,org-table-eval-formula}
2858 Install a new formula for the current column and replace current field with
2859 the result of the formula.  The command prompts for a formula, with default
2860 taken from the @samp{#+TBLFM} line, applies it to the current field and
2861 stores it.  With a numeric prefix argument(e.g., @kbd{C-5 C-c =}) the command
2862 will apply it to that many consecutive fields in the current column.
2863 @end table
2865 @node Lookup functions, Editing and debugging formulas, Column formulas, The spreadsheet
2866 @subsection Lookup functions
2867 @cindex lookup functions in tables
2868 @cindex table lookup functions
2870 Org has three predefined Emacs Lisp functions for lookups in tables.
2871 @table @code
2872 @item (org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)
2873 @findex org-lookup-first
2874 Searches for the first element @code{S} in list @code{S-LIST} for which
2875 @lisp
2876 (PREDICATE VAL S)
2877 @end lisp
2878 is @code{t}; returns the value from the corresponding position in list
2879 @code{R-LIST}.  The default @code{PREDICATE} is @code{equal}.  Note that the
2880 parameters @code{VAL} and @code{S} are passed to @code{PREDICATE} in the same
2881 order as the correspoding parameters are in the call to
2882 @code{org-lookup-first}, where @code{VAL} precedes @code{S-LIST}.  If
2883 @code{R-LIST} is @code{nil}, the matching element @code{S} of @code{S-LIST}
2884 is returned.
2885 @item (org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)
2886 @findex org-lookup-last
2887 Similar to @code{org-lookup-first} above, but searches for the @i{last}
2888 element for which @code{PREDICATE} is @code{t}.
2889 @item (org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)
2890 @findex org-lookup-all
2891 Similar to @code{org-lookup-first}, but searches for @i{all} elements for
2892 which @code{PREDICATE} is @code{t}, and returns @i{all} corresponding
2893 values.  This function can not be used by itself in a formula, because it
2894 returns a list of values.  However, powerful lookups can be built when this
2895 function is combined with other Emacs Lisp functions.
2896 @end table
2898 If the ranges used in these functions contain empty fields, the @code{E} mode
2899 for the formula should usually be specified: otherwise empty fields will not be
2900 included in @code{S-LIST} and/or @code{R-LIST} which can, for example, result
2901 in an incorrect mapping from an element of @code{S-LIST} to the corresponding
2902 element of @code{R-LIST}.
2904 These three functions can be used to implement associative arrays, count
2905 matching cells, rank results, group data etc.  For practical examples
2906 see @uref{http://orgmode.org/worg/org-tutorials/org-lookups.html, this
2907 tutorial on Worg}.
2909 @node Editing and debugging formulas, Updating the table, Lookup functions, The spreadsheet
2910 @subsection Editing and debugging formulas
2911 @cindex formula editing
2912 @cindex editing, of table formulas
2914 @vindex org-table-use-standard-references
2915 You can edit individual formulas in the minibuffer or directly in the
2916 field.  Org can also prepare a special buffer with all active
2917 formulas of a table.  When offering a formula for editing, Org
2918 converts references to the standard format (like @code{B3} or @code{D&})
2919 if possible.  If you prefer to only work with the internal format (like
2920 @code{@@3$2} or @code{$4}), configure the variable
2921 @code{org-table-use-standard-references}.
2923 @table @kbd
2924 @orgcmdkkc{C-c =,C-u C-c =,org-table-eval-formula}
2925 Edit the formula associated with the current column/field in the
2926 minibuffer.  See @ref{Column formulas}, and @ref{Field and range formulas}.
2927 @orgcmd{C-u C-u C-c =,org-table-eval-formula}
2928 Re-insert the active formula (either a
2929 field formula, or a column formula) into the current field, so that you
2930 can edit it directly in the field.  The advantage over editing in the
2931 minibuffer is that you can use the command @kbd{C-c ?}.
2932 @orgcmd{C-c ?,org-table-field-info}
2933 While editing a formula in a table field, highlight the field(s)
2934 referenced by the reference at the cursor position in the formula.
2935 @kindex C-c @}
2936 @findex org-table-toggle-coordinate-overlays
2937 @item C-c @}
2938 Toggle the display of row and column numbers for a table, using overlays
2939 (@command{org-table-toggle-coordinate-overlays}).  These are updated each
2940 time the table is aligned; you can force it with @kbd{C-c C-c}.
2941 @kindex C-c @{
2942 @findex org-table-toggle-formula-debugger
2943 @item C-c @{
2944 Toggle the formula debugger on and off
2945 (@command{org-table-toggle-formula-debugger}).  See below.
2946 @orgcmd{C-c ',org-table-edit-formulas}
2947 Edit all formulas for the current table in a special buffer, where the
2948 formulas will be displayed one per line.  If the current field has an
2949 active formula, the cursor in the formula editor will mark it.
2950 While inside the special buffer, Org will automatically highlight
2951 any field or range reference at the cursor position.  You may edit,
2952 remove and add formulas, and use the following commands:
2954 @table @kbd
2955 @orgcmdkkc{C-c C-c,C-x C-s,org-table-fedit-finish}
2956 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2957 prefix, also apply the new formulas to the entire table.
2958 @orgcmd{C-c C-q,org-table-fedit-abort}
2959 Exit the formula editor without installing changes.
2960 @orgcmd{C-c C-r,org-table-fedit-toggle-ref-type}
2961 Toggle all references in the formula editor between standard (like
2962 @code{B3}) and internal (like @code{@@3$2}).
2963 @orgcmd{@key{TAB},org-table-fedit-lisp-indent}
2964 Pretty-print or indent Lisp formula at point.  When in a line containing
2965 a Lisp formula, format the formula according to Emacs Lisp rules.
2966 Another @key{TAB} collapses the formula back again.  In the open
2967 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
2968 @orgcmd{M-@key{TAB},lisp-complete-symbol}
2969 Complete Lisp symbols, just like in Emacs Lisp mode.
2970 @kindex S-@key{up}
2971 @kindex S-@key{down}
2972 @kindex S-@key{left}
2973 @kindex S-@key{right}
2974 @findex org-table-fedit-ref-up
2975 @findex org-table-fedit-ref-down
2976 @findex org-table-fedit-ref-left
2977 @findex org-table-fedit-ref-right
2978 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2979 Shift the reference at point.  For example, if the reference is
2980 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2981 This also works for relative references and for hline references.
2982 @orgcmdkkcc{M-S-@key{up},M-S-@key{down},org-table-fedit-line-up,org-table-fedit-line-down}
2983 Move the test line for column formulas in the Org buffer up and
2984 down.
2985 @orgcmdkkcc{M-@key{up},M-@key{down},org-table-fedit-scroll-down,org-table-fedit-scroll-up}
2986 Scroll the window displaying the table.
2987 @kindex C-c @}
2988 @findex org-table-toggle-coordinate-overlays
2989 @item C-c @}
2990 Turn the coordinate grid in the table on and off.
2991 @end table
2992 @end table
2994 Making a table field blank does not remove the formula associated with
2995 the field, because that is stored in a different line (the @samp{#+TBLFM}
2996 line)---during the next recalculation the field will be filled again.
2997 To remove a formula from a field, you have to give an empty reply when
2998 prompted for the formula, or to edit the @samp{#+TBLFM} line.
3000 @kindex C-c C-c
3001 You may edit the @samp{#+TBLFM} directly and re-apply the changed
3002 equations with @kbd{C-c C-c} in that line or with the normal
3003 recalculation commands in the table.
3005 @subsubheading Debugging formulas
3006 @cindex formula debugging
3007 @cindex debugging, of table formulas
3008 When the evaluation of a formula leads to an error, the field content
3009 becomes the string @samp{#ERROR}.  If you would like see what is going
3010 on during variable substitution and calculation in order to find a bug,
3011 turn on formula debugging in the @code{Tbl} menu and repeat the
3012 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
3013 field.  Detailed information will be displayed.
3015 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
3016 @subsection Updating the table
3017 @cindex recomputing table fields
3018 @cindex updating, table
3020 Recalculation of a table is normally not automatic, but needs to be
3021 triggered by a command.  See @ref{Advanced features}, for a way to make
3022 recalculation at least semi-automatic.
3024 In order to recalculate a line of a table or the entire table, use the
3025 following commands:
3027 @table @kbd
3028 @orgcmd{C-c *,org-table-recalculate}
3029 Recalculate the current row by first applying the stored column formulas
3030 from left to right, and all field/range formulas in the current row.
3032 @kindex C-u C-c *
3033 @item C-u C-c *
3034 @kindex C-u C-c C-c
3035 @itemx C-u C-c C-c
3036 Recompute the entire table, line by line.  Any lines before the first
3037 hline are left alone, assuming that these are part of the table header.
3039 @orgcmdkkc{C-u C-u C-c *,C-u C-u C-c C-c,org-table-iterate}
3040 Iterate the table by recomputing it until no further changes occur.
3041 This may be necessary if some computed fields use the value of other
3042 fields that are computed @i{later} in the calculation sequence.
3043 @item M-x org-table-recalculate-buffer-tables
3044 @findex org-table-recalculate-buffer-tables
3045 Recompute all tables in the current buffer.
3046 @item M-x org-table-iterate-buffer-tables
3047 @findex org-table-iterate-buffer-tables
3048 Iterate all tables in the current buffer, in order to converge table-to-table
3049 dependencies.
3050 @end table
3052 @node Advanced features,  , Updating the table, The spreadsheet
3053 @subsection Advanced features
3055 If you want the recalculation of fields to happen automatically, or if you
3056 want to be able to assign @i{names}@footnote{Such names must start by an
3057 alphabetic character and use only alphanumeric/underscore characters.} to
3058 fields and columns, you need to reserve the first column of the table for
3059 special marking characters.
3061 @table @kbd
3062 @orgcmd{C-#,org-table-rotate-recalc-marks}
3063 Rotate the calculation mark in first column through the states @samp{ },
3064 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
3065 change all marks in the region.
3066 @end table
3068 Here is an example of a table that collects exam results of students and
3069 makes use of these features:
3071 @example
3072 @group
3073 |---+---------+--------+--------+--------+-------+------|
3074 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
3075 |---+---------+--------+--------+--------+-------+------|
3076 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
3077 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
3078 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
3079 |---+---------+--------+--------+--------+-------+------|
3080 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
3081 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
3082 |---+---------+--------+--------+--------+-------+------|
3083 |   | Average |        |        |        |  25.0 |      |
3084 | ^ |         |        |        |        |    at |      |
3085 | $ | max=50  |        |        |        |       |      |
3086 |---+---------+--------+--------+--------+-------+------|
3087 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
3088 @end group
3089 @end example
3091 @noindent @b{Important}: please note that for these special tables,
3092 recalculating the table with @kbd{C-u C-c *} will only affect rows that
3093 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
3094 to the field itself.  The column formulas are not applied in rows with
3095 empty first field.
3097 @cindex marking characters, tables
3098 The marking characters have the following meaning:
3100 @table @samp
3101 @item !
3102 The fields in this line define names for the columns, so that you may
3103 refer to a column as @samp{$Tot} instead of @samp{$6}.
3104 @item ^
3105 This row defines names for the fields @emph{above} the row.  With such
3106 a definition, any formula in the table may use @samp{$m1} to refer to
3107 the value @samp{10}.  Also, if you assign a formula to a names field, it
3108 will be stored as @samp{$name=...}.
3109 @item _
3110 Similar to @samp{^}, but defines names for the fields in the row
3111 @emph{below}.
3112 @item $
3113 Fields in this row can define @emph{parameters} for formulas.  For
3114 example, if a field in a @samp{$} row contains @samp{max=50}, then
3115 formulas in this table can refer to the value 50 using @samp{$max}.
3116 Parameters work exactly like constants, only that they can be defined on
3117 a per-table basis.
3118 @item #
3119 Fields in this row are automatically recalculated when pressing
3120 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
3121 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
3122 lines will be left alone by this command.
3123 @item *
3124 Selects this line for global recalculation with @kbd{C-u C-c *}, but
3125 not for automatic recalculation.  Use this when automatic
3126 recalculation slows down editing too much.
3127 @item @w{ }
3128 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
3129 All lines that should be recalculated should be marked with @samp{#}
3130 or @samp{*}.
3131 @item /
3132 Do not export this line.  Useful for lines that contain the narrowing
3133 @samp{<N>} markers or column group markers.
3134 @end table
3136 Finally, just to whet your appetite for what can be done with the
3137 fantastic @file{calc.el} package, here is a table that computes the Taylor
3138 series of degree @code{n} at location @code{x} for a couple of
3139 functions.
3141 @example
3142 @group
3143 |---+-------------+---+-----+--------------------------------------|
3144 |   | Func        | n | x   | Result                               |
3145 |---+-------------+---+-----+--------------------------------------|
3146 | # | exp(x)      | 1 | x   | 1 + x                                |
3147 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
3148 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
3149 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
3150 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
3151 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
3152 |---+-------------+---+-----+--------------------------------------|
3153 #+TBLFM: $5=taylor($2,$4,$3);n3
3154 @end group
3155 @end example
3157 @node Org-Plot,  , The spreadsheet, Tables
3158 @section Org-Plot
3159 @cindex graph, in tables
3160 @cindex plot tables using Gnuplot
3161 @cindex #+PLOT
3163 Org-Plot can produce 2D and 3D graphs of information stored in org tables
3164 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
3165 @uref{http://xafs.org/BruceRavel/GnuplotMode}.  To see this in action, ensure
3166 that you have both Gnuplot and Gnuplot mode installed on your system, then
3167 call @code{org-plot/gnuplot} on the following table.
3169 @example
3170 @group
3171 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
3172 | Sede      | Max cites | H-index |
3173 |-----------+-----------+---------|
3174 | Chile     |    257.72 |   21.39 |
3175 | Leeds     |    165.77 |   19.68 |
3176 | Sao Paolo |     71.00 |   11.50 |
3177 | Stockholm |    134.19 |   14.33 |
3178 | Morelia   |    257.56 |   17.67 |
3179 @end group
3180 @end example
3182 Notice that Org Plot is smart enough to apply the table's headers as labels.
3183 Further control over the labels, type, content, and appearance of plots can
3184 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
3185 for a complete list of Org-plot options.  For more information and examples
3186 see the Org-plot tutorial at
3187 @uref{http://orgmode.org/worg/org-tutorials/org-plot.html}.
3189 @subsubheading Plot Options
3191 @table @code
3192 @item set
3193 Specify any @command{gnuplot} option to be set when graphing.
3195 @item title
3196 Specify the title of the plot.
3198 @item ind
3199 Specify which column of the table to use as the @code{x} axis.
3201 @item deps
3202 Specify the columns to graph as a Lisp style list, surrounded by parentheses
3203 and separated by spaces for example @code{dep:(3 4)} to graph the third and
3204 fourth columns (defaults to graphing all other columns aside from the @code{ind}
3205 column).
3207 @item type
3208 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
3210 @item with
3211 Specify a @code{with} option to be inserted for every col being plotted
3212 (e.g., @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
3213 Defaults to @code{lines}.
3215 @item file
3216 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
3218 @item labels
3219 List of labels to be used for the @code{deps} (defaults to the column headers
3220 if they exist).
3222 @item line
3223 Specify an entire line to be inserted in the Gnuplot script.
3225 @item map
3226 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
3227 flat mapping rather than a @code{3d} slope.
3229 @item timefmt
3230 Specify format of Org mode timestamps as they will be parsed by Gnuplot.
3231 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
3233 @item script
3234 If you want total control, you can specify a script file (place the file name
3235 between double-quotes) which will be used to plot.  Before plotting, every
3236 instance of @code{$datafile} in the specified script will be replaced with
3237 the path to the generated data file.  Note: even if you set this option, you
3238 may still want to specify the plot type, as that can impact the content of
3239 the data file.
3240 @end table
3242 @node Hyperlinks, TODO Items, Tables, Top
3243 @chapter Hyperlinks
3244 @cindex hyperlinks
3246 Like HTML, Org provides links inside a file, external links to
3247 other files, Usenet articles, emails, and much more.
3249 @menu
3250 * Link format::                 How links in Org are formatted
3251 * Internal links::              Links to other places in the current file
3252 * External links::              URL-like links to the world
3253 * Handling links::              Creating, inserting and following
3254 * Using links outside Org::     Linking from my C source code?
3255 * Link abbreviations::          Shortcuts for writing complex links
3256 * Search options::              Linking to a specific location
3257 * Custom searches::             When the default search is not enough
3258 @end menu
3260 @node Link format, Internal links, Hyperlinks, Hyperlinks
3261 @section Link format
3262 @cindex link format
3263 @cindex format, of links
3265 Org will recognize plain URL-like links and activate them as
3266 clickable links.  The general link format, however, looks like this:
3268 @example
3269 [[link][description]]       @r{or alternatively}           [[link]]
3270 @end example
3272 @noindent
3273 Once a link in the buffer is complete (all brackets present), Org
3274 will change the display so that @samp{description} is displayed instead
3275 of @samp{[[link][description]]} and @samp{link} is displayed instead of
3276 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
3277 which by default is an underlined face.  You can directly edit the
3278 visible part of a link.  Note that this can be either the @samp{link}
3279 part (if there is no description) or the @samp{description} part.  To
3280 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
3281 cursor on the link.
3283 If you place the cursor at the beginning or just behind the end of the
3284 displayed text and press @key{BACKSPACE}, you will remove the
3285 (invisible) bracket at that location.  This makes the link incomplete
3286 and the internals are again displayed as plain text.  Inserting the
3287 missing bracket hides the link internals again.  To show the
3288 internal structure of all links, use the menu entry
3289 @code{Org->Hyperlinks->Literal links}.
3291 @node Internal links, External links, Link format, Hyperlinks
3292 @section Internal links
3293 @cindex internal links
3294 @cindex links, internal
3295 @cindex targets, for links
3297 @cindex property, CUSTOM_ID
3298 If the link does not look like a URL, it is considered to be internal in the
3299 current file.  The most important case is a link like
3300 @samp{[[#my-custom-id]]} which will link to the entry with the
3301 @code{CUSTOM_ID} property @samp{my-custom-id}.  Such custom IDs are very good
3302 for HTML export (@pxref{HTML export}) where they produce pretty section
3303 links.  You are responsible yourself to make sure these custom IDs are unique
3304 in a file.
3306 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
3307 lead to a text search in the current file.
3309 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
3310 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
3311 point to the corresponding headline.  The preferred match for a text link is
3312 a @i{dedicated target}: the same string in double angular brackets.  Targets
3313 may be located anywhere; sometimes it is convenient to put them into a
3314 comment line.  For example
3316 @example
3317 # <<My Target>>
3318 @end example
3320 @noindent In HTML export (@pxref{HTML export}), such targets will become
3321 named anchors for direct access through @samp{http} links@footnote{Note that
3322 text before the first headline is usually not exported, so the first such
3323 target should be after the first headline, or in the line directly before the
3324 first headline.}.
3326 If no dedicated target exists, Org will search for a headline that is exactly
3327 the link text but may also include a TODO keyword and tags@footnote{To insert
3328 a link targeting a headline, in-buffer completion can be used.  Just type a
3329 star followed by a few optional letters into the buffer and press
3330 @kbd{M-@key{TAB}}.  All headlines in the current buffer will be offered as
3331 completions.}.  In non-Org files, the search will look for the words in the
3332 link text.  In the above example the search would be for @samp{my target}.
3334 Following a link pushes a mark onto Org's own mark ring.  You can
3335 return to the previous position with @kbd{C-c &}.  Using this command
3336 several times in direct succession goes back to positions recorded
3337 earlier.
3339 @menu
3340 * Radio targets::               Make targets trigger links in plain text
3341 @end menu
3343 @node Radio targets,  , Internal links, Internal links
3344 @subsection Radio targets
3345 @cindex radio targets
3346 @cindex targets, radio
3347 @cindex links, radio targets
3349 Org can automatically turn any occurrences of certain target names
3350 in normal text into a link.  So without explicitly creating a link, the
3351 text connects to the target radioing its position.  Radio targets are
3352 enclosed by triple angular brackets.  For example, a target @samp{<<<My
3353 Target>>>} causes each occurrence of @samp{my target} in normal text to
3354 become activated as a link.  The Org file is scanned automatically
3355 for radio targets only when the file is first loaded into Emacs.  To
3356 update the target list during editing, press @kbd{C-c C-c} with the
3357 cursor on or at a target.
3359 @node External links, Handling links, Internal links, Hyperlinks
3360 @section External links
3361 @cindex links, external
3362 @cindex external links
3363 @cindex links, external
3364 @cindex Gnus links
3365 @cindex BBDB links
3366 @cindex IRC links
3367 @cindex URL links
3368 @cindex file links
3369 @cindex VM links
3370 @cindex RMAIL links
3371 @cindex WANDERLUST links
3372 @cindex MH-E links
3373 @cindex USENET links
3374 @cindex SHELL links
3375 @cindex Info links
3376 @cindex Elisp links
3378 Org supports links to files, websites, Usenet and email messages,
3379 BBDB database entries and links to both IRC conversations and their
3380 logs.  External links are URL-like locators.  They start with a short
3381 identifying string followed by a colon.  There can be no space after
3382 the colon.  The following list shows examples for each link type.
3384 @example
3385 http://www.astro.uva.nl/~dominik          @r{on the web}
3386 doi:10.1000/182                           @r{DOI for an electronic resource}
3387 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
3388 /home/dominik/images/jupiter.jpg          @r{same as above}
3389 file:papers/last.pdf                      @r{file, relative path}
3390 ./papers/last.pdf                         @r{same as above}
3391 file:/myself@@some.where:papers/last.pdf   @r{file, path on remote machine}
3392 /myself@@some.where:papers/last.pdf        @r{same as above}
3393 file:sometextfile::NNN                    @r{file, jump to line number}
3394 file:projects.org                         @r{another Org file}
3395 file:projects.org::some words             @r{text search in Org file}@footnote{
3396 The actual behavior of the search will depend on the value of
3397 the variable @code{org-link-search-must-match-exact-headline}.  If its value
3398 is nil, then a fuzzy text search will be done.  If it is t, then only the
3399 exact headline will be matched.  If the value is @code{'query-to-create},
3400 then an exact headline will be searched; if it is not found, then the user
3401 will be queried to create it.}
3402 file:projects.org::*task title            @r{heading search in Org file}
3403 file+sys:/path/to/file                    @r{open via OS, like double-click}
3404 file+emacs:/path/to/file                  @r{force opening by Emacs}
3405 docview:papers/last.pdf::NNN              @r{open in doc-view mode at page}
3406 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
3407 news:comp.emacs                           @r{Usenet link}
3408 mailto:adent@@galaxy.net                   @r{Mail link}
3409 vm:folder                                 @r{VM folder link}
3410 vm:folder#id                              @r{VM message link}
3411 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
3412 vm-imap:account:folder                    @r{VM IMAP folder link}
3413 vm-imap:account:folder#id                 @r{VM IMAP message link}
3414 wl:folder                                 @r{WANDERLUST folder link}
3415 wl:folder#id                              @r{WANDERLUST message link}
3416 mhe:folder                                @r{MH-E folder link}
3417 mhe:folder#id                             @r{MH-E message link}
3418 rmail:folder                              @r{RMAIL folder link}
3419 rmail:folder#id                           @r{RMAIL message link}
3420 gnus:group                                @r{Gnus group link}
3421 gnus:group#id                             @r{Gnus article link}
3422 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
3423 irc:/irc.com/#emacs/bob                   @r{IRC link}
3424 info:org#External links                   @r{Info node link}
3425 shell:ls *.org                            @r{A shell command}
3426 elisp:org-agenda                          @r{Interactive Elisp command}
3427 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
3428 @end example
3430 For customizing Org to add new link types @ref{Adding hyperlink types}.
3432 A link should be enclosed in double brackets and may contain a
3433 descriptive text to be displayed instead of the URL (@pxref{Link
3434 format}), for example:
3436 @example
3437 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3438 @end example
3440 @noindent
3441 If the description is a file name or URL that points to an image, HTML
3442 export (@pxref{HTML export}) will inline the image as a clickable
3443 button.  If there is no description at all and the link points to an
3444 image,
3445 that image will be inlined into the exported HTML file.
3447 @cindex square brackets, around links
3448 @cindex plain text external links
3449 Org also finds external links in the normal text and activates them
3450 as links.  If spaces must be part of the link (for example in
3451 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
3452 about the end of the link, enclose them in square brackets.
3454 @node Handling links, Using links outside Org, External links, Hyperlinks
3455 @section Handling links
3456 @cindex links, handling
3458 Org provides methods to create a link in the correct syntax, to
3459 insert it into an Org file, and to follow the link.
3461 @table @kbd
3462 @orgcmd{C-c l,org-store-link}
3463 @cindex storing links
3464 Store a link to the current location.  This is a @emph{global} command (you
3465 must create the key binding yourself) which can be used in any buffer to
3466 create a link.  The link will be stored for later insertion into an Org
3467 buffer (see below).  What kind of link will be created depends on the current
3468 buffer:
3470 @b{Org mode buffers}@*
3471 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
3472 to the target.  Otherwise it points to the current headline, which will also
3473 be the description@footnote{If the headline contains a timestamp, it will be
3474 removed from the link and result in a wrong link---you should avoid putting
3475 timestamp in the headline.}.
3477 @vindex org-id-link-to-org-use-id
3478 @cindex property, CUSTOM_ID
3479 @cindex property, ID
3480 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
3481 will be stored.  In addition or alternatively (depending on the value of
3482 @code{org-id-link-to-org-use-id}), a globally unique @code{ID} property will
3483 be created and/or used to construct a link@footnote{The library @code{org-id}
3484 must first be loaded, either through @code{org-customize} by enabling
3485 @code{id} in @code{org-modules} , or by adding @code{(require 'org-id)} in
3486 your @file{.emacs}.}. So using this command in Org
3487 buffers will potentially create two links: a human-readable from the custom
3488 ID, and one that is globally unique and works even if the entry is moved from
3489 file to file.  Later, when inserting the link, you need to decide which one
3490 to use.
3492 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
3493 Pretty much all Emacs mail clients are supported.  The link will point to the
3494 current article, or, in some GNUS buffers, to the group.  The description is
3495 constructed from the author and the subject.
3497 @b{Web browsers: W3 and W3M}@*
3498 Here the link will be the current URL, with the page title as description.
3500 @b{Contacts: BBDB}@*
3501 Links created in a BBDB buffer will point to the current entry.
3503 @b{Chat: IRC}@*
3504 @vindex org-irc-link-to-logs
3505 For IRC links, if you set the variable @code{org-irc-link-to-logs} to
3506 @code{t}, a @samp{file:/} style link to the relevant point in the logs for
3507 the current conversation is created.  Otherwise an @samp{irc:/} style link to
3508 the user/channel/server under the point will be stored.
3510 @b{Other files}@*
3511 For any other files, the link will point to the file, with a search string
3512 (@pxref{Search options}) pointing to the contents of the current line.  If
3513 there is an active region, the selected words will form the basis of the
3514 search string.  If the automatically created link is not working correctly or
3515 accurately enough, you can write custom functions to select the search string
3516 and to do the search for particular file types---see @ref{Custom searches}.
3517 The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
3519 @b{Agenda view}@*
3520 When the cursor is in an agenda view, the created link points to the
3521 entry referenced by the current line.
3524 @orgcmd{C-c C-l,org-insert-link}
3525 @cindex link completion
3526 @cindex completion, of links
3527 @cindex inserting links
3528 @vindex org-keep-stored-link-after-insertion
3529 Insert a link@footnote{ Note that you don't have to use this command to
3530 insert a link.  Links in Org are plain text, and you can type or paste them
3531 straight into the buffer.  By using this command, the links are automatically
3532 enclosed in double brackets, and you will be asked for the optional
3533 descriptive text.}.  This prompts for a link to be inserted into the buffer.
3534 You can just type a link, using text for an internal link, or one of the link
3535 type prefixes mentioned in the examples above.  The link will be inserted
3536 into the buffer@footnote{After insertion of a stored link, the link will be
3537 removed from the list of stored links.  To keep it in the list later use, use
3538 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
3539 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
3540 If some text was selected when this command is called, the selected text
3541 becomes the default description.
3543 @b{Inserting stored links}@*
3544 All links stored during the
3545 current session are part of the history for this prompt, so you can access
3546 them with @key{up} and @key{down} (or @kbd{M-p/n}).
3548 @b{Completion support}@* Completion with @key{TAB} will help you to insert
3549 valid link prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
3550 defined through link abbreviations (@pxref{Link abbreviations}).  If you
3551 press @key{RET} after inserting only the @var{prefix}, Org will offer
3552 specific completion support for some link types@footnote{This works by
3553 calling a special function @code{org-PREFIX-complete-link}.}  For
3554 example, if you type @kbd{file @key{RET}}, file name completion (alternative
3555 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
3556 @key{RET}} you can complete contact names.
3557 @orgkey C-u C-c C-l
3558 @cindex file name completion
3559 @cindex completion, of file names
3560 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
3561 a file will be inserted and you may use file name completion to select
3562 the name of the file.  The path to the file is inserted relative to the
3563 directory of the current Org file, if the linked file is in the current
3564 directory or in a sub-directory of it, or if the path is written relative
3565 to the current directory using @samp{../}.  Otherwise an absolute path
3566 is used, if possible with @samp{~/} for your home directory.  You can
3567 force an absolute path with two @kbd{C-u} prefixes.
3569 @item C-c C-l @ @r{(with cursor on existing link)}
3570 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
3571 link and description parts of the link.
3573 @cindex following links
3574 @orgcmd{C-c C-o,org-open-at-point}
3575 @vindex org-file-apps
3576 @vindex org-link-frame-setup
3577 Open link at point.  This will launch a web browser for URLs (using
3578 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
3579 the corresponding links, and execute the command in a shell link.  When the
3580 cursor is on an internal link, this command runs the corresponding search.
3581 When the cursor is on a TAG list in a headline, it creates the corresponding
3582 TAGS view.  If the cursor is on a timestamp, it compiles the agenda for that
3583 date.  Furthermore, it will visit text and remote files in @samp{file:} links
3584 with Emacs and select a suitable application for local non-text files.
3585 Classification of files is based on file extension only.  See option
3586 @code{org-file-apps}.  If you want to override the default application and
3587 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
3588 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
3589 If the cursor is on a headline, but not on a link, offer all links in the
3590 headline and entry text.  If you want to setup the frame configuration for
3591 following links, customize @code{org-link-frame-setup}.
3593 @orgkey @key{RET}
3594 @vindex org-return-follows-link
3595 When @code{org-return-follows-link} is set, @kbd{@key{RET}} will also follow
3596 the link at point.
3598 @kindex mouse-2
3599 @kindex mouse-1
3600 @item mouse-2
3601 @itemx mouse-1
3602 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
3603 would.  Under Emacs 22 and later, @kbd{mouse-1} will also follow a link.
3605 @kindex mouse-3
3606 @item mouse-3
3607 @vindex org-display-internal-link-with-indirect-buffer
3608 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
3609 internal links to be displayed in another window@footnote{See the
3610 variable @code{org-display-internal-link-with-indirect-buffer}}.
3612 @orgcmd{C-c C-x C-v,org-toggle-inline-images}
3613 @cindex inlining images
3614 @cindex images, inlining
3615 @vindex org-startup-with-inline-images
3616 @cindex @code{inlineimages}, STARTUP keyword
3617 @cindex @code{noinlineimages}, STARTUP keyword
3618 Toggle the inline display of linked images.  Normally this will only inline
3619 images that have no description part in the link, i.e., images that will also
3620 be inlined during export.  When called with a prefix argument, also display
3621 images that do have a link description.  You can ask for inline images to be
3622 displayed at startup by configuring the variable
3623 @code{org-startup-with-inline-images}@footnote{with corresponding
3624 @code{#+STARTUP} keywords @code{inlineimages} and @code{inlineimages}}.
3625 @orgcmd{C-c %,org-mark-ring-push}
3626 @cindex mark ring
3627 Push the current position onto the mark ring, to be able to return
3628 easily.  Commands following an internal link do this automatically.
3630 @orgcmd{C-c &,org-mark-ring-goto}
3631 @cindex links, returning to
3632 Jump back to a recorded position.  A position is recorded by the
3633 commands following internal links, and by @kbd{C-c %}.  Using this
3634 command several times in direct succession moves through a ring of
3635 previously recorded positions.
3637 @orgcmdkkcc{C-c C-x C-n,C-c C-x C-p,org-next-link,org-previous-link}
3638 @cindex links, finding next/previous
3639 Move forward/backward to the next link in the buffer.  At the limit of
3640 the buffer, the search fails once, and then wraps around.  The key
3641 bindings for this are really too long; you might want to bind this also
3642 to @kbd{C-n} and @kbd{C-p}
3643 @lisp
3644 (add-hook 'org-load-hook
3645   (lambda ()
3646     (define-key org-mode-map "\C-n" 'org-next-link)
3647     (define-key org-mode-map "\C-p" 'org-previous-link)))
3648 @end lisp
3649 @end table
3651 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
3652 @section Using links outside Org
3654 You can insert and follow links that have Org syntax not only in
3655 Org, but in any Emacs buffer.  For this, you should create two
3656 global commands, like this (please select suitable global keys
3657 yourself):
3659 @lisp
3660 (global-set-key "\C-c L" 'org-insert-link-global)
3661 (global-set-key "\C-c o" 'org-open-at-point-global)
3662 @end lisp
3664 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
3665 @section Link abbreviations
3666 @cindex link abbreviations
3667 @cindex abbreviation, links
3669 Long URLs can be cumbersome to type, and often many similar links are
3670 needed in a document.  For this you can use link abbreviations.  An
3671 abbreviated link looks like this
3673 @example
3674 [[linkword:tag][description]]
3675 @end example
3677 @noindent
3678 @vindex org-link-abbrev-alist
3679 where the tag is optional.
3680 The @i{linkword} must be a word, starting with a letter, followed by
3681 letters, numbers, @samp{-}, and @samp{_}.  Abbreviations are resolved
3682 according to the information in the variable @code{org-link-abbrev-alist}
3683 that relates the linkwords to replacement text.  Here is an example:
3685 @smalllisp
3686 @group
3687 (setq org-link-abbrev-alist
3688   '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3689     ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
3690     ("google"    . "http://www.google.com/search?q=")
3691     ("gmap"      . "http://maps.google.com/maps?q=%s")
3692     ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
3693     ("ads"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
3694 @end group
3695 @end smalllisp
3697 If the replacement text contains the string @samp{%s}, it will be
3698 replaced with the tag.  Using @samp{%h} instead of @samp{%s} will
3699 url-encode the tag (see the example above, where we need to encode
3700 the URL parameter.)  Using @samp{%(my-function)} will pass the tag
3701 to a custom function, and replace it by the resulting string.
3703 If the replacement text don't contain any specifier, it will simply
3704 be appended to the string in order to create the link.
3706 Instead of a string, you may also specify a function that will be
3707 called with the tag as the only argument to create the link.
3709 With the above setting, you could link to a specific bug with
3710 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
3711 @code{[[google:OrgMode]]}, show the map location of the Free Software
3712 Foundation @code{[[gmap:51 Franklin Street, Boston]]} or of Carsten office
3713 @code{[[omap:Science Park 904, Amsterdam, The Netherlands]]} and find out
3714 what the Org author is doing besides Emacs hacking with
3715 @code{[[ads:Dominik,C]]}.
3717 If you need special abbreviations just for a single Org buffer, you
3718 can define them in the file with
3720 @cindex #+LINK
3721 @example
3722 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3723 #+LINK: google    http://www.google.com/search?q=%s
3724 @end example
3726 @noindent
3727 In-buffer completion (@pxref{Completion}) can be used after @samp{[} to
3728 complete link abbreviations.  You may also define a function
3729 @code{org-PREFIX-complete-link} that implements special (e.g., completion)
3730 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
3731 not accept any arguments, and return the full link with prefix.
3733 @node Search options, Custom searches, Link abbreviations, Hyperlinks
3734 @section Search options in file links
3735 @cindex search option in file links
3736 @cindex file links, searching
3738 File links can contain additional information to make Emacs jump to a
3739 particular location in the file when following a link.  This can be a
3740 line number or a search option after a double@footnote{For backward
3741 compatibility, line numbers can also follow a single colon.} colon.  For
3742 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
3743 links}) to a file, it encodes the words in the current line as a search
3744 string that can be used to find this line back later when following the
3745 link with @kbd{C-c C-o}.
3747 Here is the syntax of the different ways to attach a search to a file
3748 link, together with an explanation:
3750 @example
3751 [[file:~/code/main.c::255]]
3752 [[file:~/xx.org::My Target]]
3753 [[file:~/xx.org::*My Target]]
3754 [[file:~/xx.org::#my-custom-id]]
3755 [[file:~/xx.org::/regexp/]]
3756 @end example
3758 @table @code
3759 @item 255
3760 Jump to line 255.
3761 @item My Target
3762 Search for a link target @samp{<<My Target>>}, or do a text search for
3763 @samp{my target}, similar to the search in internal links, see
3764 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3765 link will become a HTML reference to the corresponding named anchor in
3766 the linked file.
3767 @item *My Target
3768 In an Org file, restrict search to headlines.
3769 @item #my-custom-id
3770 Link to a heading with a @code{CUSTOM_ID} property
3771 @item /regexp/
3772 Do a regular expression search for @code{regexp}.  This uses the Emacs
3773 command @code{occur} to list all matches in a separate window.  If the
3774 target file is in Org mode, @code{org-occur} is used to create a
3775 sparse tree with the matches.
3776 @c If the target file is a directory,
3777 @c @code{grep} will be used to search all files in the directory.
3778 @end table
3780 As a degenerate case, a file link with an empty file name can be used
3781 to search the current file.  For example, @code{[[file:::find me]]} does
3782 a search for @samp{find me} in the current file, just as
3783 @samp{[[find me]]} would.
3785 @node Custom searches,  , Search options, Hyperlinks
3786 @section Custom Searches
3787 @cindex custom search strings
3788 @cindex search strings, custom
3790 The default mechanism for creating search strings and for doing the
3791 actual search related to a file link may not work correctly in all
3792 cases.  For example, Bib@TeX{} database files have many entries like
3793 @samp{year="1993"} which would not result in good search strings,
3794 because the only unique identification for a Bib@TeX{} entry is the
3795 citation key.
3797 @vindex org-create-file-search-functions
3798 @vindex org-execute-file-search-functions
3799 If you come across such a problem, you can write custom functions to set
3800 the right search string for a particular file type, and to do the search
3801 for the string in the file.  Using @code{add-hook}, these functions need
3802 to be added to the hook variables
3803 @code{org-create-file-search-functions} and
3804 @code{org-execute-file-search-functions}.  See the docstring for these
3805 variables for more information.  Org actually uses this mechanism
3806 for Bib@TeX{} database files, and you can use the corresponding code as
3807 an implementation example.  See the file @file{org-bibtex.el}.
3809 @node TODO Items, Tags, Hyperlinks, Top
3810 @chapter TODO items
3811 @cindex TODO items
3813 Org mode does not maintain TODO lists as separate documents@footnote{Of
3814 course, you can make a document that contains only long lists of TODO items,
3815 but this is not required.}.  Instead, TODO items are an integral part of the
3816 notes file, because TODO items usually come up while taking notes!  With Org
3817 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3818 information is not duplicated, and the entire context from which the TODO
3819 item emerged is always present.
3821 Of course, this technique for managing TODO items scatters them
3822 throughout your notes file.  Org mode compensates for this by providing
3823 methods to give you an overview of all the things that you have to do.
3825 @menu
3826 * TODO basics::                 Marking and displaying TODO entries
3827 * TODO extensions::             Workflow and assignments
3828 * Progress logging::            Dates and notes for progress
3829 * Priorities::                  Some things are more important than others
3830 * Breaking down tasks::         Splitting a task into manageable pieces
3831 * Checkboxes::                  Tick-off lists
3832 @end menu
3834 @node TODO basics, TODO extensions, TODO Items, TODO Items
3835 @section Basic TODO functionality
3837 Any headline becomes a TODO item when it starts with the word
3838 @samp{TODO}, for example:
3840 @example
3841 *** TODO Write letter to Sam Fortune
3842 @end example
3844 @noindent
3845 The most important commands to work with TODO entries are:
3847 @table @kbd
3848 @orgcmd{C-c C-t,org-todo}
3849 @cindex cycling, of TODO states
3850 @vindex org-use-fast-todo-selection
3852 Rotate the TODO state of the current item among
3854 @example
3855 ,-> (unmarked) -> TODO -> DONE --.
3856 '--------------------------------'
3857 @end example
3859 If TODO keywords have fast access keys (see @ref{Fast access to TODO
3860 states}), you will be prompted for a TODO keyword through the fast selection
3861 interface; this is the default behavior when
3862 @var{org-use-fast-todo-selection} is non-nil.
3864 The same rotation can also be done ``remotely'' from the timeline and agenda
3865 buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3867 @orgkey{C-u C-c C-t}
3868 When TODO keywords have no selection keys, select a specific keyword using
3869 completion; otherwise force cycling through TODO states with no prompt.  When
3870 @var{org-use-fast-todo-selection} is set to @code{prefix}, use the fast
3871 selection interface.
3873 @kindex S-@key{right}
3874 @kindex S-@key{left}
3875 @item S-@key{right} @ @r{/} @ S-@key{left}
3876 @vindex org-treat-S-cursor-todo-selection-as-state-change
3877 Select the following/preceding TODO state, similar to cycling.  Useful
3878 mostly if more than two TODO states are possible (@pxref{TODO
3879 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
3880 with @code{shift-selection-mode}.  See also the variable
3881 @code{org-treat-S-cursor-todo-selection-as-state-change}.
3882 @orgcmd{C-c / t,org-show-todo-tree}
3883 @cindex sparse tree, for TODO
3884 @vindex org-todo-keywords
3885 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3886 entire buffer, but shows all TODO items (with not-DONE state) and the
3887 headings hierarchy above them.  With a prefix argument (or by using @kbd{C-c
3888 / T}), search for a specific TODO@.  You will be prompted for the keyword, and
3889 you can also give a list of keywords like @code{KWD1|KWD2|...} to list
3890 entries that match any one of these keywords.  With a numeric prefix argument
3891 N, show the tree for the Nth keyword in the variable
3892 @code{org-todo-keywords}.  With two prefix arguments, find all TODO states,
3893 both un-done and done.
3894 @orgcmd{C-c a t,org-todo-list}
3895 Show the global TODO list.  Collects the TODO items (with not-DONE states)
3896 from all agenda files (@pxref{Agenda Views}) into a single buffer.  The new
3897 buffer will be in @code{agenda-mode}, which provides commands to examine and
3898 manipulate the TODO entries from the new buffer (@pxref{Agenda commands}).
3899 @xref{Global TODO list}, for more information.
3900 @orgcmd{S-M-@key{RET},org-insert-todo-heading}
3901 Insert a new TODO entry below the current one.
3902 @end table
3904 @noindent
3905 @vindex org-todo-state-tags-triggers
3906 Changing a TODO state can also trigger tag changes.  See the docstring of the
3907 option @code{org-todo-state-tags-triggers} for details.
3909 @node TODO extensions, Progress logging, TODO basics, TODO Items
3910 @section Extended use of TODO keywords
3911 @cindex extended TODO keywords
3913 @vindex org-todo-keywords
3914 By default, marked TODO entries have one of only two states: TODO and
3915 DONE@.  Org mode allows you to classify TODO items in more complex ways
3916 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3917 special setup, the TODO keyword system can work differently in different
3918 files.
3920 Note that @i{tags} are another way to classify headlines in general and
3921 TODO items in particular (@pxref{Tags}).
3923 @menu
3924 * Workflow states::             From TODO to DONE in steps
3925 * TODO types::                  I do this, Fred does the rest
3926 * Multiple sets in one file::   Mixing it all, and still finding your way
3927 * Fast access to TODO states::  Single letter selection of a state
3928 * Per-file keywords::           Different files, different requirements
3929 * Faces for TODO keywords::     Highlighting states
3930 * TODO dependencies::           When one task needs to wait for others
3931 @end menu
3933 @node Workflow states, TODO types, TODO extensions, TODO extensions
3934 @subsection TODO keywords as workflow states
3935 @cindex TODO workflow
3936 @cindex workflow states as TODO keywords
3938 You can use TODO keywords to indicate different @emph{sequential} states
3939 in the process of working on an item, for example@footnote{Changing
3940 this variable only becomes effective after restarting Org mode in a
3941 buffer.}:
3943 @lisp
3944 (setq org-todo-keywords
3945   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3946 @end lisp
3948 The vertical bar separates the TODO keywords (states that @emph{need
3949 action}) from the DONE states (which need @emph{no further action}).  If
3950 you don't provide the separator bar, the last state is used as the DONE
3951 state.
3952 @cindex completion, of TODO keywords
3953 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3954 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED@.  You may
3955 also use a numeric prefix argument to quickly select a specific state.  For
3956 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY@.
3957 Or you can use @kbd{S-@key{left}} to go backward through the sequence.  If you
3958 define many keywords, you can use in-buffer completion
3959 (@pxref{Completion}) or even a special one-key selection scheme
3960 (@pxref{Fast access to TODO states}) to insert these words into the
3961 buffer.  Changing a TODO state can be logged with a timestamp, see
3962 @ref{Tracking TODO state changes}, for more information.
3964 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3965 @subsection TODO keywords as types
3966 @cindex TODO types
3967 @cindex names as TODO keywords
3968 @cindex types as TODO keywords
3970 The second possibility is to use TODO keywords to indicate different
3971 @emph{types} of action items.  For example, you might want to indicate
3972 that items are for ``work'' or ``home''.  Or, when you work with several
3973 people on a single project, you might want to assign action items
3974 directly to persons, by using their names as TODO keywords.  This would
3975 be set up like this:
3977 @lisp
3978 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3979 @end lisp
3981 In this case, different keywords do not indicate a sequence, but rather
3982 different types.  So the normal work flow would be to assign a task to a
3983 person, and later to mark it DONE@.  Org mode supports this style by adapting
3984 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3985 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3986 times in succession, it will still cycle through all names, in order to first
3987 select the right type for a task.  But when you return to the item after some
3988 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3989 to DONE@.  Use prefix arguments or completion to quickly select a specific
3990 name.  You can also review the items of a specific TODO type in a sparse tree
3991 by using a numeric prefix to @kbd{C-c / t}.  For example, to see all things
3992 Lucy has to do, you would use @kbd{C-3 C-c / t}.  To collect Lucy's items
3993 from all agenda files into a single buffer, you would use the numeric prefix
3994 argument as well when creating the global TODO list: @kbd{C-3 C-c a t}.
3996 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3997 @subsection Multiple keyword sets in one file
3998 @cindex TODO keyword sets
4000 Sometimes you may want to use different sets of TODO keywords in
4001 parallel.  For example, you may want to have the basic
4002 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
4003 separate state indicating that an item has been canceled (so it is not
4004 DONE, but also does not require action).  Your setup would then look
4005 like this:
4007 @lisp
4008 (setq org-todo-keywords
4009       '((sequence "TODO" "|" "DONE")
4010         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
4011         (sequence "|" "CANCELED")))
4012 @end lisp
4014 The keywords should all be different, this helps Org mode to keep track
4015 of which subsequence should be used for a given entry.  In this setup,
4016 @kbd{C-c C-t} only operates within a subsequence, so it switches from
4017 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
4018 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
4019 select the correct sequence.  Besides the obvious ways like typing a
4020 keyword or using completion, you may also apply the following commands:
4022 @table @kbd
4023 @kindex C-S-@key{right}
4024 @kindex C-S-@key{left}
4025 @kindex C-u C-u C-c C-t
4026 @item C-u C-u C-c C-t
4027 @itemx C-S-@key{right}
4028 @itemx C-S-@key{left}
4029 These keys jump from one TODO subset to the next.  In the above example,
4030 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
4031 @code{DONE} to @code{REPORT}, and any of the words in the second row to
4032 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
4033 @code{shift-selection-mode} (@pxref{Conflicts}).
4034 @kindex S-@key{right}
4035 @kindex S-@key{left}
4036 @item S-@key{right}
4037 @itemx S-@key{left}
4038 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
4039 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
4040 from @code{DONE} to @code{REPORT} in the example above.  See also
4041 @ref{Conflicts}, for a discussion of the interaction with
4042 @code{shift-selection-mode}.
4043 @end table
4045 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
4046 @subsection Fast access to TODO states
4048 If you would like to quickly change an entry to an arbitrary TODO state
4049 instead of cycling through the states, you can set up keys for single-letter
4050 access to the states.  This is done by adding the selection character after
4051 each keyword, in parentheses@footnote{All characters are allowed except
4052 @code{@@^!}, which have a special meaning here.}.  For example:
4054 @lisp
4055 (setq org-todo-keywords
4056       '((sequence "TODO(t)" "|" "DONE(d)")
4057         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
4058         (sequence "|" "CANCELED(c)")))
4059 @end lisp
4061 @vindex org-fast-tag-selection-include-todo
4062 If you then press @kbd{C-c C-t} followed by the selection key, the entry
4063 will be switched to this state.  @kbd{SPC} can be used to remove any TODO
4064 keyword from an entry.@footnote{Check also the variable
4065 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
4066 state through the tags interface (@pxref{Setting tags}), in case you like to
4067 mingle the two concepts.  Note that this means you need to come up with
4068 unique keys across both sets of keywords.}
4070 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
4071 @subsection Setting up keywords for individual files
4072 @cindex keyword options
4073 @cindex per-file keywords
4074 @cindex #+TODO
4075 @cindex #+TYP_TODO
4076 @cindex #+SEQ_TODO
4078 It can be very useful to use different aspects of the TODO mechanism in
4079 different files.  For file-local settings, you need to add special lines
4080 to the file which set the keywords and interpretation for that file
4081 only.  For example, to set one of the two examples discussed above, you
4082 need one of the following lines, starting in column zero anywhere in the
4083 file:
4085 @example
4086 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
4087 @end example
4088 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
4089 interpretation, but it means the same as @code{#+TODO}), or
4090 @example
4091 #+TYP_TODO: Fred Sara Lucy Mike | DONE
4092 @end example
4094 A setup for using several sets in parallel would be:
4096 @example
4097 #+TODO: TODO | DONE
4098 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
4099 #+TODO: | CANCELED
4100 @end example
4102 @cindex completion, of option keywords
4103 @kindex M-@key{TAB}
4104 @noindent To make sure you are using the correct keyword, type
4105 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
4107 @cindex DONE, final TODO keyword
4108 Remember that the keywords after the vertical bar (or the last keyword
4109 if no bar is there) must always mean that the item is DONE (although you
4110 may use a different word).  After changing one of these lines, use
4111 @kbd{C-c C-c} with the cursor still in the line to make the changes
4112 known to Org mode@footnote{Org mode parses these lines only when
4113 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
4114 cursor in a line starting with @samp{#+} is simply restarting Org mode
4115 for the current buffer.}.
4117 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
4118 @subsection Faces for TODO keywords
4119 @cindex faces, for TODO keywords
4121 @vindex org-todo @r{(face)}
4122 @vindex org-done @r{(face)}
4123 @vindex org-todo-keyword-faces
4124 Org mode highlights TODO keywords with special faces: @code{org-todo}
4125 for keywords indicating that an item still has to be acted upon, and
4126 @code{org-done} for keywords indicating that an item is finished.  If
4127 you are using more than 2 different states, you might want to use
4128 special faces for some of them.  This can be done using the variable
4129 @code{org-todo-keyword-faces}.  For example:
4131 @lisp
4132 @group
4133 (setq org-todo-keyword-faces
4134       '(("TODO" . org-warning) ("STARTED" . "yellow")
4135         ("CANCELED" . (:foreground "blue" :weight bold))))
4136 @end group
4137 @end lisp
4139 While using a list with face properties as shown for CANCELED @emph{should}
4140 work, this does not always seem to be the case.  If necessary, define a
4141 special face and use that.  A string is interpreted as a color.  The variable
4142 @code{org-faces-easy-properties} determines if that color is interpreted as a
4143 foreground or a background color.
4145 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
4146 @subsection TODO dependencies
4147 @cindex TODO dependencies
4148 @cindex dependencies, of TODO states
4150 @vindex org-enforce-todo-dependencies
4151 @cindex property, ORDERED
4152 The structure of Org files (hierarchy and lists) makes it easy to define TODO
4153 dependencies.  Usually, a parent TODO task should not be marked DONE until
4154 all subtasks (defined as children tasks) are marked as DONE@.  And sometimes
4155 there is a logical sequence to a number of (sub)tasks, so that one task
4156 cannot be acted upon before all siblings above it are done.  If you customize
4157 the variable @code{org-enforce-todo-dependencies}, Org will block entries
4158 from changing state to DONE while they have children that are not DONE@.
4159 Furthermore, if an entry has a property @code{ORDERED}, each of its children
4160 will be blocked until all earlier siblings are marked DONE@.  Here is an
4161 example:
4163 @example
4164 * TODO Blocked until (two) is done
4165 ** DONE one
4166 ** TODO two
4168 * Parent
4169   :PROPERTIES:
4170   :ORDERED: t
4171   :END:
4172 ** TODO a
4173 ** TODO b, needs to wait for (a)
4174 ** TODO c, needs to wait for (a) and (b)
4175 @end example
4177 @table @kbd
4178 @orgcmd{C-c C-x o,org-toggle-ordered-property}
4179 @vindex org-track-ordered-property-with-tag
4180 @cindex property, ORDERED
4181 Toggle the @code{ORDERED} property of the current entry.  A property is used
4182 for this behavior because this should be local to the current entry, not
4183 inherited like a tag.  However, if you would like to @i{track} the value of
4184 this property with a tag for better visibility, customize the variable
4185 @code{org-track-ordered-property-with-tag}.
4186 @orgkey{C-u C-u C-u C-c C-t}
4187 Change TODO state, circumventing any state blocking.
4188 @end table
4190 @vindex org-agenda-dim-blocked-tasks
4191 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
4192 that cannot be closed because of such dependencies will be shown in a dimmed
4193 font or even made invisible in agenda views (@pxref{Agenda Views}).
4195 @cindex checkboxes and TODO dependencies
4196 @vindex org-enforce-todo-dependencies
4197 You can also block changes of TODO states by looking at checkboxes
4198 (@pxref{Checkboxes}).  If you set the variable
4199 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
4200 checkboxes will be blocked from switching to DONE.
4202 If you need more complex dependency structures, for example dependencies
4203 between entries in different trees or files, check out the contributed
4204 module @file{org-depend.el}.
4206 @page
4207 @node Progress logging, Priorities, TODO extensions, TODO Items
4208 @section Progress logging
4209 @cindex progress logging
4210 @cindex logging, of progress
4212 Org mode can automatically record a timestamp and possibly a note when
4213 you mark a TODO item as DONE, or even each time you change the state of
4214 a TODO item.  This system is highly configurable; settings can be on a
4215 per-keyword basis and can be localized to a file or even a subtree.  For
4216 information on how to clock working time for a task, see @ref{Clocking
4217 work time}.
4219 @menu
4220 * Closing items::               When was this entry marked DONE?
4221 * Tracking TODO state changes::  When did the status change?
4222 * Tracking your habits::        How consistent have you been?
4223 @end menu
4225 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
4226 @subsection Closing items
4228 The most basic logging is to keep track of @emph{when} a certain TODO
4229 item was finished.  This is achieved with@footnote{The corresponding
4230 in-buffer setting is: @code{#+STARTUP: logdone}}
4232 @lisp
4233 (setq org-log-done 'time)
4234 @end lisp
4236 @noindent
4237 Then each time you turn an entry from a TODO (not-done) state into any
4238 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
4239 just after the headline.  If you turn the entry back into a TODO item
4240 through further state cycling, that line will be removed again.  If you
4241 want to record a note along with the timestamp, use@footnote{The
4242 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
4244 @lisp
4245 (setq org-log-done 'note)
4246 @end lisp
4248 @noindent
4249 You will then be prompted for a note, and that note will be stored below
4250 the entry with a @samp{Closing Note} heading.
4252 In the timeline (@pxref{Timeline}) and in the agenda
4253 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
4254 display the TODO items with a @samp{CLOSED} timestamp on each day,
4255 giving you an overview of what has been done.
4257 @node Tracking TODO state changes, Tracking your habits, Closing items, Progress logging
4258 @subsection Tracking TODO state changes
4259 @cindex drawer, for state change recording
4261 @vindex org-log-states-order-reversed
4262 @vindex org-log-into-drawer
4263 @cindex property, LOG_INTO_DRAWER
4264 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
4265 might want to keep track of when a state change occurred and maybe take a
4266 note about this change.  You can either record just a timestamp, or a
4267 time-stamped note for a change.  These records will be inserted after the
4268 headline as an itemized list, newest first@footnote{See the variable
4269 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
4270 want to get the notes out of the way into a drawer (@pxref{Drawers}).
4271 Customize the variable @code{org-log-into-drawer} to get this behavior---the
4272 recommended drawer for this is called @code{LOGBOOK}@footnote{Note that the
4273 @code{LOGBOOK} drawer is unfolded when pressing @key{SPC} in the agenda to
4274 show an entry---use @key{C-u SPC} to keep it folded here}.  You can also
4275 overrule the setting of this variable for a subtree by setting a
4276 @code{LOG_INTO_DRAWER} property.
4278 Since it is normally too much to record a note for every state, Org mode
4279 expects configuration on a per-keyword basis for this.  This is achieved by
4280 adding special markers @samp{!} (for a timestamp) or @samp{@@} (for a note
4281 with timestamp) in parentheses after each keyword.  For example, with the
4282 setting
4284 @lisp
4285 (setq org-todo-keywords
4286   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
4287 @end lisp
4289 To record a timestamp without a note for TODO keywords configured with
4290 @samp{@@}, just type @kbd{C-c C-c} to enter a blank note when prompted.
4292 @noindent
4293 @vindex org-log-done
4294 you not only define global TODO keywords and fast access keys, but also
4295 request that a time is recorded when the entry is set to
4296 DONE@footnote{It is possible that Org mode will record two timestamps
4297 when you are using both @code{org-log-done} and state change logging.
4298 However, it will never prompt for two notes---if you have configured
4299 both, the state change recording note will take precedence and cancel
4300 the @samp{Closing Note}.}, and that a note is recorded when switching to
4301 WAIT or CANCELED@.  The setting for WAIT is even more special: the
4302 @samp{!} after the slash means that in addition to the note taken when
4303 entering the state, a timestamp should be recorded when @i{leaving} the
4304 WAIT state, if and only if the @i{target} state does not configure
4305 logging for entering it.  So it has no effect when switching from WAIT
4306 to DONE, because DONE is configured to record a timestamp only.  But
4307 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
4308 setting now triggers a timestamp even though TODO has no logging
4309 configured.
4311 You can use the exact same syntax for setting logging preferences local
4312 to a buffer:
4313 @example
4314 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
4315 @end example
4317 @cindex property, LOGGING
4318 In order to define logging settings that are local to a subtree or a
4319 single item, define a LOGGING property in this entry.  Any non-empty
4320 LOGGING property resets all logging settings to nil.  You may then turn
4321 on logging for this specific tree using STARTUP keywords like
4322 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
4323 settings like @code{TODO(!)}.  For example
4325 @example
4326 * TODO Log each state with only a time
4327   :PROPERTIES:
4328   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4329   :END:
4330 * TODO Only log when switching to WAIT, and when repeating
4331   :PROPERTIES:
4332   :LOGGING: WAIT(@@) logrepeat
4333   :END:
4334 * TODO No logging at all
4335   :PROPERTIES:
4336   :LOGGING: nil
4337   :END:
4338 @end example
4340 @node Tracking your habits,  , Tracking TODO state changes, Progress logging
4341 @subsection Tracking your habits
4342 @cindex habits
4344 Org has the ability to track the consistency of a special category of TODOs,
4345 called ``habits''.  A habit has the following properties:
4347 @enumerate
4348 @item
4349 You have enabled the @code{habits} module by customizing the variable
4350 @code{org-modules}.
4351 @item
4352 The habit is a TODO item, with a TODO keyword representing an open state.
4353 @item
4354 The property @code{STYLE} is set to the value @code{habit}.
4355 @item
4356 The TODO has a scheduled date, usually with a @code{.+} style repeat
4357 interval.  A @code{++} style may be appropriate for habits with time
4358 constraints, e.g., must be done on weekends, or a @code{+} style for an
4359 unusual habit that can have a backlog, e.g., weekly reports.
4360 @item
4361 The TODO may also have minimum and maximum ranges specified by using the
4362 syntax @samp{.+2d/3d}, which says that you want to do the task at least every
4363 three days, but at most every two days.
4364 @item
4365 You must also have state logging for the @code{DONE} state enabled
4366 (@pxref{Tracking TODO state changes}), in order for historical data to be
4367 represented in the consistency graph.  If it is not enabled it is not an
4368 error, but the consistency graphs will be largely meaningless.
4369 @end enumerate
4371 To give you an idea of what the above rules look like in action, here's an
4372 actual habit with some history:
4374 @example
4375 ** TODO Shave
4376    SCHEDULED: <2009-10-17 Sat .+2d/4d>
4377    - State "DONE"       from "TODO"       [2009-10-15 Thu]
4378    - State "DONE"       from "TODO"       [2009-10-12 Mon]
4379    - State "DONE"       from "TODO"       [2009-10-10 Sat]
4380    - State "DONE"       from "TODO"       [2009-10-04 Sun]
4381    - State "DONE"       from "TODO"       [2009-10-02 Fri]
4382    - State "DONE"       from "TODO"       [2009-09-29 Tue]
4383    - State "DONE"       from "TODO"       [2009-09-25 Fri]
4384    - State "DONE"       from "TODO"       [2009-09-19 Sat]
4385    - State "DONE"       from "TODO"       [2009-09-16 Wed]
4386    - State "DONE"       from "TODO"       [2009-09-12 Sat]
4387    :PROPERTIES:
4388    :STYLE:    habit
4389    :LAST_REPEAT: [2009-10-19 Mon 00:36]
4390    :END:
4391 @end example
4393 What this habit says is: I want to shave at most every 2 days (given by the
4394 @code{SCHEDULED} date and repeat interval) and at least every 4 days.  If
4395 today is the 15th, then the habit first appears in the agenda on Oct 17,
4396 after the minimum of 2 days has elapsed, and will appear overdue on Oct 19,
4397 after four days have elapsed.
4399 What's really useful about habits is that they are displayed along with a
4400 consistency graph, to show how consistent you've been at getting that task
4401 done in the past.  This graph shows every day that the task was done over the
4402 past three weeks, with colors for each day.  The colors used are:
4404 @table @code
4405 @item Blue
4406 If the task wasn't to be done yet on that day.
4407 @item Green
4408 If the task could have been done on that day.
4409 @item Yellow
4410 If the task was going to be overdue the next day.
4411 @item Red
4412 If the task was overdue on that day.
4413 @end table
4415 In addition to coloring each day, the day is also marked with an asterisk if
4416 the task was actually done that day, and an exclamation mark to show where
4417 the current day falls in the graph.
4419 There are several configuration variables that can be used to change the way
4420 habits are displayed in the agenda.
4422 @table @code
4423 @item org-habit-graph-column
4424 The buffer column at which the consistency graph should be drawn.  This will
4425 overwrite any text in that column, so it is a good idea to keep your habits'
4426 titles brief and to the point.
4427 @item org-habit-preceding-days
4428 The amount of history, in days before today, to appear in consistency graphs.
4429 @item org-habit-following-days
4430 The number of days after today that will appear in consistency graphs.
4431 @item org-habit-show-habits-only-for-today
4432 If non-nil, only show habits in today's agenda view.  This is set to true by
4433 default.
4434 @end table
4436 Lastly, pressing @kbd{K} in the agenda buffer will cause habits to
4437 temporarily be disabled and they won't appear at all.  Press @kbd{K} again to
4438 bring them back.  They are also subject to tag filtering, if you have habits
4439 which should only be done in certain contexts, for example.
4441 @node Priorities, Breaking down tasks, Progress logging, TODO Items
4442 @section Priorities
4443 @cindex priorities
4445 If you use Org mode extensively, you may end up with enough TODO items that
4446 it starts to make sense to prioritize them.  Prioritizing can be done by
4447 placing a @emph{priority cookie} into the headline of a TODO item, like this
4449 @example
4450 *** TODO [#A] Write letter to Sam Fortune
4451 @end example
4453 @noindent
4454 @vindex org-priority-faces
4455 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
4456 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie is
4457 treated just like priority @samp{B}.  Priorities make a difference only for
4458 sorting in the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they
4459 have no inherent meaning to Org mode.  The cookies can be highlighted with
4460 special faces by customizing the variable @code{org-priority-faces}.
4462 Priorities can be attached to any outline node; they do not need to be TODO
4463 items.
4465 @table @kbd
4466 @item @kbd{C-c ,}
4467 @kindex @kbd{C-c ,}
4468 @findex org-priority
4469 Set the priority of the current headline (@command{org-priority}).  The
4470 command prompts for a priority character @samp{A}, @samp{B} or @samp{C}.
4471 When you press @key{SPC} instead, the priority cookie is removed from the
4472 headline.  The priorities can also be changed ``remotely'' from the timeline
4473 and agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
4475 @orgcmdkkcc{S-@key{up},S-@key{down},org-priority-up,org-priority-down}
4476 @vindex org-priority-start-cycle-with-default
4477 Increase/decrease priority of current headline@footnote{See also the option
4478 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
4479 also used to modify timestamps (@pxref{Creating timestamps}).  See also
4480 @ref{Conflicts}, for a discussion of the interaction with
4481 @code{shift-selection-mode}.
4482 @end table
4484 @vindex org-highest-priority
4485 @vindex org-lowest-priority
4486 @vindex org-default-priority
4487 You can change the range of allowed priorities by setting the variables
4488 @code{org-highest-priority}, @code{org-lowest-priority}, and
4489 @code{org-default-priority}.  For an individual buffer, you may set
4490 these values (highest, lowest, default) like this (please make sure that
4491 the highest priority is earlier in the alphabet than the lowest
4492 priority):
4494 @cindex #+PRIORITIES
4495 @example
4496 #+PRIORITIES: A C B
4497 @end example
4499 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
4500 @section Breaking tasks down into subtasks
4501 @cindex tasks, breaking down
4502 @cindex statistics, for TODO items
4504 @vindex org-agenda-todo-list-sublevels
4505 It is often advisable to break down large tasks into smaller, manageable
4506 subtasks.  You can do this by creating an outline tree below a TODO item,
4507 with detailed subtasks on the tree@footnote{To keep subtasks out of the
4508 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
4509 the overview over the fraction of subtasks that are already completed, insert
4510 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
4511 be updated each time the TODO status of a child changes, or when pressing
4512 @kbd{C-c C-c} on the cookie.  For example:
4514 @example
4515 * Organize Party [33%]
4516 ** TODO Call people [1/2]
4517 *** TODO Peter
4518 *** DONE Sarah
4519 ** TODO Buy food
4520 ** DONE Talk to neighbor
4521 @end example
4523 @cindex property, COOKIE_DATA
4524 If a heading has both checkboxes and TODO children below it, the meaning of
4525 the statistics cookie become ambiguous.  Set the property
4526 @code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
4527 this issue.
4529 @vindex org-hierarchical-todo-statistics
4530 If you would like to have the statistics cookie count any TODO entries in the
4531 subtree (not just direct children), configure the variable
4532 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
4533 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
4534 property.
4536 @example
4537 * Parent capturing statistics [2/20]
4538   :PROPERTIES:
4539   :COOKIE_DATA: todo recursive
4540   :END:
4541 @end example
4543 If you would like a TODO entry to automatically change to DONE
4544 when all children are done, you can use the following setup:
4546 @example
4547 (defun org-summary-todo (n-done n-not-done)
4548   "Switch entry to DONE when all subentries are done, to TODO otherwise."
4549   (let (org-log-done org-log-states)   ; turn off logging
4550     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4552 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4553 @end example
4556 Another possibility is the use of checkboxes to identify (a hierarchy of) a
4557 large number of subtasks (@pxref{Checkboxes}).
4560 @node Checkboxes,  , Breaking down tasks, TODO Items
4561 @section Checkboxes
4562 @cindex checkboxes
4564 @vindex org-list-automatic-rules
4565 Every item in a plain list@footnote{With the exception of description
4566 lists.  But you can allow it by modifying @code{org-list-automatic-rules}
4567 accordingly.} (@pxref{Plain lists}) can be made into a checkbox by starting
4568 it with the string @samp{[ ]}.  This feature is similar to TODO items
4569 (@pxref{TODO Items}), but is more lightweight.  Checkboxes are not included
4570 in the global TODO list, so they are often great to split a task into a
4571 number of simple steps.  Or you can use them in a shopping list.  To toggle a
4572 checkbox, use @kbd{C-c C-c}, or use the mouse (thanks to Piotr Zielinski's
4573 @file{org-mouse.el}).
4575 Here is an example of a checkbox list.
4577 @example
4578 * TODO Organize party [2/4]
4579   - [-] call people [1/3]
4580     - [ ] Peter
4581     - [X] Sarah
4582     - [ ] Sam
4583   - [X] order food
4584   - [ ] think about what music to play
4585   - [X] talk to the neighbors
4586 @end example
4588 Checkboxes work hierarchically, so if a checkbox item has children that
4589 are checkboxes, toggling one of the children checkboxes will make the
4590 parent checkbox reflect if none, some, or all of the children are
4591 checked.
4593 @cindex statistics, for checkboxes
4594 @cindex checkbox statistics
4595 @cindex property, COOKIE_DATA
4596 @vindex org-hierarchical-checkbox-statistics
4597 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
4598 indicating how many checkboxes present in this entry have been checked off,
4599 and the total number of checkboxes present.  This can give you an idea on how
4600 many checkboxes remain, even without opening a folded entry.  The cookies can
4601 be placed into a headline or into (the first line of) a plain list item.
4602 Each cookie covers checkboxes of direct children structurally below the
4603 headline/item on which the cookie appears@footnote{Set the variable
4604 @code{org-hierarchical-checkbox-statistics} if you want such cookies to
4605 count all checkboxes below the cookie, not just those belonging to direct
4606 children.}.  You have to insert the cookie yourself by typing either
4607 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
4608 result, as in the examples above.  With @samp{[%]} you get information about
4609 the percentage of checkboxes checked (in the above example, this would be
4610 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
4611 count either checkboxes below the heading or TODO states of children, and it
4612 will display whatever was changed last.  Set the property @code{COOKIE_DATA}
4613 to either @samp{checkbox} or @samp{todo} to resolve this issue.
4615 @cindex blocking, of checkboxes
4616 @cindex checkbox blocking
4617 @cindex property, ORDERED
4618 If the current outline node has an @code{ORDERED} property, checkboxes must
4619 be checked off in sequence, and an error will be thrown if you try to check
4620 off a box while there are unchecked boxes above it.
4622 @noindent The following commands work with checkboxes:
4624 @table @kbd
4625 @orgcmd{C-c C-c,org-toggle-checkbox}
4626 Toggle checkbox status or (with prefix arg) checkbox presence at point.
4627 With a single prefix argument, add an empty checkbox or remove the current
4628 one@footnote{@kbd{C-u C-c C-c} on the @emph{first} item of a list with no checkbox
4629 will add checkboxes to the rest of the list.}.  With a double prefix argument, set it to @samp{[-]}, which is
4630 considered to be an intermediate state.
4631 @orgcmd{C-c C-x C-b,org-toggle-checkbox}
4632 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
4633 double prefix argument, set it to @samp{[-]}, which is considered to be an
4634 intermediate state.
4635 @itemize @minus
4636 @item
4637 If there is an active region, toggle the first checkbox in the region
4638 and set all remaining boxes to the same status as the first.  With a prefix
4639 arg, add or remove the checkbox for all items in the region.
4640 @item
4641 If the cursor is in a headline, toggle checkboxes in the region between
4642 this headline and the next (so @emph{not} the entire subtree).
4643 @item
4644 If there is no active region, just toggle the checkbox at point.
4645 @end itemize
4646 @orgcmd{M-S-@key{RET},org-insert-todo-heading}
4647 Insert a new item with a checkbox.  This works only if the cursor is already
4648 in a plain list item (@pxref{Plain lists}).
4649 @orgcmd{C-c C-x o,org-toggle-ordered-property}
4650 @vindex org-track-ordered-property-with-tag
4651 @cindex property, ORDERED
4652 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
4653 be checked off in sequence.  A property is used for this behavior because
4654 this should be local to the current entry, not inherited like a tag.
4655 However, if you would like to @i{track} the value of this property with a tag
4656 for better visibility, customize the variable
4657 @code{org-track-ordered-property-with-tag}.
4658 @orgcmd{C-c #,org-update-statistics-cookies}
4659 Update the statistics cookie in the current outline entry.  When called with
4660 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
4661 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
4662 new ones with @kbd{M-S-@key{RET}}.  TODO statistics cookies update when
4663 changing TODO states.  If you delete boxes/entries or add/change them by
4664 hand, use this command to get things back into sync.
4665 @end table
4667 @node Tags, Properties and Columns, TODO Items, Top
4668 @chapter Tags
4669 @cindex tags
4670 @cindex headline tagging
4671 @cindex matching, tags
4672 @cindex sparse tree, tag based
4674 An excellent way to implement labels and contexts for cross-correlating
4675 information is to assign @i{tags} to headlines.  Org mode has extensive
4676 support for tags.
4678 @vindex org-tag-faces
4679 Every headline can contain a list of tags; they occur at the end of the
4680 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
4681 @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
4682 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
4683 Tags will by default be in bold face with the same color as the headline.
4684 You may specify special faces for specific tags using the variable
4685 @code{org-tag-faces}, in much the same way as you can for TODO keywords
4686 (@pxref{Faces for TODO keywords}).
4688 @menu
4689 * Tag inheritance::             Tags use the tree structure of the outline
4690 * Setting tags::                How to assign tags to a headline
4691 * Tag searches::                Searching for combinations of tags
4692 @end menu
4694 @node Tag inheritance, Setting tags, Tags, Tags
4695 @section Tag inheritance
4696 @cindex tag inheritance
4697 @cindex inheritance, of tags
4698 @cindex sublevels, inclusion into tags match
4700 @i{Tags} make use of the hierarchical structure of outline trees.  If a
4701 heading has a certain tag, all subheadings will inherit the tag as
4702 well.  For example, in the list
4704 @example
4705 * Meeting with the French group      :work:
4706 ** Summary by Frank                  :boss:notes:
4707 *** TODO Prepare slides for him      :action:
4708 @end example
4710 @noindent
4711 the final heading will have the tags @samp{:work:}, @samp{:boss:},
4712 @samp{:notes:}, and @samp{:action:} even though the final heading is not
4713 explicitly marked with those tags.  You can also set tags that all entries in
4714 a file should inherit just as if these tags were defined in a hypothetical
4715 level zero that surrounds the entire file.  Use a line like this@footnote{As
4716 with all these in-buffer settings, pressing @kbd{C-c C-c} activates any
4717 changes in the line.}:
4719 @cindex #+FILETAGS
4720 @example
4721 #+FILETAGS: :Peter:Boss:Secret:
4722 @end example
4724 @noindent
4725 @vindex org-use-tag-inheritance
4726 @vindex org-tags-exclude-from-inheritance
4727 To limit tag inheritance to specific tags, use @code{org-tags-exclude-from-inheritance}.
4728 To turn it off entirely, use @code{org-use-tag-inheritance}.
4730 @vindex org-tags-match-list-sublevels
4731 When a headline matches during a tags search while tag inheritance is turned
4732 on, all the sublevels in the same tree will (for a simple match form) match
4733 as well@footnote{This is only true if the search does not involve more
4734 complex tests including properties (@pxref{Property searches}).}.  The list
4735 of matches may then become very long.  If you only want to see the first tags
4736 match in a subtree, configure the variable
4737 @code{org-tags-match-list-sublevels} (not recommended).
4739 @vindex org-agenda-use-tag-inheritance
4740 Tag inheritance is relevant when the agenda search tries to match a tag,
4741 either in the @code{tags} or @code{tags-todo} agenda types.  In other agenda
4742 types, @code{org-use-tag-inheritance} has no effect.  Still, you may want to
4743 have your tags correctly set in the agenda, so that tag filtering works fine,
4744 with inherited tags.  Set @code{org-agenda-use-tag-inheritance} to control
4745 this: the default value includes all agenda types, but setting this to nil
4746 can really speed up agenda generation.
4748 @node Setting tags, Tag searches, Tag inheritance, Tags
4749 @section Setting tags
4750 @cindex setting tags
4751 @cindex tags, setting
4753 @kindex M-@key{TAB}
4754 Tags can simply be typed into the buffer at the end of a headline.
4755 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
4756 also a special command for inserting tags:
4758 @table @kbd
4759 @orgcmd{C-c C-q,org-set-tags-command}
4760 @cindex completion, of tags
4761 @vindex org-tags-column
4762 Enter new tags for the current headline.  Org mode will either offer
4763 completion or a special single-key interface for setting tags, see
4764 below.  After pressing @key{RET}, the tags will be inserted and aligned
4765 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
4766 tags in the current buffer will be aligned to that column, just to make
4767 things look nice.  TAGS are automatically realigned after promotion,
4768 demotion, and TODO state changes (@pxref{TODO basics}).
4769 @orgcmd{C-c C-c,org-set-tags-command}
4770 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
4771 @end table
4773 @vindex org-tag-alist
4774 Org supports tag insertion based on a @emph{list of tags}.  By
4775 default this list is constructed dynamically, containing all tags
4776 currently used in the buffer.  You may also globally specify a hard list
4777 of tags with the variable @code{org-tag-alist}.  Finally you can set
4778 the default tags for a given file with lines like
4780 @cindex #+TAGS
4781 @example
4782 #+TAGS: @@work @@home @@tennisclub
4783 #+TAGS: laptop car pc sailboat
4784 @end example
4786 If you have globally defined your preferred set of tags using the
4787 variable @code{org-tag-alist}, but would like to use a dynamic tag list
4788 in a specific file, add an empty TAGS option line to that file:
4790 @example
4791 #+TAGS:
4792 @end example
4794 @vindex org-tag-persistent-alist
4795 If you have a preferred set of tags that you would like to use in every file,
4796 in addition to those defined on a per-file basis by TAGS option lines, then
4797 you may specify a list of tags with the variable
4798 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
4799 by adding a STARTUP option line to that file:
4801 @example
4802 #+STARTUP: noptag
4803 @end example
4805 By default Org mode uses the standard minibuffer completion facilities for
4806 entering tags.  However, it also implements another, quicker, tag selection
4807 method called @emph{fast tag selection}.  This allows you to select and
4808 deselect tags with just a single key press.  For this to work well you should
4809 assign unique letters to most of your commonly used tags.  You can do this
4810 globally by configuring the variable @code{org-tag-alist} in your
4811 @file{.emacs} file.  For example, you may find the need to tag many items in
4812 different files with @samp{:@@home:}.  In this case you can set something
4813 like:
4815 @lisp
4816 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
4817 @end lisp
4819 @noindent If the tag is only relevant to the file you are working on, then you
4820 can instead set the TAGS option line as:
4822 @example
4823 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
4824 @end example
4826 @noindent The tags interface will show the available tags in a splash
4827 window.  If you want to start a new line after a specific tag, insert
4828 @samp{\n} into the tag list
4830 @example
4831 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
4832 @end example
4834 @noindent or write them in two lines:
4836 @example
4837 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
4838 #+TAGS: laptop(l)  pc(p)
4839 @end example
4841 @noindent
4842 You can also group together tags that are mutually exclusive by using
4843 braces, as in:
4845 @example
4846 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
4847 @end example
4849 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
4850 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
4852 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
4853 these lines to activate any changes.
4855 @noindent
4856 To set these mutually exclusive groups in the variable @code{org-tags-alist},
4857 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
4858 of the braces.  Similarly, you can use @code{:newline} to indicate a line
4859 break.  The previous example would be set globally by the following
4860 configuration:
4862 @lisp
4863 (setq org-tag-alist '((:startgroup . nil)
4864                       ("@@work" . ?w) ("@@home" . ?h)
4865                       ("@@tennisclub" . ?t)
4866                       (:endgroup . nil)
4867                       ("laptop" . ?l) ("pc" . ?p)))
4868 @end lisp
4870 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
4871 automatically present you with a special interface, listing inherited tags,
4872 the tags of the current headline, and a list of all valid tags with
4873 corresponding keys@footnote{Keys will automatically be assigned to tags which
4874 have no configured keys.}.  In this interface, you can use the following
4875 keys:
4877 @table @kbd
4878 @item a-z...
4879 Pressing keys assigned to tags will add or remove them from the list of
4880 tags in the current line.  Selecting a tag in a group of mutually
4881 exclusive tags will turn off any other tags from that group.
4882 @kindex @key{TAB}
4883 @item @key{TAB}
4884 Enter a tag in the minibuffer, even if the tag is not in the predefined
4885 list.  You will be able to complete on all tags present in the buffer.
4886 You can also add several tags: just separate them with a comma.
4888 @kindex @key{SPC}
4889 @item @key{SPC}
4890 Clear all tags for this line.
4891 @kindex @key{RET}
4892 @item @key{RET}
4893 Accept the modified set.
4894 @item C-g
4895 Abort without installing changes.
4896 @item q
4897 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
4898 @item !
4899 Turn off groups of mutually exclusive tags.  Use this to (as an
4900 exception) assign several tags from such a group.
4901 @item C-c
4902 Toggle auto-exit after the next change (see below).
4903 If you are using expert mode, the first @kbd{C-c} will display the
4904 selection window.
4905 @end table
4907 @noindent
4908 This method lets you assign tags to a headline with very few keys.  With
4909 the above setup, you could clear the current tags and set @samp{@@home},
4910 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
4911 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
4912 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
4913 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
4914 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
4915 @key{RET} @key{RET}}.
4917 @vindex org-fast-tag-selection-single-key
4918 If you find that most of the time you need only a single key press to
4919 modify your list of tags, set the variable
4920 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
4921 press @key{RET} to exit fast tag selection---it will immediately exit
4922 after the first change.  If you then occasionally need more keys, press
4923 @kbd{C-c} to turn off auto-exit for the current tag selection process
4924 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
4925 C-c}).  If you set the variable to the value @code{expert}, the special
4926 window is not even shown for single-key tag selection, it comes up only
4927 when you press an extra @kbd{C-c}.
4929 @node Tag searches,  , Setting tags, Tags
4930 @section Tag searches
4931 @cindex tag searches
4932 @cindex searching for tags
4934 Once a system of tags has been set up, it can be used to collect related
4935 information into special lists.
4937 @table @kbd
4938 @orgcmdkkc{C-c / m,C-c \\,org-match-sparse-tree}
4939 Create a sparse tree with all headlines matching a tags search.  With a
4940 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4941 @orgcmd{C-c a m,org-tags-view}
4942 Create a global list of tag matches from all agenda files.
4943 @xref{Matching tags and properties}.
4944 @orgcmd{C-c a M,org-tags-view}
4945 @vindex org-tags-match-list-sublevels
4946 Create a global list of tag matches from all agenda files, but check
4947 only TODO items and force checking subitems (see variable
4948 @code{org-tags-match-list-sublevels}).
4949 @end table
4951 These commands all prompt for a match string which allows basic Boolean logic
4952 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
4953 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
4954 which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of the search
4955 string is rich and allows also matching against TODO keywords, entry levels
4956 and properties.  For a complete description with many examples, see
4957 @ref{Matching tags and properties}.
4960 @node Properties and Columns, Dates and Times, Tags, Top
4961 @chapter Properties and columns
4962 @cindex properties
4964 A property is a key-value pair associated with an entry.  Properties can be
4965 set so they are associated with a single entry, with every entry in a tree,
4966 or with every entry in an Org mode file.
4968 There are two main applications for properties in Org mode.  First,
4969 properties are like tags, but with a value.  Imagine maintaining a file where
4970 you document bugs and plan releases for a piece of software.  Instead of
4971 using tags like @code{:release_1:}, @code{:release_2:}, you can use a
4972 property, say @code{:Release:}, that in different subtrees has different
4973 values, such as @code{1.0} or @code{2.0}.  Second, you can use properties to
4974 implement (very basic) database capabilities in an Org buffer.  Imagine
4975 keeping track of your music CDs, where properties could be things such as the
4976 album, artist, date of release, number of tracks, and so on.
4978 Properties can be conveniently edited and viewed in column view
4979 (@pxref{Column view}).
4981 @menu
4982 * Property syntax::             How properties are spelled out
4983 * Special properties::          Access to other Org mode features
4984 * Property searches::           Matching property values
4985 * Property inheritance::        Passing values down the tree
4986 * Column view::                 Tabular viewing and editing
4987 * Property API::                Properties for Lisp programmers
4988 @end menu
4990 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
4991 @section Property syntax
4992 @cindex property syntax
4993 @cindex drawer, for properties
4995 Properties are key-value pairs.  When they are associated with a single entry
4996 or with a tree they need to be inserted into a special
4997 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
4998 is specified on a single line, with the key (surrounded by colons)
4999 first, and the value after it.  Here is an example:
5001 @example
5002 * CD collection
5003 ** Classic
5004 *** Goldberg Variations
5005     :PROPERTIES:
5006     :Title:     Goldberg Variations
5007     :Composer:  J.S. Bach
5008     :Artist:    Glen Gould
5009     :Publisher: Deutsche Grammophon
5010     :NDisks:    1
5011     :END:
5012 @end example
5014 Depending on the value of @code{org-use-property-inheritance}, a property set
5015 this way will either be associated with a single entry, or the sub-tree
5016 defined by the entry, see @ref{Property inheritance}.
5018 You may define the allowed values for a particular property @samp{:Xyz:}
5019 by setting a property @samp{:Xyz_ALL:}.  This special property is
5020 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
5021 the entire tree.  When allowed values are defined, setting the
5022 corresponding property becomes easier and is less prone to typing
5023 errors.  For the example with the CD collection, we can predefine
5024 publishers and the number of disks in a box like this:
5026 @example
5027 * CD collection
5028   :PROPERTIES:
5029   :NDisks_ALL:  1 2 3 4
5030   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
5031   :END:
5032 @end example
5034 If you want to set properties that can be inherited by any entry in a
5035 file, use a line like
5036 @cindex property, _ALL
5037 @cindex #+PROPERTY
5038 @example
5039 #+PROPERTY: NDisks_ALL 1 2 3 4
5040 @end example
5042 Contrary to properties set from a special drawer, you have to refresh the
5043 buffer with @kbd{C-c C-c} to activate this changes.
5045 If you want to add to the value of an existing property, append a @code{+} to
5046 the property name.  The following results in the property @code{var} having
5047 the value ``foo=1 bar=2''.
5048 @cindex property, +
5049 @example
5050 #+PROPERTY: var  foo=1
5051 #+PROPERTY: var+ bar=2
5052 @end example
5054 It is also possible to add to the values of inherited properties.  The
5055 following results in the @code{genres} property having the value ``Classic
5056 Baroque'' under the @code{Goldberg Variations} subtree.
5057 @cindex property, +
5058 @example
5059 * CD collection
5060 ** Classic
5061     :PROPERTIES:
5062     :GENRES: Classic
5063     :END:
5064 *** Goldberg Variations
5065     :PROPERTIES:
5066     :Title:     Goldberg Variations
5067     :Composer:  J.S. Bach
5068     :Artist:    Glen Gould
5069     :Publisher: Deutsche Grammophon
5070     :NDisks:    1
5071     :GENRES+:   Baroque
5072     :END:
5073 @end example
5074 Note that a property can only have one entry per Drawer.
5076 @vindex org-global-properties
5077 Property values set with the global variable
5078 @code{org-global-properties} can be inherited by all entries in all
5079 Org files.
5081 @noindent
5082 The following commands help to work with properties:
5084 @table @kbd
5085 @orgcmd{M-@key{TAB},pcomplete}
5086 After an initial colon in a line, complete property keys.  All keys used
5087 in the current file will be offered as possible completions.
5088 @orgcmd{C-c C-x p,org-set-property}
5089 Set a property.  This prompts for a property name and a value.  If
5090 necessary, the property drawer is created as well.
5091 @item C-u M-x org-insert-drawer
5092 @cindex org-insert-drawer
5093 Insert a property drawer into the current entry.  The drawer will be
5094 inserted early in the entry, but after the lines with planning
5095 information like deadlines.
5096 @orgcmd{C-c C-c,org-property-action}
5097 With the cursor in a property drawer, this executes property commands.
5098 @orgcmd{C-c C-c s,org-set-property}
5099 Set a property in the current entry.  Both the property and the value
5100 can be inserted using completion.
5101 @orgcmdkkcc{S-@key{right},S-@key{left},org-property-next-allowed-value,org-property-previous-allowed-value}
5102 Switch property at point to the next/previous allowed value.
5103 @orgcmd{C-c C-c d,org-delete-property}
5104 Remove a property from the current entry.
5105 @orgcmd{C-c C-c D,org-delete-property-globally}
5106 Globally remove a property, from all entries in the current file.
5107 @orgcmd{C-c C-c c,org-compute-property-at-point}
5108 Compute the property at point, using the operator and scope from the
5109 nearest column format definition.
5110 @end table
5112 @node Special properties, Property searches, Property syntax, Properties and Columns
5113 @section Special properties
5114 @cindex properties, special
5116 Special properties provide an alternative access method to Org mode features,
5117 like the TODO state or the priority of an entry, discussed in the previous
5118 chapters.  This interface exists so that you can include these states in a
5119 column view (@pxref{Column view}), or to use them in queries.  The following
5120 property names are special and (except for @code{:CATEGORY:}) should not be
5121 used as keys in the properties drawer:
5123 @cindex property, special, ID
5124 @cindex property, special, TODO
5125 @cindex property, special, TAGS
5126 @cindex property, special, ALLTAGS
5127 @cindex property, special, CATEGORY
5128 @cindex property, special, PRIORITY
5129 @cindex property, special, DEADLINE
5130 @cindex property, special, SCHEDULED
5131 @cindex property, special, CLOSED
5132 @cindex property, special, TIMESTAMP
5133 @cindex property, special, TIMESTAMP_IA
5134 @cindex property, special, CLOCKSUM
5135 @cindex property, special, CLOCKSUM_T
5136 @cindex property, special, BLOCKED
5137 @c guessing that ITEM is needed in this area; also, should this list be sorted?
5138 @cindex property, special, ITEM
5139 @cindex property, special, FILE
5140 @example
5141 ID           @r{A globally unique ID used for synchronization during}
5142              @r{iCalendar or MobileOrg export.}
5143 TODO         @r{The TODO keyword of the entry.}
5144 TAGS         @r{The tags defined directly in the headline.}
5145 ALLTAGS      @r{All tags, including inherited ones.}
5146 CATEGORY     @r{The category of an entry.}
5147 PRIORITY     @r{The priority of the entry, a string with a single letter.}
5148 DEADLINE     @r{The deadline time string, without the angular brackets.}
5149 SCHEDULED    @r{The scheduling timestamp, without the angular brackets.}
5150 CLOSED       @r{When was this entry closed?}
5151 TIMESTAMP    @r{The first keyword-less timestamp in the entry.}
5152 TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
5153 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
5154              @r{must be run first to compute the values in the current buffer.}
5155 CLOCKSUM_T   @r{The sum of CLOCK intervals in the subtree for today.}
5156              @r{@code{org-clock-sum-today} must be run first to compute the}
5157              @r{values in the current buffer.}
5158 BLOCKED      @r{"t" if task is currently blocked by children or siblings}
5159 ITEM         @r{The headline of the entry.}
5160 FILE         @r{The filename the entry is located in.}
5161 @end example
5163 @node Property searches, Property inheritance, Special properties, Properties and Columns
5164 @section Property searches
5165 @cindex properties, searching
5166 @cindex searching, of properties
5168 To create sparse trees and special lists with selection based on properties,
5169 the same commands are used as for tag searches (@pxref{Tag searches}).
5171 @table @kbd
5172 @orgcmdkkc{C-c / m,C-c \\,org-match-sparse-tree}
5173 Create a sparse tree with all matching entries.  With a
5174 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
5175 @orgcmd{C-c a m,org-tags-view}
5176 Create a global list of tag/property  matches from all agenda files.
5177 @xref{Matching tags and properties}.
5178 @orgcmd{C-c a M,org-tags-view}
5179 @vindex org-tags-match-list-sublevels
5180 Create a global list of tag matches from all agenda files, but check
5181 only TODO items and force checking of subitems (see variable
5182 @code{org-tags-match-list-sublevels}).
5183 @end table
5185 The syntax for the search string is described in @ref{Matching tags and
5186 properties}.
5188 There is also a special command for creating sparse trees based on a
5189 single property:
5191 @table @kbd
5192 @orgkey{C-c / p}
5193 Create a sparse tree based on the value of a property.  This first
5194 prompts for the name of a property, and then for a value.  A sparse tree
5195 is created with all entries that define this property with the given
5196 value.  If you enclose the value in curly braces, it is interpreted as
5197 a regular expression and matched against the property values.
5198 @end table
5200 @node Property inheritance, Column view, Property searches, Properties and Columns
5201 @section Property Inheritance
5202 @cindex properties, inheritance
5203 @cindex inheritance, of properties
5205 @vindex org-use-property-inheritance
5206 The outline structure of Org mode documents lends itself to an
5207 inheritance model of properties: if the parent in a tree has a certain
5208 property, the children can inherit this property.  Org mode does not
5209 turn this on by default, because it can slow down property searches
5210 significantly and is often not needed.  However, if you find inheritance
5211 useful, you can turn it on by setting the variable
5212 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
5213 all properties inherited from the parent, to a list of properties
5214 that should be inherited, or to a regular expression that matches
5215 inherited properties.  If a property has the value @samp{nil}, this is
5216 interpreted as an explicit undefine of the property, so that inheritance
5217 search will stop at this value and return @code{nil}.
5219 Org mode has a few properties for which inheritance is hard-coded, at
5220 least for the special applications for which they are used:
5222 @cindex property, COLUMNS
5223 @table @code
5224 @item COLUMNS
5225 The @code{:COLUMNS:} property defines the format of column view
5226 (@pxref{Column view}).  It is inherited in the sense that the level
5227 where a @code{:COLUMNS:} property is defined is used as the starting
5228 point for a column view table, independently of the location in the
5229 subtree from where columns view is turned on.
5230 @item CATEGORY
5231 @cindex property, CATEGORY
5232 For agenda view, a category set through a @code{:CATEGORY:} property
5233 applies to the entire subtree.
5234 @item ARCHIVE
5235 @cindex property, ARCHIVE
5236 For archiving, the @code{:ARCHIVE:} property may define the archive
5237 location for the entire subtree (@pxref{Moving subtrees}).
5238 @item LOGGING
5239 @cindex property, LOGGING
5240 The LOGGING property may define logging settings for an entry or a
5241 subtree (@pxref{Tracking TODO state changes}).
5242 @end table
5244 @node Column view, Property API, Property inheritance, Properties and Columns
5245 @section Column view
5247 A great way to view and edit properties in an outline tree is
5248 @emph{column view}.  In column view, each outline node is turned into a
5249 table row.  Columns in this table provide access to properties of the
5250 entries.  Org mode implements columns by overlaying a tabular structure
5251 over the headline of each item.  While the headlines have been turned
5252 into a table row, you can still change the visibility of the outline
5253 tree.  For example, you get a compact table by switching to CONTENTS
5254 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
5255 is active), but you can still open, read, and edit the entry below each
5256 headline.  Or, you can switch to column view after executing a sparse
5257 tree command and in this way get a table only for the selected items.
5258 Column view also works in agenda buffers (@pxref{Agenda Views}) where
5259 queries have collected selected items, possibly from a number of files.
5261 @menu
5262 * Defining columns::            The COLUMNS format property
5263 * Using column view::           How to create and use column view
5264 * Capturing column view::       A dynamic block for column view
5265 @end menu
5267 @node Defining columns, Using column view, Column view, Column view
5268 @subsection Defining columns
5269 @cindex column view, for properties
5270 @cindex properties, column view
5272 Setting up a column view first requires defining the columns.  This is
5273 done by defining a column format line.
5275 @menu
5276 * Scope of column definitions::  Where defined, where valid?
5277 * Column attributes::           Appearance and content of a column
5278 @end menu
5280 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
5281 @subsubsection Scope of column definitions
5283 To define a column format for an entire file, use a line like
5285 @cindex #+COLUMNS
5286 @example
5287 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5288 @end example
5290 To specify a format that only applies to a specific tree, add a
5291 @code{:COLUMNS:} property to the top node of that tree, for example:
5293 @example
5294 ** Top node for columns view
5295    :PROPERTIES:
5296    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5297    :END:
5298 @end example
5300 If a @code{:COLUMNS:} property is present in an entry, it defines columns
5301 for the entry itself, and for the entire subtree below it.  Since the
5302 column definition is part of the hierarchical structure of the document,
5303 you can define columns on level 1 that are general enough for all
5304 sublevels, and more specific columns further down, when you edit a
5305 deeper part of the tree.
5307 @node Column attributes,  , Scope of column definitions, Defining columns
5308 @subsubsection Column attributes
5309 A column definition sets the attributes of a column.  The general
5310 definition looks like this:
5312 @example
5313  %[@var{width}]@var{property}[(@var{title})][@{@var{summary-type}@}]
5314 @end example
5316 @noindent
5317 Except for the percent sign and the property name, all items are
5318 optional.  The individual parts have the following meaning:
5320 @example
5321 @var{width}           @r{An integer specifying the width of the column in characters.}
5322                 @r{If omitted, the width will be determined automatically.}
5323 @var{property}        @r{The property that should be edited in this column.}
5324                 @r{Special properties representing meta data are allowed here}
5325                 @r{as well (@pxref{Special properties})}
5326 @var{title}           @r{The header text for the column.  If omitted, the property}
5327                 @r{name is used.}
5328 @{@var{summary-type}@}  @r{The summary type.  If specified, the column values for}
5329                 @r{parent nodes are computed from the children.}
5330                 @r{Supported summary types are:}
5331                 @{+@}       @r{Sum numbers in this column.}
5332                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
5333                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
5334                 @{:@}       @r{Sum times, HH:MM, plain numbers are hours.}
5335                 @{X@}       @r{Checkbox status, @samp{[X]} if all children are @samp{[X]}.}
5336                 @{X/@}      @r{Checkbox status, @samp{[n/m]}.}
5337                 @{X%@}      @r{Checkbox status, @samp{[n%]}.}
5338                 @{min@}     @r{Smallest number in column.}
5339                 @{max@}     @r{Largest number.}
5340                 @{mean@}    @r{Arithmetic mean of numbers.}
5341                 @{:min@}    @r{Smallest time value in column.}
5342                 @{:max@}    @r{Largest time value.}
5343                 @{:mean@}   @r{Arithmetic mean of time values.}
5344                 @{@@min@}    @r{Minimum age (in days/hours/mins/seconds).}
5345                 @{@@max@}    @r{Maximum age (in days/hours/mins/seconds).}
5346                 @{@@mean@}   @r{Arithmetic mean of ages (in days/hours/mins/seconds).}
5347                 @{est+@}    @r{Add low-high estimates.}
5348 @end example
5350 @noindent
5351 Be aware that you can only have one summary type for any property you
5352 include.  Subsequent columns referencing the same property will all display the
5353 same summary information.
5355 The @code{est+} summary type requires further explanation.  It is used for
5356 combining estimates, expressed as low-high ranges.  For example, instead
5357 of estimating a particular task will take 5 days, you might estimate it as
5358 5--6 days if you're fairly confident you know how much work is required, or
5359 1--10 days if you don't really know what needs to be done.  Both ranges
5360 average at 5.5 days, but the first represents a more predictable delivery.
5362 When combining a set of such estimates, simply adding the lows and highs
5363 produces an unrealistically wide result.  Instead, @code{est+} adds the
5364 statistical mean and variance of the sub-tasks, generating a final estimate
5365 from the sum.  For example, suppose you had ten tasks, each of which was
5366 estimated at 0.5 to 2 days of work.  Straight addition produces an estimate
5367 of 5 to 20 days, representing what to expect if everything goes either
5368 extremely well or extremely poorly.  In contrast, @code{est+} estimates the
5369 full job more realistically, at 10--15 days.
5371 Here is an example for a complete columns definition, along with allowed
5372 values.
5374 @example
5375 :COLUMNS:  %25ITEM %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.}
5376                    %10Time_Estimate@{:@} %CLOCKSUM %CLOCKSUM_T
5377 :Owner_ALL:    Tammy Mark Karl Lisa Don
5378 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
5379 :Approved_ALL: "[ ]" "[X]"
5380 @end example
5382 @noindent
5383 The first column, @samp{%25ITEM}, means the first 25 characters of the
5384 item itself, i.e., of the headline.  You probably always should start the
5385 column definition with the @samp{ITEM} specifier.  The other specifiers
5386 create columns @samp{Owner} with a list of names as allowed values, for
5387 @samp{Status} with four different possible values, and for a checkbox
5388 field @samp{Approved}.  When no width is given after the @samp{%}
5389 character, the column will be exactly as wide as it needs to be in order
5390 to fully display all values.  The @samp{Approved} column does have a
5391 modified title (@samp{Approved?}, with a question mark).  Summaries will
5392 be created for the @samp{Time_Estimate} column by adding time duration
5393 expressions like HH:MM, and for the @samp{Approved} column, by providing
5394 an @samp{[X]} status if all children have been checked.  The
5395 @samp{CLOCKSUM} and @samp{CLOCKSUM_T} columns are special, they lists the
5396 sums of CLOCK intervals in the subtree, either for all clocks or just for
5397 today.
5399 @node Using column view, Capturing column view, Defining columns, Column view
5400 @subsection Using column view
5402 @table @kbd
5403 @tsubheading{Turning column view on and off}
5404 @orgcmd{C-c C-x C-c,org-columns}
5405 @vindex org-columns-default-format
5406 Turn on column view.  If the cursor is before the first headline in the file,
5407 column view is turned on for the entire file, using the @code{#+COLUMNS}
5408 definition.  If the cursor is somewhere inside the outline, this command
5409 searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
5410 defines a format.  When one is found, the column view table is established
5411 for the tree starting at the entry that contains the @code{:COLUMNS:}
5412 property.  If no such property is found, the format is taken from the
5413 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
5414 and column view is established for the current entry and its subtree.
5415 @orgcmd{r,org-columns-redo}
5416 Recreate the column view, to include recent changes made in the buffer.
5417 @orgcmd{g,org-columns-redo}
5418 Same as @kbd{r}.
5419 @orgcmd{q,org-columns-quit}
5420 Exit column view.
5421 @tsubheading{Editing values}
5422 @item @key{left} @key{right} @key{up} @key{down}
5423 Move through the column view from field to field.
5424 @kindex S-@key{left}
5425 @kindex S-@key{right}
5426 @item  S-@key{left}/@key{right}
5427 Switch to the next/previous allowed value of the field.  For this, you
5428 have to have specified allowed values for a property.
5429 @item 1..9,0
5430 Directly select the Nth allowed value, @kbd{0} selects the 10th value.
5431 @orgcmdkkcc{n,p,org-columns-next-allowed-value,org-columns-previous-allowed-value}
5432 Same as @kbd{S-@key{left}/@key{right}}
5433 @orgcmd{e,org-columns-edit-value}
5434 Edit the property at point.  For the special properties, this will
5435 invoke the same interface that you normally use to change that
5436 property.  For example, when editing a TAGS property, the tag completion
5437 or fast selection interface will pop up.
5438 @orgcmd{C-c C-c,org-columns-set-tags-or-toggle}
5439 When there is a checkbox at point, toggle it.
5440 @orgcmd{v,org-columns-show-value}
5441 View the full value of this property.  This is useful if the width of
5442 the column is smaller than that of the value.
5443 @orgcmd{a,org-columns-edit-allowed}
5444 Edit the list of allowed values for this property.  If the list is found
5445 in the hierarchy, the modified values is stored there.  If no list is
5446 found, the new value is stored in the first entry that is part of the
5447 current column view.
5448 @tsubheading{Modifying the table structure}
5449 @orgcmdkkcc{<,>,org-columns-narrow,org-columns-widen}
5450 Make the column narrower/wider by one character.
5451 @orgcmd{S-M-@key{right},org-columns-new}
5452 Insert a new column, to the left of the current column.
5453 @orgcmd{S-M-@key{left},org-columns-delete}
5454 Delete the current column.
5455 @end table
5457 @node Capturing column view,  , Using column view, Column view
5458 @subsection Capturing column view
5460 Since column view is just an overlay over a buffer, it cannot be
5461 exported or printed directly.  If you want to capture a column view, use
5462 a @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
5463 of this block looks like this:
5465 @cindex #+BEGIN, columnview
5466 @example
5467 * The column view
5468 #+BEGIN: columnview :hlines 1 :id "label"
5470 #+END:
5471 @end example
5473 @noindent This dynamic block has the following parameters:
5475 @table @code
5476 @item :id
5477 This is the most important parameter.  Column view is a feature that is
5478 often localized to a certain (sub)tree, and the capture block might be
5479 at a different location in the file.  To identify the tree whose view to
5480 capture, you can use 4 values:
5481 @cindex property, ID
5482 @example
5483 local     @r{use the tree in which the capture block is located}
5484 global    @r{make a global view, including all headings in the file}
5485 "file:@var{path-to-file}"
5486           @r{run column view at the top of this file}
5487 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
5488           @r{property with the value @i{label}.  You can use}
5489           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
5490           @r{the current entry and copy it to the kill-ring.}
5491 @end example
5492 @item :hlines
5493 When @code{t}, insert an hline after every line.  When a number @var{N}, insert
5494 an hline before each headline with level @code{<= @var{N}}.
5495 @item :vlines
5496 When set to @code{t}, force column groups to get vertical lines.
5497 @item :maxlevel
5498 When set to a number, don't capture entries below this level.
5499 @item :skip-empty-rows
5500 When set to @code{t}, skip rows where the only non-empty specifier of the
5501 column view is @code{ITEM}.
5503 @end table
5505 @noindent
5506 The following commands insert or update the dynamic block:
5508 @table @kbd
5509 @orgcmd{C-c C-x i,org-insert-columns-dblock}
5510 Insert a dynamic block capturing a column view.  You will be prompted
5511 for the scope or ID of the view.
5512 @orgcmdkkc{C-c C-c,C-c C-x C-u,org-dblock-update}
5513 Update dynamic block at point.  The cursor needs to be in the
5514 @code{#+BEGIN} line of the dynamic block.
5515 @orgcmd{C-u C-c C-x C-u,org-update-all-dblocks}
5516 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5517 you have several clock table blocks, column-capturing blocks or other dynamic
5518 blocks in a buffer.
5519 @end table
5521 You can add formulas to the column view table and you may add plotting
5522 instructions in front of the table---these will survive an update of the
5523 block.  If there is a @code{#+TBLFM:} after the table, the table will
5524 actually be recalculated automatically after an update.
5526 An alternative way to capture and process property values into a table is
5527 provided by Eric Schulte's @file{org-collector.el} which is a contributed
5528 package@footnote{Contributed packages are not part of Emacs, but are
5529 distributed with the main distribution of Org (visit
5530 @uref{http://orgmode.org}).}.  It provides a general API to collect
5531 properties from entries in a certain scope, and arbitrary Lisp expressions to
5532 process these values before inserting them into a table or a dynamic block.
5534 @node Property API,  , Column view, Properties and Columns
5535 @section The Property API
5536 @cindex properties, API
5537 @cindex API, for properties
5539 There is a full API for accessing and changing properties.  This API can
5540 be used by Emacs Lisp programs to work with properties and to implement
5541 features based on them.  For more information see @ref{Using the
5542 property API}.
5544 @node Dates and Times, Capture - Refile - Archive, Properties and Columns, Top
5545 @chapter Dates and times
5546 @cindex dates
5547 @cindex times
5548 @cindex timestamp
5549 @cindex date stamp
5551 To assist project planning, TODO items can be labeled with a date and/or
5552 a time.  The specially formatted string carrying the date and time
5553 information is called a @emph{timestamp} in Org mode.  This may be a
5554 little confusing because timestamp is often used as indicating when
5555 something was created or last changed.  However, in Org mode this term
5556 is used in a much wider sense.
5558 @menu
5559 * Timestamps::                  Assigning a time to a tree entry
5560 * Creating timestamps::         Commands which insert timestamps
5561 * Deadlines and scheduling::    Planning your work
5562 * Clocking work time::          Tracking how long you spend on a task
5563 * Effort estimates::            Planning work effort in advance
5564 * Relative timer::              Notes with a running timer
5565 * Countdown timer::             Starting a countdown timer for a task
5566 @end menu
5569 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
5570 @section Timestamps, deadlines, and scheduling
5571 @cindex timestamps
5572 @cindex ranges, time
5573 @cindex date stamps
5574 @cindex deadlines
5575 @cindex scheduling
5577 A timestamp is a specification of a date (possibly with a time or a range of
5578 times) in a special format, either @samp{<2003-09-16 Tue>}@footnote{In this
5579 simplest form, the day name is optional when you type the date yourself.
5580 However, any dates inserted or modified by Org will add that day name, for
5581 reading convenience.} or @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16
5582 Tue 12:00-12:30>}@footnote{This is inspired by the standard ISO 8601
5583 date/time format.  To use an alternative format, see @ref{Custom time
5584 format}.}.  A timestamp can appear anywhere in the headline or body of an Org
5585 tree entry.  Its presence causes entries to be shown on specific dates in the
5586 agenda (@pxref{Weekly/daily agenda}).  We distinguish:
5588 @table @var
5589 @item Plain timestamp; Event; Appointment
5590 @cindex timestamp
5591 @cindex appointment
5592 A simple timestamp just assigns a date/time to an item.  This is just
5593 like writing down an appointment or event in a paper agenda.  In the
5594 timeline and agenda displays, the headline of an entry associated with a
5595 plain timestamp will be shown exactly on that date.
5597 @example
5598 * Meet Peter at the movies
5599   <2006-11-01 Wed 19:15>
5600 * Discussion on climate change
5601   <2006-11-02 Thu 20:00-22:00>
5602 @end example
5604 @item Timestamp with repeater interval
5605 @cindex timestamp, with repeater interval
5606 A timestamp may contain a @emph{repeater interval}, indicating that it
5607 applies not only on the given date, but again and again after a certain
5608 interval of N days (d), weeks (w), months (m), or years (y).  The
5609 following will show up in the agenda every Wednesday:
5611 @example
5612 * Pick up Sam at school
5613   <2007-05-16 Wed 12:30 +1w>
5614 @end example
5616 @item Diary-style sexp entries
5617 For more complex date specifications, Org mode supports using the special
5618 sexp diary entries implemented in the Emacs calendar/diary
5619 package@footnote{When working with the standard diary sexp functions, you
5620 need to be very careful with the order of the arguments.  That order depend
5621 evilly on the variable @code{calendar-date-style} (or, for older Emacs
5622 versions, @code{european-calendar-style}).  For example, to specify a date
5623 December 12, 2005, the call might look like @code{(diary-date 12 1 2005)} or
5624 @code{(diary-date 1 12 2005)} or @code{(diary-date 2005 12 1)}, depending on
5625 the settings.  This has been the source of much confusion.  Org mode users
5626 can resort to special versions of these functions like @code{org-date} or
5627 @code{org-anniversary}.  These work just like the corresponding @code{diary-}
5628 functions, but with stable ISO order of arguments (year, month, day) wherever
5629 applicable, independent of the value of @code{calendar-date-style}.}.  For
5630 example with optional time
5632 @example
5633 * 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
5634   <%%(diary-float t 4 2)>
5635 @end example
5637 @item Time/Date range
5638 @cindex timerange
5639 @cindex date range
5640 Two timestamps connected by @samp{--} denote a range.  The headline
5641 will be shown on the first and last day of the range, and on any dates
5642 that are displayed and fall in the range.  Here is an example:
5644 @example
5645 ** Meeting in Amsterdam
5646    <2004-08-23 Mon>--<2004-08-26 Thu>
5647 @end example
5649 @item Inactive timestamp
5650 @cindex timestamp, inactive
5651 @cindex inactive timestamp
5652 Just like a plain timestamp, but with square brackets instead of
5653 angular ones.  These timestamps are inactive in the sense that they do
5654 @emph{not} trigger an entry to show up in the agenda.
5656 @example
5657 * Gillian comes late for the fifth time
5658   [2006-11-01 Wed]
5659 @end example
5661 @end table
5663 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
5664 @section Creating timestamps
5665 @cindex creating timestamps
5666 @cindex timestamps, creating
5668 For Org mode to recognize timestamps, they need to be in the specific
5669 format.  All commands listed below produce timestamps in the correct
5670 format.
5672 @table @kbd
5673 @orgcmd{C-c .,org-time-stamp}
5674 Prompt for a date and insert a corresponding timestamp.  When the cursor is
5675 at an existing timestamp in the buffer, the command is used to modify this
5676 timestamp instead of inserting a new one.  When this command is used twice in
5677 succession, a time range is inserted.
5679 @orgcmd{C-c !,org-time-stamp-inactive}
5680 Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
5681 an agenda entry.
5683 @kindex C-u C-c .
5684 @kindex C-u C-c !
5685 @item C-u C-c .
5686 @itemx C-u C-c !
5687 @vindex org-time-stamp-rounding-minutes
5688 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
5689 contains date and time.  The default time can be rounded to multiples of 5
5690 minutes, see the option @code{org-time-stamp-rounding-minutes}.
5692 @orgkey{C-c C-c}
5693 Normalize timestamp, insert/fix day name if missing or wrong.
5695 @orgcmd{C-c <,org-date-from-calendar}
5696 Insert a timestamp corresponding to the cursor date in the Calendar.
5698 @orgcmd{C-c >,org-goto-calendar}
5699 Access the Emacs calendar for the current date.  If there is a
5700 timestamp in the current line, go to the corresponding date
5701 instead.
5703 @orgcmd{C-c C-o,org-open-at-point}
5704 Access the agenda for the date given by the timestamp or -range at
5705 point (@pxref{Weekly/daily agenda}).
5707 @orgcmdkkcc{S-@key{left},S-@key{right},org-timestamp-down-day,org-timestamp-up-day}
5708 Change date at cursor by one day.  These key bindings conflict with
5709 shift-selection and related modes (@pxref{Conflicts}).
5711 @orgcmdkkcc{S-@key{up},S-@key{down},org-timestamp-up,org-timestamp-down-down}
5712 Change the item under the cursor in a timestamp.  The cursor can be on a
5713 year, month, day, hour or minute.  When the timestamp contains a time range
5714 like @samp{15:30-16:30}, modifying the first time will also shift the second,
5715 shifting the time block with constant length.  To change the length, modify
5716 the second time.  Note that if the cursor is in a headline and not at a
5717 timestamp, these same keys modify the priority of an item.
5718 (@pxref{Priorities}).  The key bindings also conflict with shift-selection and
5719 related modes (@pxref{Conflicts}).
5721 @orgcmd{C-c C-y,org-evaluate-time-range}
5722 @cindex evaluate time range
5723 Evaluate a time range by computing the difference between start and end.
5724 With a prefix argument, insert result after the time range (in a table: into
5725 the following column).
5726 @end table
5729 @menu
5730 * The date/time prompt::        How Org mode helps you entering date and time
5731 * Custom time format::          Making dates look different
5732 @end menu
5734 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
5735 @subsection The date/time prompt
5736 @cindex date, reading in minibuffer
5737 @cindex time, reading in minibuffer
5739 @vindex org-read-date-prefer-future
5740 When Org mode prompts for a date/time, the default is shown in default
5741 date/time format, and the prompt therefore seems to ask for a specific
5742 format.  But it will in fact accept date/time information in a variety of
5743 formats.  Generally, the information should start at the beginning of the
5744 string.  Org mode will find whatever information is in
5745 there and derive anything you have not specified from the @emph{default date
5746 and time}.  The default is usually the current date and time, but when
5747 modifying an existing timestamp, or when entering the second stamp of a
5748 range, it is taken from the stamp in the buffer.  When filling in
5749 information, Org mode assumes that most of the time you will want to enter a
5750 date in the future: if you omit the month/year and the given day/month is
5751 @i{before} today, it will assume that you mean a future date@footnote{See the
5752 variable @code{org-read-date-prefer-future}.  You may set that variable to
5753 the symbol @code{time} to even make a time before now shift the date to
5754 tomorrow.}.  If the date has been automatically shifted into the future, the
5755 time prompt will show this with @samp{(=>F).}
5757 For example, let's assume that today is @b{June 13, 2006}.  Here is how
5758 various inputs will be interpreted, the items filled in by Org mode are
5759 in @b{bold}.
5761 @example
5762 3-2-5         @result{} 2003-02-05
5763 2/5/3         @result{} 2003-02-05
5764 14            @result{} @b{2006}-@b{06}-14
5765 12            @result{} @b{2006}-@b{07}-12
5766 2/5           @result{} @b{2007}-02-05
5767 Fri           @result{} nearest Friday (default date or later)
5768 sep 15        @result{} @b{2006}-09-15
5769 feb 15        @result{} @b{2007}-02-15
5770 sep 12 9      @result{} 2009-09-12
5771 12:45         @result{} @b{2006}-@b{06}-@b{13} 12:45
5772 22 sept 0:34  @result{} @b{2006}-09-22 0:34
5773 w4            @result{} ISO week for of the current year @b{2006}
5774 2012 w4 fri   @result{} Friday of ISO week 4 in 2012
5775 2012-w04-5    @result{} Same as above
5776 @end example
5778 Furthermore you can specify a relative date by giving, as the
5779 @emph{first} thing in the input: a plus/minus sign, a number and a
5780 letter ([dwmy]) to indicate change in days, weeks, months, or years.  With a
5781 single plus or minus, the date is always relative to today.  With a
5782 double plus or minus, it is relative to the default date.  If instead of
5783 a single letter, you use the abbreviation of day name, the date will be
5784 the Nth such day, e.g.:
5786 @example
5787 +0            @result{} today
5788 .             @result{} today
5789 +4d           @result{} four days from today
5790 +4            @result{} same as above
5791 +2w           @result{} two weeks from today
5792 ++5           @result{} five days from default date
5793 +2tue         @result{} second Tuesday from now.
5794 @end example
5796 @vindex parse-time-months
5797 @vindex parse-time-weekdays
5798 The function understands English month and weekday abbreviations.  If
5799 you want to use unabbreviated names and/or other languages, configure
5800 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
5802 @vindex org-read-date-force-compatible-dates
5803 Not all dates can be represented in a given Emacs implementation.  By default
5804 Org mode forces dates into the compatibility range 1970--2037 which works on
5805 all Emacs implementations.  If you want to use dates outside of this range,
5806 read the docstring of the variable
5807 @code{org-read-date-force-compatible-dates}.
5809 You can specify a time range by giving start and end times or by giving a
5810 start time and a duration (in HH:MM format).  Use one or two dash(es) as the
5811 separator in the former case and use '+' as the separator in the latter
5812 case, e.g.:
5814 @example
5815 11am-1:15pm    @result{} 11:00-13:15
5816 11am--1:15pm   @result{} same as above
5817 11am+2:15      @result{} same as above
5818 @end example
5820 @cindex calendar, for selecting date
5821 @vindex org-popup-calendar-for-date-prompt
5822 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
5823 you don't need/want the calendar, configure the variable
5824 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
5825 prompt, either by clicking on a date in the calendar, or by pressing
5826 @key{RET}, the date selected in the calendar will be combined with the
5827 information entered at the prompt.  You can control the calendar fully
5828 from the minibuffer:
5830 @kindex <
5831 @kindex >
5832 @kindex M-v
5833 @kindex C-v
5834 @kindex mouse-1
5835 @kindex S-@key{right}
5836 @kindex S-@key{left}
5837 @kindex S-@key{down}
5838 @kindex S-@key{up}
5839 @kindex M-S-@key{right}
5840 @kindex M-S-@key{left}
5841 @kindex @key{RET}
5842 @example
5843 @key{RET}           @r{Choose date at cursor in calendar.}
5844 mouse-1        @r{Select date by clicking on it.}
5845 S-@key{right}/@key{left}     @r{One day forward/backward.}
5846 S-@key{down}/@key{up}     @r{One week forward/backward.}
5847 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
5848 > / <          @r{Scroll calendar forward/backward by one month.}
5849 M-v / C-v      @r{Scroll calendar forward/backward by 3 months.}
5850 @end example
5852 @vindex org-read-date-display-live
5853 The actions of the date/time prompt may seem complex, but I assure you they
5854 will grow on you, and you will start getting annoyed by pretty much any other
5855 way of entering a date/time out there.  To help you understand what is going
5856 on, the current interpretation of your input will be displayed live in the
5857 minibuffer@footnote{If you find this distracting, turn the display of with
5858 @code{org-read-date-display-live}.}.
5860 @node Custom time format,  , The date/time prompt, Creating timestamps
5861 @subsection Custom time format
5862 @cindex custom date/time format
5863 @cindex time format, custom
5864 @cindex date format, custom
5866 @vindex org-display-custom-times
5867 @vindex org-time-stamp-custom-formats
5868 Org mode uses the standard ISO notation for dates and times as it is
5869 defined in ISO 8601.  If you cannot get used to this and require another
5870 representation of date and time to keep you happy, you can get it by
5871 customizing the variables @code{org-display-custom-times} and
5872 @code{org-time-stamp-custom-formats}.
5874 @table @kbd
5875 @orgcmd{C-c C-x C-t,org-toggle-time-stamp-overlays}
5876 Toggle the display of custom formats for dates and times.
5877 @end table
5879 @noindent
5880 Org mode needs the default format for scanning, so the custom date/time
5881 format does not @emph{replace} the default format---instead it is put
5882 @emph{over} the default format using text properties.  This has the
5883 following consequences:
5884 @itemize @bullet
5885 @item
5886 You cannot place the cursor onto a timestamp anymore, only before or
5887 after.
5888 @item
5889 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
5890 each component of a timestamp.  If the cursor is at the beginning of
5891 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
5892 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
5893 time will be changed by one minute.
5894 @item
5895 If the timestamp contains a range of clock times or a repeater, these
5896 will not be overlaid, but remain in the buffer as they were.
5897 @item
5898 When you delete a timestamp character-by-character, it will only
5899 disappear from the buffer after @emph{all} (invisible) characters
5900 belonging to the ISO timestamp have been removed.
5901 @item
5902 If the custom timestamp format is longer than the default and you are
5903 using dates in tables, table alignment will be messed up.  If the custom
5904 format is shorter, things do work as expected.
5905 @end itemize
5908 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
5909 @section Deadlines and scheduling
5911 A timestamp may be preceded by special keywords to facilitate planning:
5913 @table @var
5914 @item DEADLINE
5915 @cindex DEADLINE keyword
5917 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
5918 to be finished on that date.
5920 @vindex org-deadline-warning-days
5921 @vindex org-agenda-skip-deadline-prewarning-if-scheduled
5922 On the deadline date, the task will be listed in the agenda.  In
5923 addition, the agenda for @emph{today} will carry a warning about the
5924 approaching or missed deadline, starting
5925 @code{org-deadline-warning-days} before the due date, and continuing
5926 until the entry is marked DONE@.  An example:
5928 @example
5929 *** TODO write article about the Earth for the Guide
5930     DEADLINE: <2004-02-29 Sun>
5931     The editor in charge is [[bbdb:Ford Prefect]]
5932 @end example
5934 You can specify a different lead time for warnings for a specific
5935 deadlines using the following syntax.  Here is an example with a warning
5936 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.  This warning is
5937 deactivated if the task get scheduled and you set
5938 @code{org-agenda-skip-deadline-prewarning-if-scheduled} to @code{t}.
5940 @item SCHEDULED
5941 @cindex SCHEDULED keyword
5943 Meaning: you are planning to start working on that task on the given
5944 date.
5946 @vindex org-agenda-skip-scheduled-if-done
5947 The headline will be listed under the given date@footnote{It will still
5948 be listed on that date after it has been marked DONE@.  If you don't like
5949 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
5950 addition, a reminder that the scheduled date has passed will be present
5951 in the compilation for @emph{today}, until the entry is marked DONE, i.e.,
5952 the task will automatically be forwarded until completed.
5954 @example
5955 *** TODO Call Trillian for a date on New Years Eve.
5956     SCHEDULED: <2004-12-25 Sat>
5957 @end example
5959 @vindex org-scheduled-delay-days
5960 @vindex org-agenda-skip-scheduled-delay-if-deadline
5961 If you want to @emph{delay} the display of this task in the agenda, use
5962 @code{SCHEDULED: <2004-12-25 Sat -2d>}: the task is still scheduled on the
5963 25th but will appear two days later.  In case the task contains a repeater,
5964 the delay is considered to affect all occurrences; if you want it to affect
5965 only the first scheduled occurrence of the task, use @code{--2d} instead.
5966 See @code{org-scheduled-delay-days} and
5967 @code{org-agenda-skip-scheduled-delay-if-deadline} for details on how to
5968 control this globally or per agenda.
5970 @noindent
5971 @b{Important:} Scheduling an item in Org mode should @i{not} be
5972 understood in the same way that we understand @i{scheduling a meeting}.
5973 Setting a date for a meeting is just a simple appointment, you should
5974 mark this entry with a simple plain timestamp, to get this item shown
5975 on the date where it applies.  This is a frequent misunderstanding by
5976 Org users.  In Org mode, @i{scheduling} means setting a date when you
5977 want to start working on an action item.
5978 @end table
5980 You may use timestamps with repeaters in scheduling and deadline
5981 entries.  Org mode will issue early and late warnings based on the
5982 assumption that the timestamp represents the @i{nearest instance} of
5983 the repeater.  However, the use of diary sexp entries like
5985 @code{<%%(diary-float t 42)>}
5987 in scheduling and deadline timestamps is limited.  Org mode does not
5988 know enough about the internals of each sexp function to issue early and
5989 late warnings.  However, it will show the item on each day where the
5990 sexp entry matches.
5992 @menu
5993 * Inserting deadline/schedule::  Planning items
5994 * Repeated tasks::              Items that show up again and again
5995 @end menu
5997 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
5998 @subsection Inserting deadlines or schedules
6000 The following commands allow you to quickly insert@footnote{The @samp{SCHEDULED} and
6001 @samp{DEADLINE} dates are inserted on the line right below the headline.  Don't put
6002 any text between this line and the headline.} a deadline or to schedule
6003 an item:
6005 @table @kbd
6007 @orgcmd{C-c C-d,org-deadline}
6008 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will happen
6009 in the line directly following the headline.  Any CLOSED timestamp will be
6010 removed.  When called with a prefix arg, an existing deadline will be removed
6011 from the entry.  Depending on the variable @code{org-log-redeadline}@footnote{with corresponding
6012 @code{#+STARTUP} keywords @code{logredeadline}, @code{lognoteredeadline},
6013 and @code{nologredeadline}}, a note will be taken when changing an existing
6014 deadline.
6016 @orgcmd{C-c C-s,org-schedule}
6017 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
6018 happen in the line directly following the headline.  Any CLOSED timestamp
6019 will be removed.  When called with a prefix argument, remove the scheduling
6020 date from the entry.  Depending on the variable
6021 @code{org-log-reschedule}@footnote{with corresponding @code{#+STARTUP}
6022 keywords @code{logreschedule}, @code{lognotereschedule}, and
6023 @code{nologreschedule}}, a note will be taken when changing an existing
6024 scheduling time.
6026 @orgcmd{C-c C-x C-k,org-mark-entry-for-agenda-action}
6027 @kindex k a
6028 @kindex k s
6029 Mark the current entry for agenda action.  After you have marked the entry
6030 like this, you can open the agenda or the calendar to find an appropriate
6031 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
6032 schedule the marked item.
6034 @orgcmd{C-c / d,org-check-deadlines}
6035 @cindex sparse tree, for deadlines
6036 @vindex org-deadline-warning-days
6037 Create a sparse tree with all deadlines that are either past-due, or
6038 which will become due within @code{org-deadline-warning-days}.
6039 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
6040 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
6041 all deadlines due tomorrow.
6043 @orgcmd{C-c / b,org-check-before-date}
6044 Sparse tree for deadlines and scheduled items before a given date.
6046 @orgcmd{C-c / a,org-check-after-date}
6047 Sparse tree for deadlines and scheduled items after a given date.
6048 @end table
6050 Note that @code{org-schedule} and @code{org-deadline} supports
6051 setting the date by indicating a relative time: e.g., +1d will set
6052 the date to the next day after today, and --1w will set the date
6053 to the previous week before any current timestamp.
6055 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
6056 @subsection Repeated tasks
6057 @cindex tasks, repeated
6058 @cindex repeated tasks
6060 Some tasks need to be repeated again and again.  Org mode helps to
6061 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
6062 or plain timestamp.  In the following example
6063 @example
6064 ** TODO Pay the rent
6065    DEADLINE: <2005-10-01 Sat +1m>
6066 @end example
6067 @noindent
6068 the @code{+1m} is a repeater; the intended interpretation is that the task
6069 has a deadline on <2005-10-01> and repeats itself every (one) month starting
6070 from that time.  You can use yearly, monthly, weekly, daily and hourly repeat
6071 cookies by using the @code{y/w/m/d/h} letters.  If you need both a repeater
6072 and a special warning period in a deadline entry, the repeater should come
6073 first and the warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
6075 @vindex org-todo-repeat-to-state
6076 Deadlines and scheduled items produce entries in the agenda when they are
6077 over-due, so it is important to be able to mark such an entry as completed
6078 once you have done so.  When you mark a DEADLINE or a SCHEDULE with the TODO
6079 keyword DONE, it will no longer produce entries in the agenda.  The problem
6080 with this is, however, that then also the @emph{next} instance of the
6081 repeated entry will not be active.  Org mode deals with this in the following
6082 way: When you try to mark such an entry DONE (using @kbd{C-c C-t}), it will
6083 shift the base date of the repeating timestamp by the repeater interval, and
6084 immediately set the entry state back to TODO@footnote{In fact, the target
6085 state is taken from, in this sequence, the @code{REPEAT_TO_STATE} property or
6086 the variable @code{org-todo-repeat-to-state}.  If neither of these is
6087 specified, the target state defaults to the first state of the TODO state
6088 sequence.}.  In the example above, setting the state to DONE would actually
6089 switch the date like this:
6091 @example
6092 ** TODO Pay the rent
6093    DEADLINE: <2005-11-01 Tue +1m>
6094 @end example
6096 @vindex org-log-repeat
6097 A timestamp@footnote{You can change this using the option
6098 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
6099 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
6100 will also be prompted for a note.} will be added under the deadline, to keep
6101 a record that you actually acted on the previous instance of this deadline.
6103 As a consequence of shifting the base date, this entry will no longer be
6104 visible in the agenda when checking past dates, but all future instances
6105 will be visible.
6107 With the @samp{+1m} cookie, the date shift will always be exactly one
6108 month.  So if you have not paid the rent for three months, marking this
6109 entry DONE will still keep it as an overdue deadline.  Depending on the
6110 task, this may not be the best way to handle it.  For example, if you
6111 forgot to call your father for 3 weeks, it does not make sense to call
6112 him 3 times in a single day to make up for it.  Finally, there are tasks
6113 like changing batteries which should always repeat a certain time
6114 @i{after} the last time you did it.  For these tasks, Org mode has
6115 special repeaters  @samp{++} and @samp{.+}.  For example:
6117 @example
6118 ** TODO Call Father
6119    DEADLINE: <2008-02-10 Sun ++1w>
6120    Marking this DONE will shift the date by at least one week,
6121    but also by as many weeks as it takes to get this date into
6122    the future.  However, it stays on a Sunday, even if you called
6123    and marked it done on Saturday.
6124 ** TODO Check the batteries in the smoke detectors
6125    DEADLINE: <2005-11-01 Tue .+1m>
6126    Marking this DONE will shift the date to one month after
6127    today.
6128 @end example
6130 @vindex org-agenda-skip-scheduled-if-deadline-is-shown
6131 You may have both scheduling and deadline information for a specific task.
6132 If the repeater is set for the scheduling information only, you probably want
6133 the repeater to be ignored after the deadline.  If so, set the variable
6134 @code{org-agenda-skip-scheduled-if-deadline-is-shown} to
6135 @code{repeated-after-deadline}.  If you want both scheduling and deadline
6136 information to repeat after the same interval, set the same repeater for both
6137 timestamps.
6139 An alternative to using a repeater is to create a number of copies of a task
6140 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
6141 created for this purpose, it is described in @ref{Structure editing}.
6144 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
6145 @section Clocking work time
6146 @cindex clocking time
6147 @cindex time clocking
6149 Org mode allows you to clock the time you spend on specific tasks in a
6150 project.  When you start working on an item, you can start the clock.  When
6151 you stop working on that task, or when you mark the task done, the clock is
6152 stopped and the corresponding time interval is recorded.  It also computes
6153 the total time spent on each subtree@footnote{Clocking only works if all
6154 headings are indented with less than 30 stars.  This is a hardcoded
6155 limitation of `lmax' in `org-clock-sum'.} of a project.  And it remembers a
6156 history or tasks recently clocked, to that you can jump quickly between a
6157 number of tasks absorbing your time.
6159 To save the clock history across Emacs sessions, use
6160 @lisp
6161 (setq org-clock-persist 'history)
6162 (org-clock-persistence-insinuate)
6163 @end lisp
6164 When you clock into a new task after resuming Emacs, the incomplete
6165 clock@footnote{To resume the clock under the assumption that you have worked
6166 on this task while outside Emacs, use @code{(setq org-clock-persist t)}.}
6167 will be found (@pxref{Resolving idle time}) and you will be prompted about
6168 what to do with it.
6170 @menu
6171 * Clocking commands::           Starting and stopping a clock
6172 * The clock table::             Detailed reports
6173 * Resolving idle time::         Resolving time when you've been idle
6174 @end menu
6176 @node Clocking commands, The clock table, Clocking work time, Clocking work time
6177 @subsection Clocking commands
6179 @table @kbd
6180 @orgcmd{C-c C-x C-i,org-clock-in}
6181 @vindex org-clock-into-drawer
6182 @vindex org-clock-continuously
6183 @cindex property, LOG_INTO_DRAWER
6184 Start the clock on the current item (clock-in).  This inserts the CLOCK
6185 keyword together with a timestamp.  If this is not the first clocking of
6186 this item, the multiple CLOCK lines will be wrapped into a
6187 @code{:LOGBOOK:} drawer (see also the variable
6188 @code{org-clock-into-drawer}).  You can also overrule
6189 the setting of this variable for a subtree by setting a
6190 @code{CLOCK_INTO_DRAWER} or @code{LOG_INTO_DRAWER} property.
6191 When called with a @kbd{C-u} prefix argument,
6192 select the task from a list of recently clocked tasks.  With two @kbd{C-u
6193 C-u} prefixes, clock into the task at point and mark it as the default task;
6194 the default task will then always be available with letter @kbd{d} when
6195 selecting a clocking task.  With three @kbd{C-u C-u C-u} prefixes, force
6196 continuous clocking by starting the clock when the last clock stopped.@*
6197 @cindex property: CLOCK_MODELINE_TOTAL
6198 @cindex property: LAST_REPEAT
6199 @vindex org-clock-modeline-total
6200 While the clock is running, the current clocking time is shown in the mode
6201 line, along with the title of the task.  The clock time shown will be all
6202 time ever clocked for this task and its children.  If the task has an effort
6203 estimate (@pxref{Effort estimates}), the mode line displays the current
6204 clocking time against it@footnote{To add an effort estimate ``on the fly'',
6205 hook a function doing this to @code{org-clock-in-prepare-hook}.}  If the task
6206 is a repeating one (@pxref{Repeated tasks}), only the time since the last
6207 reset of the task @footnote{as recorded by the @code{LAST_REPEAT} property}
6208 will be shown.  More control over what time is shown can be exercised with
6209 the @code{CLOCK_MODELINE_TOTAL} property.  It may have the values
6210 @code{current} to show only the current clocking instance, @code{today} to
6211 show all time clocked on this tasks today (see also the variable
6212 @code{org-extend-today-until}), @code{all} to include all time, or
6213 @code{auto} which is the default@footnote{See also the variable
6214 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
6215 mode line entry will pop up a menu with clocking options.
6217 @orgcmd{C-c C-x C-o,org-clock-out}
6218 @vindex org-log-note-clock-out
6219 Stop the clock (clock-out).  This inserts another timestamp at the same
6220 location where the clock was last started.  It also directly computes
6221 the resulting time in inserts it after the time range as @samp{=>
6222 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
6223 possibility to record an additional note together with the clock-out
6224 timestamp@footnote{The corresponding in-buffer setting is:
6225 @code{#+STARTUP: lognoteclock-out}}.
6226 @orgcmd{C-c C-x C-x,org-clock-in-last}
6227 @vindex org-clock-continuously
6228 Reclock the last clocked task.  With one @kbd{C-u} prefix argument,
6229 select the task from the clock history.  With two @kbd{C-u} prefixes,
6230 force continuous clocking by starting the clock when the last clock
6231 stopped.
6232 @orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
6233 Update the effort estimate for the current clock task.
6234 @kindex C-c C-y
6235 @kindex C-c C-c
6236 @orgcmdkkc{C-c C-c,C-c C-y,org-evaluate-time-range}
6237 Recompute the time interval after changing one of the timestamps.  This
6238 is only necessary if you edit the timestamps directly.  If you change
6239 them with @kbd{S-@key{cursor}} keys, the update is automatic.
6240 @orgcmd{C-S-@key{up/down},org-clock-timestamps-up/down}
6241 On @code{CLOCK} log lines, increase/decrease both timestamps so that the
6242 clock duration keeps the same.
6243 @orgcmd{S-M-@key{up/down},org-timestamp-up/down}
6244 On @code{CLOCK} log lines, increase/decrease the timestamp at point and
6245 the one of the previous (or the next clock) timestamp by the same duration.
6246 For example, if you hit @kbd{S-M-@key{up}} to increase a clocked-out timestamp
6247 by five minutes, then the clocked-in timestamp of the next clock will be
6248 increased by five minutes.
6249 @orgcmd{C-c C-t,org-todo}
6250 Changing the TODO state of an item to DONE automatically stops the clock
6251 if it is running in this same item.
6252 @orgcmd{C-c C-x C-q,org-clock-cancel}
6253 Cancel the current clock.  This is useful if a clock was started by
6254 mistake, or if you ended up working on something else.
6255 @orgcmd{C-c C-x C-j,org-clock-goto}
6256 Jump to the headline of the currently clocked in task.  With a @kbd{C-u}
6257 prefix arg, select the target task from a list of recently clocked tasks.
6258 @orgcmd{C-c C-x C-d,org-clock-display}
6259 @vindex org-remove-highlights-with-change
6260 Display time summaries for each subtree in the current buffer.  This puts
6261 overlays at the end of each headline, showing the total time recorded under
6262 that heading, including the time of any subheadings.  You can use visibility
6263 cycling to study the tree, but the overlays disappear when you change the
6264 buffer (see variable @code{org-remove-highlights-with-change}) or press
6265 @kbd{C-c C-c}.
6266 @end table
6268 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
6269 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
6270 worked on or closed during a day.
6272 @strong{Important:} note that both @code{org-clock-out} and
6273 @code{org-clock-in-last} can have a global keybinding and will not
6274 modify the window disposition.
6276 @node The clock table, Resolving idle time, Clocking commands, Clocking work time
6277 @subsection The clock table
6278 @cindex clocktable, dynamic block
6279 @cindex report, of clocked time
6281 Org mode can produce quite complex reports based on the time clocking
6282 information.  Such a report is called a @emph{clock table}, because it is
6283 formatted as one or several Org tables.
6285 @table @kbd
6286 @orgcmd{C-c C-x C-r,org-clock-report}
6287 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
6288 report as an Org mode table into the current file.  When the cursor is
6289 at an existing clock table, just update it.  When called with a prefix
6290 argument, jump to the first clock report in the current document and
6291 update it.  The clock table always includes also trees with
6292 @code{:ARCHIVE:} tag.
6293 @orgcmdkkc{C-c C-c,C-c C-x C-u,org-dblock-update}
6294 Update dynamic block at point.  The cursor needs to be in the
6295 @code{#+BEGIN} line of the dynamic block.
6296 @orgkey{C-u C-c C-x C-u}
6297 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
6298 you have several clock table blocks in a buffer.
6299 @orgcmdkxkc{S-@key{left},S-@key{right},org-clocktable-try-shift}
6300 Shift the current @code{:block} interval and update the table.  The cursor
6301 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
6302 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
6303 @end table
6306 Here is an example of the frame for a clock table as it is inserted into the
6307 buffer with the @kbd{C-c C-x C-r} command:
6309 @cindex #+BEGIN, clocktable
6310 @example
6311 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
6312 #+END: clocktable
6313 @end example
6314 @noindent
6315 @vindex org-clocktable-defaults
6316 The @samp{BEGIN} line and specify a number of options to define the scope,
6317 structure, and formatting of the report.  Defaults for all these options can
6318 be configured in the variable @code{org-clocktable-defaults}.
6320 @noindent First there are options that determine which clock entries are to
6321 be selected:
6322 @example
6323 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
6324              @r{Clocks at deeper levels will be summed into the upper level.}
6325 :scope       @r{The scope to consider.  This can be any of the following:}
6326              nil        @r{the current buffer or narrowed region}
6327              file       @r{the full current buffer}
6328              subtree    @r{the subtree where the clocktable is located}
6329              tree@var{N}      @r{the surrounding level @var{N} tree, for example @code{tree3}}
6330              tree       @r{the surrounding level 1 tree}
6331              agenda     @r{all agenda files}
6332              ("file"..) @r{scan these files}
6333              file-with-archives    @r{current file and its archives}
6334              agenda-with-archives  @r{all agenda files, including archives}
6335 :block       @r{The time block to consider.  This block is specified either}
6336              @r{absolute, or relative to the current time and may be any of}
6337              @r{these formats:}
6338              2007-12-31    @r{New year eve 2007}
6339              2007-12       @r{December 2007}
6340              2007-W50      @r{ISO-week 50 in 2007}
6341              2007-Q2       @r{2nd quarter in 2007}
6342              2007          @r{the year 2007}
6343              today, yesterday, today-@var{N}          @r{a relative day}
6344              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
6345              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
6346              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
6347              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
6348 :tstart      @r{A time string specifying when to start considering times.}
6349              @r{Relative times like @code{"<-2w>"} can also be used.  See}
6350              @r{@ref{Matching tags and properties} for relative time syntax.}
6351 :tend        @r{A time string specifying when to stop considering times.}
6352              @r{Relative times like @code{"<now>"} can also be used.  See}
6353              @r{@ref{Matching tags and properties} for relative time syntax.}
6354 :wstart      @r{The starting day of the week.  The default is 1 for monday.}
6355 :mstart      @r{The starting day of the month.  The default 1 is for the first}
6356              @r{day of the month.}
6357 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
6358              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
6359 :stepskip0   @r{Do not show steps that have zero time.}
6360 :fileskip0   @r{Do not show table sections from files which did not contribute.}
6361 :tags        @r{A tags match to select entries that should contribute.  See}
6362              @r{@ref{Matching tags and properties} for the match syntax.}
6363 @end example
6365 Then there are options which determine the formatting of the table.  There
6366 options are interpreted by the function @code{org-clocktable-write-default},
6367 but you can specify your own function using the @code{:formatter} parameter.
6368 @example
6369 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
6370 :lang        @r{Language@footnote{Language terms can be set through the variable @code{org-clock-clocktable-language-setup}.} to use for descriptive cells like "Task".}
6371 :link        @r{Link the item headlines in the table to their origins.}
6372 :narrow      @r{An integer to limit the width of the headline column in}
6373              @r{the org table.  If you write it like @samp{50!}, then the}
6374              @r{headline will also be shortened in export.}
6375 :indent      @r{Indent each headline field according to its level.}
6376 :tcolumns    @r{Number of columns to be used for times.  If this is smaller}
6377              @r{than @code{:maxlevel}, lower levels will be lumped into one column.}
6378 :level       @r{Should a level number column be included?}
6379 :compact     @r{Abbreviation for @code{:level nil :indent t :narrow 40! :tcolumns 1}}
6380              @r{All are overwritten except if there is an explicit @code{:narrow}}
6381 :timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
6382              @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
6383 :properties  @r{List of properties that should be shown in the table.  Each}
6384              @r{property will get its own column.}
6385 :inherit-props @r{When this flag is @code{t}, the values for @code{:properties} will be inherited.}
6386 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
6387              @r{As a special case, @samp{:formula %} adds a column with % time.}
6388              @r{If you do not specify a formula here, any existing formula}
6389              @r{below the clock table will survive updates and be evaluated.}
6390 :formatter   @r{A function to format clock data and insert it into the buffer.}
6391 @end example
6392 To get a clock summary of the current level 1 tree, for the current
6393 day, you could write
6394 @example
6395 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
6396 #+END: clocktable
6397 @end example
6398 @noindent
6399 and to use a specific time range you could write@footnote{Note that all
6400 parameters must be specified in a single line---the line is broken here
6401 only to fit it into the manual.}
6402 @example
6403 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
6404                     :tend "<2006-08-10 Thu 12:00>"
6405 #+END: clocktable
6406 @end example
6407 A range starting a week ago and ending right now could be written as
6408 @example
6409 #+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
6410 #+END: clocktable
6411 @end example
6412 A summary of the current subtree with % times would be
6413 @example
6414 #+BEGIN: clocktable :scope subtree :link t :formula %
6415 #+END: clocktable
6416 @end example
6417 A horizontally compact representation of everything clocked during last week
6418 would be
6419 @example
6420 #+BEGIN: clocktable :scope agenda :block lastweek :compact t
6421 #+END: clocktable
6422 @end example
6424 @node Resolving idle time,  , The clock table, Clocking work time
6425 @subsection Resolving idle time and continuous clocking
6427 @subsubheading Resolving idle time
6428 @cindex resolve idle time
6429 @vindex org-clock-x11idle-program-name
6431 @cindex idle, resolve, dangling
6432 If you clock in on a work item, and then walk away from your
6433 computer---perhaps to take a phone call---you often need to ``resolve'' the
6434 time you were away by either subtracting it from the current clock, or
6435 applying it to another one.
6437 @vindex org-clock-idle-time
6438 By customizing the variable @code{org-clock-idle-time} to some integer, such
6439 as 10 or 15, Emacs can alert you when you get back to your computer after
6440 being idle for that many minutes@footnote{On computers using Mac OS X,
6441 idleness is based on actual user idleness, not just Emacs' idle time.  For
6442 X11, you can install a utility program @file{x11idle.c}, available in the
6443 @code{contrib/scripts} directory of the Org git distribution, or install the
6444 @file{xprintidle} package and set it to the variable
6445 @code{org-clock-x11idle-program-name} if you are running Debian, to get the
6446 same general treatment of idleness.  On other systems, idle time refers to
6447 Emacs idle time only.}, and ask what you want to do with the idle time.
6448 There will be a question waiting for you when you get back, indicating how
6449 much idle time has passed (constantly updated with the current amount), as
6450 well as a set of choices to correct the discrepancy:
6452 @table @kbd
6453 @item k
6454 To keep some or all of the minutes and stay clocked in, press @kbd{k}.  Org
6455 will ask how many of the minutes to keep.  Press @key{RET} to keep them all,
6456 effectively changing nothing, or enter a number to keep that many minutes.
6457 @item K
6458 If you use the shift key and press @kbd{K}, it will keep however many minutes
6459 you request and then immediately clock out of that task.  If you keep all of
6460 the minutes, this is the same as just clocking out of the current task.
6461 @item s
6462 To keep none of the minutes, use @kbd{s} to subtract all the away time from
6463 the clock, and then check back in from the moment you returned.
6464 @item S
6465 To keep none of the minutes and just clock out at the start of the away time,
6466 use the shift key and press @kbd{S}.  Remember that using shift will always
6467 leave you clocked out, no matter which option you choose.
6468 @item C
6469 To cancel the clock altogether, use @kbd{C}.  Note that if instead of
6470 canceling you subtract the away time, and the resulting clock amount is less
6471 than a minute, the clock will still be canceled rather than clutter up the
6472 log with an empty entry.
6473 @end table
6475 What if you subtracted those away minutes from the current clock, and now
6476 want to apply them to a new clock?  Simply clock in to any task immediately
6477 after the subtraction.  Org will notice that you have subtracted time ``on
6478 the books'', so to speak, and will ask if you want to apply those minutes to
6479 the next task you clock in on.
6481 There is one other instance when this clock resolution magic occurs.  Say you
6482 were clocked in and hacking away, and suddenly your cat chased a mouse who
6483 scared a hamster that crashed into your UPS's power button!  You suddenly
6484 lose all your buffers, but thanks to auto-save you still have your recent Org
6485 mode changes, including your last clock in.
6487 If you restart Emacs and clock into any task, Org will notice that you have a
6488 dangling clock which was never clocked out from your last session.  Using
6489 that clock's starting time as the beginning of the unaccounted-for period,
6490 Org will ask how you want to resolve that time.  The logic and behavior is
6491 identical to dealing with away time due to idleness; it is just happening due
6492 to a recovery event rather than a set amount of idle time.
6494 You can also check all the files visited by your Org agenda for dangling
6495 clocks at any time using @kbd{M-x org-resolve-clocks RET} (or @kbd{C-c C-x C-z}).
6497 @subsubheading Continuous clocking
6498 @cindex continuous clocking
6499 @vindex org-clock-continuously
6501 You may want to start clocking from the time when you clocked out the
6502 previous task.  To enable this systematically, set @code{org-clock-continuously}
6503 to @code{t}.  Each time you clock in, Org retrieves the clock-out time of the
6504 last clocked entry for this session, and start the new clock from there.
6506 If you only want this from time to time, use three universal prefix arguments
6507 with @code{org-clock-in} and two @kbd{C-u C-u} with @code{org-clock-in-last}.
6509 @node Effort estimates, Relative timer, Clocking work time, Dates and Times
6510 @section Effort estimates
6511 @cindex effort estimates
6513 @cindex property, Effort
6514 @vindex org-effort-property
6515 If you want to plan your work in a very detailed way, or if you need to
6516 produce offers with quotations of the estimated work effort, you may want to
6517 assign effort estimates to entries.  If you are also clocking your work, you
6518 may later want to compare the planned effort with the actual working time, a
6519 great way to improve planning estimates.  Effort estimates are stored in a
6520 special property @samp{Effort}@footnote{You may change the property being
6521 used with the variable @code{org-effort-property}.}.  You can set the effort
6522 for an entry with the following commands:
6524 @table @kbd
6525 @orgcmd{C-c C-x e,org-set-effort}
6526 Set the effort estimate for the current entry.  With a numeric prefix
6527 argument, set it to the Nth allowed value (see below).  This command is also
6528 accessible from the agenda with the @kbd{e} key.
6529 @orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
6530 Modify the effort estimate of the item currently being clocked.
6531 @end table
6533 Clearly the best way to work with effort estimates is through column view
6534 (@pxref{Column view}).  You should start by setting up discrete values for
6535 effort estimates, and a @code{COLUMNS} format that displays these values
6536 together with clock sums (if you want to clock your time).  For a specific
6537 buffer you can use
6539 @example
6540 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
6541 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
6542 @end example
6544 @noindent
6545 @vindex org-global-properties
6546 @vindex org-columns-default-format
6547 or, even better, you can set up these values globally by customizing the
6548 variables @code{org-global-properties} and @code{org-columns-default-format}.
6549 In particular if you want to use this setup also in the agenda, a global
6550 setup may be advised.
6552 The way to assign estimates to individual items is then to switch to column
6553 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
6554 value.  The values you enter will immediately be summed up in the hierarchy.
6555 In the column next to it, any clocked time will be displayed.
6557 @vindex org-agenda-columns-add-appointments-to-effort-sum
6558 If you switch to column view in the daily/weekly agenda, the effort column
6559 will summarize the estimated work effort for each day@footnote{Please note
6560 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
6561 column view}).}, and you can use this to find space in your schedule.  To get
6562 an overview of the entire part of the day that is committed, you can set the
6563 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
6564 appointments on a day that take place over a specified time interval will
6565 then also be added to the load estimate of the day.
6567 Effort estimates can be used in secondary agenda filtering that is triggered
6568 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
6569 these estimates defined consistently, two or three key presses will narrow
6570 down the list to stuff that fits into an available time slot.
6572 @node Relative timer, Countdown timer, Effort estimates, Dates and Times
6573 @section Taking notes with a relative timer
6574 @cindex relative timer
6576 When taking notes during, for example, a meeting or a video viewing, it can
6577 be useful to have access to times relative to a starting time.  Org provides
6578 such a relative timer and make it easy to create timed notes.
6580 @table @kbd
6581 @orgcmd{C-c C-x .,org-timer}
6582 Insert a relative time into the buffer.  The first time you use this, the
6583 timer will be started.  When called with a prefix argument, the timer is
6584 restarted.
6585 @orgcmd{C-c C-x -,org-timer-item}
6586 Insert a description list item with the current relative time.  With a prefix
6587 argument, first reset the timer to 0.
6588 @orgcmd{M-@key{RET},org-insert-heading}
6589 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
6590 new timer items.
6591 @c for key sequences with a comma, command name macros fail :(
6592 @kindex C-c C-x ,
6593 @item C-c C-x ,
6594 Pause the timer, or continue it if it is already paused
6595 (@command{org-timer-pause-or-continue}).
6596 @c removed the sentence because it is redundant to the following item
6597 @kindex C-u C-c C-x ,
6598 @item C-u C-c C-x ,
6599 Stop the timer.  After this, you can only start a new timer, not continue the
6600 old one.  This command also removes the timer from the mode line.
6601 @orgcmd{C-c C-x 0,org-timer-start}
6602 Reset the timer without inserting anything into the buffer.  By default, the
6603 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
6604 specific starting offset.  The user is prompted for the offset, with a
6605 default taken from a timer string at point, if any, So this can be used to
6606 restart taking notes after a break in the process.  When called with a double
6607 prefix argument @kbd{C-u C-u}, change all timer strings in the active region
6608 by a certain amount.  This can be used to fix timer strings if the timer was
6609 not started at exactly the right moment.
6610 @end table
6612 @node Countdown timer,  , Relative timer, Dates and Times
6613 @section Countdown timer
6614 @cindex Countdown timer
6615 @kindex C-c C-x ;
6616 @kindex ;
6618 Calling @code{org-timer-set-timer} from an Org mode buffer runs a countdown
6619 timer.  Use @kbd{;} from agenda buffers, @key{C-c C-x ;} everywhere else.
6621 @code{org-timer-set-timer} prompts the user for a duration and displays a
6622 countdown timer in the modeline.  @code{org-timer-default-timer} sets the
6623 default countdown value.  Giving a prefix numeric argument overrides this
6624 default value.
6626 @node Capture - Refile - Archive, Agenda Views, Dates and Times, Top
6627 @chapter Capture - Refile - Archive
6628 @cindex capture
6630 An important part of any organization system is the ability to quickly
6631 capture new ideas and tasks, and to associate reference material with them.
6632 Org does this using a process called @i{capture}.  It also can store files
6633 related to a task (@i{attachments}) in a special directory.  Once in the
6634 system, tasks and projects need to be moved around.  Moving completed project
6635 trees to an archive file keeps the system compact and fast.
6637 @menu
6638 * Capture::                     Capturing new stuff
6639 * Attachments::                 Add files to tasks
6640 * RSS Feeds::                   Getting input from RSS feeds
6641 * Protocols::                   External (e.g., Browser) access to Emacs and Org
6642 * Refile and copy::             Moving/copying a tree from one place to another
6643 * Archiving::                   What to do with finished projects
6644 @end menu
6646 @node Capture, Attachments, Capture - Refile - Archive, Capture - Refile - Archive
6647 @section Capture
6648 @cindex capture
6650 Capture lets you quickly store notes with little interruption of your work
6651 flow.  Org's method for capturing new items is heavily inspired by John
6652 Wiegley excellent @code{remember.el} package.  Up to version 6.36, Org
6653 used a special setup for @file{remember.el}, then replaced it with
6654 @file{org-remember.el}.  As of version 8.0, @file{org-remember.el} has
6655 been completely replaced by @file{org-capture.el}.
6657 If your configuration depends on @file{org-remember.el}, you need to update
6658 it and use the setup described below.  To convert your
6659 @code{org-remember-templates}, run the command
6660 @example
6661 @kbd{M-x org-capture-import-remember-templates @key{RET}}
6662 @end example
6663 @noindent and then customize the new variable with @kbd{M-x
6664 customize-variable org-capture-templates}, check the result, and save the
6665 customization.
6667 @menu
6668 * Setting up capture::          Where notes will be stored
6669 * Using capture::               Commands to invoke and terminate capture
6670 * Capture templates::           Define the outline of different note types
6671 @end menu
6673 @node Setting up capture, Using capture, Capture, Capture
6674 @subsection Setting up capture
6676 The following customization sets a default target file for notes, and defines
6677 a global key@footnote{Please select your own key, @kbd{C-c c} is only a
6678 suggestion.}  for capturing new material.
6680 @vindex org-default-notes-file
6681 @example
6682 (setq org-default-notes-file (concat org-directory "/notes.org"))
6683 (define-key global-map "\C-cc" 'org-capture)
6684 @end example
6686 @node Using capture, Capture templates, Setting up capture, Capture
6687 @subsection Using capture
6689 @table @kbd
6690 @orgcmd{C-c c,org-capture}
6691 Call the command @code{org-capture}.  Note that this keybinding is global and
6692 not active by default: you need to install it.  If you have templates
6693 @cindex date tree
6694 defined @pxref{Capture templates}, it will offer these templates for
6695 selection or use a new Org outline node as the default template.  It will
6696 insert the template into the target file and switch to an indirect buffer
6697 narrowed to this new node.  You may then insert the information you want.
6699 @orgcmd{C-c C-c,org-capture-finalize}
6700 Once you have finished entering information into the capture buffer, @kbd{C-c
6701 C-c} will return you to the window configuration before the capture process,
6702 so that you can resume your work without further distraction.  When called
6703 with a prefix arg, finalize and then jump to the captured item.
6705 @orgcmd{C-c C-w,org-capture-refile}
6706 Finalize the capture process by refiling (@pxref{Refile and copy}) the note to
6707 a different place.  Please realize that this is a normal refiling command
6708 that will be executed---so the cursor position at the moment you run this
6709 command is important.  If you have inserted a tree with a parent and
6710 children, first move the cursor back to the parent.  Any prefix argument
6711 given to this command will be passed on to the @code{org-refile} command.
6713 @orgcmd{C-c C-k,org-capture-kill}
6714 Abort the capture process and return to the previous state.
6716 @end table
6718 You can also call @code{org-capture} in a special way from the agenda, using
6719 the @kbd{k c} key combination.  With this access, any timestamps inserted by
6720 the selected capture template will default to the cursor date in the agenda,
6721 rather than to the current date.
6723 To find the locations of the last stored capture, use @code{org-capture} with
6724 prefix commands:
6726 @table @kbd
6727 @orgkey{C-u C-c c}
6728 Visit the target location of a capture template.  You get to select the
6729 template in the usual way.
6730 @orgkey{C-u C-u C-c c}
6731 Visit the last stored capture item in its buffer.
6732 @end table
6734 @vindex org-capture-bookmark
6735 @cindex org-capture-last-stored
6736 You can also jump to the bookmark @code{org-capture-last-stored}, which will
6737 automatically be created unless you set @code{org-capture-bookmark} to
6738 @code{nil}.
6740 To insert the capture at point in an Org buffer, call @code{org-capture} with
6741 a @code{C-0} prefix argument.
6743 @node Capture templates,  , Using capture, Capture
6744 @subsection Capture templates
6745 @cindex templates, for Capture
6747 You can use templates for different types of capture items, and
6748 for different target locations.  The easiest way to create such templates is
6749 through the customize interface.
6751 @table @kbd
6752 @orgkey{C-c c C}
6753 Customize the variable @code{org-capture-templates}.
6754 @end table
6756 Before we give the formal description of template definitions, let's look at
6757 an example.  Say you would like to use one template to create general TODO
6758 entries, and you want to put these entries under the heading @samp{Tasks} in
6759 your file @file{~/org/gtd.org}.  Also, a date tree in the file
6760 @file{journal.org} should capture journal entries.  A possible configuration
6761 would look like:
6763 @example
6764 (setq org-capture-templates
6765  '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
6766         "* TODO %?\n  %i\n  %a")
6767    ("j" "Journal" entry (file+datetree "~/org/journal.org")
6768         "* %?\nEntered on %U\n  %i\n  %a")))
6769 @end example
6771 @noindent If you then press @kbd{C-c c t}, Org will prepare the template
6772 for you like this:
6773 @example
6774 * TODO
6775   [[file:@var{link to where you initiated capture}]]
6776 @end example
6778 @noindent
6779 During expansion of the template, @code{%a} has been replaced by a link to
6780 the location from where you called the capture command.  This can be
6781 extremely useful for deriving tasks from emails, for example.  You fill in
6782 the task definition, press @code{C-c C-c} and Org returns you to the same
6783 place where you started the capture process.
6785 To define special keys to capture to a particular template without going
6786 through the interactive template selection, you can create your key binding
6787 like this:
6789 @lisp
6790 (define-key global-map "\C-cx"
6791    (lambda () (interactive) (org-capture nil "x")))
6792 @end lisp
6794 @menu
6795 * Template elements::           What is needed for a complete template entry
6796 * Template expansion::          Filling in information about time and context
6797 * Templates in contexts::       Only show a template in a specific context
6798 @end menu
6800 @node Template elements, Template expansion, Capture templates, Capture templates
6801 @subsubsection Template elements
6803 Now lets look at the elements of a template definition.  Each entry in
6804 @code{org-capture-templates} is a list with the following items:
6806 @table @var
6807 @item keys
6808 The keys that will select the template, as a string, characters
6809 only, for example @code{"a"} for a template to be selected with a
6810 single key, or @code{"bt"} for selection with two keys.  When using
6811 several keys, keys using the same prefix key must be sequential
6812 in the list and preceded by a 2-element entry explaining the
6813 prefix key, for example
6814 @example
6815          ("b" "Templates for marking stuff to buy")
6816 @end example
6817 @noindent If you do not define a template for the @kbd{C} key, this key will
6818 be used to open the customize buffer for this complex variable.
6820 @item description
6821 A short string describing the template, which will be shown during
6822 selection.
6824 @item type
6825 The type of entry, a symbol.  Valid values are:
6827 @table @code
6828 @item entry
6829 An Org mode node, with a headline.  Will be filed as the child of the target
6830 entry or as a top-level entry.  The target file should be an Org mode file.
6831 @item item
6832 A plain list item, placed in the first plain  list at the target
6833 location.  Again the target file should be an Org file.
6834 @item checkitem
6835 A checkbox item.  This only differs from the plain list item by the
6836 default template.
6837 @item table-line
6838 a new line in the first table at the target location.  Where exactly the
6839 line will be inserted depends on the properties @code{:prepend} and
6840 @code{:table-line-pos} (see below).
6841 @item plain
6842 Text to be inserted as it is.
6843 @end table
6845 @item target
6846 @vindex org-default-notes-file
6847 Specification of where the captured item should be placed.  In Org mode
6848 files, targets usually define a node.  Entries will become children of this
6849 node.  Other types will be added to the table or list in the body of this
6850 node.  Most target specifications contain a file name.  If that file name is
6851 the empty string, it defaults to @code{org-default-notes-file}.  A file can
6852 also be given as a variable, function, or Emacs Lisp form.
6854 Valid values are:
6856 @table @code
6857 @item (file "path/to/file")
6858 Text will be placed at the beginning or end of that file.
6860 @item (id "id of existing org entry")
6861 Filing as child of this entry, or in the body of the entry.
6863 @item (file+headline "path/to/file" "node headline")
6864 Fast configuration if the target heading is unique in the file.
6866 @item (file+olp "path/to/file" "Level 1 heading" "Level 2" ...)
6867 For non-unique headings, the full path is safer.
6869 @item (file+regexp  "path/to/file" "regexp to find location")
6870 Use a regular expression to position the cursor.
6872 @item (file+datetree "path/to/file")
6873 Will create a heading in a date tree for today's date.
6875 @item (file+datetree+prompt "path/to/file")
6876 Will create a heading in a date tree, but will prompt for the date.
6878 @item (file+function "path/to/file" function-finding-location)
6879 A function to find the right location in the file.
6881 @item (clock)
6882 File to the entry that is currently being clocked.
6884 @item (function function-finding-location)
6885 Most general way, write your own function to find both
6886 file and location.
6887 @end table
6889 @item template
6890 The template for creating the capture item.  If you leave this empty, an
6891 appropriate default template will be used.  Otherwise this is a string with
6892 escape codes, which will be replaced depending on time and context of the
6893 capture call.  The string with escapes may be loaded from a template file,
6894 using the special syntax @code{(file "path/to/template")}.  See below for
6895 more details.
6897 @item properties
6898 The rest of the entry is a property list of additional options.
6899 Recognized properties are:
6901 @table @code
6902 @item :prepend
6903 Normally new captured information will be appended at
6904 the target location (last child, last table line, last list item...).
6905 Setting this property will change that.
6907 @item :immediate-finish
6908 When set, do not offer to edit the information, just
6909 file it away immediately.  This makes sense if the template only needs
6910 information that can be added automatically.
6912 @item :empty-lines
6913 Set this to the number of lines to insert
6914 before and after the new item.  Default 0, only common other value is 1.
6916 @item :clock-in
6917 Start the clock in this item.
6919 @item :clock-keep
6920 Keep the clock running when filing the captured entry.
6922 @item :clock-resume
6923 If starting the capture interrupted a clock, restart that clock when finished
6924 with the capture.  Note that @code{:clock-keep} has precedence over
6925 @code{:clock-resume}.  When setting both to @code{t}, the current clock will
6926 run and the previous one will not be resumed.
6928 @item :unnarrowed
6929 Do not narrow the target buffer, simply show the full buffer.  Default is to
6930 narrow it so that you only see the new material.
6932 @item :table-line-pos
6933 Specification of the location in the table where the new line should be
6934 inserted.  It should be a string like @code{"II-3"} meaning that the new
6935 line should become the third line before the second horizontal separator
6936 line.
6938 @item :kill-buffer
6939 If the target file was not yet visited when capture was invoked, kill the
6940 buffer again after capture is completed.
6941 @end table
6942 @end table
6944 @node Template expansion, Templates in contexts, Template elements, Capture templates
6945 @subsubsection Template expansion
6947 In the template itself, special @kbd{%}-escapes@footnote{If you need one of
6948 these sequences literally, escape the @kbd{%} with a backslash.} allow
6949 dynamic insertion of content.  The templates are expanded in the order given here:
6951 @smallexample
6952 %[@var{file}]     @r{Insert the contents of the file given by @var{file}.}
6953 %(@var{sexp})     @r{Evaluate Elisp @var{sexp} and replace with the result.}
6954                   @r{For convenience, %:keyword (see below) placeholders}
6955                   @r{within the expression will be expanded prior to this.}
6956                   @r{The sexp must return a string.}
6957 %<...>      @r{The result of format-time-string on the ... format specification.}
6958 %t          @r{Timestamp, date only.}
6959 %T          @r{Timestamp, with date and time.}
6960 %u, %U      @r{Like the above, but inactive timestamps.}
6961 %i          @r{Initial content, the region when capture is called while the}
6962             @r{region is active.}
6963             @r{The entire text will be indented like @code{%i} itself.}
6964 %a          @r{Annotation, normally the link created with @code{org-store-link}.}
6965 %A          @r{Like @code{%a}, but prompt for the description part.}
6966 %l          @r{Like %a, but only insert the literal link.}
6967 %c          @r{Current kill ring head.}
6968 %x          @r{Content of the X clipboard.}
6969 %k          @r{Title of the currently clocked task.}
6970 %K          @r{Link to the currently clocked task.}
6971 %n          @r{User name (taken from @code{user-full-name}).}
6972 %f          @r{File visited by current buffer when org-capture was called.}
6973 %F          @r{Full path of the file or directory visited by current buffer.}
6974 %:keyword   @r{Specific information for certain link types, see below.}
6975 %^g         @r{Prompt for tags, with completion on tags in target file.}
6976 %^G         @r{Prompt for tags, with completion all tags in all agenda files.}
6977 %^t         @r{Like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}.}
6978             @r{You may define a prompt like @code{%^@{Birthday@}t}.}
6979 %^C         @r{Interactive selection of which kill or clip to use.}
6980 %^L         @r{Like @code{%^C}, but insert as link.}
6981 %^@{@var{prop}@}p   @r{Prompt the user for a value for property @var{prop}.}
6982 %^@{@var{prompt}@}  @r{prompt the user for a string and replace this sequence with it.}
6983             @r{You may specify a default value and a completion table with}
6984             @r{%^@{prompt|default|completion2|completion3...@}.}
6985             @r{The arrow keys access a prompt-specific history.}
6986 %\n         @r{Insert the text entered at the nth %^@{@var{prompt}@}, where @code{n} is}
6987             @r{a number, starting from 1.}
6988 %?          @r{After completing the template, position cursor here.}
6989 @end smallexample
6991 @noindent
6992 For specific link types, the following keywords will be
6993 defined@footnote{If you define your own link types (@pxref{Adding
6994 hyperlink types}), any property you store with
6995 @code{org-store-link-props} can be accessed in capture templates in a
6996 similar way.}:
6998 @vindex org-from-is-user-regexp
6999 @smallexample
7000 Link type                        |  Available keywords
7001 ---------------------------------+----------------------------------------------
7002 bbdb                             |  %:name %:company
7003 irc                              |  %:server %:port %:nick
7004 vm, vm-imap, wl, mh, mew, rmail  |  %:type %:subject %:message-id
7005                                  |  %:from %:fromname %:fromaddress
7006                                  |  %:to   %:toname   %:toaddress
7007                                  |  %:date @r{(message date header field)}
7008                                  |  %:date-timestamp @r{(date as active timestamp)}
7009                                  |  %:date-timestamp-inactive @r{(date as inactive timestamp)}
7010                                  |  %: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}.}}
7011 gnus                             |  %:group, @r{for messages also all email fields}
7012 w3, w3m                          |  %:url
7013 info                             |  %:file %:node
7014 calendar                         |  %:date
7015 @end smallexample
7017 @noindent
7018 To place the cursor after template expansion use:
7020 @smallexample
7021 %?          @r{After completing the template, position cursor here.}
7022 @end smallexample
7024 @node Templates in contexts,  , Template expansion, Capture templates
7025 @subsubsection Templates in contexts
7027 @vindex org-capture-templates-contexts
7028 To control whether a capture template should be accessible from a specific
7029 context, you can customize @var{org-capture-templates-contexts}.  Let's say
7030 for example that you have a capture template @code{"p"} for storing Gnus
7031 emails containing patches.  Then you would configure this option like this:
7033 @example
7034 (setq org-capture-templates-contexts
7035       '(("p" (in-mode . "message-mode"))))
7036 @end example
7038 You can also tell that the command key @code{"p"} should refer to another
7039 template.  In that case, add this command key like this:
7041 @example
7042 (setq org-capture-templates-contexts
7043       '(("p" "q" (in-mode . "message-mode"))))
7044 @end example
7046 See the docstring of the variable for more information.
7048 @node Attachments, RSS Feeds, Capture, Capture - Refile - Archive
7049 @section Attachments
7050 @cindex attachments
7052 @vindex org-attach-directory
7053 It is often useful to associate reference material with an outline node/task.
7054 Small chunks of plain text can simply be stored in the subtree of a project.
7055 Hyperlinks (@pxref{Hyperlinks}) can establish associations with
7056 files that live elsewhere on your computer or in the cloud, like emails or
7057 source code files belonging to a project.  Another method is @i{attachments},
7058 which are files located in a directory belonging to an outline node.  Org
7059 uses directories named by the unique ID of each entry.  These directories are
7060 located in the @file{data} directory which lives in the same directory where
7061 your Org file lives@footnote{If you move entries or Org files from one
7062 directory to another, you may want to configure @code{org-attach-directory}
7063 to contain an absolute path.}.  If you initialize this directory with
7064 @code{git init}, Org will automatically commit changes when it sees them.
7065 The attachment system has been contributed to Org by John Wiegley.
7067 In cases where it seems better to do so, you can also attach a directory of your
7068 choice to an entry.  You can also make children inherit the attachment
7069 directory from a parent, so that an entire subtree uses the same attached
7070 directory.
7072 @noindent The following commands deal with attachments:
7074 @table @kbd
7075 @orgcmd{C-c C-a,org-attach}
7076 The dispatcher for commands related to the attachment system.  After these
7077 keys, a list of commands is displayed and you must press an additional key
7078 to select a command:
7080 @table @kbd
7081 @orgcmdtkc{a,C-c C-a a,org-attach-attach}
7082 @vindex org-attach-method
7083 Select a file and move it into the task's attachment directory.  The file
7084 will be copied, moved, or linked, depending on @code{org-attach-method}.
7085 Note that hard links are not supported on all systems.
7087 @kindex C-c C-a c
7088 @kindex C-c C-a m
7089 @kindex C-c C-a l
7090 @item c/m/l
7091 Attach a file using the copy/move/link method.
7092 Note that hard links are not supported on all systems.
7094 @orgcmdtkc{n,C-c C-a n,org-attach-new}
7095 Create a new attachment as an Emacs buffer.
7097 @orgcmdtkc{z,C-c C-a z,org-attach-sync}
7098 Synchronize the current task with its attachment directory, in case you added
7099 attachments yourself.
7101 @orgcmdtkc{o,C-c C-a o,org-attach-open}
7102 @vindex org-file-apps
7103 Open current task's attachment.  If there is more than one, prompt for a
7104 file name first.  Opening will follow the rules set by @code{org-file-apps}.
7105 For more details, see the information on following hyperlinks
7106 (@pxref{Handling links}).
7108 @orgcmdtkc{O,C-c C-a O,org-attach-open-in-emacs}
7109 Also open the attachment, but force opening the file in Emacs.
7111 @orgcmdtkc{f,C-c C-a f,org-attach-reveal}
7112 Open the current task's attachment directory.
7114 @orgcmdtkc{F,C-c C-a F,org-attach-reveal-in-emacs}
7115 Also open the directory, but force using @command{dired} in Emacs.
7117 @orgcmdtkc{d,C-c C-a d,org-attach-delete-one}
7118 Select and delete a single attachment.
7120 @orgcmdtkc{D,C-c C-a D,org-attach-delete-all}
7121 Delete all of a task's attachments.  A safer way is to open the directory in
7122 @command{dired} and delete from there.
7124 @orgcmdtkc{s,C-c C-a s,org-attach-set-directory}
7125 @cindex property, ATTACH_DIR
7126 Set a specific directory as the entry's attachment directory.  This works by
7127 putting the directory path into the @code{ATTACH_DIR} property.
7129 @orgcmdtkc{i,C-c C-a i,org-attach-set-inherit}
7130 @cindex property, ATTACH_DIR_INHERIT
7131 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
7132 same directory for attachments as the parent does.
7133 @end table
7134 @end table
7136 @node RSS Feeds, Protocols, Attachments, Capture - Refile - Archive
7137 @section RSS feeds
7138 @cindex RSS feeds
7139 @cindex Atom feeds
7141 Org can add and change entries based on information found in RSS feeds and
7142 Atom feeds.  You could use this to make a task out of each new podcast in a
7143 podcast feed.  Or you could use a phone-based note-creating service on the
7144 web to import tasks into Org.  To access feeds, configure the variable
7145 @code{org-feed-alist}.  The docstring of this variable has detailed
7146 information.  Here is just an example:
7148 @example
7149 (setq org-feed-alist
7150      '(("Slashdot"
7151          "http://rss.slashdot.org/Slashdot/slashdot"
7152          "~/txt/org/feeds.org" "Slashdot Entries")))
7153 @end example
7155 @noindent
7156 will configure that new items from the feed provided by
7157 @code{rss.slashdot.org} will result in new entries in the file
7158 @file{~/org/feeds.org} under the heading @samp{Slashdot Entries}, whenever
7159 the following command is used:
7161 @table @kbd
7162 @orgcmd{C-c C-x g,org-feed-update-all}
7163 @item C-c C-x g
7164 Collect items from the feeds configured in @code{org-feed-alist} and act upon
7165 them.
7166 @orgcmd{C-c C-x G,org-feed-goto-inbox}
7167 Prompt for a feed name and go to the inbox configured for this feed.
7168 @end table
7170 Under the same headline, Org will create a drawer @samp{FEEDSTATUS} in which
7171 it will store information about the status of items in the feed, to avoid
7172 adding the same item several times.  You should add @samp{FEEDSTATUS} to the
7173 list of drawers in that file:
7175 @example
7176 #+DRAWERS: LOGBOOK PROPERTIES FEEDSTATUS
7177 @end example
7179 For more information, including how to read atom feeds, see
7180 @file{org-feed.el} and the docstring of @code{org-feed-alist}.
7182 @node Protocols, Refile and copy, RSS Feeds, Capture - Refile - Archive
7183 @section Protocols for external access
7184 @cindex protocols, for external access
7185 @cindex emacsserver
7187 You can set up Org for handling protocol calls from outside applications that
7188 are passed to Emacs through the @file{emacsserver}.  For example, you can
7189 configure bookmarks in your web browser to send a link to the current page to
7190 Org and create a note from it using capture (@pxref{Capture}).  Or you
7191 could create a bookmark that will tell Emacs to open the local source file of
7192 a remote website you are looking at with the browser.  See
7193 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
7194 documentation and setup instructions.
7196 @node Refile and copy, Archiving, Protocols, Capture - Refile - Archive
7197 @section Refile and copy
7198 @cindex refiling notes
7199 @cindex copying notes
7201 When reviewing the captured data, you may want to refile or to copy some of
7202 the entries into a different list, for example into a project.  Cutting,
7203 finding the right location, and then pasting the note is cumbersome.  To
7204 simplify this process, you can use the following special command:
7206 @table @kbd
7207 @orgcmd{C-c M-w,org-copy}
7208 @findex org-copy
7209 Copying works like refiling, except that the original note is not deleted.
7210 @orgcmd{C-c C-w,org-refile}
7211 @findex org-refile
7212 @vindex org-reverse-note-order
7213 @vindex org-refile-targets
7214 @vindex org-refile-use-outline-path
7215 @vindex org-outline-path-complete-in-steps
7216 @vindex org-refile-allow-creating-parent-nodes
7217 @vindex org-log-refile
7218 @vindex org-refile-use-cache
7219 Refile the entry or region at point.  This command offers possible locations
7220 for refiling the entry and lets you select one with completion.  The item (or
7221 all items in the region) is filed below the target heading as a subitem.
7222 Depending on @code{org-reverse-note-order}, it will be either the first or
7223 last subitem.@*
7224 By default, all level 1 headlines in the current buffer are considered to be
7225 targets, but you can have more complex definitions across a number of files.
7226 See the variable @code{org-refile-targets} for details.  If you would like to
7227 select a location via a file-path-like completion along the outline path, see
7228 the variables @code{org-refile-use-outline-path} and
7229 @code{org-outline-path-complete-in-steps}.  If you would like to be able to
7230 create new nodes as new parents for refiling on the fly, check the
7231 variable @code{org-refile-allow-creating-parent-nodes}.
7232 When the variable @code{org-log-refile}@footnote{with corresponding
7233 @code{#+STARTUP} keywords @code{logrefile}, @code{lognoterefile},
7234 and @code{nologrefile}} is set, a timestamp or a note will be
7235 recorded when an entry has been refiled.
7236 @orgkey{C-u C-c C-w}
7237 Use the refile interface to jump to a heading.
7238 @orgcmd{C-u C-u C-c C-w,org-refile-goto-last-stored}
7239 Jump to the location where @code{org-refile} last moved a tree to.
7240 @item C-2 C-c C-w
7241 Refile as the child of the item currently being clocked.
7242 @orgcmdtkc{C-0 C-c C-w @ @r{or} @ C-u C-u C-u C-c C-w,C-0 C-c C-w,org-refile-cache-clear}
7243 Clear the target cache.  Caching of refile targets can be turned on by
7244 setting @code{org-refile-use-cache}.  To make the command see new possible
7245 targets, you have to clear the cache with this command.
7246 @end table
7248 @node Archiving,  , Refile and copy, Capture - Refile - Archive
7249 @section Archiving
7250 @cindex archiving
7252 When a project represented by a (sub)tree is finished, you may want
7253 to move the tree out of the way and to stop it from contributing to the
7254 agenda.  Archiving is important to keep your working files compact and global
7255 searches like the construction of agenda views fast.
7257 @table @kbd
7258 @orgcmd{C-c C-x C-a,org-archive-subtree-default}
7259 @vindex org-archive-default-command
7260 Archive the current entry using the command specified in the variable
7261 @code{org-archive-default-command}.
7262 @end table
7264 @menu
7265 * Moving subtrees::             Moving a tree to an archive file
7266 * Internal archiving::          Switch off a tree but keep it in the file
7267 @end menu
7269 @node Moving subtrees, Internal archiving, Archiving, Archiving
7270 @subsection Moving a tree to the archive file
7271 @cindex external archiving
7273 The most common archiving action is to move a project tree to another file,
7274 the archive file.
7276 @table @kbd
7277 @orgcmdkskc{C-c C-x C-s,C-c $,org-archive-subtree}
7278 @vindex org-archive-location
7279 Archive the subtree starting at the cursor position to the location
7280 given by @code{org-archive-location}.
7281 @orgkey{C-u C-c C-x C-s}
7282 Check if any direct children of the current headline could be moved to
7283 the archive.  To do this, each subtree is checked for open TODO entries.
7284 If none are found, the command offers to move it to the archive
7285 location.  If the cursor is @emph{not} on a headline when this command
7286 is invoked, the level 1 trees will be checked.
7287 @end table
7289 @cindex archive locations
7290 The default archive location is a file in the same directory as the
7291 current file, with the name derived by appending @file{_archive} to the
7292 current file name.  You can also choose what heading to file archived
7293 items under, with the possibility to add them to a datetree in a file.
7294 For information and examples on how to specify the file and the heading,
7295 see the documentation string of the variable
7296 @code{org-archive-location}.
7298 There is also an in-buffer option for setting this variable, for
7299 example@footnote{For backward compatibility, the following also works:
7300 If there are several such lines in a file, each specifies the archive
7301 location for the text below it.  The first such line also applies to any
7302 text before its definition.  However, using this method is
7303 @emph{strongly} deprecated as it is incompatible with the outline
7304 structure of the document.  The correct method for setting multiple
7305 archive locations in a buffer is using properties.}:
7307 @cindex #+ARCHIVE
7308 @example
7309 #+ARCHIVE: %s_done::
7310 @end example
7312 @cindex property, ARCHIVE
7313 @noindent
7314 If you would like to have a special ARCHIVE location for a single entry
7315 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
7316 location as the value (@pxref{Properties and Columns}).
7318 @vindex org-archive-save-context-info
7319 When a subtree is moved, it receives a number of special properties that
7320 record context information like the file from where the entry came, its
7321 outline path the archiving time etc.  Configure the variable
7322 @code{org-archive-save-context-info} to adjust the amount of information
7323 added.
7326 @node Internal archiving,  , Moving subtrees, Archiving
7327 @subsection Internal archiving
7329 If you want to just switch off (for agenda views) certain subtrees without
7330 moving them to a different file, you can use the @code{ARCHIVE tag}.
7332 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
7333 its location in the outline tree, but behaves in the following way:
7334 @itemize @minus
7335 @item
7336 @vindex org-cycle-open-archived-trees
7337 It does not open when you attempt to do so with a visibility cycling
7338 command (@pxref{Visibility cycling}).  You can force cycling archived
7339 subtrees with @kbd{C-@key{TAB}}, or by setting the option
7340 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
7341 @code{show-all} will open archived subtrees.
7342 @item
7343 @vindex org-sparse-tree-open-archived-trees
7344 During sparse tree construction (@pxref{Sparse trees}), matches in
7345 archived subtrees are not exposed, unless you configure the option
7346 @code{org-sparse-tree-open-archived-trees}.
7347 @item
7348 @vindex org-agenda-skip-archived-trees
7349 During agenda view construction (@pxref{Agenda Views}), the content of
7350 archived trees is ignored unless you configure the option
7351 @code{org-agenda-skip-archived-trees}, in which case these trees will always
7352 be included.  In the agenda you can press @kbd{v a} to get archives
7353 temporarily included.
7354 @item
7355 @vindex org-export-with-archived-trees
7356 Archived trees are not exported (@pxref{Exporting}), only the headline
7357 is.  Configure the details using the variable
7358 @code{org-export-with-archived-trees}.
7359 @item
7360 @vindex org-columns-skip-archived-trees
7361 Archived trees are excluded from column view unless the variable
7362 @code{org-columns-skip-archived-trees} is configured to @code{nil}.
7363 @end itemize
7365 The following commands help manage the ARCHIVE tag:
7367 @table @kbd
7368 @orgcmd{C-c C-x a,org-toggle-archive-tag}
7369 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
7370 the headline changes to a shadowed face, and the subtree below it is
7371 hidden.
7372 @orgkey{C-u C-c C-x a}
7373 Check if any direct children of the current headline should be archived.
7374 To do this, each subtree is checked for open TODO entries.  If none are
7375 found, the command offers to set the ARCHIVE tag for the child.  If the
7376 cursor is @emph{not} on a headline when this command is invoked, the
7377 level 1 trees will be checked.
7378 @orgcmd{C-@kbd{TAB},org-force-cycle-archived}
7379 Cycle a tree even if it is tagged with ARCHIVE.
7380 @orgcmd{C-c C-x A,org-archive-to-archive-sibling}
7381 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
7382 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}.  The
7383 entry becomes a child of that sibling and in this way retains a lot of its
7384 original context, including inherited tags and approximate position in the
7385 outline.
7386 @end table
7389 @node Agenda Views, Markup, Capture - Refile - Archive, Top
7390 @chapter Agenda views
7391 @cindex agenda views
7393 Due to the way Org works, TODO items, time-stamped items, and
7394 tagged headlines can be scattered throughout a file or even a number of
7395 files.  To get an overview of open action items, or of events that are
7396 important for a particular date, this information must be collected,
7397 sorted and displayed in an organized way.
7399 Org can select items based on various criteria and display them
7400 in a separate buffer.  Seven different view types are provided:
7402 @itemize @bullet
7403 @item
7404 an @emph{agenda} that is like a calendar and shows information
7405 for specific dates,
7406 @item
7407 a @emph{TODO list} that covers all unfinished
7408 action items,
7409 @item
7410 a @emph{match view}, showings headlines based on the tags, properties, and
7411 TODO state associated with them,
7412 @item
7413 a @emph{timeline view} that shows all events in a single Org file,
7414 in time-sorted view,
7415 @item
7416 a @emph{text search view} that shows all entries from multiple files
7417 that contain specified keywords,
7418 @item
7419 a @emph{stuck projects view} showing projects that currently don't move
7420 along, and
7421 @item
7422 @emph{custom views} that are special searches and combinations of different
7423 views.
7424 @end itemize
7426 @noindent
7427 The extracted information is displayed in a special @emph{agenda
7428 buffer}.  This buffer is read-only, but provides commands to visit the
7429 corresponding locations in the original Org files, and even to
7430 edit these files remotely.
7432 @vindex org-agenda-window-setup
7433 @vindex org-agenda-restore-windows-after-quit
7434 Two variables control how the agenda buffer is displayed and whether the
7435 window configuration is restored when the agenda exits:
7436 @code{org-agenda-window-setup} and
7437 @code{org-agenda-restore-windows-after-quit}.
7439 @menu
7440 * Agenda files::                Files being searched for agenda information
7441 * Agenda dispatcher::           Keyboard access to agenda views
7442 * Built-in agenda views::       What is available out of the box?
7443 * Presentation and sorting::    How agenda items are prepared for display
7444 * Agenda commands::             Remote editing of Org trees
7445 * Custom agenda views::         Defining special searches and views
7446 * Exporting Agenda Views::      Writing a view to a file
7447 * Agenda column view::          Using column view for collected entries
7448 @end menu
7450 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
7451 @section Agenda files
7452 @cindex agenda files
7453 @cindex files for agenda
7455 @vindex org-agenda-files
7456 The information to be shown is normally collected from all @emph{agenda
7457 files}, the files listed in the variable
7458 @code{org-agenda-files}@footnote{If the value of that variable is not a
7459 list, but a single file name, then the list of agenda files will be
7460 maintained in that external file.}.  If a directory is part of this list,
7461 all files with the extension @file{.org} in this directory will be part
7462 of the list.
7464 Thus, even if you only work with a single Org file, that file should
7465 be put into the list@footnote{When using the dispatcher, pressing
7466 @kbd{<} before selecting a command will actually limit the command to
7467 the current file, and ignore @code{org-agenda-files} until the next
7468 dispatcher command.}.  You can customize @code{org-agenda-files}, but
7469 the easiest way to maintain it is through the following commands
7471 @cindex files, adding to agenda list
7472 @table @kbd
7473 @orgcmd{C-c [,org-agenda-file-to-front}
7474 Add current file to the list of agenda files.  The file is added to
7475 the front of the list.  If it was already in the list, it is moved to
7476 the front.  With a prefix argument, file is added/moved to the end.
7477 @orgcmd{C-c ],org-remove-file}
7478 Remove current file from the list of agenda files.
7479 @kindex C-,
7480 @cindex cycling, of agenda files
7481 @orgcmd{C-',org-cycle-agenda-files}
7482 @itemx C-,
7483 Cycle through agenda file list, visiting one file after the other.
7484 @kindex M-x org-iswitchb
7485 @item M-x org-iswitchb
7486 Command to use an @code{iswitchb}-like interface to switch to and between Org
7487 buffers.
7488 @end table
7490 @noindent
7491 The Org menu contains the current list of files and can be used
7492 to visit any of them.
7494 If you would like to focus the agenda temporarily on a file not in
7495 this list, or on just one file in the list, or even on only a subtree in a
7496 file, then this can be done in different ways.  For a single agenda command,
7497 you may press @kbd{<} once or several times in the dispatcher
7498 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
7499 extended period, use the following commands:
7501 @table @kbd
7502 @orgcmd{C-c C-x <,org-agenda-set-restriction-lock}
7503 Permanently restrict the agenda to the current subtree.  When with a
7504 prefix argument, or with the cursor before the first headline in a file,
7505 the agenda scope is set to the entire file.  This restriction remains in
7506 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
7507 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
7508 agenda view, the new restriction takes effect immediately.
7509 @orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
7510 Remove the permanent restriction created by @kbd{C-c C-x <}.
7511 @end table
7513 @noindent
7514 When working with @file{speedbar.el}, you can use the following commands in
7515 the Speedbar frame:
7517 @table @kbd
7518 @orgcmdtkc{< @r{in the speedbar frame},<,org-speedbar-set-agenda-restriction}
7519 Permanently restrict the agenda to the item---either an Org file or a subtree
7520 in such a file---at the cursor in the Speedbar frame.
7521 If there is a window displaying an agenda view, the new restriction takes
7522 effect immediately.
7523 @orgcmdtkc{> @r{in the speedbar frame},>,org-agenda-remove-restriction-lock}
7524 Lift the restriction.
7525 @end table
7527 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
7528 @section The agenda dispatcher
7529 @cindex agenda dispatcher
7530 @cindex dispatching agenda commands
7531 The views are created through a dispatcher, which should be bound to a
7532 global key---for example @kbd{C-c a} (@pxref{Activation}).  In the
7533 following we will assume that @kbd{C-c a} is indeed how the dispatcher
7534 is accessed and list keyboard access to commands accordingly.  After
7535 pressing @kbd{C-c a}, an additional letter is required to execute a
7536 command.  The dispatcher offers the following default commands:
7538 @table @kbd
7539 @item a
7540 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
7541 @item t @r{/} T
7542 Create a list of all TODO items (@pxref{Global TODO list}).
7543 @item m @r{/} M
7544 Create a list of headlines matching a TAGS expression (@pxref{Matching
7545 tags and properties}).
7546 @item L
7547 Create the timeline view for the current buffer (@pxref{Timeline}).
7548 @item s
7549 Create a list of entries selected by a boolean expression of keywords
7550 and/or regular expressions that must or must not occur in the entry.
7551 @item /
7552 @vindex org-agenda-text-search-extra-files
7553 Search for a regular expression in all agenda files and additionally in
7554 the files listed in @code{org-agenda-text-search-extra-files}.  This
7555 uses the Emacs command @code{multi-occur}.  A prefix argument can be
7556 used to specify the number of context lines for each match, default is
7558 @item # @r{/} !
7559 Create a list of stuck projects (@pxref{Stuck projects}).
7560 @item <
7561 Restrict an agenda command to the current buffer@footnote{For backward
7562 compatibility, you can also press @kbd{1} to restrict to the current
7563 buffer.}.  After pressing @kbd{<}, you still need to press the character
7564 selecting the command.
7565 @item < <
7566 If there is an active region, restrict the following agenda command to
7567 the region.  Otherwise, restrict it to the current subtree@footnote{For
7568 backward compatibility, you can also press @kbd{0} to restrict to the
7569 current region/subtree.}.  After pressing @kbd{< <}, you still need to press the
7570 character selecting the command.
7572 @item *
7573 @vindex org-agenda-sticky
7574 Toggle sticky agenda views.  By default, Org maintains only a single agenda
7575 buffer and rebuilds it each time you change the view, to make sure everything
7576 is always up to date.  If you switch between views often and the build time
7577 bothers you, you can turn on sticky agenda buffers (make this the default by
7578 customizing the variable @code{org-agenda-sticky}).  With sticky agendas, the
7579 dispatcher only switches to the selected view, you need to update it by hand
7580 with @kbd{r} or @kbd{g}.  You can toggle sticky agenda view any time with
7581 @code{org-toggle-sticky-agenda}.
7582 @end table
7584 You can also define custom commands that will be accessible through the
7585 dispatcher, just like the default commands.  This includes the
7586 possibility to create extended agenda buffers that contain several
7587 blocks together, for example the weekly agenda, the global TODO list and
7588 a number of special tags matches.  @xref{Custom agenda views}.
7590 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
7591 @section The built-in agenda views
7593 In this section we describe the built-in views.
7595 @menu
7596 * Weekly/daily agenda::         The calendar page with current tasks
7597 * Global TODO list::            All unfinished action items
7598 * Matching tags and properties::  Structured information with fine-tuned search
7599 * Timeline::                    Time-sorted view for single file
7600 * Search view::                 Find entries by searching for text
7601 * Stuck projects::              Find projects you need to review
7602 @end menu
7604 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
7605 @subsection The weekly/daily agenda
7606 @cindex agenda
7607 @cindex weekly agenda
7608 @cindex daily agenda
7610 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
7611 paper agenda, showing all the tasks for the current week or day.
7613 @table @kbd
7614 @cindex org-agenda, command
7615 @orgcmd{C-c a a,org-agenda-list}
7616 Compile an agenda for the current week from a list of Org files.  The agenda
7617 shows the entries for each day.  With a numeric prefix@footnote{For backward
7618 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
7619 listed before the agenda.  This feature is deprecated, use the dedicated TODO
7620 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
7621 C-c a a}) you may set the number of days to be displayed.
7622 @end table
7624 @vindex org-agenda-span
7625 @vindex org-agenda-ndays
7626 The default number of days displayed in the agenda is set by the variable
7627 @code{org-agenda-span} (or the obsolete @code{org-agenda-ndays}).  This
7628 variable can be set to any number of days you want to see by default in the
7629 agenda, or to a span name, such a @code{day}, @code{week}, @code{month} or
7630 @code{year}.
7632 Remote editing from the agenda buffer means, for example, that you can
7633 change the dates of deadlines and appointments from the agenda buffer.
7634 The commands available in the Agenda buffer are listed in @ref{Agenda
7635 commands}.
7637 @subsubheading Calendar/Diary integration
7638 @cindex calendar integration
7639 @cindex diary integration
7641 Emacs contains the calendar and diary by Edward M. Reingold.  The
7642 calendar displays a three-month calendar with holidays from different
7643 countries and cultures.  The diary allows you to keep track of
7644 anniversaries, lunar phases, sunrise/set, recurrent appointments
7645 (weekly, monthly) and more.  In this way, it is quite complementary to
7646 Org.  It can be very useful to combine output from Org with
7647 the diary.
7649 In order to include entries from the Emacs diary into Org mode's
7650 agenda, you only need to customize the variable
7652 @lisp
7653 (setq org-agenda-include-diary t)
7654 @end lisp
7656 @noindent After that, everything will happen automatically.  All diary
7657 entries including holidays, anniversaries, etc., will be included in the
7658 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
7659 @key{RET} can be used from the agenda buffer to jump to the diary
7660 file in order to edit existing diary entries.  The @kbd{i} command to
7661 insert new entries for the current date works in the agenda buffer, as
7662 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
7663 Sunrise/Sunset times, show lunar phases and to convert to other
7664 calendars, respectively.  @kbd{c} can be used to switch back and forth
7665 between calendar and agenda.
7667 If you are using the diary only for sexp entries and holidays, it is
7668 faster to not use the above setting, but instead to copy or even move
7669 the entries into an Org file.  Org mode evaluates diary-style sexp
7670 entries, and does it faster because there is no overhead for first
7671 creating the diary display.  Note that the sexp entries must start at
7672 the left margin, no whitespace is allowed before them.  For example,
7673 the following segment of an Org file will be processed and entries
7674 will be made in the agenda:
7676 @example
7677 * Birthdays and similar stuff
7678 #+CATEGORY: Holiday
7679 %%(org-calendar-holiday)   ; special function for holiday names
7680 #+CATEGORY: Ann
7681 %%(org-anniversary 1956  5 14)@footnote{@code{org-anniversary} is just like @code{diary-anniversary}, but the argument order is always according to ISO and therefore independent of the value of @code{calendar-date-style}.} Arthur Dent is %d years old
7682 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
7683 @end example
7685 @subsubheading Anniversaries from BBDB
7686 @cindex BBDB, anniversaries
7687 @cindex anniversaries, from BBDB
7689 If you are using the Big Brothers Database to store your contacts, you will
7690 very likely prefer to store anniversaries in BBDB rather than in a
7691 separate Org or diary file.  Org supports this and will show BBDB
7692 anniversaries as part of the agenda.  All you need to do is to add the
7693 following to one of your agenda files:
7695 @example
7696 * Anniversaries
7697   :PROPERTIES:
7698   :CATEGORY: Anniv
7699   :END:
7700 %%(org-bbdb-anniversaries)
7701 @end example
7703 You can then go ahead and define anniversaries for a BBDB record.  Basically,
7704 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
7705 record and then add the date in the format @code{YYYY-MM-DD} or @code{MM-DD},
7706 followed by a space and the class of the anniversary (@samp{birthday} or
7707 @samp{wedding}, or a format string).  If you omit the class, it will default to
7708 @samp{birthday}.  Here are a few examples, the header for the file
7709 @file{org-bbdb.el} contains more detailed information.
7711 @example
7712 1973-06-22
7713 06-22
7714 1955-08-02 wedding
7715 2008-04-14 %s released version 6.01 of org mode, %d years ago
7716 @end example
7718 After a change to BBDB, or for the first agenda display during an Emacs
7719 session, the agenda display will suffer a short delay as Org updates its
7720 hash with anniversaries.  However, from then on things will be very fast---much
7721 faster in fact than a long list of @samp{%%(diary-anniversary)} entries
7722 in an Org or Diary file.
7724 @subsubheading Appointment reminders
7725 @cindex @file{appt.el}
7726 @cindex appointment reminders
7727 @cindex appointment
7728 @cindex reminders
7730 Org can interact with Emacs appointments notification facility.  To add the
7731 appointments of your agenda files, use the command @code{org-agenda-to-appt}.
7732 This command lets you filter through the list of your appointments and add
7733 only those belonging to a specific category or matching a regular expression.
7734 It also reads a @code{APPT_WARNTIME} property which will then override the
7735 value of @code{appt-message-warning-time} for this appointment.  See the
7736 docstring for details.
7738 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
7739 @subsection The global TODO list
7740 @cindex global TODO list
7741 @cindex TODO list, global
7743 The global TODO list contains all unfinished TODO items formatted and
7744 collected into a single place.
7746 @table @kbd
7747 @orgcmd{C-c a t,org-todo-list}
7748 Show the global TODO list.  This collects the TODO items from all agenda
7749 files (@pxref{Agenda Views}) into a single buffer.  By default, this lists
7750 items with a state the is not a DONE state.  The buffer is in
7751 @code{agenda-mode}, so there are commands to examine and manipulate the TODO
7752 entries directly from that buffer (@pxref{Agenda commands}).
7753 @orgcmd{C-c a T,org-todo-list}
7754 @cindex TODO keyword matching
7755 @vindex org-todo-keywords
7756 Like the above, but allows selection of a specific TODO keyword.  You can
7757 also do this by specifying a prefix argument to @kbd{C-c a t}.  You are
7758 prompted for a keyword, and you may also specify several keywords by
7759 separating them with @samp{|} as the boolean OR operator.  With a numeric
7760 prefix, the Nth keyword in @code{org-todo-keywords} is selected.
7761 @kindex r
7762 The @kbd{r} key in the agenda buffer regenerates it, and you can give
7763 a prefix argument to this command to change the selected TODO keyword,
7764 for example @kbd{3 r}.  If you often need a search for a specific
7765 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
7766 Matching specific TODO keywords can also be done as part of a tags
7767 search (@pxref{Tag searches}).
7768 @end table
7770 Remote editing of TODO items means that you can change the state of a
7771 TODO entry with a single key press.  The commands available in the
7772 TODO list are described in @ref{Agenda commands}.
7774 @cindex sublevels, inclusion into TODO list
7775 Normally the global TODO list simply shows all headlines with TODO
7776 keywords.  This list can become very long.  There are two ways to keep
7777 it more compact:
7778 @itemize @minus
7779 @item
7780 @vindex org-agenda-todo-ignore-scheduled
7781 @vindex org-agenda-todo-ignore-deadlines
7782 @vindex org-agenda-todo-ignore-timestamp
7783 @vindex org-agenda-todo-ignore-with-date
7784 Some people view a TODO item that has been @emph{scheduled} for execution or
7785 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
7786 Configure the variables @code{org-agenda-todo-ignore-scheduled},
7787 @code{org-agenda-todo-ignore-deadlines},
7788 @code{org-agenda-todo-ignore-timestamp} and/or
7789 @code{org-agenda-todo-ignore-with-date} to exclude such items from the global
7790 TODO list.
7791 @item
7792 @vindex org-agenda-todo-list-sublevels
7793 TODO items may have sublevels to break up the task into subtasks.  In
7794 such cases it may be enough to list only the highest level TODO headline
7795 and omit the sublevels from the global list.  Configure the variable
7796 @code{org-agenda-todo-list-sublevels} to get this behavior.
7797 @end itemize
7799 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
7800 @subsection Matching tags and properties
7801 @cindex matching, of tags
7802 @cindex matching, of properties
7803 @cindex tags view
7804 @cindex match view
7806 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
7807 or have properties (@pxref{Properties and Columns}), you can select headlines
7808 based on this metadata and collect them into an agenda buffer.  The match
7809 syntax described here also applies when creating sparse trees with @kbd{C-c /
7812 @table @kbd
7813 @orgcmd{C-c a m,org-tags-view}
7814 Produce a list of all headlines that match a given set of tags.  The
7815 command prompts for a selection criterion, which is a boolean logic
7816 expression with tags, like @samp{+work+urgent-withboss} or
7817 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
7818 define a custom command for it (@pxref{Agenda dispatcher}).
7819 @orgcmd{C-c a M,org-tags-view}
7820 @vindex org-tags-match-list-sublevels
7821 @vindex org-agenda-tags-todo-honor-ignore-options
7822 Like @kbd{C-c a m}, but only select headlines that are also TODO items in a
7823 not-DONE state and force checking subitems (see variable
7824 @code{org-tags-match-list-sublevels}).  To exclude scheduled/deadline items,
7825 see the variable @code{org-agenda-tags-todo-honor-ignore-options}.  Matching
7826 specific TODO keywords together with a tags match is also possible, see
7827 @ref{Tag searches}.
7828 @end table
7830 The commands available in the tags list are described in @ref{Agenda
7831 commands}.
7833 @subsubheading Match syntax
7835 @cindex Boolean logic, for tag/property searches
7836 A search string can use Boolean operators @samp{&} for AND and @samp{|} for
7837 OR@.  @samp{&} binds more strongly than @samp{|}.  Parentheses are currently
7838 not implemented.  Each element in the search is either a tag, a regular
7839 expression matching tags, or an expression like @code{PROPERTY OPERATOR
7840 VALUE} with a comparison operator, accessing a property value.  Each element
7841 may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
7842 sugar for positive selection.  The AND operator @samp{&} is optional when
7843 @samp{+} or @samp{-} is present.  Here are some examples, using only tags.
7845 @table @samp
7846 @item +work-boss
7847 Select headlines tagged @samp{:work:}, but discard those also tagged
7848 @samp{:boss:}.
7849 @item work|laptop
7850 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
7851 @item work|laptop+night
7852 Like before, but require the @samp{:laptop:} lines to be tagged also
7853 @samp{:night:}.
7854 @end table
7856 @cindex regular expressions, with tags search
7857 Instead of a tag, you may also specify a regular expression enclosed in curly
7858 braces.  For example,
7859 @samp{work+@{^boss.*@}} matches headlines that contain the tag
7860 @samp{:work:} and any tag @i{starting} with @samp{boss}.
7862 @cindex TODO keyword matching, with tags search
7863 @cindex level, require for tags/property match
7864 @cindex category, require for tags/property match
7865 @vindex org-odd-levels-only
7866 You may also test for properties (@pxref{Properties and Columns}) at the same
7867 time as matching tags.  The properties may be real properties, or special
7868 properties that represent other metadata (@pxref{Special properties}).  For
7869 example, the ``property'' @code{TODO} represents the TODO keyword of the
7870 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
7871 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
7872 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
7873 DONE@.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
7874 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
7875 The ITEM special property cannot currently be used in tags/property
7876 searches@footnote{But @pxref{x-agenda-skip-entry-regexp,
7877 ,skipping entries based on regexp}.}.
7879 Here are more examples:
7881 @table @samp
7882 @item work+TODO="WAITING"
7883 Select @samp{:work:}-tagged TODO lines with the specific TODO
7884 keyword @samp{WAITING}.
7885 @item work+TODO="WAITING"|home+TODO="WAITING"
7886 Waiting tasks both at work and at home.
7887 @end table
7889 When matching properties, a number of different operators can be used to test
7890 the value of a property.  Here is a complex example:
7892 @example
7893 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
7894          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
7895 @end example
7897 @noindent
7898 The type of comparison will depend on how the comparison value is written:
7899 @itemize @minus
7900 @item
7901 If the comparison value is a plain number, a numerical comparison is done,
7902 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
7903 @samp{>=}, and @samp{<>}.
7904 @item
7905 If the comparison value is enclosed in double-quotes,
7906 a string comparison is done, and the same operators are allowed.
7907 @item
7908 If the comparison value is enclosed in double-quotes @emph{and} angular
7909 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
7910 assumed to be date/time specifications in the standard Org way, and the
7911 comparison will be done accordingly.  Special values that will be recognized
7912 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
7913 @code{"<tomorrow>"} for these days at 0:00 hours, i.e., without a time
7914 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
7915 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
7916 respectively, can be used.
7917 @item
7918 If the comparison value is enclosed
7919 in curly braces, a regexp match is performed, with @samp{=} meaning that the
7920 regexp matches the property value, and @samp{<>} meaning that it does not
7921 match.
7922 @end itemize
7924 So the search string in the example finds entries tagged @samp{:work:} but
7925 not @samp{:boss:}, which also have a priority value @samp{A}, a
7926 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
7927 property that is numerically smaller than 2, a @samp{:With:} property that is
7928 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
7929 on or after October 11, 2008.
7931 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
7932 other properties will slow down the search.  However, once you have paid the
7933 price by accessing one property, testing additional properties is cheap
7934 again.
7936 You can configure Org mode to use property inheritance during a search, but
7937 beware that this can slow down searches considerably.  See @ref{Property
7938 inheritance}, for details.
7940 For backward compatibility, and also for typing speed, there is also a
7941 different way to test TODO states in a search.  For this, terminate the
7942 tags/property part of the search string (which may include several terms
7943 connected with @samp{|}) with a @samp{/} and then specify a Boolean
7944 expression just for TODO keywords.  The syntax is then similar to that for
7945 tags, but should be applied with care: for example, a positive selection on
7946 several TODO keywords cannot meaningfully be combined with boolean AND@.
7947 However, @emph{negative selection} combined with AND can be meaningful.  To
7948 make sure that only lines are checked that actually have any TODO keyword
7949 (resulting in a speed-up), use @kbd{C-c a M}, or equivalently start the TODO
7950 part after the slash with @samp{!}.  Using @kbd{C-c a M} or @samp{/!} will
7951 not match TODO keywords in a DONE state.  Examples:
7953 @table @samp
7954 @item work/WAITING
7955 Same as @samp{work+TODO="WAITING"}
7956 @item work/!-WAITING-NEXT
7957 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
7958 nor @samp{NEXT}
7959 @item work/!+WAITING|+NEXT
7960 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
7961 @samp{NEXT}.
7962 @end table
7964 @node Timeline, Search view, Matching tags and properties, Built-in agenda views
7965 @subsection Timeline for a single file
7966 @cindex timeline, single file
7967 @cindex time-sorted view
7969 The timeline summarizes all time-stamped items from a single Org mode
7970 file in a @emph{time-sorted view}.  The main purpose of this command is
7971 to give an overview over events in a project.
7973 @table @kbd
7974 @orgcmd{C-c a L,org-timeline}
7975 Show a time-sorted view of the Org file, with all time-stamped items.
7976 When called with a @kbd{C-u} prefix, all unfinished TODO entries
7977 (scheduled or not) are also listed under the current date.
7978 @end table
7980 @noindent
7981 The commands available in the timeline buffer are listed in
7982 @ref{Agenda commands}.
7984 @node Search view, Stuck projects, Timeline, Built-in agenda views
7985 @subsection Search view
7986 @cindex search view
7987 @cindex text search
7988 @cindex searching, for text
7990 This agenda view is a general text search facility for Org mode entries.
7991 It is particularly useful to find notes.
7993 @table @kbd
7994 @orgcmd{C-c a s,org-search-view}
7995 This is a special search that lets you select entries by matching a substring
7996 or specific words using a boolean logic.
7997 @end table
7998 For example, the search string @samp{computer equipment} will find entries
7999 that contain @samp{computer equipment} as a substring.  If the two words are
8000 separated by more space or a line break, the search will still match.
8001 Search view can also search for specific keywords in the entry, using Boolean
8002 logic.  The search string @samp{+computer +wifi -ethernet -@{8\.11[bg]@}}
8003 will search for note entries that contain the keywords @code{computer}
8004 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
8005 not matched by the regular expression @code{8\.11[bg]}, meaning to
8006 exclude both 8.11b and 8.11g.  The first @samp{+} is necessary to turn on
8007 word search, other @samp{+} characters are optional.  For more details, see
8008 the docstring of the command @code{org-search-view}.
8010 @vindex org-agenda-text-search-extra-files
8011 Note that in addition to the agenda files, this command will also search
8012 the files listed in @code{org-agenda-text-search-extra-files}.
8014 @node Stuck projects,  , Search view, Built-in agenda views
8015 @subsection Stuck projects
8016 @pindex GTD, Getting Things Done
8018 If you are following a system like David Allen's GTD to organize your
8019 work, one of the ``duties'' you have is a regular review to make sure
8020 that all projects move along.  A @emph{stuck} project is a project that
8021 has no defined next actions, so it will never show up in the TODO lists
8022 Org mode produces.  During the review, you need to identify such
8023 projects and define next actions for them.
8025 @table @kbd
8026 @orgcmd{C-c a #,org-agenda-list-stuck-projects}
8027 List projects that are stuck.
8028 @kindex C-c a !
8029 @item C-c a !
8030 @vindex org-stuck-projects
8031 Customize the variable @code{org-stuck-projects} to define what a stuck
8032 project is and how to find it.
8033 @end table
8035 You almost certainly will have to configure this view before it will
8036 work for you.  The built-in default assumes that all your projects are
8037 level-2 headlines, and that a project is not stuck if it has at least
8038 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
8040 Let's assume that you, in your own way of using Org mode, identify
8041 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
8042 indicate a project that should not be considered yet.  Let's further
8043 assume that the TODO keyword DONE marks finished projects, and that NEXT
8044 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
8045 is a next action even without the NEXT tag.  Finally, if the project
8046 contains the special word IGNORE anywhere, it should not be listed
8047 either.  In this case you would start by identifying eligible projects
8048 with a tags/todo match@footnote{@xref{Tag searches}.}
8049 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
8050 IGNORE in the subtree to identify projects that are not stuck.  The
8051 correct customization for this is
8053 @lisp
8054 (setq org-stuck-projects
8055       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
8056                                "\\<IGNORE\\>"))
8057 @end lisp
8059 Note that if a project is identified as non-stuck, the subtree of this entry
8060 will still be searched for stuck projects.
8062 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
8063 @section Presentation and sorting
8064 @cindex presentation, of agenda items
8066 @vindex org-agenda-prefix-format
8067 @vindex org-agenda-tags-column
8068 Before displaying items in an agenda view, Org mode visually prepares the
8069 items and sorts them.  Each item occupies a single line.  The line starts
8070 with a @emph{prefix} that contains the @emph{category} (@pxref{Categories})
8071 of the item and other important information.  You can customize in which
8072 column tags will be displayed through @code{org-agenda-tags-column}.  You can
8073 also customize the prefix using the option @code{org-agenda-prefix-format}.
8074 This prefix is followed by a cleaned-up version of the outline headline
8075 associated with the item.
8077 @menu
8078 * Categories::                  Not all tasks are equal
8079 * Time-of-day specifications::  How the agenda knows the time
8080 * Sorting of agenda items::     The order of things
8081 @end menu
8083 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
8084 @subsection Categories
8086 @cindex category
8087 @cindex #+CATEGORY
8088 The category is a broad label assigned to each agenda item.  By default,
8089 the category is simply derived from the file name, but you can also
8090 specify it with a special line in the buffer, like this@footnote{For
8091 backward compatibility, the following also works: if there are several
8092 such lines in a file, each specifies the category for the text below it.
8093 The first category also applies to any text before the first CATEGORY
8094 line.  However, using this method is @emph{strongly} deprecated as it is
8095 incompatible with the outline structure of the document.  The correct
8096 method for setting multiple categories in a buffer is using a
8097 property.}:
8099 @example
8100 #+CATEGORY: Thesis
8101 @end example
8103 @noindent
8104 @cindex property, CATEGORY
8105 If you would like to have a special CATEGORY for a single entry or a
8106 (sub)tree, give the entry a @code{:CATEGORY:} property with the
8107 special category you want to apply as the value.
8109 @noindent
8110 The display in the agenda buffer looks best if the category is not
8111 longer than 10 characters.
8113 @noindent
8114 You can set up icons for category by customizing the
8115 @code{org-agenda-category-icon-alist} variable.
8117 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
8118 @subsection Time-of-day specifications
8119 @cindex time-of-day specification
8121 Org mode checks each agenda item for a time-of-day specification.  The
8122 time can be part of the timestamp that triggered inclusion into the
8123 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
8124 ranges can be specified with two timestamps, like
8126 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
8128 In the headline of the entry itself, a time(range) may also appear as
8129 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
8130 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
8131 specifications in diary entries are recognized as well.
8133 For agenda display, Org mode extracts the time and displays it in a
8134 standard 24 hour format as part of the prefix.  The example times in
8135 the previous paragraphs would end up in the agenda like this:
8137 @example
8138     8:30-13:00 Arthur Dent lies in front of the bulldozer
8139    12:45...... Ford Prefect arrives and takes Arthur to the pub
8140    19:00...... The Vogon reads his poem
8141    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8142 @end example
8144 @cindex time grid
8145 If the agenda is in single-day mode, or for the display of today, the
8146 timed entries are embedded in a time grid, like
8148 @example
8149     8:00...... ------------------
8150     8:30-13:00 Arthur Dent lies in front of the bulldozer
8151    10:00...... ------------------
8152    12:00...... ------------------
8153    12:45...... Ford Prefect arrives and takes Arthur to the pub
8154    14:00...... ------------------
8155    16:00...... ------------------
8156    18:00...... ------------------
8157    19:00...... The Vogon reads his poem
8158    20:00...... ------------------
8159    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8160 @end example
8162 @vindex org-agenda-use-time-grid
8163 @vindex org-agenda-time-grid
8164 The time grid can be turned on and off with the variable
8165 @code{org-agenda-use-time-grid}, and can be configured with
8166 @code{org-agenda-time-grid}.
8168 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
8169 @subsection Sorting of agenda items
8170 @cindex sorting, of agenda items
8171 @cindex priorities, of agenda items
8172 Before being inserted into a view, the items are sorted.  How this is
8173 done depends on the type of view.
8174 @itemize @bullet
8175 @item
8176 @vindex org-agenda-files
8177 For the daily/weekly agenda, the items for each day are sorted.  The
8178 default order is to first collect all items containing an explicit
8179 time-of-day specification.  These entries will be shown at the beginning
8180 of the list, as a @emph{schedule} for the day.  After that, items remain
8181 grouped in categories, in the sequence given by @code{org-agenda-files}.
8182 Within each category, items are sorted by priority (@pxref{Priorities}),
8183 which is composed of the base priority (2000 for priority @samp{A}, 1000
8184 for @samp{B}, and 0 for @samp{C}), plus additional increments for
8185 overdue scheduled or deadline items.
8186 @item
8187 For the TODO list, items remain in the order of categories, but within
8188 each category, sorting takes place according to priority
8189 (@pxref{Priorities}).  The priority used for sorting derives from the
8190 priority cookie, with additions depending on how close an item is to its due
8191 or scheduled date.
8192 @item
8193 For tags matches, items are not sorted at all, but just appear in the
8194 sequence in which they are found in the agenda files.
8195 @end itemize
8197 @vindex org-agenda-sorting-strategy
8198 Sorting can be customized using the variable
8199 @code{org-agenda-sorting-strategy}, and may also include criteria based on
8200 the estimated effort of an entry (@pxref{Effort estimates}).
8202 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
8203 @section Commands in the agenda buffer
8204 @cindex commands, in agenda buffer
8206 Entries in the agenda buffer are linked back to the Org file or diary
8207 file where they originate.  You are not allowed to edit the agenda
8208 buffer itself, but commands are provided to show and jump to the
8209 original entry location, and to edit the Org files ``remotely'' from
8210 the agenda buffer.  In this way, all information is stored only once,
8211 removing the risk that your agenda and note files may diverge.
8213 Some commands can be executed with mouse clicks on agenda lines.  For
8214 the other commands, the cursor needs to be in the desired line.
8216 @table @kbd
8217 @tsubheading{Motion}
8218 @cindex motion commands in agenda
8219 @orgcmd{n,org-agenda-next-line}
8220 Next line (same as @key{down} and @kbd{C-n}).
8221 @orgcmd{p,org-agenda-previous-line}
8222 Previous line (same as @key{up} and @kbd{C-p}).
8223 @tsubheading{View/Go to Org file}
8224 @orgcmdkkc{@key{SPC},mouse-3,org-agenda-show-and-scroll-up}
8225 Display the original location of the item in another window.
8226 With prefix arg, make sure that the entire entry is made visible in the
8227 outline, not only the heading.
8229 @orgcmd{L,org-agenda-recenter}
8230 Display original location and recenter that window.
8232 @orgcmdkkc{@key{TAB},mouse-2,org-agenda-goto}
8233 Go to the original location of the item in another window.
8235 @orgcmd{@key{RET},org-agenda-switch-to}
8236 Go to the original location of the item and delete other windows.
8238 @orgcmd{F,org-agenda-follow-mode}
8239 @vindex org-agenda-start-with-follow-mode
8240 Toggle Follow mode.  In Follow mode, as you move the cursor through
8241 the agenda buffer, the other window always shows the corresponding
8242 location in the Org file.  The initial setting for this mode in new
8243 agenda buffers can be set with the variable
8244 @code{org-agenda-start-with-follow-mode}.
8246 @orgcmd{C-c C-x b,org-agenda-tree-to-indirect-buffer}
8247 Display the entire subtree of the current item in an indirect buffer.  With a
8248 numeric prefix argument N, go up to level N and then take that tree.  If N is
8249 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
8250 previously used indirect buffer.
8252 @orgcmd{C-c C-o,org-agenda-open-link}
8253 Follow a link in the entry.  This will offer a selection of any links in the
8254 text belonging to the referenced Org node.  If there is only one link, it
8255 will be followed without a selection prompt.
8257 @tsubheading{Change display}
8258 @cindex display changing, in agenda
8259 @kindex A
8260 @item A
8261 Interactively select another agenda view and append it to the current view.
8263 @kindex o
8264 @item o
8265 Delete other windows.
8267 @orgcmdkskc{v d,d,org-agenda-day-view}
8268 @xorgcmdkskc{v w,w,org-agenda-week-view}
8269 @xorgcmd{v m,org-agenda-month-view}
8270 @xorgcmd{v y,org-agenda-year-view}
8271 @xorgcmd{v SPC,org-agenda-reset-view}
8272 @vindex org-agenda-span
8273 Switch to day/week/month/year view.  When switching to day or week view, this
8274 setting becomes the default for subsequent agenda refreshes.  Since month and
8275 year views are slow to create, they do not become the default.  A numeric
8276 prefix argument may be used to jump directly to a specific day of the year,
8277 ISO week, month, or year, respectively.  For example, @kbd{32 d} jumps to
8278 February 1st, @kbd{9 w} to ISO week number 9.  When setting day, week, or
8279 month view, a year may be encoded in the prefix argument as well.  For
8280 example, @kbd{200712 w} will jump to week 12 in 2007.  If such a year
8281 specification has only one or two digits, it will be mapped to the interval
8282 1938--2037.  @kbd{v @key{SPC}} will reset to what is set in
8283 @code{org-agenda-span}.
8285 @orgcmd{f,org-agenda-later}
8286 Go forward in time to display the following @code{org-agenda-current-span} days.
8287 For example, if the display covers a week, switch to the following week.
8288 With prefix arg, go forward that many times @code{org-agenda-current-span} days.
8290 @orgcmd{b,org-agenda-earlier}
8291 Go backward in time to display earlier dates.
8293 @orgcmd{.,org-agenda-goto-today}
8294 Go to today.
8296 @orgcmd{j,org-agenda-goto-date}
8297 Prompt for a date and go there.
8299 @orgcmd{J,org-agenda-clock-goto}
8300 Go to the currently clocked-in task @i{in the agenda buffer}.
8302 @orgcmd{D,org-agenda-toggle-diary}
8303 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
8305 @orgcmdkskc{v l,l,org-agenda-log-mode}
8306 @kindex v L
8307 @vindex org-log-done
8308 @vindex org-agenda-log-mode-items
8309 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
8310 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
8311 entries that have been clocked on that day.  You can configure the entry
8312 types that should be included in log mode using the variable
8313 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
8314 all possible logbook entries, including state changes.  When called with two
8315 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
8316 @kbd{v L} is equivalent to @kbd{C-u v l}.
8318 @orgcmdkskc{v [,[,org-agenda-manipulate-query-add}
8319 Include inactive timestamps into the current view.  Only for weekly/daily
8320 agenda and timeline views.
8322 @orgcmd{v a,org-agenda-archives-mode}
8323 @xorgcmd{v A,org-agenda-archives-mode 'files}
8324 Toggle Archives mode.  In Archives mode, trees that are marked
8325 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
8326 capital @kbd{A}, even all archive files are included.  To exit archives mode,
8327 press @kbd{v a} again.
8329 @orgcmdkskc{v R,R,org-agenda-clockreport-mode}
8330 @vindex org-agenda-start-with-clockreport-mode
8331 @vindex org-clock-report-include-clocking-task
8332 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
8333 always show a table with the clocked times for the timespan and file scope
8334 covered by the current agenda view.  The initial setting for this mode in new
8335 agenda buffers can be set with the variable
8336 @code{org-agenda-start-with-clockreport-mode}.  By using a prefix argument
8337 when toggling this mode (i.e., @kbd{C-u R}), the clock table will not show
8338 contributions from entries that are hidden by agenda filtering@footnote{Only
8339 tags filtering will be respected here, effort filtering is ignored.}.  See
8340 also the variable @code{org-clock-report-include-clocking-task}.
8342 @orgkey{v c}
8343 @vindex org-agenda-clock-consistency-checks
8344 Show overlapping clock entries, clocking gaps, and other clocking problems in
8345 the current agenda range.  You can then visit clocking lines and fix them
8346 manually.  See the variable @code{org-agenda-clock-consistency-checks} for
8347 information on how to customize the definition of what constituted a clocking
8348 problem.  To return to normal agenda display, press @kbd{l} to exit Logbook
8349 mode.
8351 @orgcmdkskc{v E,E,org-agenda-entry-text-mode}
8352 @vindex org-agenda-start-with-entry-text-mode
8353 @vindex org-agenda-entry-text-maxlines
8354 Toggle entry text mode.  In entry text mode, a number of lines from the Org
8355 outline node referenced by an agenda line will be displayed below the line.
8356 The maximum number of lines is given by the variable
8357 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
8358 prefix argument will temporarily modify that number to the prefix value.
8360 @orgcmd{G,org-agenda-toggle-time-grid}
8361 @vindex org-agenda-use-time-grid
8362 @vindex org-agenda-time-grid
8363 Toggle the time grid on and off.  See also the variables
8364 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
8366 @orgcmd{r,org-agenda-redo}
8367 Recreate the agenda buffer, for example to reflect the changes after
8368 modification of the timestamps of items with @kbd{S-@key{left}} and
8369 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
8370 argument is interpreted to create a selective list for a specific TODO
8371 keyword.
8372 @orgcmd{g,org-agenda-redo}
8373 Same as @kbd{r}.
8375 @orgcmdkskc{C-x C-s,s,org-save-all-org-buffers}
8376 Save all Org buffers in the current Emacs session, and also the locations of
8377 IDs.
8379 @orgcmd{C-c C-x C-c,org-agenda-columns}
8380 @vindex org-columns-default-format
8381 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
8382 view format is taken from the entry at point, or (if there is no entry at
8383 point), from the first entry in the agenda view.  So whatever the format for
8384 that entry would be in the original buffer (taken from a property, from a
8385 @code{#+COLUMNS} line, or from the default variable
8386 @code{org-columns-default-format}), will be used in the agenda.
8388 @orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
8389 Remove the restriction lock on the agenda, if it is currently restricted to a
8390 file or subtree (@pxref{Agenda files}).
8392 @tsubheading{Secondary filtering and query editing}
8393 @cindex filtering, by tag category and effort, in agenda
8394 @cindex tag filtering, in agenda
8395 @cindex category filtering, in agenda
8396 @cindex effort filtering, in agenda
8397 @cindex query editing, in agenda
8399 @orgcmd{<,org-agenda-filter-by-category}
8400 @vindex org-agenda-category-filter-preset
8402 Filter the current agenda view with respect to the category of the item at
8403 point.  Pressing @code{<} another time will remove this filter.  You can add
8404 a filter preset through the option @code{org-agenda-category-filter-preset}
8405 (see below.)
8407 @orgcmd{|,org-agenda-filter-by-regexp}
8408 @vindex org-agenda-regexp-filter-preset
8410 Filter the agenda view by a regular expression: only show agenda entries
8411 matching the regular expression the user entered.  When called with a prefix
8412 argument, it will filter @emph{out} entries matching the regexp.  With two
8413 universal prefix arguments, it will remove all the regexp filters, which can
8414 be cumulated.  You can add a filter preset through the option
8415 @code{org-agenda-category-filter-preset} (see below.)
8417 @orgcmd{/,org-agenda-filter-by-tag}
8418 @vindex org-agenda-tag-filter-preset
8419 Filter the agenda view with respect to a tag and/or effort estimates.  The
8420 difference between this and a custom agenda command is that filtering is very
8421 fast, so that you can switch quickly between different filters without having
8422 to recreate the agenda.@footnote{Custom commands can preset a filter by
8423 binding the variable @code{org-agenda-tag-filter-preset} as an option.  This
8424 filter will then be applied to the view and persist as a basic filter through
8425 refreshes and more secondary filtering.  The filter is a global property of
8426 the entire agenda view---in a block agenda, you should only set this in the
8427 global options section, not in the section of an individual block.}
8429 You will be prompted for a tag selection letter; @key{SPC} will mean any tag at
8430 all.  Pressing @key{TAB} at that prompt will offer use completion to select a
8431 tag (including any tags that do not have a selection character).  The command
8432 then hides all entries that do not contain or inherit this tag.  When called
8433 with prefix arg, remove the entries that @emph{do} have the tag.  A second
8434 @kbd{/} at the prompt will turn off the filter and unhide any hidden entries.
8435 If the first key you press is either @kbd{+} or @kbd{-}, the previous filter
8436 will be narrowed by requiring or forbidding the selected additional tag.
8437 Instead of pressing @kbd{+} or @kbd{-} after @kbd{/}, you can also
8438 immediately use the @kbd{\} command.
8440 @vindex org-sort-agenda-noeffort-is-high
8441 In order to filter for effort estimates, you should set up allowed
8442 efforts globally, for example
8443 @lisp
8444 (setq org-global-properties
8445     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
8446 @end lisp
8447 You can then filter for an effort by first typing an operator, one of
8448 @kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
8449 estimate in your array of allowed values, where @kbd{0} means the 10th value.
8450 The filter will then restrict to entries with effort smaller-or-equal, equal,
8451 or larger-or-equal than the selected value.  If the digits 0--9 are not used
8452 as fast access keys to tags, you can also simply press the index digit
8453 directly without an operator.  In this case, @kbd{<} will be assumed.  For
8454 application of the operator, entries without a defined effort will be treated
8455 according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
8456 for tasks without effort definition, press @kbd{?} as the operator.
8458 Org also supports automatic, context-aware tag filtering.  If the variable
8459 @code{org-agenda-auto-exclude-function} is set to a user-defined function,
8460 that function can decide which tags should be excluded from the agenda
8461 automatically.  Once this is set, the @kbd{/} command then accepts @kbd{RET}
8462 as a sub-option key and runs the auto exclusion logic.  For example, let's
8463 say you use a @code{Net} tag to identify tasks which need network access, an
8464 @code{Errand} tag for errands in town, and a @code{Call} tag for making phone
8465 calls.  You could auto-exclude these tags based on the availability of the
8466 Internet, and outside of business hours, with something like this:
8468 @lisp
8469 @group
8470 (defun org-my-auto-exclude-function (tag)
8471   (and (cond
8472         ((string= tag "Net")
8473          (/= 0 (call-process "/sbin/ping" nil nil nil
8474                              "-c1" "-q" "-t1" "mail.gnu.org")))
8475         ((or (string= tag "Errand") (string= tag "Call"))
8476          (let ((hour (nth 2 (decode-time))))
8477            (or (< hour 8) (> hour 21)))))
8478        (concat "-" tag)))
8480 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
8481 @end group
8482 @end lisp
8484 @orgcmd{\\,org-agenda-filter-by-tag-refine}
8485 Narrow the current agenda filter by an additional condition.  When called with
8486 prefix arg, remove the entries that @emph{do} have the tag, or that do match
8487 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
8488 @kbd{-} as the first key after the @kbd{/} command.
8491 @kindex [
8492 @kindex ]
8493 @kindex @{
8494 @kindex @}
8495 @item [ ] @{ @}
8496 @table @i
8497 @item @r{in} search view
8498 add new search words (@kbd{[} and @kbd{]}) or new regular expressions
8499 (@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
8500 add a positive search term prefixed by @samp{+}, indicating that this search
8501 term @i{must} occur/match in the entry.  The closing bracket/brace will add a
8502 negative search term which @i{must not} occur/match in the entry for it to be
8503 selected.
8504 @end table
8506 @tsubheading{Remote editing}
8507 @cindex remote editing, from agenda
8509 @item 0--9
8510 Digit argument.
8512 @cindex undoing remote-editing events
8513 @cindex remote editing, undo
8514 @orgcmd{C-_,org-agenda-undo}
8515 Undo a change due to a remote editing command.  The change is undone
8516 both in the agenda buffer and in the remote buffer.
8518 @orgcmd{t,org-agenda-todo}
8519 Change the TODO state of the item, both in the agenda and in the
8520 original org file.
8522 @orgcmd{C-S-@key{right},org-agenda-todo-nextset}
8523 @orgcmd{C-S-@key{left},org-agenda-todo-previousset}
8524 Switch to the next/previous set of TODO keywords.
8526 @orgcmd{C-k,org-agenda-kill}
8527 @vindex org-agenda-confirm-kill
8528 Delete the current agenda item along with the entire subtree belonging
8529 to it in the original Org file.  If the text to be deleted remotely
8530 is longer than one line, the kill needs to be confirmed by the user.  See
8531 variable @code{org-agenda-confirm-kill}.
8533 @orgcmd{C-c C-w,org-agenda-refile}
8534 Refile the entry at point.
8536 @orgcmdkskc{C-c C-x C-a,a,org-agenda-archive-default-with-confirmation}
8537 @vindex org-archive-default-command
8538 Archive the subtree corresponding to the entry at point using the default
8539 archiving command set in @code{org-archive-default-command}.  When using the
8540 @code{a} key, confirmation will be required.
8542 @orgcmd{C-c C-x a,org-agenda-toggle-archive-tag}
8543 Toggle the ARCHIVE tag for the current headline.
8545 @orgcmd{C-c C-x A,org-agenda-archive-to-archive-sibling}
8546 Move the subtree corresponding to the current entry to its @emph{archive
8547 sibling}.
8549 @orgcmdkskc{C-c C-x C-s,$,org-agenda-archive}
8550 Archive the subtree corresponding to the current headline.  This means the
8551 entry will be moved to the configured archive location, most likely a
8552 different file.
8554 @orgcmd{T,org-agenda-show-tags}
8555 @vindex org-agenda-show-inherited-tags
8556 Show all tags associated with the current item.  This is useful if you have
8557 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
8558 tags of a headline occasionally.
8560 @orgcmd{:,org-agenda-set-tags}
8561 Set tags for the current headline.  If there is an active region in the
8562 agenda, change a tag for all headings in the region.
8564 @kindex ,
8565 @item ,
8566 Set the priority for the current item (@command{org-agenda-priority}).
8567 Org mode prompts for the priority character.  If you reply with @key{SPC},
8568 the priority cookie is removed from the entry.
8570 @orgcmd{P,org-agenda-show-priority}
8571 Display weighted priority of current item.
8573 @orgcmdkkc{+,S-@key{up},org-agenda-priority-up}
8574 Increase the priority of the current item.  The priority is changed in
8575 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
8576 key for this.
8578 @orgcmdkkc{-,S-@key{down},org-agenda-priority-down}
8579 Decrease the priority of the current item.
8581 @orgcmdkkc{z,C-c C-z,org-agenda-add-note}
8582 @vindex org-log-into-drawer
8583 Add a note to the entry.  This note will be recorded, and then filed to the
8584 same location where state change notes are put.  Depending on
8585 @code{org-log-into-drawer}, this may be inside a drawer.
8587 @orgcmd{C-c C-a,org-attach}
8588 Dispatcher for all command related to attachments.
8590 @orgcmd{C-c C-s,org-agenda-schedule}
8591 Schedule this item.  With prefix arg remove the scheduling timestamp
8593 @orgcmd{C-c C-d,org-agenda-deadline}
8594 Set a deadline for this item.  With prefix arg remove the deadline.
8596 @orgcmd{S-@key{right},org-agenda-do-date-later}
8597 Change the timestamp associated with the current line by one day into the
8598 future.  If the date is in the past, the first call to this command will move
8599 it to today.@*
8600 With a numeric prefix argument, change it by that many days.  For example,
8601 @kbd{3 6 5 S-@key{right}} will change it by a year.  With a @kbd{C-u} prefix,
8602 change the time by one hour.  If you immediately repeat the command, it will
8603 continue to change hours even without the prefix arg.  With a double @kbd{C-u
8604 C-u} prefix, do the same for changing minutes.@*
8605 The stamp is changed in the original Org file, but the change is not directly
8606 reflected in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
8608 @orgcmd{S-@key{left},org-agenda-do-date-earlier}
8609 Change the timestamp associated with the current line by one day
8610 into the past.
8612 @orgcmd{>,org-agenda-date-prompt}
8613 Change the timestamp associated with the current line.  The key @kbd{>} has
8614 been chosen, because it is the same as @kbd{S-.}  on my keyboard.
8616 @orgcmd{I,org-agenda-clock-in}
8617 Start the clock on the current item.  If a clock is running already, it
8618 is stopped first.
8620 @orgcmd{O,org-agenda-clock-out}
8621 Stop the previously started clock.
8623 @orgcmd{X,org-agenda-clock-cancel}
8624 Cancel the currently running clock.
8626 @orgcmd{J,org-agenda-clock-goto}
8627 Jump to the running clock in another window.
8629 @orgcmd{k,org-agenda-capture}
8630 Like @code{org-capture}, but use the date at point as the default date for
8631 the capture template.  See @var{org-capture-use-agenda-date} to make this
8632 the default behavior of @code{org-capture}.
8633 @cindex capturing, from agenda
8634 @vindex org-capture-use-agenda-date
8636 @tsubheading{Bulk remote editing selected entries}
8637 @cindex remote editing, bulk, from agenda
8638 @vindex org-agenda-bulk-persistent-marks
8639 @vindex org-agenda-bulk-custom-functions
8641 @orgcmd{m,org-agenda-bulk-mark}
8642 Mark the entry at point for bulk action.  With prefix arg, mark that many
8643 successive entries.
8645 @orgcmd{%,org-agenda-bulk-mark-regexp}
8646 Mark entries matching a regular expression for bulk action.
8648 @orgcmd{u,org-agenda-bulk-unmark}
8649 Unmark entry for bulk action.
8651 @orgcmd{U,org-agenda-bulk-remove-all-marks}
8652 Unmark all marked entries for bulk action.
8654 @orgcmd{B,org-agenda-bulk-action}
8655 Bulk action: act on all marked entries in the agenda.  This will prompt for
8656 another key to select the action to be applied.  The prefix arg to @kbd{B}
8657 will be passed through to the @kbd{s} and @kbd{d} commands, to bulk-remove
8658 these special timestamps.  By default, marks are removed after the bulk.  If
8659 you want them to persist, set @code{org-agenda-bulk-persistent-marks} to
8660 @code{t} or hit @kbd{p} at the prompt.
8662 @example
8663 *  @r{Toggle persistent marks.}
8664 $  @r{Archive all selected entries.}
8665 A  @r{Archive entries by moving them to their respective archive siblings.}
8666 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
8667    @r{changes the state of all selected entries, bypassing blocking and}
8668    @r{suppressing logging notes (but not timestamps).}
8669 +  @r{Add a tag to all selected entries.}
8670 -  @r{Remove a tag from all selected entries.}
8671 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
8672    @r{by a fixed number of days, use something starting with double plus}
8673    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
8674 d  @r{Set deadline to a specific date.}
8675 r  @r{Prompt for a single refile target and move all entries.  The entries}
8676    @r{will no longer be in the agenda; refresh (@kbd{g}) to bring them back.}
8677 S  @r{Reschedule randomly into the coming N days.  N will be prompted for.}
8678    @r{With prefix arg (@kbd{C-u B S}), scatter only across weekdays.}
8679 f  @r{Apply a function@footnote{You can also create persistent custom functions through@code{org-agenda-bulk-custom-functions}.} to marked entries.}
8680    @r{For example, the function below sets the CATEGORY property of the}
8681    @r{entries to web.}
8682    @r{(defun set-category ()}
8683    @r{  (interactive "P")}
8684    @r{  (let* ((marker (or (org-get-at-bol 'org-hd-marker)}
8685    @r{                     (org-agenda-error)))}
8686    @r{            (buffer (marker-buffer marker)))}
8687    @r{       (with-current-buffer buffer}
8688    @r{         (save-excursion}
8689    @r{           (save-restriction}
8690    @r{             (widen)}
8691    @r{             (goto-char marker)}
8692    @r{             (org-back-to-heading t)}
8693    @r{             (org-set-property "CATEGORY" "web"))))))}
8694 @end example
8697 @tsubheading{Calendar commands}
8698 @cindex calendar commands, from agenda
8700 @orgcmd{c,org-agenda-goto-calendar}
8701 Open the Emacs calendar and move to the date at the agenda cursor.
8703 @orgcmd{c,org-calendar-goto-agenda}
8704 When in the calendar, compute and show the Org mode agenda for the
8705 date at the cursor.
8707 @cindex diary entries, creating from agenda
8708 @orgcmd{i,org-agenda-diary-entry}
8709 @vindex org-agenda-diary-file
8710 Insert a new entry into the diary, using the date at the cursor and (for
8711 block entries) the date at the mark.  This will add to the Emacs diary
8712 file@footnote{This file is parsed for the agenda when
8713 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
8714 command in the calendar.  The diary file will pop up in another window, where
8715 you can add the entry.
8717 If you configure @code{org-agenda-diary-file} to point to an Org mode file,
8718 Org will create entries (in Org mode syntax) in that file instead.  Most
8719 entries will be stored in a date-based outline tree that will later make it
8720 easy to archive appointments from previous months/years.  The tree will be
8721 built under an entry with a @code{DATE_TREE} property, or else with years as
8722 top-level entries.  Emacs will prompt you for the entry text---if you specify
8723 it, the entry will be created in @code{org-agenda-diary-file} without further
8724 interaction.  If you directly press @key{RET} at the prompt without typing
8725 text, the target file will be shown in another window for you to finish the
8726 entry there.  See also the @kbd{k r} command.
8728 @orgcmd{M,org-agenda-phases-of-moon}
8729 Show the phases of the moon for the three months around current date.
8731 @orgcmd{S,org-agenda-sunrise-sunset}
8732 Show sunrise and sunset times.  The geographical location must be set
8733 with calendar variables, see the documentation for the Emacs calendar.
8735 @orgcmd{C,org-agenda-convert-date}
8736 Convert the date at cursor into many other cultural and historic
8737 calendars.
8739 @orgcmd{H,org-agenda-holidays}
8740 Show holidays for three months around the cursor date.
8742 @item M-x org-export-icalendar-combine-agenda-files
8743 Export a single iCalendar file containing entries from all agenda files.
8744 This is a globally available command, and also available in the agenda menu.
8746 @tsubheading{Exporting to a file}
8747 @orgcmd{C-x C-w,org-agenda-write}
8748 @cindex exporting agenda views
8749 @cindex agenda views, exporting
8750 @vindex org-agenda-exporter-settings
8751 Write the agenda view to a file.  Depending on the extension of the selected
8752 file name, the view will be exported as HTML (@file{.html} or @file{.htm}),
8753 Postscript (@file{.ps}), PDF (@file{.pdf}), Org (@file{.org}) and plain text
8754 (any other extension).  When exporting to Org, only the body of original
8755 headlines are exported, not subtrees or inherited tags.  When called with a
8756 @kbd{C-u} prefix argument, immediately open the newly created file.  Use the
8757 variable @code{org-agenda-exporter-settings} to set options for
8758 @file{ps-print} and for @file{htmlize} to be used during export.
8760 @tsubheading{Quit and Exit}
8761 @orgcmd{q,org-agenda-quit}
8762 Quit agenda, remove the agenda buffer.
8764 @cindex agenda files, removing buffers
8765 @orgcmd{x,org-agenda-exit}
8766 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
8767 for the compilation of the agenda.  Buffers created by the user to
8768 visit Org files will not be removed.
8769 @end table
8772 @node Custom agenda views, Exporting Agenda Views, Agenda commands, Agenda Views
8773 @section Custom agenda views
8774 @cindex custom agenda views
8775 @cindex agenda views, custom
8777 Custom agenda commands serve two purposes: to store and quickly access
8778 frequently used TODO and tags searches, and to create special composite
8779 agenda buffers.  Custom agenda commands will be accessible through the
8780 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
8782 @menu
8783 * Storing searches::            Type once, use often
8784 * Block agenda::                All the stuff you need in a single buffer
8785 * Setting Options::             Changing the rules
8786 @end menu
8788 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
8789 @subsection Storing searches
8791 The first application of custom searches is the definition of keyboard
8792 shortcuts for frequently used searches, either creating an agenda
8793 buffer, or a sparse tree (the latter covering of course only the current
8794 buffer).
8795 @kindex C-c a C
8796 @vindex org-agenda-custom-commands
8797 @cindex agenda views, main example
8798 @cindex agenda, as an agenda views
8799 @cindex agenda*, as an agenda views
8800 @cindex tags, as an agenda view
8801 @cindex todo, as an agenda view
8802 @cindex tags-todo
8803 @cindex todo-tree
8804 @cindex occur-tree
8805 @cindex tags-tree
8807 Custom commands are configured in the variable
8808 @code{org-agenda-custom-commands}.  You can customize this variable, for
8809 example by pressing @kbd{C-c a C}.  You can also directly set it with Emacs
8810 Lisp in @file{.emacs}.  The following example contains all valid agenda
8811 views:
8813 @lisp
8814 @group
8815 (setq org-agenda-custom-commands
8816       '(("x" agenda)
8817         ("y" agenda*)
8818         ("w" todo "WAITING")
8819         ("W" todo-tree "WAITING")
8820         ("u" tags "+boss-urgent")
8821         ("v" tags-todo "+boss-urgent")
8822         ("U" tags-tree "+boss-urgent")
8823         ("f" occur-tree "\\<FIXME\\>")
8824         ("h" . "HOME+Name tags searches") ; description for "h" prefix
8825         ("hl" tags "+home+Lisa")
8826         ("hp" tags "+home+Peter")
8827         ("hk" tags "+home+Kim")))
8828 @end group
8829 @end lisp
8831 @noindent
8832 The initial string in each entry defines the keys you have to press
8833 after the dispatcher command @kbd{C-c a} in order to access the command.
8834 Usually this will be just a single character, but if you have many
8835 similar commands, you can also define two-letter combinations where the
8836 first character is the same in several combinations and serves as a
8837 prefix key@footnote{You can provide a description for a prefix key by
8838 inserting a cons cell with the prefix and the description.}.  The second
8839 parameter is the search type, followed by the string or regular
8840 expression to be used for the matching.  The example above will
8841 therefore define:
8843 @table @kbd
8844 @item C-c a x
8845 as a global search for agenda entries planned@footnote{@emph{Planned} means
8846 here that these entries have some planning information attached to them, like
8847 a time-stamp, a scheduled or a deadline string.  See
8848 @var{org-agenda-entry-types} on how to set what planning information will be
8849 taken into account.} this week/day.
8850 @item C-c a y
8851 as a global search for agenda entries planned this week/day, but only those
8852 with an hour specification like @code{[h]h:mm}---think of them as appointments.
8853 @item C-c a w
8854 as a global search for TODO entries with @samp{WAITING} as the TODO
8855 keyword
8856 @item C-c a W
8857 as the same search, but only in the current buffer and displaying the
8858 results as a sparse tree
8859 @item C-c a u
8860 as a global tags search for headlines marked @samp{:boss:} but not
8861 @samp{:urgent:}
8862 @item C-c a v
8863 as the same search as @kbd{C-c a u}, but limiting the search to
8864 headlines that are also TODO items
8865 @item C-c a U
8866 as the same search as @kbd{C-c a u}, but only in the current buffer and
8867 displaying the result as a sparse tree
8868 @item C-c a f
8869 to create a sparse tree (again: current buffer only) with all entries
8870 containing the word @samp{FIXME}
8871 @item C-c a h
8872 as a prefix command for a HOME tags search where you have to press an
8873 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
8874 Peter, or Kim) as additional tag to match.
8875 @end table
8877 Note that the @code{*-tree} agenda views need to be called from an
8878 Org buffer as they operate on the current buffer only.
8880 @node Block agenda, Setting Options, Storing searches, Custom agenda views
8881 @subsection Block agenda
8882 @cindex block agenda
8883 @cindex agenda, with block views
8885 Another possibility is the construction of agenda views that comprise
8886 the results of @emph{several} commands, each of which creates a block in
8887 the agenda buffer.  The available commands include @code{agenda} for the
8888 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
8889 for the global TODO list (as constructed with @kbd{C-c a t}), and the
8890 matching commands discussed above: @code{todo}, @code{tags}, and
8891 @code{tags-todo}.  Here are two examples:
8893 @lisp
8894 @group
8895 (setq org-agenda-custom-commands
8896       '(("h" "Agenda and Home-related tasks"
8897          ((agenda "")
8898           (tags-todo "home")
8899           (tags "garden")))
8900         ("o" "Agenda and Office-related tasks"
8901          ((agenda "")
8902           (tags-todo "work")
8903           (tags "office")))))
8904 @end group
8905 @end lisp
8907 @noindent
8908 This will define @kbd{C-c a h} to create a multi-block view for stuff
8909 you need to attend to at home.  The resulting agenda buffer will contain
8910 your agenda for the current week, all TODO items that carry the tag
8911 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
8912 command @kbd{C-c a o} provides a similar view for office tasks.
8914 @node Setting Options,  , Block agenda, Custom agenda views
8915 @subsection Setting options for custom commands
8916 @cindex options, for custom agenda views
8918 @vindex org-agenda-custom-commands
8919 Org mode contains a number of variables regulating agenda construction
8920 and display.  The global variables define the behavior for all agenda
8921 commands, including the custom commands.  However, if you want to change
8922 some settings just for a single custom view, you can do so.  Setting
8923 options requires inserting a list of variable names and values at the
8924 right spot in @code{org-agenda-custom-commands}.  For example:
8926 @lisp
8927 @group
8928 (setq org-agenda-custom-commands
8929       '(("w" todo "WAITING"
8930          ((org-agenda-sorting-strategy '(priority-down))
8931           (org-agenda-prefix-format "  Mixed: ")))
8932         ("U" tags-tree "+boss-urgent"
8933          ((org-show-following-heading nil)
8934           (org-show-hierarchy-above nil)))
8935         ("N" search ""
8936          ((org-agenda-files '("~org/notes.org"))
8937           (org-agenda-text-search-extra-files nil)))))
8938 @end group
8939 @end lisp
8941 @noindent
8942 Now the @kbd{C-c a w} command will sort the collected entries only by
8943 priority, and the prefix format is modified to just say @samp{  Mixed: }
8944 instead of giving the category of the entry.  The sparse tags tree of
8945 @kbd{C-c a U} will now turn out ultra-compact, because neither the
8946 headline hierarchy above the match, nor the headline following the match
8947 will be shown.  The command @kbd{C-c a N} will do a text search limited
8948 to only a single file.
8950 @vindex org-agenda-custom-commands
8951 For command sets creating a block agenda,
8952 @code{org-agenda-custom-commands} has two separate spots for setting
8953 options.  You can add options that should be valid for just a single
8954 command in the set, and options that should be valid for all commands in
8955 the set.  The former are just added to the command entry; the latter
8956 must come after the list of command entries.  Going back to the block
8957 agenda example (@pxref{Block agenda}), let's change the sorting strategy
8958 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
8959 the results for GARDEN tags query in the opposite order,
8960 @code{priority-up}.  This would look like this:
8962 @lisp
8963 @group
8964 (setq org-agenda-custom-commands
8965       '(("h" "Agenda and Home-related tasks"
8966          ((agenda)
8967           (tags-todo "home")
8968           (tags "garden"
8969                 ((org-agenda-sorting-strategy '(priority-up)))))
8970          ((org-agenda-sorting-strategy '(priority-down))))
8971         ("o" "Agenda and Office-related tasks"
8972          ((agenda)
8973           (tags-todo "work")
8974           (tags "office")))))
8975 @end group
8976 @end lisp
8978 As you see, the values and parentheses setting is a little complex.
8979 When in doubt, use the customize interface to set this variable---it
8980 fully supports its structure.  Just one caveat: when setting options in
8981 this interface, the @emph{values} are just Lisp expressions.  So if the
8982 value is a string, you need to add the double-quotes around the value
8983 yourself.
8985 @vindex org-agenda-custom-commands-contexts
8986 To control whether an agenda command should be accessible from a specific
8987 context, you can customize @var{org-agenda-custom-commands-contexts}.  Let's
8988 say for example that you have an agenda commands @code{"o"} displaying a view
8989 that you only need when reading emails.  Then you would configure this option
8990 like this:
8992 @example
8993 (setq org-agenda-custom-commands-contexts
8994       '(("o" (in-mode . "message-mode"))))
8995 @end example
8997 You can also tell that the command key @code{"o"} should refer to another
8998 command key @code{"r"}.  In that case, add this command key like this:
9000 @example
9001 (setq org-agenda-custom-commands-contexts
9002       '(("o" "r" (in-mode . "message-mode"))))
9003 @end example
9005 See the docstring of the variable for more information.
9007 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
9008 @section Exporting Agenda Views
9009 @cindex agenda views, exporting
9011 If you are away from your computer, it can be very useful to have a printed
9012 version of some agenda views to carry around.  Org mode can export custom
9013 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
9014 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
9015 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
9016 a PDF file will also create the postscript file.}, and iCalendar files.  If
9017 you want to do this only occasionally, use the command
9019 @table @kbd
9020 @orgcmd{C-x C-w,org-agenda-write}
9021 @cindex exporting agenda views
9022 @cindex agenda views, exporting
9023 @vindex org-agenda-exporter-settings
9024 Write the agenda view to a file.  Depending on the extension of the selected
9025 file name, the view will be exported as HTML (extension @file{.html} or
9026 @file{.htm}), Postscript (extension @file{.ps}), iCalendar (extension
9027 @file{.ics}), or plain text (any other extension).  Use the variable
9028 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
9029 for @file{htmlize} to be used during export, for example
9031 @vindex org-agenda-add-entry-text-maxlines
9032 @vindex htmlize-output-type
9033 @vindex ps-number-of-columns
9034 @vindex ps-landscape-mode
9035 @lisp
9036 (setq org-agenda-exporter-settings
9037       '((ps-number-of-columns 2)
9038         (ps-landscape-mode t)
9039         (org-agenda-add-entry-text-maxlines 5)
9040         (htmlize-output-type 'css)))
9041 @end lisp
9042 @end table
9044 If you need to export certain agenda views frequently, you can associate
9045 any custom agenda command with a list of output file names
9046 @footnote{If you want to store standard views like the weekly agenda
9047 or the global TODO list as well, you need to define custom commands for
9048 them in order to be able to specify file names.}.  Here is an example
9049 that first defines custom commands for the agenda and the global
9050 TODO list, together with a number of files to which to export them.
9051 Then we define two block agenda commands and specify file names for them
9052 as well.  File names can be relative to the current working directory,
9053 or absolute.
9055 @lisp
9056 @group
9057 (setq org-agenda-custom-commands
9058       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
9059         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
9060         ("h" "Agenda and Home-related tasks"
9061          ((agenda "")
9062           (tags-todo "home")
9063           (tags "garden"))
9064          nil
9065          ("~/views/home.html"))
9066         ("o" "Agenda and Office-related tasks"
9067          ((agenda)
9068           (tags-todo "work")
9069           (tags "office"))
9070          nil
9071          ("~/views/office.ps" "~/calendars/office.ics"))))
9072 @end group
9073 @end lisp
9075 The extension of the file name determines the type of export.  If it is
9076 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
9077 the buffer to HTML and save it to this file name.  If the extension is
9078 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
9079 Postscript output.  If the extension is @file{.ics}, iCalendar export is
9080 run export over all files that were used to construct the agenda, and
9081 limit the export to entries listed in the agenda.  Any other
9082 extension produces a plain ASCII file.
9084 The export files are @emph{not} created when you use one of those
9085 commands interactively because this might use too much overhead.
9086 Instead, there is a special command to produce @emph{all} specified
9087 files in one step:
9089 @table @kbd
9090 @orgcmd{C-c a e,org-store-agenda-views}
9091 Export all agenda views that have export file names associated with
9092 them.
9093 @end table
9095 You can use the options section of the custom agenda commands to also
9096 set options for the export commands.  For example:
9098 @lisp
9099 (setq org-agenda-custom-commands
9100       '(("X" agenda ""
9101          ((ps-number-of-columns 2)
9102           (ps-landscape-mode t)
9103           (org-agenda-prefix-format " [ ] ")
9104           (org-agenda-with-colors nil)
9105           (org-agenda-remove-tags t))
9106          ("theagenda.ps"))))
9107 @end lisp
9109 @noindent
9110 This command sets two options for the Postscript exporter, to make it
9111 print in two columns in landscape format---the resulting page can be cut
9112 in two and then used in a paper agenda.  The remaining settings modify
9113 the agenda prefix to omit category and scheduling information, and
9114 instead include a checkbox to check off items.  We also remove the tags
9115 to make the lines compact, and we don't want to use colors for the
9116 black-and-white printer.  Settings specified in
9117 @code{org-agenda-exporter-settings} will also apply, but the settings
9118 in @code{org-agenda-custom-commands} take precedence.
9120 @noindent
9121 From the command line you may also use
9122 @example
9123 emacs -eval (org-batch-store-agenda-views) -kill
9124 @end example
9125 @noindent
9126 or, if you need to modify some parameters@footnote{Quoting depends on the
9127 system you use, please check the FAQ for examples.}
9128 @example
9129 emacs -eval '(org-batch-store-agenda-views                      \
9130               org-agenda-span (quote month)                     \
9131               org-agenda-start-day "2007-11-01"                 \
9132               org-agenda-include-diary nil                      \
9133               org-agenda-files (quote ("~/org/project.org")))'  \
9134       -kill
9135 @end example
9136 @noindent
9137 which will create the agenda views restricted to the file
9138 @file{~/org/project.org}, without diary entries and with a 30-day
9139 extent.
9141 You can also extract agenda information in a way that allows further
9142 processing by other programs.  See @ref{Extracting agenda information}, for
9143 more information.
9146 @node Agenda column view,  , Exporting Agenda Views, Agenda Views
9147 @section Using column view in the agenda
9148 @cindex column view, in agenda
9149 @cindex agenda, column view
9151 Column view (@pxref{Column view}) is normally used to view and edit
9152 properties embedded in the hierarchical structure of an Org file.  It can be
9153 quite useful to use column view also from the agenda, where entries are
9154 collected by certain criteria.
9156 @table @kbd
9157 @orgcmd{C-c C-x C-c,org-agenda-columns}
9158 Turn on column view in the agenda.
9159 @end table
9161 To understand how to use this properly, it is important to realize that the
9162 entries in the agenda are no longer in their proper outline environment.
9163 This causes the following issues:
9165 @enumerate
9166 @item
9167 @vindex org-columns-default-format
9168 @vindex org-overriding-columns-format
9169 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
9170 entries in the agenda are collected from different files, and different files
9171 may have different @code{COLUMNS} formats, this is a non-trivial problem.
9172 Org first checks if the variable @code{org-agenda-overriding-columns-format} is
9173 currently set, and if so, takes the format from there.  Otherwise it takes
9174 the format associated with the first item in the agenda, or, if that item
9175 does not have a specific format (defined in a property, or in its file), it
9176 uses @code{org-columns-default-format}.
9177 @item
9178 @cindex property, special, CLOCKSUM
9179 If any of the columns has a summary type defined (@pxref{Column attributes}),
9180 turning on column view in the agenda will visit all relevant agenda files and
9181 make sure that the computations of this property are up to date.  This is
9182 also true for the special @code{CLOCKSUM} property.  Org will then sum the
9183 values displayed in the agenda.  In the daily/weekly agenda, the sums will
9184 cover a single day; in all other views they cover the entire block.  It is
9185 vital to realize that the agenda may show the same entry @emph{twice} (for
9186 example as scheduled and as a deadline), and it may show two entries from the
9187 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
9188 cases, the summation in the agenda will lead to incorrect results because
9189 some values will count double.
9190 @item
9191 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
9192 the entire clocked time for this item.  So even in the daily/weekly agenda,
9193 the clocksum listed in column view may originate from times outside the
9194 current view.  This has the advantage that you can compare these values with
9195 a column listing the planned total effort for a task---one of the major
9196 applications for column view in the agenda.  If you want information about
9197 clocked time in the displayed period use clock table mode (press @kbd{R} in
9198 the agenda).
9200 @item
9201 @cindex property, special, CLOCKSUM_T
9202 When the column view in the agenda shows the @code{CLOCKSUM_T}, that is
9203 always today's clocked time for this item.  So even in the weekly agenda,
9204 the clocksum listed in column view only originates from today.  This lets
9205 you compare the time you spent on a task for today, with the time already
9206 spent (via @code{CLOCKSUM}) and with the planned total effort for it.
9207 @end enumerate
9210 @node Markup, Exporting, Agenda Views, Top
9211 @chapter Markup for rich export
9213 When exporting Org mode documents, the exporter tries to reflect the
9214 structure of the document as accurately as possible in the backend.  Since
9215 export targets like HTML, @LaTeX{} allow much richer formatting, Org mode has
9216 rules on how to prepare text for rich export.  This section summarizes the
9217 markup rules used in an Org mode buffer.
9219 @menu
9220 * Structural markup elements::  The basic structure as seen by the exporter
9221 * Images and tables::           Tables and Images will be included
9222 * Literal examples::            Source code examples with special formatting
9223 * Include files::               Include additional files into a document
9224 * Index entries::               Making an index
9225 * Macro replacement::           Use macros to create complex output
9226 * Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
9227 @end menu
9229 @node Structural markup elements, Images and tables, Markup, Markup
9230 @section Structural markup elements
9232 @menu
9233 * Document title::              Where the title is taken from
9234 * Headings and sections::       The document structure as seen by the exporter
9235 * Table of contents::           The if and where of the table of contents
9236 * Lists::                       Lists
9237 * Paragraphs::                  Paragraphs
9238 * Footnote markup::             Footnotes
9239 * Emphasis and monospace::      Bold, italic, etc.
9240 * Horizontal rules::            Make a line
9241 * Comment lines::               What will *not* be exported
9242 @end menu
9244 @node Document title, Headings and sections, Structural markup elements, Structural markup elements
9245 @subheading Document title
9246 @cindex document title, markup rules
9248 @noindent
9249 The title of the exported document is taken from the special line
9251 @cindex #+TITLE
9252 @example
9253 #+TITLE: This is the title of the document
9254 @end example
9256 @noindent
9257 If this line does not exist, the title will be the name of the file
9258 associated to buffer, without extension, or the buffer name.
9260 @cindex property, EXPORT_TITLE
9261 If you are exporting only a subtree by marking is as the region, the heading
9262 of the subtree will become the title of the document.  If the subtree has a
9263 property @code{EXPORT_TITLE}, that will take precedence.
9265 @node Headings and sections, Table of contents, Document title, Structural markup elements
9266 @subheading Headings and sections
9267 @cindex headings and sections, markup rules
9269 @vindex org-export-headline-levels
9270 The outline structure of the document as described in @ref{Document
9271 Structure}, forms the basis for defining sections of the exported document.
9272 However, since the outline structure is also used for (for example) lists of
9273 tasks, only the first three outline levels will be used as headings.  Deeper
9274 levels will become itemized lists.  You can change the location of this
9275 switch globally by setting the variable @code{org-export-headline-levels}, or on a
9276 per-file basis with a line
9278 @cindex #+OPTIONS
9279 @example
9280 #+OPTIONS: H:4
9281 @end example
9283 @node Table of contents, Lists, Headings and sections, Structural markup elements
9284 @subheading Table of contents
9285 @cindex table of contents, markup rules
9287 @cindex #+TOC
9288 @vindex org-export-with-toc
9289 The table of contents is normally inserted directly before the first headline
9290 of the file.  If you would like to get it to a different location, insert
9291 @code{#+TOC: headlines} at the desired location.  The depth of the table of
9292 contents is by default the same as the number of headline levels, but you can
9293 choose a smaller number, or turn off the table of contents entirely, by
9294 configuring the variable @code{org-export-with-toc}, or on a per-file basis
9295 with a line like
9297 @example
9298 #+OPTIONS: toc:2          (only to two levels in TOC)
9299 #+TOC: headlines 2        (the same, at a specific location)
9300 #+OPTIONS: toc:nil        (no TOC at all)
9301 @end example
9303 The same @code{TOC} keyword can also generate a list of all tables
9304 (resp. a listings) with a caption in the buffer.
9306 @example
9307 #+TOC: listings           (build a list of listings)
9308 #+TOC: tables             (build a list of tables)
9309 @end example
9311 @cindex property, ALT_TITLE
9312 The headline's title usually determines its corresponding entry in a table of
9313 contents.  However, it is possible to specifify an alternative title by
9314 setting @code{ALT_TITLE} property accordingly.  It will then be used when
9315 building the table.
9317 @node Lists, Paragraphs, Table of contents, Structural markup elements
9318 @subheading Lists
9319 @cindex lists, markup rules
9321 Plain lists as described in @ref{Plain lists}, are translated to the backend's
9322 syntax for such lists.  Most backends support unordered, ordered, and
9323 description lists.
9325 @node Paragraphs, Footnote markup, Lists, Structural markup elements
9326 @subheading Paragraphs, line breaks, and quoting
9327 @cindex paragraphs, markup rules
9329 Paragraphs are separated by at least one empty line.  If you need to enforce
9330 a line break within a paragraph, use @samp{\\} at the end of a line.
9332 To keep the line breaks in a region, but otherwise use normal formatting, you
9333 can use this construct, which can also be used to format poetry.
9335 @cindex #+BEGIN_VERSE
9336 @example
9337 #+BEGIN_VERSE
9338  Great clouds overhead
9339  Tiny black birds rise and fall
9340  Snow covers Emacs
9342      -- AlexSchroeder
9343 #+END_VERSE
9344 @end example
9346 When quoting a passage from another document, it is customary to format this
9347 as a paragraph that is indented on both the left and the right margin.  You
9348 can include quotations in Org mode documents like this:
9350 @cindex #+BEGIN_QUOTE
9351 @example
9352 #+BEGIN_QUOTE
9353 Everything should be made as simple as possible,
9354 but not any simpler -- Albert Einstein
9355 #+END_QUOTE
9356 @end example
9358 If you would like to center some text, do it like this:
9359 @cindex #+BEGIN_CENTER
9360 @example
9361 #+BEGIN_CENTER
9362 Everything should be made as simple as possible, \\
9363 but not any simpler
9364 #+END_CENTER
9365 @end example
9368 @node Footnote markup, Emphasis and monospace, Paragraphs, Structural markup elements
9369 @subheading Footnote markup
9370 @cindex footnotes, markup rules
9371 @cindex @file{footnote.el}
9373 Footnotes defined in the way described in @ref{Footnotes}, will be exported
9374 by all backends.  Org allows multiple references to the same note, and
9375 multiple footnotes side by side.
9377 @node Emphasis and monospace, Horizontal rules, Footnote markup, Structural markup elements
9378 @subheading Emphasis and monospace
9380 @cindex underlined text, markup rules
9381 @cindex bold text, markup rules
9382 @cindex italic text, markup rules
9383 @cindex verbatim text, markup rules
9384 @cindex code text, markup rules
9385 @cindex strike-through text, markup rules
9386 @vindex org-fontify-emphasized-text
9387 @vindex org-emphasis-regexp-components
9388 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
9389 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
9390 in the code and verbatim string is not processed for Org mode specific
9391 syntax; it is exported verbatim.
9393 To turn off fontification for marked up text, you can set
9394 @code{org-fontify-emphasized-text} to @code{nil}.  To fine tune what
9395 characters are allowed before and after the special characters, see
9396 @code{org-emphasis-regexp-components}.
9398 @node Horizontal rules, Comment lines, Emphasis and monospace, Structural markup elements
9399 @subheading  Horizontal rules
9400 @cindex horizontal rules, markup rules
9401 A line consisting of only dashes, and at least 5 of them, will be exported as
9402 a horizontal line (@samp{<hr/>} in HTML and @code{\hrule} in @LaTeX{}).
9404 @node Comment lines,  , Horizontal rules, Structural markup elements
9405 @subheading Comment lines
9406 @cindex comment lines
9407 @cindex exporting, not
9408 @cindex #+BEGIN_COMMENT
9410 Lines starting with zero or more whitespace characters followed by one
9411 @samp{#} and a whitespace are treated as comments and will never be exported.
9412 Also entire subtrees starting with the word @samp{COMMENT} will never be
9413 exported.  Finally, regions surrounded by @samp{#+BEGIN_COMMENT}
9414 ... @samp{#+END_COMMENT} will not be exported.
9416 @table @kbd
9417 @kindex C-c ;
9418 @item C-c ;
9419 Toggle the COMMENT keyword at the beginning of an entry.
9420 @end table
9423 @node Images and tables, Literal examples, Structural markup elements, Markup
9424 @section Images and Tables
9426 @cindex tables, markup rules
9427 @cindex #+CAPTION
9428 @cindex #+LABEL
9429 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
9430 the @file{table.el} package will be exported properly.  For Org mode tables,
9431 the lines before the first horizontal separator line will become table header
9432 lines.  You can use the following lines somewhere before the table to assign
9433 a caption and a label for cross references, and in the text you can refer to
9434 the object with @code{\ref@{tab:basic-data@}}:
9436 @example
9437 #+CAPTION: This is the caption for the next table (or link)
9438 #+LABEL:   tab:basic-data
9439    | ... | ...|
9440    |-----|----|
9441 @end example
9443 Optionally, the caption can take the form:
9444 @example
9445 #+CAPTION: [Caption for list of figures]@{Caption for table (or link).@}
9446 @end example
9448 @cindex inlined images, markup rules
9449 Some backends (HTML and @LaTeX{}) allow you to directly include images into
9450 the exported document.  Org does this, if a link to an image files does not
9451 have a description part, for example @code{[[./img/a.jpg]]}.  If you wish to
9452 define a caption for the image and maybe a label for internal cross
9453 references, make sure that the link is on a line by itself and precede it
9454 with @code{#+CAPTION} and @code{#+LABEL} as follows:
9456 @example
9457 #+CAPTION: This is the caption for the next figure link (or table)
9458 #+LABEL:   fig:SED-HR4049
9459 [[./img/a.jpg]]
9460 @end example
9462 You may also define additional attributes for the figure.  As this is
9463 backend-specific, see the sections about the individual backends for more
9464 information.
9466 @xref{Handling links,the discussion of image links}.
9468 @node Literal examples, Include files, Images and tables, Markup
9469 @section Literal examples
9470 @cindex literal examples, markup rules
9471 @cindex code line references, markup rules
9473 You can include literal examples that should not be subjected to
9474 markup.  Such examples will be typeset in monospace, so this is well suited
9475 for source code and similar examples.
9476 @cindex #+BEGIN_EXAMPLE
9478 @example
9479 #+BEGIN_EXAMPLE
9480 Some example from a text file.
9481 #+END_EXAMPLE
9482 @end example
9484 Note that such blocks may be @i{indented} in order to align nicely with
9485 indented text and in particular with plain list structure (@pxref{Plain
9486 lists}).  For simplicity when using small examples, you can also start the
9487 example lines with a colon followed by a space.  There may also be additional
9488 whitespace before the colon:
9490 @example
9491 Here is an example
9492    : Some example from a text file.
9493 @end example
9495 @cindex formatting source code, markup rules
9496 If the example is source code from a programming language, or any other text
9497 that can be marked up by font-lock in Emacs, you can ask for the example to
9498 look like the fontified Emacs buffer@footnote{This works automatically for
9499 the HTML backend (it requires version 1.34 of the @file{htmlize.el} package,
9500 which is distributed with Org).  Fontified code chunks in @LaTeX{} can be
9501 achieved using either the listings or the
9502 @url{http://code.google.com/p/minted, minted,} package.  Refer to
9503 @code{org-latex-listings} documentation for details.}.  This is done
9504 with the @samp{src} block, where you also need to specify the name of the
9505 major mode that should be used to fontify the example@footnote{Code in
9506 @samp{src} blocks may also be evaluated either interactively or on export.
9507 See @pxref{Working With Source Code} for more information on evaluating code
9508 blocks.}, see @ref{Easy Templates} for shortcuts to easily insert code
9509 blocks.
9510 @cindex #+BEGIN_SRC
9512 @example
9513 #+BEGIN_SRC emacs-lisp
9514   (defun org-xor (a b)
9515      "Exclusive or."
9516      (if a (not b) b))
9517 #+END_SRC
9518 @end example
9520 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
9521 switch to the end of the @code{BEGIN} line, to get the lines of the example
9522 numbered.  If you use a @code{+n} switch, the numbering from the previous
9523 numbered snippet will be continued in the current one.  In literal examples,
9524 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
9525 targets for special hyperlinks like @code{[[(name)]]} (i.e., the reference name
9526 enclosed in single parenthesis).  In HTML, hovering the mouse over such a
9527 link will remote-highlight the corresponding code line, which is kind of
9528 cool.
9530 You can also add a @code{-r} switch which @i{removes} the labels from the
9531 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
9532 labels in the source code while using line numbers for the links, which might
9533 be useful to explain those in an Org mode example code.}.  With the @code{-n}
9534 switch, links to these references will be labeled by the line numbers from
9535 the code listing, otherwise links will use the labels with no parentheses.
9536 Here is an example:
9538 @example
9539 #+BEGIN_SRC emacs-lisp -n -r
9540 (save-excursion                  (ref:sc)
9541    (goto-char (point-min))       (ref:jump)
9542 #+END_SRC
9543 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
9544 jumps to point-min.
9545 @end example
9547 @vindex org-coderef-label-format
9548 If the syntax for the label format conflicts with the language syntax, use a
9549 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
9550 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
9552 HTML export also allows examples to be published as text areas (@pxref{Text
9553 areas in HTML export}).
9555 Because the @code{#+BEGIN_...} and @code{#+END_...} patterns need to be added
9556 so often, shortcuts are provided using the Easy Templates facility
9557 (@pxref{Easy Templates}).
9559 @table @kbd
9560 @kindex C-c '
9561 @item C-c '
9562 Edit the source code example at point in its native mode.  This works by
9563 switching to a temporary buffer with the source code.  You need to exit by
9564 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*},
9565 @samp{,*}, @samp{#+} and @samp{,#+} will get a comma prepended, to keep them
9566 from being interpreted by Org as outline nodes or special syntax.  These
9567 commas will be stripped for editing with @kbd{C-c '}, and also for export.}.
9568 The edited version will then replace the old version in the Org buffer.
9569 Fixed-width regions (where each line starts with a colon followed by a space)
9570 will be edited using @code{artist-mode}@footnote{You may select
9571 a different-mode with the variable @code{org-edit-fixed-width-region-mode}.}
9572 to allow creating ASCII drawings easily.  Using this command in an empty line
9573 will create a new fixed-width region.
9574 @kindex C-c l
9575 @item C-c l
9576 Calling @code{org-store-link} while editing a source code example in a
9577 temporary buffer created with @kbd{C-c '} will prompt for a label.  Make sure
9578 that it is unique in the current buffer, and insert it with the proper
9579 formatting like @samp{(ref:label)} at the end of the current line.  Then the
9580 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
9581 @end table
9584 @node Include files, Index entries, Literal examples, Markup
9585 @section Include files
9586 @cindex include files, markup rules
9588 During export, you can include the content of another file.  For example, to
9589 include your @file{.emacs} file, you could use:
9590 @cindex #+INCLUDE
9592 @example
9593 #+INCLUDE: "~/.emacs" src emacs-lisp
9594 @end example
9596 @noindent
9597 The optional second and third parameter are the markup (e.g., @samp{quote},
9598 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
9599 language for formatting the contents.  The markup is optional; if it is not
9600 given, the text will be assumed to be in Org mode format and will be
9601 processed normally.  The include line will also allow additional keyword
9602 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
9603 first line and for each following line, @code{:minlevel} in order to get
9604 Org mode content demoted to a specified level, as well as any options
9605 accepted by the selected markup.  For example, to include a file as an item,
9608 @example
9609 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
9610 @end example
9612 You can also include a portion of a file by specifying a lines range using
9613 the @code{:lines} parameter.  The line at the upper end of the range will not
9614 be included.  The start and/or the end of the range may be omitted to use the
9615 obvious defaults.
9617 @example
9618 #+INCLUDE: "~/.emacs" :lines "5-10"   @r{Include lines 5 to 10, 10 excluded}
9619 #+INCLUDE: "~/.emacs" :lines "-10"    @r{Include lines 1 to 10, 10 excluded}
9620 #+INCLUDE: "~/.emacs" :lines "10-"    @r{Include lines from 10 to EOF}
9621 @end example
9623 @table @kbd
9624 @kindex C-c '
9625 @item C-c '
9626 Visit the include file at point.
9627 @end table
9629 @node Index entries, Macro replacement, Include files, Markup
9630 @section Index entries
9631 @cindex index entries, for publishing
9633 You can specify entries that will be used for generating an index during
9634 publishing.  This is done by lines starting with @code{#+INDEX}.  An entry
9635 the contains an exclamation mark will create a sub item.  See @ref{Generating
9636 an index} for more information.
9638 @example
9639 * Curriculum Vitae
9640 #+INDEX: CV
9641 #+INDEX: Application!CV
9642 @end example
9647 @node Macro replacement, Embedded @LaTeX{}, Index entries, Markup
9648 @section Macro replacement
9649 @cindex macro replacement, during export
9650 @cindex #+MACRO
9652 You can define text snippets with
9654 @example
9655 #+MACRO: name   replacement text $1, $2 are arguments
9656 @end example
9658 @noindent which can be referenced anywhere in the document (even in
9659 code examples) with @code{@{@{@{name(arg1,arg2)@}@}@}}.  In addition to
9660 defined macros, @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc.,
9661 will reference information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and
9662 similar lines.  Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
9663 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
9664 and to the modification time of the file being exported, respectively.
9665 @var{FORMAT} should be a format string understood by
9666 @code{format-time-string}.
9668 Macro expansion takes place during export, and some people use it to
9669 construct complex HTML code.
9672 @node Embedded @LaTeX{},  , Macro replacement, Markup
9673 @section Embedded @LaTeX{}
9674 @cindex @TeX{} interpretation
9675 @cindex @LaTeX{} interpretation
9677 Plain ASCII is normally sufficient for almost all note taking.  Exceptions
9678 include scientific notes, which often require mathematical symbols and the
9679 occasional formula.  @LaTeX{}@footnote{@LaTeX{} is a macro system based on
9680 Donald E. Knuth's @TeX{} system.  Many of the features described here as
9681 ``@LaTeX{}'' are really from @TeX{}, but for simplicity I am blurring this
9682 distinction.}  is widely used to typeset scientific documents.  Org mode
9683 supports embedding @LaTeX{} code into its files, because many academics are
9684 used to writing and reading @LaTeX{} source code, and because it can be
9685 readily processed to produce pretty output for a number of export backends.
9687 @menu
9688 * Special symbols::             Greek letters and other symbols
9689 * Subscripts and superscripts::  Simple syntax for raising/lowering text
9690 * @LaTeX{} fragments::          Complex formulas made easy
9691 * Previewing @LaTeX{} fragments::  What will this snippet look like?
9692 * CDLaTeX mode::                Speed up entering of formulas
9693 @end menu
9695 @node Special symbols, Subscripts and superscripts, Embedded @LaTeX{}, Embedded @LaTeX{}
9696 @subsection Special symbols
9697 @cindex math symbols
9698 @cindex special symbols
9699 @cindex @TeX{} macros
9700 @cindex @LaTeX{} fragments, markup rules
9701 @cindex HTML entities
9702 @cindex @LaTeX{} entities
9704 You can use @LaTeX{} macros to insert special symbols like @samp{\alpha} to
9705 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
9706 for these macros is available, just type @samp{\} and maybe a few letters,
9707 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike @LaTeX{}
9708 code, Org mode allows these macros to be present without surrounding math
9709 delimiters, for example:
9711 @example
9712 Angles are written as Greek letters \alpha, \beta and \gamma.
9713 @end example
9715 @vindex org-entities
9716 During export, these symbols will be transformed into the native format of
9717 the exporter backend.  Strings like @code{\alpha} will be exported as
9718 @code{&alpha;} in the HTML output, and as @code{$\alpha$} in the @LaTeX{}
9719 output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in HTML and
9720 @code{~} in @LaTeX{}.  If you need such a symbol inside a word, terminate it
9721 like this: @samp{\Aacute@{@}stor}.
9723 A large number of entities is provided, with names taken from both HTML and
9724 @LaTeX{}; see the variable @code{org-entities} for the complete list.
9725 @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
9726 @samp{...} are all converted into special commands creating hyphens of
9727 different lengths or a compact set of dots.
9729 If you would like to see entities displayed as UTF8 characters, use the
9730 following command@footnote{You can turn this on by default by setting the
9731 variable @code{org-pretty-entities}, or on a per-file base with the
9732 @code{#+STARTUP} option @code{entitiespretty}.}:
9734 @table @kbd
9735 @kindex C-c C-x \
9736 @item C-c C-x \
9737 Toggle display of entities as UTF-8 characters.  This does not change the
9738 buffer content which remains plain ASCII, but it overlays the UTF-8 character
9739 for display purposes only.
9740 @end table
9742 @node Subscripts and superscripts, @LaTeX{} fragments, Special symbols, Embedded @LaTeX{}
9743 @subsection Subscripts and superscripts
9744 @cindex subscript
9745 @cindex superscript
9747 Just like in @LaTeX{}, @samp{^} and @samp{_} are used to indicate super-
9748 and subscripts.  Again, these can be used without embedding them in
9749 math-mode delimiters.  To increase the readability of ASCII text, it is
9750 not necessary (but OK) to surround multi-character sub- and superscripts
9751 with curly braces.  For example
9753 @example
9754 The mass of the sun is M_sun = 1.989 x 10^30 kg.  The radius of
9755 the sun is R_@{sun@} = 6.96 x 10^8 m.
9756 @end example
9758 @vindex org-export-with-sub-superscripts
9759 To avoid interpretation as raised or lowered text, you can quote @samp{^} and
9760 @samp{_} with a backslash: @samp{\^} and @samp{\_}.  If you write a text
9761 where the underscore is often used in a different context, Org's convention
9762 to always interpret these as subscripts can get in your way.  Configure the
9763 variable @code{org-export-with-sub-superscripts} to globally change this
9764 convention, or use, on a per-file basis:
9766 @example
9767 #+OPTIONS: ^:@{@}
9768 @end example
9770 @noindent With this setting, @samp{a_b} will not be interpreted as a
9771 subscript, but @samp{a_@{b@}} will.
9773 @table @kbd
9774 @kindex C-c C-x \
9775 @item C-c C-x \
9776 In addition to showing entities as UTF-8 characters, this command will also
9777 format sub- and superscripts in a WYSIWYM way.
9778 @end table
9780 @node @LaTeX{} fragments, Previewing @LaTeX{} fragments, Subscripts and superscripts, Embedded @LaTeX{}
9781 @subsection @LaTeX{} fragments
9782 @cindex @LaTeX{} fragments
9784 @vindex org-format-latex-header
9785 Going beyond symbols and sub- and superscripts, a full formula language is
9786 needed.  Org mode can contain @LaTeX{} math fragments, and it supports ways
9787 to process these for several export backends.  When exporting to @LaTeX{},
9788 the code is obviously left as it is.  When exporting to HTML, Org invokes the
9789 @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in
9790 HTML export}) to process and display the math@footnote{If you plan to use
9791 this regularly or on pages with significant page views, you should install
9792 @file{MathJax} on your own
9793 server in order to limit the load of our server.}.  Finally, it can also
9794 process the mathematical expressions into images@footnote{For this to work
9795 you need to be on a system with a working @LaTeX{} installation.  You also
9796 need the @file{dvipng} program or the @file{convert}, respectively available
9797 at @url{http://sourceforge.net/projects/dvipng/} and from the
9798 @file{imagemagick} suite.  The @LaTeX{} header that will be used when
9799 processing a fragment can be configured with the variable
9800 @code{org-format-latex-header}.} that can be displayed in a browser.
9802 @LaTeX{} fragments don't need any special marking at all.  The following
9803 snippets will be identified as @LaTeX{} source code:
9804 @itemize @bullet
9805 @item
9806 Environments of any kind@footnote{When @file{MathJax} is used, only the
9807 environment recognized by @file{MathJax} will be processed.  When
9808 @file{dvipng} is used to create images, any @LaTeX{} environments will be
9809 handled.}.  The only requirement is that the @code{\begin} and @code{\end}
9810 statements appear on a new line, at the beginning of the line or after
9811 whitespaces only.
9812 @item
9813 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
9814 currency specifications, single @samp{$} characters are only recognized as
9815 math delimiters if the enclosed text contains at most two line breaks, is
9816 directly attached to the @samp{$} characters with no whitespace in between,
9817 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
9818 For the other delimiters, there is no such restriction, so when in doubt, use
9819 @samp{\(...\)} as inline math delimiters.
9820 @end itemize
9822 @noindent For example:
9824 @example
9825 \begin@{equation@}                          % arbitrary environments,
9826 x=\sqrt@{b@}                                % even tables, figures
9827 \end@{equation@}                            % etc
9829 If $a^2=b$ and \( b=2 \), then the solution must be
9830 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
9831 @end example
9833 @noindent
9834 @vindex org-format-latex-options
9835 If you need any of the delimiter ASCII sequences for other purposes, you
9836 can configure the option @code{org-format-latex-options} to deselect the
9837 ones you do not wish to have interpreted by the @LaTeX{} converter.
9839 @vindex org-export-with-LaTeX-fragments
9840 @LaTeX{} processing can be configured with the variable
9841 @code{org-export-with-LaTeX-fragments}.  The default setting is @code{t}
9842 which means @file{MathJax} for HTML, and no processing for ASCII and @LaTeX{}
9843 backends.  You can also set this variable on a per-file basis using one of
9844 these lines:
9846 @example
9847 #+OPTIONS: LaTeX:t          @r{Do the right thing automatically (MathJax)}
9848 #+OPTIONS: LaTeX:dvipng     @r{Force using dvipng images}
9849 #+OPTIONS: LaTeX:nil        @r{Do not process @LaTeX{} fragments at all}
9850 #+OPTIONS: LaTeX:verbatim   @r{Verbatim export, for jsMath or so}
9851 @end example
9853 @node Previewing @LaTeX{} fragments, CDLaTeX mode, @LaTeX{} fragments, Embedded @LaTeX{}
9854 @subsection Previewing @LaTeX{} fragments
9855 @cindex @LaTeX{} fragments, preview
9857 If you have @file{dvipng} installed, @LaTeX{} fragments can be processed to
9858 produce preview images of the typeset expressions:
9860 @table @kbd
9861 @kindex C-c C-x C-l
9862 @item C-c C-x C-l
9863 Produce a preview image of the @LaTeX{} fragment at point and overlay it
9864 over the source code.  If there is no fragment at point, process all
9865 fragments in the current entry (between two headlines).  When called
9866 with a prefix argument, process the entire subtree.  When called with
9867 two prefix arguments, or when the cursor is before the first headline,
9868 process the entire buffer.
9869 @kindex C-c C-c
9870 @item C-c C-c
9871 Remove the overlay preview images.
9872 @end table
9874 @vindex org-format-latex-options
9875 You can customize the variable @code{org-format-latex-options} to influence
9876 some aspects of the preview.  In particular, the @code{:scale} (and for HTML
9877 export, @code{:html-scale}) property can be used to adjust the size of the
9878 preview images.
9880 @vindex org-startup-with-latex-preview
9881 You can turn on the previewing of all @LaTeX{} fragments in a file with
9883 @example
9884 #+STARTUP: latexpreview
9885 @end example
9887 To disable it, simply use
9889 @example
9890 #+STARTUP: nolatexpreview
9891 @end example
9893 @node CDLaTeX mode,  , Previewing @LaTeX{} fragments, Embedded @LaTeX{}
9894 @subsection Using CD@LaTeX{} to enter math
9895 @cindex CD@LaTeX{}
9897 CD@LaTeX{} mode is a minor mode that is normally used in combination with a
9898 major @LaTeX{} mode like AUC@TeX{} in order to speed-up insertion of
9899 environments and math templates.  Inside Org mode, you can make use of
9900 some of the features of CD@LaTeX{} mode.  You need to install
9901 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
9902 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
9903 Don't use CD@LaTeX{} mode itself under Org mode, but use the light
9904 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
9905 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
9906 Org files with
9908 @lisp
9909 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
9910 @end lisp
9912 When this mode is enabled, the following features are present (for more
9913 details see the documentation of CD@LaTeX{} mode):
9914 @itemize @bullet
9915 @kindex C-c @{
9916 @item
9917 Environment templates can be inserted with @kbd{C-c @{}.
9918 @item
9919 @kindex @key{TAB}
9920 The @key{TAB} key will do template expansion if the cursor is inside a
9921 @LaTeX{} fragment@footnote{Org mode has a method to test if the cursor is
9922 inside such a fragment, see the documentation of the function
9923 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
9924 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
9925 correctly inside the first brace.  Another @key{TAB} will get you into
9926 the second brace.  Even outside fragments, @key{TAB} will expand
9927 environment abbreviations at the beginning of a line.  For example, if
9928 you write @samp{equ} at the beginning of a line and press @key{TAB},
9929 this abbreviation will be expanded to an @code{equation} environment.
9930 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
9931 @item
9932 @kindex _
9933 @kindex ^
9934 @vindex cdlatex-simplify-sub-super-scripts
9935 Pressing @kbd{_} and @kbd{^} inside a @LaTeX{} fragment will insert these
9936 characters together with a pair of braces.  If you use @key{TAB} to move
9937 out of the braces, and if the braces surround only a single character or
9938 macro, they are removed again (depending on the variable
9939 @code{cdlatex-simplify-sub-super-scripts}).
9940 @item
9941 @kindex `
9942 Pressing the backquote @kbd{`} followed by a character inserts math
9943 macros, also outside @LaTeX{} fragments.  If you wait more than 1.5 seconds
9944 after the backquote, a help window will pop up.
9945 @item
9946 @kindex '
9947 Pressing the single-quote @kbd{'} followed by another character modifies
9948 the symbol before point with an accent or a font.  If you wait more than
9949 1.5 seconds after the single-quote, a help window will pop up.  Character
9950 modification will work only inside @LaTeX{} fragments; outside the quote
9951 is normal.
9952 @end itemize
9954 @node Exporting, Publishing, Markup, Top
9955 @chapter Exporting
9956 @cindex exporting
9958 Org mode documents can be exported into a variety of other formats.  For
9959 printing and sharing notes, ASCII export produces a readable and simple
9960 version of an Org file.  HTML export allows you to publish a notes file on
9961 the web.  @LaTeX{} export lets you use Org mode and its structured editing
9962 functions to easily create @LaTeX{} files.  OpenDocument Text (ODT) export
9963 allows seamless collaboration across organizational boundaries.  To
9964 incorporate entries with associated times like deadlines or appointments into
9965 a desktop calendar program like iCal, Org mode can also produce extracts in
9966 the iCalendar format.  Currently, Org mode only supports export, not import
9967 of these different formats.
9969 Org supports export of selected regions when @code{transient-mark-mode} is
9970 enabled (default in Emacs 23).
9972 @menu
9973 * Selective export::            Using tags to select and exclude trees
9974 * Export options::              Per-file export settings
9975 * The export dispatcher::       How to access exporter commands
9976 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
9977 * HTML export::                 Exporting to HTML
9978 * @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
9979 * OpenDocument Text export::    Exporting to OpenDocument Text
9980 * iCalendar export::            Exporting in iCalendar format
9981 @end menu
9983 @node Selective export, Export options, Exporting, Exporting
9984 @section Selective export
9985 @cindex export, selective by tags or TODO keyword
9987 @vindex org-export-select-tags
9988 @vindex org-export-exclude-tags
9989 @cindex org-export-with-tasks
9990 You may use tags to select the parts of a document that should be exported,
9991 or to exclude parts from export.  This behavior is governed by two variables:
9992 @code{org-export-select-tags} and @code{org-export-exclude-tags},
9993 respectively defaulting to @code{'(:export:)} and @code{'(:noexport:)}.
9995 @enumerate
9996 @item
9997 Org first checks if any of the @emph{select} tags is present in the
9998 buffer.  If yes, all trees that do not carry one of these tags will be
9999 excluded.  If a selected tree is a subtree, the heading hierarchy above it
10000 will also be selected for export, but not the text below those headings.
10002 @item
10003 If none of the select tags is found, the whole buffer will be selected for
10004 export.
10006 @item
10007 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
10008 be removed from the export buffer.
10009 @end enumerate
10011 The variable @code{org-export-with-tasks} can be configured to select which
10012 kind of tasks should be included for export.  See the docstring of the
10013 variable for more information.
10015 @node Export options, The export dispatcher, Selective export, Exporting
10016 @section Export options
10017 @cindex options, for export
10019 @cindex completion, of option keywords
10020 The exporter recognizes special lines in the buffer which provide
10021 additional information.  These lines may be put anywhere in the file.
10022 The whole set of lines can be inserted into the buffer with @kbd{C-c
10023 C-e t}.  For individual lines, a good way to make sure the keyword is
10024 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
10025 (@pxref{Completion}).   For a summary of other in-buffer settings not
10026 specifically related to export, see @ref{In-buffer settings}.
10027 In particular, note that you can place commonly-used (export) options in
10028 a separate file which can be included using @code{#+SETUPFILE}.
10030 @table @kbd
10031 @orgcmd{C-c C-e t,org-insert-export-options-template}
10032 Insert template with export options, see example below.
10033 @end table
10035 @cindex #+TITLE
10036 @cindex #+AUTHOR
10037 @cindex #+DATE
10038 @cindex #+EMAIL
10039 @cindex #+DESCRIPTION
10040 @cindex #+KEYWORDS
10041 @cindex #+LANGUAGE
10042 @cindex #+TEXT
10043 @cindex #+OPTIONS
10044 @cindex #+BIND
10045 @cindex #+HTML_LINK_UP
10046 @cindex #+HTML_LINK_HOME
10047 @cindex #+SELECT_TAGS
10048 @cindex #+EXCLUDE_TAGS
10049 @cindex #+LaTeX_HEADER
10050 @vindex user-full-name
10051 @vindex user-mail-address
10052 @vindex org-export-default-language
10053 @vindex org-export-date-timestamp-format
10054 @example
10055 #+TITLE:       the title to be shown (default is the buffer name)
10056 #+AUTHOR:      the author (default taken from @code{user-full-name})
10057 #+DATE:        a date, an Org timestamp@footnote{@code{org-export-date-timestamp-format} defines how this timestamp will be exported.}, or a format string for @code{format-time-string}
10058 #+EMAIL:       his/her email address (default from @code{user-mail-address})
10059 #+DESCRIPTION: the page description, e.g., for the XHTML meta tag
10060 #+KEYWORDS:    the page keywords, e.g., for the XHTML meta tag
10061 #+LANGUAGE:    language for HTML, e.g., @samp{en} (@code{org-export-default-language})
10062 #+TEXT:        Some descriptive text to be inserted at the beginning.
10063 #+TEXT:        Several lines may be given.
10064 #+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
10065 #+BIND:        lisp-var lisp-val, e.g., @code{org-latex-image-default-option width=.7\\linewidth}
10066                @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
10067 #+HTML_LINK_UP:     the ``up'' link of an exported page
10068 #+HTML_LINK_HOME:   the ``home'' link of an exported page
10069 #+LaTeX_HEADER: extra line(s) for the @LaTeX{} header, like \usepackage@{xyz@}
10070 #+SELECT_TAGS:   Tags that select a tree for export
10071 #+EXCLUDE_TAGS:  Tags that exclude a tree from export
10072 @end example
10074 @noindent
10075 The @code{#+OPTIONS} line is a compact@footnote{If you want to configure many options
10076 this way, you can use several @code{#+OPTIONS} lines.} form to specify export
10077 settings.  Here you can:
10078 @cindex headline levels
10079 @cindex section-numbers
10080 @cindex table of contents
10081 @cindex line-break preservation
10082 @cindex quoted HTML tags
10083 @cindex fixed-width sections
10084 @cindex tables
10085 @cindex @TeX{}-like syntax for sub- and superscripts
10086 @cindex footnotes
10087 @cindex special strings
10088 @cindex emphasized text
10089 @cindex @TeX{} macros
10090 @cindex @LaTeX{} fragments
10091 @cindex author info, in export
10092 @cindex time info, in export
10093 @vindex org-export-plist-vars
10094 @vindex org-export-author-info
10095 @vindex org-export-creator-info
10096 @vindex org-export-email-info
10097 @vindex org-export-time-stamp-file
10098 @example
10099 H:         @r{set the number of headline levels for export}
10100 num:       @r{turn on/off section-numbers}
10101 toc:       @r{turn on/off table of contents, or set level limit (integer)}
10102 \n:        @r{turn on/off line-break-preservation (DOES NOT WORK)}
10103 @@:         @r{turn on/off quoted HTML tags}
10104 ::         @r{turn on/off fixed-width sections}
10105 |:         @r{turn on/off tables}
10106 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
10107            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
10108            @r{the simple @code{a_b} will be left as it is.}
10109 -:         @r{turn on/off conversion of special strings.}
10110 f:         @r{turn on/off footnotes like this[1].}
10111 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
10112 tasks:     @r{turn on/off inclusion of tasks (TODO items), can be nil to remove}
10113            @r{all tasks, @code{todo} to remove DONE tasks, or list of kwds to keep}
10114 pri:       @r{turn on/off priority cookies}
10115 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
10116 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
10117 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
10118 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
10119 LaTeX:     @r{configure export of @LaTeX{} fragments.  Default @code{auto}}
10120 skip:      @r{turn on/off skipping the text before the first heading}
10121 author:    @r{turn on/off inclusion of author name/email into exported file}
10122 email:     @r{turn on/off inclusion of author email into exported file}
10123 creator:   @r{turn on/off inclusion of creator info into exported file}
10124 timestamp: @r{turn on/off inclusion creation time into exported file}
10125 d:         @r{turn on/off inclusion of drawers, or list drawers to include}
10126 @end example
10127 @noindent
10128 These options take effect in both the HTML and @LaTeX{} export, except for
10129 @code{TeX} and @code{LaTeX} options, which are respectively @code{t} and
10130 @code{nil} for the @LaTeX{} export.
10132 The default values for these and many other options are given by a set of
10133 variables.  For a list of such variables, the corresponding OPTIONS keys and
10134 also the publishing keys (@pxref{Project alist}), see the constant
10135 @code{org-export-plist-vars}.
10137 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
10138 calling an export command, the subtree can overrule some of the file's export
10139 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
10140 @code{EXPORT_TEXT}, @code{EXPORT_AUTHOR}, @code{EXPORT_DATE}, and
10141 @code{EXPORT_OPTIONS}.
10143 @node The export dispatcher, ASCII/Latin-1/UTF-8 export, Export options, Exporting
10144 @section The export dispatcher
10145 @cindex dispatcher, for export commands
10147 All export commands can be reached using the export dispatcher, which is a
10148 prefix key that prompts for an additional key specifying the command.
10149 Normally the entire file is exported, but if there is an active region that
10150 contains one outline tree, the first heading is used as document title and
10151 the subtrees are exported.
10153 @table @kbd
10154 @orgcmd{C-c C-e,org-export}
10155 @vindex org-export-run-in-background
10156 Dispatcher for export and publishing commands.  Displays a help-window
10157 listing the additional key(s) needed to launch an export or publishing
10158 command.  The prefix arg is passed through to the exporter.  A double prefix
10159 @kbd{C-u C-u} causes most commands to be executed in the background, in a
10160 separate Emacs process@footnote{To make this behavior the default, customize
10161 the variable @code{org-export-run-in-background}.}.
10162 @orgcmd{C-c C-e v,org-export-visible}
10163 Like @kbd{C-c C-e}, but only export the text that is currently visible
10164 (i.e., not hidden by outline visibility).
10165 @orgcmd{C-u C-u C-c C-e,org-export}
10166 @vindex org-export-run-in-background
10167 Call the exporter, but reverse the setting of
10168 @code{org-export-run-in-background}, i.e., request background processing if
10169 not set, or force processing in the current Emacs process if set.
10170 @end table
10172 @node ASCII/Latin-1/UTF-8 export, HTML export, The export dispatcher, Exporting
10173 @section ASCII/Latin-1/UTF-8 export
10174 @cindex ASCII export
10175 @cindex Latin-1 export
10176 @cindex UTF-8 export
10178 ASCII export produces a simple and very readable version of an Org mode
10179 file, containing only plain ASCII@.  Latin-1 and UTF-8 export augment the file
10180 with special characters and symbols available in these encodings.
10182 @cindex region, active
10183 @cindex active region
10184 @cindex transient-mark-mode
10185 @table @kbd
10186 @orgcmd{C-c C-e a,org-export-as-ascii}
10187 @cindex property, EXPORT_FILE_NAME
10188 Export as an ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
10189 will be @file{myfile.txt}.  The file will be overwritten without
10190 warning.  If there is an active region@footnote{This requires
10191 @code{transient-mark-mode} be turned on.}, only the region will be
10192 exported.  If the selected region is a single tree@footnote{To select the
10193 current subtree, use @kbd{C-c @@}.}, the tree head will
10194 become the document title.  If the tree head entry has or inherits an
10195 @code{EXPORT_FILE_NAME} property, that name will be used for the
10196 export.
10197 @orgcmd{C-c C-e A,org-export-as-ascii-to-buffer}
10198 Export to a temporary buffer.  Do not create a file.
10199 @orgcmd{C-c C-e n,org-export-as-latin1}
10200 @xorgcmd{C-c C-e N,org-export-as-latin1-to-buffer}
10201 Like the above commands, but use Latin-1 encoding.
10202 @orgcmd{C-c C-e u,org-export-as-utf8}
10203 @xorgcmd{C-c C-e U,org-export-as-utf8-to-buffer}
10204 Like the above commands, but use UTF-8 encoding.
10205 @item C-c C-e v a/n/u
10206 Export only the visible part of the document.
10207 @end table
10209 @cindex headline levels, for exporting
10210 In the exported version, the first 3 outline levels will become
10211 headlines, defining a general document structure.  Additional levels
10212 will be exported as itemized lists.  If you want that transition to occur
10213 at a different level, specify it with a prefix argument.  For example,
10215 @example
10216 @kbd{C-1 C-c C-e a}
10217 @end example
10219 @noindent
10220 creates only top level headlines and exports the rest as items.  When
10221 headlines are converted to items, the indentation of the text following
10222 the headline is changed to fit nicely under the item.  This is done with
10223 the assumption that the first body line indicates the base indentation of
10224 the body text.  Any indentation larger than this is adjusted to preserve
10225 the layout relative to the first line.  Should there be lines with less
10226 indentation than the first one, these are left alone.
10228 @vindex org-export-ascii-links-to-notes
10229 Links will be exported in a footnote-like style, with the descriptive part in
10230 the text and the link in a note before the next heading.  See the variable
10231 @code{org-export-ascii-links-to-notes} for details and other options.
10233 @node HTML export, @LaTeX{} and PDF export, ASCII/Latin-1/UTF-8 export, Exporting
10234 @section HTML export
10235 @cindex HTML export
10237 Org mode contains a HTML (XHTML 1.0 strict) exporter with extensive
10238 HTML formatting, in ways similar to John Gruber's @emph{markdown}
10239 language, but with additional support for tables.
10241 @menu
10242 * HTML Export commands::        How to invoke HTML export
10243 * HTML preamble and postamble::  How to insert a preamble and a postamble
10244 * Quoting HTML tags::           Using direct HTML in Org mode
10245 * Links in HTML export::        How links will be interpreted and formatted
10246 * Tables in HTML export::       How to modify the formatting of tables
10247 * Images in HTML export::       How to insert figures into HTML output
10248 * Math formatting in HTML export::  Beautiful math also on the web
10249 * Text areas in HTML export::   An alternative way to show an example
10250 * CSS support::                 Changing the appearance of the output
10251 * JavaScript support::          Info and Folding in a web browser
10252 @end menu
10254 @node HTML Export commands, HTML preamble and postamble, HTML export, HTML export
10255 @subsection HTML export commands
10257 @cindex region, active
10258 @cindex active region
10259 @cindex transient-mark-mode
10260 @table @kbd
10261 @orgcmd{C-c C-e h,org-export-as-html}
10262 @cindex property, EXPORT_FILE_NAME
10263 Export as a HTML file.  For an Org file @file{myfile.org},
10264 the HTML file will be @file{myfile.html}.  The file will be overwritten
10265 without warning.  If there is an active region@footnote{This requires
10266 @code{transient-mark-mode} be turned on.}, only the region will be
10267 exported.  If the selected region is a single tree@footnote{To select the
10268 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
10269 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
10270 property, that name will be used for the export.
10271 @orgcmd{C-c C-e b,org-export-as-html-and-open}
10272 Export as a HTML file and immediately open it with a browser.
10273 @orgcmd{C-c C-e H,org-export-as-html-to-buffer}
10274 Export to a temporary buffer.  Do not create a file.
10275 @orgcmd{C-c C-e R,org-export-region-as-html}
10276 Export the active region to a temporary buffer.  With a prefix argument, do
10277 not produce the file header and footer, but just the plain HTML section for
10278 the region.  This is good for cut-and-paste operations.
10279 @item C-c C-e v h/b/H/R
10280 Export only the visible part of the document.
10281 @item M-x org-export-region-as-html
10282 Convert the region to HTML under the assumption that it was in Org mode
10283 syntax before.  This is a global command that can be invoked in any
10284 buffer.
10285 @item M-x org-replace-region-by-HTML
10286 Replace the active region (assumed to be in Org mode syntax) by HTML
10287 code.
10288 @end table
10290 @cindex headline levels, for exporting
10291 In the exported version, the first 3 outline levels will become headlines,
10292 defining a general document structure.  Additional levels will be exported as
10293 itemized lists.  If you want that transition to occur at a different level,
10294 specify it with a numeric prefix argument.  For example,
10296 @example
10297 @kbd{C-2 C-c C-e b}
10298 @end example
10300 @noindent
10301 creates two levels of headings and does the rest as items.
10304 @node HTML preamble and postamble, Quoting HTML tags, HTML Export commands, HTML export
10305 @subsection HTML preamble and postamble
10306 @vindex org-html-preamble
10307 @vindex org-html-postamble
10308 @vindex org-html-preamble-format
10309 @vindex org-html-postamble-format
10310 @vindex org-html-validation-link
10311 @vindex org-export-author-info
10312 @vindex org-export-email-info
10313 @vindex org-export-creator-info
10314 @vindex org-export-time-stamp-file
10316 The HTML exporter lets you define a preamble and a postamble.
10318 The default value for @code{org-html-preamble} is @code{t}, which means
10319 that the preamble is inserted depending on the relevant format string in
10320 @code{org-html-preamble-format}.
10322 Setting @code{org-html-preamble} to a string will override the default
10323 format string.  Setting it to a function, will insert the output of the
10324 function, which must be a string; such a function takes no argument but you
10325 can check against the value of @code{opt-plist}, which contains the list of
10326 publishing properties for the current file.  Setting to @code{nil} will not
10327 insert any preamble.
10329 The default value for @code{org-html-postamble} is @code{'auto}, which
10330 means that the HTML exporter will look for the value of
10331 @code{org-export-author-info}, @code{org-export-email-info},
10332 @code{org-export-creator-info} and @code{org-export-time-stamp-file},
10333 @code{org-html-validation-link} and build the postamble from these
10334 values.  Setting @code{org-html-postamble} to @code{t} will insert the
10335 postamble from the relevant format string found in
10336 @code{org-html-postamble-format}.  Setting it to @code{nil} will not
10337 insert any postamble.
10339 @node Quoting HTML tags, Links in HTML export, HTML preamble and postamble, HTML export
10340 @subsection Quoting HTML tags
10342 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
10343 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
10344 which should be interpreted as such, mark them with @samp{@@} as in
10345 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
10346 simple tags.  For more extensive HTML that should be copied verbatim to
10347 the exported file use either
10349 @cindex #+HTML
10350 @cindex #+BEGIN_HTML
10351 @example
10352 #+HTML: Literal HTML code for export
10353 @end example
10355 @noindent or
10356 @cindex #+BEGIN_HTML
10358 @example
10359 #+BEGIN_HTML
10360 All lines between these markers are exported literally
10361 #+END_HTML
10362 @end example
10365 @node Links in HTML export, Tables in HTML export, Quoting HTML tags, HTML export
10366 @subsection Links in HTML export
10368 @cindex links, in HTML export
10369 @cindex internal links, in HTML export
10370 @cindex external links, in HTML export
10371 Internal links (@pxref{Internal links}) will continue to work in HTML@.  This
10372 includes automatic links created by radio targets (@pxref{Radio
10373 targets}).  Links to external files will still work if the target file is on
10374 the same @i{relative} path as the published Org file.  Links to other
10375 @file{.org} files will be translated into HTML links under the assumption
10376 that a HTML version also exists of the linked file, at the same relative
10377 path.  @samp{id:} links can then be used to jump to specific entries across
10378 files.  For information related to linking files while publishing them to a
10379 publishing directory see @ref{Publishing links}.
10381 If you want to specify attributes for links, you can do so using a special
10382 @code{#+ATTR_HTML} line to define attributes that will be added to the
10383 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
10384 and @code{style} attributes for a link:
10386 @cindex #+ATTR_HTML
10387 @example
10388 #+ATTR_HTML: title="The Org mode homepage" style="color:red;"
10389 [[http://orgmode.org]]
10390 @end example
10392 @node Tables in HTML export, Images in HTML export, Links in HTML export, HTML export
10393 @subsection Tables
10394 @cindex tables, in HTML
10395 @vindex org-html-table-tag
10397 Org mode tables are exported to HTML using the table tag defined in
10398 @code{org-html-table-tag}.  The default setting makes tables without
10399 cell borders and frame.  If you would like to change this for individual
10400 tables, place something like the following before the table:
10402 @cindex #+CAPTION
10403 @cindex #+ATTR_HTML
10404 @example
10405 #+CAPTION: This is a table with lines around and between cells
10406 #+ATTR_HTML: border="2" rules="all" frame="border"
10407 @end example
10409 @node Images in HTML export, Math formatting in HTML export, Tables in HTML export, HTML export
10410 @subsection Images in HTML export
10412 @cindex images, inline in HTML
10413 @cindex inlining images in HTML
10414 @vindex org-html-inline-images
10415 HTML export can inline images given as links in the Org file, and
10416 it can make an image the clickable part of a link.  By
10417 default@footnote{But see the variable
10418 @code{org-html-inline-images}.}, images are inlined if a link does
10419 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
10420 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
10421 @samp{the image} that points to the image.  If the description part
10422 itself is a @code{file:} link or a @code{http:} URL pointing to an
10423 image, this image will be inlined and activated so that clicking on the
10424 image will activate the link.  For example, to include a thumbnail that
10425 will link to a high resolution version of the image, you could use:
10427 @example
10428 [[file:highres.jpg][file:thumb.jpg]]
10429 @end example
10431 If you need to add attributes to an inlined image, use a @code{#+ATTR_HTML}.
10432 In the example below we specify the @code{alt} and @code{title} attributes to
10433 support text viewers and accessibility, and align it to the right.
10435 @cindex #+CAPTION
10436 @cindex #+ATTR_HTML
10437 @example
10438 #+CAPTION: A black cat stalking a spider
10439 #+ATTR_HTML: alt="cat/spider image" title="Action!" align="right"
10440 [[./img/a.jpg]]
10441 @end example
10443 @noindent
10444 You could use @code{http} addresses just as well.
10446 @node Math formatting in HTML export, Text areas in HTML export, Images in HTML export, HTML export
10447 @subsection Math formatting in HTML export
10448 @cindex MathJax
10449 @cindex dvipng
10451 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
10452 different ways on HTML pages.  The default is to use the
10453 @uref{http://www.mathjax.org, MathJax system} which should work out of the
10454 box with Org mode installation because @code{http://orgmode.org} serves
10455 @file{MathJax} for Org mode users for small applications and for testing
10456 purposes.  @b{If you plan to use this regularly or on pages with significant
10457 page views, you should install@footnote{Installation instructions can be
10458 found on the MathJax website, see
10459 @uref{http://www.mathjax.org/resources/docs/?installation.html}.} MathJax on
10460 your own server in order to limit the load of our server.}  To configure
10461 @file{MathJax}, use the variable @code{org-html-mathjax-options} or
10462 insert something like the following into the buffer:
10464 @example
10465 #+HTML_MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js"
10466 @end example
10468 @noindent See the docstring of the variable
10469 @code{org-html-mathjax-options} for the meaning of the parameters in
10470 this line.
10472 If you prefer, you can also request that @LaTeX{} fragments are processed
10473 into small images that will be inserted into the browser page.  Before the
10474 availability of MathJax, this was the default method for Org files.  This
10475 method requires that the @file{dvipng} program is available on your system.
10476 You can still get this processing with
10478 @example
10479 #+OPTIONS: LaTeX:dvipng
10480 @end example
10482 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
10483 @subsection Text areas in HTML export
10485 @cindex text areas, in HTML
10486 An alternative way to publish literal code examples in HTML is to use text
10487 areas, where the example can even be edited before pasting it into an
10488 application.  It is triggered by a @code{-t} switch at an @code{example} or
10489 @code{src} block.  Using this switch disables any options for syntax and
10490 label highlighting, and line numbering, which may be present.  You may also
10491 use @code{-h} and @code{-w} switches to specify the height and width of the
10492 text area, which default to the number of lines in the example, and 80,
10493 respectively.  For example
10495 @example
10496 #+BEGIN_EXAMPLE -t -w 40
10497   (defun org-xor (a b)
10498      "Exclusive or."
10499      (if a (not b) b))
10500 #+END_EXAMPLE
10501 @end example
10504 @node CSS support, JavaScript support, Text areas in HTML export, HTML export
10505 @subsection CSS support
10506 @cindex CSS, for HTML export
10507 @cindex HTML export, CSS
10509 @vindex org-html-todo-kwd-class-prefix
10510 @vindex org-html-tag-class-prefix
10511 You can also give style information for the exported file.  The HTML exporter
10512 assigns the following special CSS classes@footnote{If the classes on TODO
10513 keywords and tags lead to conflicts, use the variables
10514 @code{org-html-todo-kwd-class-prefix} and
10515 @code{org-html-tag-class-prefix} to make them unique.} to appropriate
10516 parts of the document---your style specifications may change these, in
10517 addition to any of the standard classes like for headlines, tables, etc.
10518 @example
10519 p.author            @r{author information, including email}
10520 p.date              @r{publishing date}
10521 p.creator           @r{creator info, about org mode version}
10522 .title              @r{document title}
10523 .todo               @r{TODO keywords, all not-done states}
10524 .done               @r{the DONE keywords, all states that count as done}
10525 .WAITING            @r{each TODO keyword also uses a class named after itself}
10526 .timestamp          @r{timestamp}
10527 .timestamp-kwd      @r{keyword associated with a timestamp, like SCHEDULED}
10528 .timestamp-wrapper  @r{span around keyword plus timestamp}
10529 .tag                @r{tag in a headline}
10530 ._HOME              @r{each tag uses itself as a class, "@@" replaced by "_"}
10531 .target             @r{target for links}
10532 .linenr             @r{the line number in a code example}
10533 .code-highlighted   @r{for highlighting referenced code lines}
10534 div.outline-N       @r{div for outline level N (headline plus text))}
10535 div.outline-text-N  @r{extra div for text at outline level N}
10536 .section-number-N   @r{section number in headlines, different for each level}
10537 div.figure          @r{how to format an inlined image}
10538 pre.src             @r{formatted source code}
10539 pre.example         @r{normal example}
10540 p.verse             @r{verse paragraph}
10541 div.footnotes       @r{footnote section headline}
10542 p.footnote          @r{footnote definition paragraph, containing a footnote}
10543 .footref            @r{a footnote reference number (always a <sup>)}
10544 .footnum            @r{footnote number in footnote definition (always <sup>)}
10545 @end example
10547 @vindex org-html-style-default
10548 @vindex org-html-head-include-default-style
10549 @vindex org-html-head
10550 @vindex org-html-head-extra
10551 @cindex #+HTML_INCLUDE_STYLE
10552 Each exported file contains a compact default style that defines these
10553 classes in a basic way@footnote{This style is defined in the constant
10554 @code{org-html-style-default}, which you should not modify.  To turn
10555 inclusion of these defaults off, customize
10556 @code{org-html-head-include-default-style} or set @code{#+HTML_INCLUDE_STYLE}
10557 to nil on a per-file basis.}.  You may overwrite these settings, or add to
10558 them by using the variables @code{org-html-head} and
10559 @code{org-html-head-extra}.  You can override the global values of these
10560 variables for each file by using these keywords:
10562 @cindex #+HTML_HEAD
10563 @cindex #+HTML_HEAD_EXTRA
10564 @example
10565 #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
10566 #+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
10567 @end example
10569 @noindent
10570 For longer style definitions, you can use several such lines.  You could also
10571 directly write a @code{<style>} @code{</style>} section in this way, without
10572 referring to an external file.
10574 In order to add styles to a subtree, use the @code{:HTML_CONTAINER_CLASS:}
10575 property to assign a class to the tree.  In order to specify CSS styles for a
10576 particular headline, you can use the id specified in a @code{:CUSTOM_ID:}
10577 property.
10579 @c FIXME: More about header and footer styles
10580 @c FIXME: Talk about links and targets.
10582 @node JavaScript support,  , CSS support, HTML export
10583 @subsection JavaScript supported display of web pages
10585 @cindex Rose, Sebastian
10586 Sebastian Rose has written a JavaScript program especially designed to
10587 enhance the web viewing experience of HTML files created with Org.  This
10588 program allows you to view large files in two different ways.  The first one
10589 is an @emph{Info}-like mode where each section is displayed separately and
10590 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
10591 as well, press @kbd{?} for an overview of the available keys).  The second
10592 view type is a @emph{folding} view much like Org provides inside Emacs.  The
10593 script is available at @url{http://orgmode.org/org-info.js} and you can find
10594 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
10595 We host the script at our site, but if you use it a lot, you might
10596 not want to be dependent on @url{orgmode.org} and prefer to install a local
10597 copy on your own web server.
10599 To use the script, you need to make sure that the @file{org-jsinfo.el} module
10600 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
10601 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
10602 this is indeed the case.  All it then takes to make use of the program is
10603 adding a single line to the Org file:
10605 @cindex #+INFOJS_OPT
10606 @example
10607 #+INFOJS_OPT: view:info toc:nil
10608 @end example
10610 @noindent
10611 If this line is found, the HTML header will automatically contain the code
10612 needed to invoke the script.  Using the line above, you can set the following
10613 viewing options:
10615 @example
10616 path:    @r{The path to the script.  The default is to grab the script from}
10617          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
10618          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
10619 view:    @r{Initial view when the website is first shown.  Possible values are:}
10620          info      @r{Info-like interface with one section per page.}
10621          overview  @r{Folding interface, initially showing only top-level.}
10622          content   @r{Folding interface, starting with all headlines visible.}
10623          showall   @r{Folding interface, all headlines and text visible.}
10624 sdepth:  @r{Maximum headline level that will still become an independent}
10625          @r{section for info and folding modes.  The default is taken from}
10626          @r{@code{org-export-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
10627          @r{If this is smaller than in @code{org-export-headline-levels}, each}
10628          @r{info/folding section can still contain child headlines.}
10629 toc:     @r{Should the table of contents @emph{initially} be visible?}
10630          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
10631 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
10632          @r{the variables @code{org-export-headline-levels} and @code{org-export-with-toc}.}
10633 ftoc:    @r{Does the CSS of the page specify a fixed position for the "toc"?}
10634          @r{If yes, the toc will never be displayed as a section.}
10635 ltoc:    @r{Should there be short contents (children) in each section?}
10636          @r{Make this @code{above} if the section should be above initial text.}
10637 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
10638          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
10639 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
10640          @r{default), only one such button will be present.}
10641 @end example
10642 @noindent
10643 @vindex org-html-infojs-options
10644 @vindex org-html-use-infojs
10645 You can choose default values for these options by customizing the variable
10646 @code{org-html-infojs-options}.  If you always want to apply the script to your
10647 pages, configure the variable @code{org-html-use-infojs}.
10649 @node @LaTeX{} and PDF export, OpenDocument Text export, HTML export, Exporting
10650 @section @LaTeX{} and PDF export
10651 @cindex @LaTeX{} export
10652 @cindex PDF export
10653 @cindex Guerry, Bastien
10655 Org mode contains a @LaTeX{} exporter.  With further processing@footnote{The
10656 default @LaTeX{} output is designed for processing with @code{pdftex} or
10657 @LaTeX{}.  It includes packages that are not compatible with @code{xetex} and
10658 possibly @code{luatex}.  See the variables
10659 @code{org-latex-default-packages-alist} and
10660 @code{org-latex-packages-alist}.}, this backend is also used to produce PDF
10661 output.  Since the @LaTeX{} output uses @file{hyperref} to implement links
10662 and cross references, the PDF output file will be fully linked.  Beware of
10663 the fact that your @code{org} file has to be properly structured in order to
10664 be correctly exported: respect the hierarchy of sections.
10666 @menu
10667 * @LaTeX{}/PDF export commands::
10668 * Header and sectioning::       Setting up the export file structure
10669 * Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
10670 * Tables in @LaTeX{} export::   Options for exporting tables to @LaTeX{}
10671 * Images in @LaTeX{} export::   How to insert figures into @LaTeX{} output
10672 * Beamer class export::         Turning the file into a presentation
10673 @end menu
10675 @node @LaTeX{}/PDF export commands, Header and sectioning, @LaTeX{} and PDF export, @LaTeX{} and PDF export
10676 @subsection @LaTeX{} export commands
10678 @cindex region, active
10679 @cindex active region
10680 @cindex transient-mark-mode
10681 @table @kbd
10682 @orgcmd{C-c C-e l,org-export-as-latex}
10683 @cindex property EXPORT_FILE_NAME
10684 Export as a @LaTeX{} file.  For an Org file
10685 @file{myfile.org}, the @LaTeX{} file will be @file{myfile.tex}.  The file will
10686 be overwritten without warning.  If there is an active region@footnote{This
10687 requires @code{transient-mark-mode} be turned on.}, only the region will be
10688 exported.  If the selected region is a single tree@footnote{To select the
10689 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
10690 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
10691 property, that name will be used for the export.
10692 @orgcmd{C-c C-e L,org-export-as-latex-to-buffer}
10693 Export to a temporary buffer.  Do not create a file.
10694 @item C-c C-e v l/L
10695 Export only the visible part of the document.
10696 @item M-x org-export-region-as-latex
10697 Convert the region to @LaTeX{} under the assumption that it was in Org mode
10698 syntax before.  This is a global command that can be invoked in any
10699 buffer.
10700 @item M-x org-replace-region-by-latex
10701 Replace the active region (assumed to be in Org mode syntax) by @LaTeX{}
10702 code.
10703 @orgcmd{C-c C-e p,org-export-as-pdf}
10704 Export as @LaTeX{} and then process to PDF.
10705 @orgcmd{C-c C-e d,org-export-as-pdf-and-open}
10706 Export as @LaTeX{} and then process to PDF, then open the resulting PDF file.
10707 @end table
10709 @cindex headline levels, for exporting
10710 @vindex org-latex-low-levels
10711 In the exported version, the first 3 outline levels will become
10712 headlines, defining a general document structure.  Additional levels
10713 will be exported as description lists.  The exporter can ignore them or
10714 convert them to a custom string depending on
10715 @code{org-latex-low-levels}.
10717 If you want that transition to occur at a different level, specify it
10718 with a numeric prefix argument.  For example,
10720 @example
10721 @kbd{C-2 C-c C-e l}
10722 @end example
10724 @noindent
10725 creates two levels of headings and does the rest as items.
10727 @node Header and sectioning, Quoting @LaTeX{} code, @LaTeX{}/PDF export commands, @LaTeX{} and PDF export
10728 @subsection Header and sectioning structure
10729 @cindex @LaTeX{} class
10730 @cindex @LaTeX{} sectioning structure
10731 @cindex @LaTeX{} header
10732 @cindex header, for @LaTeX{} files
10733 @cindex sectioning structure, for @LaTeX{} export
10735 By default, the @LaTeX{} output uses the class @code{article}.
10737 @vindex org-latex-default-class
10738 @vindex org-latex-classes
10739 @vindex org-latex-default-packages-alist
10740 @vindex org-latex-packages-alist
10741 @cindex #+LaTeX_HEADER
10742 @cindex #+LaTeX_CLASS
10743 @cindex #+LaTeX_CLASS_OPTIONS
10744 @cindex property, LaTeX_CLASS
10745 @cindex property, LaTeX_CLASS_OPTIONS
10746 You can change this globally by setting a different value for
10747 @code{org-latex-default-class} or locally by adding an option like
10748 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
10749 property that applies when exporting a region containing only this (sub)tree.
10750 The class must be listed in @code{org-latex-classes}.  This variable
10751 defines a header template for each class@footnote{Into which the values of
10752 @code{org-latex-default-packages-alist} and
10753 @code{org-latex-packages-alist} are spliced.}, and allows you to
10754 define the sectioning structure for each class.  You can also define your own
10755 classes there.  @code{#+LaTeX_CLASS_OPTIONS} or a @code{:LaTeX_CLASS_OPTIONS:}
10756 property can specify the options for the @code{\documentclass} macro.  The
10757 options to documentclass have to be provided, as expected by @LaTeX{}, within
10758 square brackets.  You can also use @code{#+LaTeX_HEADER: \usepackage@{xyz@}}
10759 to add lines to the header.  See the docstring of
10760 @code{org-latex-classes} for more information.  An example is shown
10761 below.
10763 @example
10764 #+LaTeX_CLASS: article
10765 #+LaTeX_CLASS_OPTIONS: [a4paper]
10766 #+LaTeX_HEADER: \usepackage@{xyz@}
10768 * Headline 1
10769   some text
10770 @end example
10772 @node Quoting @LaTeX{} code, Tables in @LaTeX{} export, Header and sectioning, @LaTeX{} and PDF export
10773 @subsection Quoting @LaTeX{} code
10775 Embedded @LaTeX{} as described in @ref{Embedded @LaTeX{}}, will be correctly
10776 inserted into the @LaTeX{} file.  This includes simple macros like
10777 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
10778 you can add special code that should only be present in @LaTeX{} export with
10779 the following constructs:
10781 @cindex #+LaTeX
10782 @cindex #+BEGIN_LaTeX
10783 @example
10784 #+LaTeX: Literal @LaTeX{} code for export
10785 @end example
10787 @noindent or
10788 @cindex #+BEGIN_LaTeX
10790 @example
10791 #+BEGIN_LaTeX
10792 All lines between these markers are exported literally
10793 #+END_LaTeX
10794 @end example
10797 @node Tables in @LaTeX{} export, Images in @LaTeX{} export, Quoting @LaTeX{} code, @LaTeX{} and PDF export
10798 @subsection Tables in @LaTeX{} export
10799 @cindex tables, in @LaTeX{} export
10801 For @LaTeX{} export of a table, you can specify a label, a caption and
10802 placement options (@pxref{Images and tables}).  You can also use the
10803 @code{ATTR_LaTeX} line to request a @code{longtable} environment for the
10804 table, so that it may span several pages, or to change the default table
10805 environment from @code{table} to @code{table*} or to change the default inner
10806 tabular environment to @code{tabularx} or @code{tabulary}.  Finally, you can
10807 set the alignment string, and (with @code{tabularx} or @code{tabulary}) the
10808 width:
10810 @cindex #+CAPTION
10811 @cindex #+LABEL
10812 @cindex #+ATTR_LaTeX
10813 @example
10814 #+CAPTION: A long table
10815 #+LABEL: tbl:long
10816 #+ATTR_LaTeX: longtable align=l|lp@{3cm@}r|l
10817 | ..... | ..... |
10818 | ..... | ..... |
10819 @end example
10821 or to specify a multicolumn table with @code{tabulary}
10823 @cindex #+CAPTION
10824 @cindex #+LABEL
10825 @cindex #+ATTR_LaTeX
10826 @example
10827 #+CAPTION: A wide table with tabulary
10828 #+LABEL: tbl:wide
10829 #+ATTR_LaTeX: table* tabulary width=\textwidth
10830 | ..... | ..... |
10831 | ..... | ..... |
10832 @end example
10834 @node Images in @LaTeX{} export, Beamer class export, Tables in @LaTeX{} export, @LaTeX{} and PDF export
10835 @subsection Images in @LaTeX{} export
10836 @cindex images, inline in @LaTeX{}
10837 @cindex inlining images in @LaTeX{}
10839 Images that are linked to without a description part in the link, like
10840 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
10841 output file resulting from @LaTeX{} processing.  Org will use an
10842 @code{\includegraphics} macro to insert the image.  If you have specified a
10843 caption and/or a label as described in @ref{Images and tables}, the figure
10844 will be wrapped into a @code{figure} environment and thus become a floating
10845 element.  You can use an @code{#+ATTR_LaTeX:} line to specify various other
10846 options.  You can ask org to export an image as a float without specifying
10847 a label or a caption by using the keyword @code{float} in this line.  Various
10848 optional arguments to the @code{\includegraphics} macro can also be specified
10849 in this fashion.  To modify the placement option of the floating environment,
10850 add something like @samp{placement=[h!]} to the attributes.  It is to be noted
10851 this option can be used with tables as well@footnote{One can also take
10852 advantage of this option to pass other, unrelated options into the figure or
10853 table environment.  For an example see the section ``Exporting org files'' in
10854 @url{http://orgmode.org/worg/org-hacks.html}}.
10856 If you would like to let text flow around the image, add the word @samp{wrap}
10857 to the @code{#+ATTR_LaTeX:} line, which will make the figure occupy the left
10858 half of the page.  To fine-tune, the @code{placement} field will be the set
10859 of additional arguments needed by the @code{wrapfigure} environment.  Note
10860 that if you change the size of the image, you need to use compatible settings
10861 for @code{\includegraphics} and @code{wrapfigure}.
10863 @cindex #+CAPTION
10864 @cindex #+LABEL
10865 @cindex #+ATTR_LaTeX
10866 @example
10867 #+CAPTION:    The black-body emission of the disk around HR 4049
10868 #+LABEL:      fig:SED-HR4049
10869 #+ATTR_LaTeX: width=5cm,angle=90
10870 [[./img/sed-hr4049.pdf]]
10872 #+ATTR_LaTeX: width=0.38\textwidth wrap placement=@{r@}@{0.4\textwidth@}
10873 [[./img/hst.png]]
10874 @end example
10876 If you wish to include an image which spans multiple columns in a page, you
10877 can use the keyword @code{multicolumn} in the @code{#+ATTR_LaTeX} line.  This
10878 will export the image wrapped in a @code{figure*} environment.
10880 If you need references to a label created in this way, write
10881 @samp{\ref@{fig:SED-HR4049@}} just like in @LaTeX{}.
10883 @node Beamer class export,  , Images in @LaTeX{} export, @LaTeX{} and PDF export
10884 @subsection Beamer class export
10886 The @LaTeX{} class @file{beamer} allows production of high quality presentations
10887 using @LaTeX{} and pdf processing.  Org mode has special support for turning an
10888 Org mode file or tree into a @file{beamer} presentation.
10890 When the @LaTeX{} class for the current buffer (as set with @code{#+LaTeX_CLASS:
10891 beamer}) or subtree (set with a @code{LaTeX_CLASS} property) is
10892 @code{beamer}, a special export mode will turn the file or tree into a beamer
10893 presentation.  Any tree with not-too-deep level nesting should in principle be
10894 exportable as a beamer presentation.  By default, the top-level entries (or
10895 the first level below the selected subtree heading) will be turned into
10896 frames, and the outline structure below this level will become itemize lists.
10897 You can also configure the variable @code{org-beamer-frame-level} to a
10898 different level---then the hierarchy above frames will produce the sectioning
10899 structure of the presentation.
10901 A template for useful in-buffer settings or properties can be inserted into
10902 the buffer with @kbd{M-x org-insert-beamer-options-template}.  Among other
10903 things, this will install a column view format which is very handy for
10904 editing special properties used by beamer.
10906 You can influence the structure of the presentation using the following
10907 properties:
10909 @table @code
10910 @item BEAMER_env
10911 The environment that should be used to format this entry.  Valid environments
10912 are defined in the constant @code{org-beamer-environments-default}, and you
10913 can define more in @code{org-beamer-environments-extra}.  If this property is
10914 set, the entry will also get a @code{:B_environment:} tag to make this
10915 visible.  This tag has no semantic meaning, it is only a visual aid.
10916 @item BEAMER_envargs
10917 The beamer-special arguments that should be used for the environment, like
10918 @code{[t]} or @code{[<+->]} of @code{<2-3>}.  If the @code{BEAMER_col}
10919 property is also set, something like @code{C[t]} can be added here as well to
10920 set an options argument for the implied @code{columns} environment.
10921 @code{c[t]} or @code{c<2->} will set an options for the implied @code{column}
10922 environment.
10923 @item BEAMER_col
10924 The width of a column that should start with this entry.  If this property is
10925 set, the entry will also get a @code{:BMCOL:} property to make this visible.
10926 Also this tag is only a visual aid.  When this is a plain number, it will be
10927 interpreted as a fraction of @code{\textwidth}.  Otherwise it will be assumed
10928 that you have specified the units, like @samp{3cm}.  The first such property
10929 in a frame will start a @code{columns} environment to surround the columns.
10930 This environment is closed when an entry has a @code{BEAMER_col} property
10931 with value 0 or 1, or automatically at the end of the frame.
10932 @item BEAMER_extra
10933 Additional commands that should be inserted after the environment has been
10934 opened.  For example, when creating a frame, this can be used to specify
10935 transitions.
10936 @end table
10938 Frames will automatically receive a @code{fragile} option if they contain
10939 source code that uses the verbatim environment.  Special @file{beamer}
10940 specific code can be inserted using @code{#+BEAMER:} and
10941 @code{#+BEGIN_BEAMER...#+END_BEAMER} constructs, similar to other export
10942 backends, but with the difference that @code{#+LaTeX:} stuff will be included
10943 in the presentation as well.
10945 Outline nodes with @code{BEAMER_env} property value @samp{note} or
10946 @samp{noteNH} will be formatted as beamer notes, i,e, they will be wrapped
10947 into @code{\note@{...@}}.  The former will include the heading as part of the
10948 note text, the latter will ignore the heading of that node.  To simplify note
10949 generation, it is actually enough to mark the note with a @emph{tag} (either
10950 @code{:B_note:} or @code{:B_noteNH:}) instead of creating the
10951 @code{BEAMER_env} property.
10953 You can turn on a special minor mode @code{org-beamer-mode} for editing
10954 support with
10956 @example
10957 #+STARTUP: beamer
10958 @end example
10960 @table @kbd
10961 @orgcmd{C-c C-b,org-beamer-select-environment}
10962 In @code{org-beamer-mode}, this key offers fast selection of a beamer
10963 environment or the @code{BEAMER_col} property.
10964 @end table
10966 Column view provides a great way to set the environment of a node and other
10967 important parameters.  Make sure you are using a COLUMN format that is geared
10968 toward this special purpose.  The command @kbd{M-x
10969 org-insert-beamer-options-template} defines such a format.
10971 Here is a simple example Org document that is intended for beamer export.
10973 @smallexample
10974 #+LaTeX_CLASS: beamer
10975 #+TITLE: Example Presentation
10976 #+AUTHOR: Carsten Dominik
10977 #+LaTeX_CLASS_OPTIONS: [presentation]
10978 #+BEAMER_FRAME_LEVEL: 2
10979 #+BEAMER_HEADER_EXTRA: \usetheme@{Madrid@}\usecolortheme@{default@}
10980 #+COLUMNS: %35ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Args) %4BEAMER_col(Col) %8BEAMER_extra(Ex)
10982 * This is the first structural section
10984 ** Frame 1 \\ with a subtitle
10985 *** Thanks to Eric Fraga                                      :BMCOL:B_block:
10986     :PROPERTIES:
10987     :BEAMER_env: block
10988     :BEAMER_envargs: C[t]
10989     :BEAMER_col: 0.5
10990     :END:
10991     for the first viable beamer setup in Org
10992 *** Thanks to everyone else                                   :BMCOL:B_block:
10993     :PROPERTIES:
10994     :BEAMER_col: 0.5
10995     :BEAMER_env: block
10996     :BEAMER_envargs: <2->
10997     :END:
10998     for contributing to the discussion
10999 **** This will be formatted as a beamer note                  :B_note:
11000 ** Frame 2 \\ where we will not use columns
11001 *** Request                                                   :B_block:
11002     Please test this stuff!
11003     :PROPERTIES:
11004     :BEAMER_env: block
11005     :END:
11006 @end smallexample
11008 For more information, see the documentation on Worg.
11010 @c begin opendocument
11012 @node OpenDocument Text export, iCalendar export, @LaTeX{} and PDF export, Exporting
11013 @section OpenDocument Text export
11014 @cindex ODT
11015 @cindex OpenDocument
11016 @cindex export, OpenDocument
11017 @cindex LibreOffice
11018 @cindex org-odt.el
11019 @cindex org-modules
11021 Org Mode@footnote{Versions 7.8 or later} supports export to OpenDocument Text
11022 (ODT) format using the @file{org-odt.el} module.  Documents created
11023 by this exporter use the @cite{OpenDocument-v1.2
11024 specification}@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
11025 Open Document Format for Office Applications (OpenDocument) Version 1.2}} and
11026 are compatible with LibreOffice 3.4.
11028 @menu
11029 * Pre-requisites for ODT export::  What packages ODT exporter relies on
11030 * ODT export commands::         How to invoke ODT export
11031 * Extending ODT export::        How to produce @samp{doc}, @samp{pdf} files
11032 * Applying custom styles::      How to apply custom styles to the output
11033 * Links in ODT export::         How links will be interpreted and formatted
11034 * Tables in ODT export::        How Tables are exported
11035 * Images in ODT export::        How to insert images
11036 * Math formatting in ODT export::  How @LaTeX{} fragments are formatted
11037 * Labels and captions in ODT export::  How captions are rendered
11038 * Literal examples in ODT export::  How source and example blocks are formatted
11039 * Advanced topics in ODT export::  Read this if you are a power user
11040 @end menu
11042 @node Pre-requisites for ODT export, ODT export commands, OpenDocument Text export, OpenDocument Text export
11043 @subsection Pre-requisites for ODT export
11044 @cindex zip
11045 The ODT exporter relies on the @file{zip} program to create the final
11046 output.  Check the availability of this program before proceeding further.
11048 @node ODT export commands, Extending ODT export, Pre-requisites for ODT export, OpenDocument Text export
11049 @subsection ODT export commands
11051 @subsubheading Exporting to ODT
11052 @anchor{x-export-to-odt}
11054 @cindex region, active
11055 @cindex active region
11056 @cindex transient-mark-mode
11057 @table @kbd
11058 @orgcmd{C-c C-e o,org-export-as-odt}
11059 @cindex property EXPORT_FILE_NAME
11061 Export as OpenDocument Text file.
11063 @vindex org-export-odt-preferred-output-format
11064 If @code{org-export-odt-preferred-output-format} is specified, automatically
11065 convert the exported file to that format.  @xref{x-export-to-other-formats, ,
11066 Automatically exporting to other formats}.
11068 For an Org file @file{myfile.org}, the ODT file will be
11069 @file{myfile.odt}.  The file will be overwritten without warning.  If there
11070 is an active region,@footnote{This requires @code{transient-mark-mode} to be
11071 turned on} only the region will be exported.  If the selected region is a
11072 single tree,@footnote{To select the current subtree, use @kbd{C-c @@}} the
11073 tree head will become the document title.  If the tree head entry has, or
11074 inherits, an @code{EXPORT_FILE_NAME} property, that name will be used for the
11075 export.
11077 @orgcmd{C-c C-e O,org-export-as-odt-and-open}
11078 Export as an OpenDocument Text file and open the resulting file.
11080 @vindex org-export-odt-preferred-output-format
11081 If @code{org-export-odt-preferred-output-format} is specified, open the
11082 converted file instead.  @xref{x-export-to-other-formats, , Automatically
11083 exporting to other formats}.
11084 @end table
11086 @node Extending ODT export, Applying custom styles, ODT export commands, OpenDocument Text export
11087 @subsection Extending ODT export
11089 The ODT exporter can interface with a variety of document
11090 converters and supports popular converters out of the box.  As a result, you
11091 can use it to export to formats like @samp{doc} or convert a document from
11092 one format (say @samp{csv}) to another format (say @samp{ods} or @samp{xls}).
11094 @cindex @file{unoconv}
11095 @cindex LibreOffice
11096 If you have a working installation of LibreOffice, a document converter is
11097 pre-configured for you and you can use it right away.  If you would like to
11098 use @file{unoconv} as your preferred converter, customize the variable
11099 @code{org-export-odt-convert-process} to point to @code{unoconv}.  You can
11100 also use your own favorite converter or tweak the default settings of the
11101 @file{LibreOffice} and @samp{unoconv} converters.  @xref{Configuring a
11102 document converter}.
11104 @subsubsection Automatically exporting to other formats
11105 @anchor{x-export-to-other-formats}
11107 @vindex org-export-odt-preferred-output-format
11108 Very often, you will find yourself exporting to ODT format, only to
11109 immediately save the exported document to other formats like @samp{doc},
11110 @samp{docx}, @samp{rtf}, @samp{pdf} etc.  In such cases, you can specify your
11111 preferred output format by customizing the variable
11112 @code{org-export-odt-preferred-output-format}.  This way, the export commands
11113 (@pxref{x-export-to-odt,,Exporting to ODT}) can be extended to export to a
11114 format that is of immediate interest to you.
11116 @subsubsection Converting between document formats
11117 @anchor{x-convert-to-other-formats}
11119 There are many document converters in the wild which support conversion to
11120 and from various file formats, including, but not limited to the
11121 ODT format.  LibreOffice converter, mentioned above, is one such
11122 converter.  Once a converter is configured, you can interact with it using
11123 the following command.
11125 @vindex org-export-odt-convert
11126 @table @kbd
11128 @item M-x org-export-odt-convert
11129 Convert an existing document from one format to another.  With a prefix
11130 argument, also open the newly produced file.
11131 @end table
11133 @node Applying custom styles, Links in ODT export, Extending ODT export, OpenDocument Text export
11134 @subsection Applying custom styles
11135 @cindex styles, custom
11136 @cindex template, custom
11138 The ODT exporter ships with a set of OpenDocument styles
11139 (@pxref{Working with OpenDocument style files}) that ensure a well-formatted
11140 output.  These factory styles, however, may not cater to your specific
11141 tastes.  To customize the output, you can either modify the above styles
11142 files directly, or generate the required styles using an application like
11143 LibreOffice.  The latter method is suitable for expert and non-expert
11144 users alike, and is described here.
11146 @subsubsection Applying custom styles: the easy way
11148 @enumerate
11149 @item
11150 Create a sample @file{example.org} file with the below settings and export it
11151 to ODT format.
11153 @example
11154 #+OPTIONS: H:10 num:t
11155 @end example
11157 @item
11158 Open the above @file{example.odt} using LibreOffice.  Use the @file{Stylist}
11159 to locate the target styles---these typically have the @samp{Org} prefix---and
11160 modify those to your taste.  Save the modified file either as an
11161 OpenDocument Text (@file{.odt}) or OpenDocument Template (@file{.ott}) file.
11163 @item
11164 @cindex #+ODT_STYLES_FILE
11165 @vindex org-export-odt-styles-file
11166 Customize the variable @code{org-export-odt-styles-file} and point it to the
11167 newly created file.  For additional configuration options
11168 @pxref{x-overriding-factory-styles,,Overriding factory styles}.
11170 If you would like to choose a style on a per-file basis, you can use the
11171 @code{#+ODT_STYLES_FILE} option.  A typical setting will look like
11173 @example
11174 #+ODT_STYLES_FILE: "/path/to/example.ott"
11175 @end example
11179 @example
11180 #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
11181 @end example
11183 @end enumerate
11185 @subsubsection Using third-party styles and templates
11187 You can use third-party styles and templates for customizing your output.
11188 This will produce the desired output only if the template provides all
11189 style names that the @samp{ODT} exporter relies on.  Unless this condition is
11190 met, the output is going to be less than satisfactory.  So it is highly
11191 recommended that you only work with templates that are directly derived from
11192 the factory settings.
11194 @node Links in ODT export, Tables in ODT export, Applying custom styles, OpenDocument Text export
11195 @subsection Links in ODT export
11196 @cindex links, in ODT export
11198 ODT exporter creates native cross-references for internal links.  It creates
11199 Internet-style links for all other links.
11201 A link with no description and destined to a regular (un-itemized) outline
11202 heading is replaced with a cross-reference and section number of the heading.
11204 A @samp{\ref@{label@}}-style reference to an image, table etc. is replaced
11205 with a cross-reference and sequence number of the labeled entity.
11206 @xref{Labels and captions in ODT export}.
11208 @node Tables in ODT export, Images in ODT export, Links in ODT export, OpenDocument Text export
11209 @subsection Tables in ODT export
11210 @cindex tables, in ODT export
11212 Export of native Org mode tables (@pxref{Tables}) and simple @file{table.el}
11213 tables is supported.  However, export of complex @file{table.el} tables---tables
11214 that have column or row spans---is not supported.  Such tables are
11215 stripped from the exported document.
11217 By default, a table is exported with top and bottom frames and with rules
11218 separating row and column groups (@pxref{Column groups}).  Furthermore, all
11219 tables are typeset to occupy the same width.  If the table specifies
11220 alignment and relative width for its columns (@pxref{Column width and
11221 alignment}) then these are honored on export.@footnote{The column widths are
11222 interpreted as weighted ratios with the default weight being 1}
11224 @cindex #+ATTR_ODT
11225 You can control the width of the table by specifying @code{:rel-width}
11226 property using an @code{#+ATTR_ODT} line.
11228 For example, consider the following table which makes use of all the rules
11229 mentioned above.
11231 @example
11232 #+ATTR_ODT: :rel-width 50
11233 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
11234 |---------------+-------+-------+-------+-------|
11235 | /             |     < |       |       |     < |
11236 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
11237 | North America |     1 |    21 |   926 |   948 |
11238 | Middle East   |     6 |    75 |   844 |   925 |
11239 | Asia Pacific  |     9 |    27 |   790 |   826 |
11240 |---------------+-------+-------+-------+-------|
11241 | Sum           |    16 |   123 |  2560 |  2699 |
11242 @end example
11244 On export, the table will occupy 50% of text area.  The columns will be sized
11245 (roughly) in the ratio of 13:5:5:5:6.  The first column will be left-aligned
11246 and rest of the columns will be right-aligned.  There will be vertical rules
11247 after separating the header and last columns from other columns.  There will
11248 be horizontal rules separating the header and last rows from other rows.
11250 If you are not satisfied with the above formatting options, you can create
11251 custom table styles and associate them with a table using the
11252 @code{#+ATTR_ODT} line.  @xref{Customizing tables in ODT export}.
11254 @node Images in ODT export, Math formatting in ODT export, Tables in ODT export, OpenDocument Text export
11255 @subsection Images in ODT export
11256 @cindex images, embedding in ODT
11257 @cindex embedding images in ODT
11259 @subsubheading Embedding images
11260 You can embed images within the exported document by providing a link to the
11261 desired image file with no link description.  For example, to embed
11262 @samp{img.png} do either of the following:
11264 @example
11265 [[file:img.png]]
11266 @end example
11268 @example
11269 [[./img.png]]
11270 @end example
11272 @subsubheading Embedding clickable images
11273 You can create clickable images by providing a link whose description is a
11274 link to an image file.  For example, to embed a image
11275 @file{org-mode-unicorn.png} which when clicked jumps to
11276 @uref{http://Orgmode.org} website, do the following
11278 @example
11279 [[http://orgmode.org][./org-mode-unicorn.png]]
11280 @end example
11282 @subsubheading Sizing and scaling of embedded images
11284 @cindex #+ATTR_ODT
11285 You can control the size and scale of the embedded images using the
11286 @code{#+ATTR_ODT} attribute.
11288 @cindex identify, ImageMagick
11289 @vindex org-export-odt-pixels-per-inch
11290 The exporter specifies the desired size of the image in the final document in
11291 units of centimeters.  In order to scale the embedded images, the exporter
11292 queries for pixel dimensions of the images using one of a) ImageMagick's
11293 @file{identify} program or b) Emacs `create-image' and `image-size'
11294 APIs.@footnote{Use of @file{ImageMagick} is only desirable.  However, if you
11295 routinely produce documents that have large images or you export your Org
11296 files that has images using a Emacs batch script, then the use of
11297 @file{ImageMagick} is mandatory.} The pixel dimensions are subsequently
11298 converted in to units of centimeters using
11299 @code{org-export-odt-pixels-per-inch}.  The default value of this variable is
11300 set to @code{display-pixels-per-inch}.  You can tweak this variable to
11301 achieve the best results.
11303 The examples below illustrate the various possibilities.
11305 @table @asis
11306 @item Explicitly size the image
11307 To embed @file{img.png} as a 10 cm x 10 cm image, do the following:
11309 @example
11310 #+ATTR_ODT: :width 10 :height 10
11311 [[./img.png]]
11312 @end example
11314 @item Scale the image
11315 To embed @file{img.png} at half its size, do the following:
11317 @example
11318 #+ATTR_ODT: :scale 0.5
11319 [[./img.png]]
11320 @end example
11322 @item Scale the image to a specific width
11323 To embed @file{img.png} with a width of 10 cm while retaining the original
11324 height:width ratio, do the following:
11326 @example
11327 #+ATTR_ODT: :width 10
11328 [[./img.png]]
11329 @end example
11331 @item Scale the image to a specific height
11332 To embed @file{img.png} with a height of 10 cm while retaining the original
11333 height:width ratio, do the following
11335 @example
11336 #+ATTR_ODT: :height 10
11337 [[./img.png]]
11338 @end example
11339 @end table
11341 @subsubheading Anchoring of images
11343 @cindex #+ATTR_ODT
11344 You can control the manner in which an image is anchored by setting the
11345 @code{:anchor} property of it's @code{#+ATTR_ODT} line.  You can specify one
11346 of the the following three values for the @code{:anchor} property:
11347 @samp{"as-char"}, @samp{"paragraph"} and @samp{"page"}.
11349 To create an image that is anchored to a page, do the following:
11350 @example
11351 #+ATTR_ODT: :anchor "page"
11352 [[./img.png]]
11353 @end example
11355 @node Math formatting in ODT export, Labels and captions in ODT export, Images in ODT export, OpenDocument Text export
11356 @subsection Math formatting in ODT export
11358 The ODT exporter has special support for handling math.
11360 @menu
11361 * Working with @LaTeX{} math snippets::  How to embed @LaTeX{} math fragments
11362 * Working with MathML or OpenDocument formula files::  How to embed equations in native format
11363 @end menu
11365 @node Working with @LaTeX{} math snippets, Working with MathML or OpenDocument formula files, Math formatting in ODT export, Math formatting in ODT export
11366 @subsubsection Working with @LaTeX{} math snippets
11368 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be embedded in the ODT
11369 document in one of the following ways:
11371 @cindex MathML
11372 @enumerate
11373 @item MathML
11375 This option is activated on a per-file basis with
11377 @example
11378 #+OPTIONS: LaTeX:t
11379 @end example
11381 With this option, @LaTeX{} fragments are first converted into MathML
11382 fragments using an external @LaTeX{}-to-MathML converter program.  The
11383 resulting MathML fragments are then embedded as an OpenDocument Formula in
11384 the exported document.
11386 @vindex org-latex-to-mathml-convert-command
11387 @vindex org-latex-to-mathml-jar-file
11389 You can specify the @LaTeX{}-to-MathML converter by customizing the variables
11390 @code{org-latex-to-mathml-convert-command} and
11391 @code{org-latex-to-mathml-jar-file}.
11393 If you prefer to use @file{MathToWeb}@footnote{See
11394 @uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}} as your
11395 converter, you can configure the above variables as shown below.
11397 @lisp
11398 (setq org-latex-to-mathml-convert-command
11399       "java -jar %j -unicode -force -df %o %I"
11400       org-latex-to-mathml-jar-file
11401       "/path/to/mathtoweb.jar")
11402 @end lisp
11404 You can use the following commands to quickly verify the reliability of
11405 the @LaTeX{}-to-MathML converter.
11407 @table @kbd
11408 @item M-x org-export-as-odf
11409 Convert a @LaTeX{} math snippet to an OpenDocument formula (@file{.odf}) file.
11411 @item M-x org-export-as-odf-and-open
11412 Convert a @LaTeX{} math snippet to an OpenDocument formula (@file{.odf}) file
11413 and open the formula file with the system-registered application.
11414 @end table
11416 @cindex dvipng
11417 @item PNG images
11419 This option is activated on a per-file basis with
11421 @example
11422 #+OPTIONS: LaTeX:dvipng
11423 @end example
11425 With this option, @LaTeX{} fragments are processed into PNG images and the
11426 resulting images are embedded in the exported document.  This method requires
11427 that the @file{dvipng} program be available on your system.
11428 @end enumerate
11430 @node Working with MathML or OpenDocument formula files,  , Working with @LaTeX{} math snippets, Math formatting in ODT export
11431 @subsubsection Working with MathML or OpenDocument formula files
11433 For various reasons, you may find embedding @LaTeX{} math snippets in an
11434 ODT document less than reliable.  In that case, you can embed a
11435 math equation by linking to its MathML (@file{.mml}) source or its
11436 OpenDocument formula (@file{.odf}) file as shown below:
11438 @example
11439 [[./equation.mml]]
11440 @end example
11444 @example
11445 [[./equation.odf]]
11446 @end example
11448 @node Labels and captions in ODT export, Literal examples in ODT export, Math formatting in ODT export, OpenDocument Text export
11449 @subsection Labels and captions in ODT export
11451 You can label and caption various category of objects---an inline image, a
11452 table, a @LaTeX{} fragment or a Math formula---using @code{#+LABEL} and
11453 @code{#+CAPTION} lines.  @xref{Images and tables}.  ODT exporter enumerates
11454 each labeled or captioned object of a given category separately.  As a
11455 result, each such object is assigned a sequence number based on order of it's
11456 appearance in the Org file.
11458 In the exported document, a user-provided caption is augmented with the
11459 category and sequence number.  Consider the following inline image in an Org
11460 file.
11462 @example
11463 #+CAPTION: Bell curve
11464 #+LABEL:   fig:SED-HR4049
11465 [[./img/a.png]]
11466 @end example
11468 It could be rendered as shown below in the exported document.
11470 @example
11471 Figure 2: Bell curve
11472 @end example
11474 @vindex org-export-odt-category-strings
11475 You can modify the category component of the caption by customizing the
11476 variable @code{org-export-odt-category-strings}.  For example, to tag all
11477 embedded images with the string @samp{Illustration} (instead of the default
11478 @samp{Figure}) use the following setting.
11480 @lisp
11481 (setq org-export-odt-category-strings
11482       '(("en" "Table" "Illustration" "Equation" "Equation")))
11483 @end lisp
11485 With this, previous image will be captioned as below in the exported
11486 document.
11488 @example
11489 Illustration 2: Bell curve
11490 @end example
11492 @node Literal examples in ODT export, Advanced topics in ODT export, Labels and captions in ODT export, OpenDocument Text export
11493 @subsection Literal examples in ODT export
11495 Export of literal examples (@pxref{Literal examples}) with full fontification
11496 is supported.  Internally, the exporter relies on @file{htmlfontify.el} to
11497 generate all style definitions needed for a fancy listing.@footnote{Your
11498 @file{htmlfontify.el} library must at least be at Emacs 24.1 levels for
11499 fontification to be turned on.}  The auto-generated styles have @samp{OrgSrc}
11500 as prefix and inherit their color from the faces used by Emacs
11501 @code{font-lock} library for the source language.
11503 @vindex org-export-odt-fontify-srcblocks
11504 If you prefer to use your own custom styles for fontification, you can do so
11505 by customizing the variable
11506 @code{org-export-odt-create-custom-styles-for-srcblocks}.
11508 @vindex org-export-odt-create-custom-styles-for-srcblocks
11509 You can turn off fontification of literal examples by customizing the
11510 variable @code{org-export-odt-fontify-srcblocks}.
11512 @node Advanced topics in ODT export,  , Literal examples in ODT export, OpenDocument Text export
11513 @subsection Advanced topics in ODT export
11515 If you rely heavily on ODT export, you may want to exploit the full
11516 set of features that the exporter offers.  This section describes features
11517 that would be of interest to power users.
11519 @menu
11520 * Configuring a document converter::  How to register a document converter
11521 * Working with OpenDocument style files::  Explore the internals
11522 * Creating one-off styles::     How to produce custom highlighting etc
11523 * Customizing tables in ODT export::  How to define and use Table templates
11524 * Validating OpenDocument XML::  How to debug corrupt OpenDocument files
11525 @end menu
11527 @node Configuring a document converter, Working with OpenDocument style files, Advanced topics in ODT export, Advanced topics in ODT export
11528 @subsubsection Configuring a document converter
11529 @cindex convert
11530 @cindex doc, docx, rtf
11531 @cindex converter
11533 The ODT exporter can work with popular converters with little or no
11534 extra configuration from your side. @xref{Extending ODT export}.
11535 If you are using a converter that is not supported by default or if you would
11536 like to tweak the default converter settings, proceed as below.
11538 @enumerate
11539 @item Register the converter
11541 @vindex org-export-odt-convert-processes
11542 Name your converter and add it to the list of known converters by customizing
11543 the variable @code{org-export-odt-convert-processes}.  Also specify how the
11544 converter can be invoked via command-line to effect the conversion.
11546 @item Configure its capabilities
11548 @vindex org-export-odt-convert-capabilities
11549 @anchor{x-odt-converter-capabilities}
11550 Specify the set of formats the converter can handle by customizing the
11551 variable @code{org-export-odt-convert-capabilities}.  Use the default value
11552 for this variable as a guide for configuring your converter.  As suggested by
11553 the default setting, you can specify the full set of formats supported by the
11554 converter and not limit yourself to specifying formats that are related to
11555 just the OpenDocument Text format.
11557 @item Choose the converter
11559 @vindex org-export-odt-convert-process
11560 Select the newly added converter as the preferred one by customizing the
11561 variable @code{org-export-odt-convert-process}.
11562 @end enumerate
11564 @node Working with OpenDocument style files, Creating one-off styles, Configuring a document converter, Advanced topics in ODT export
11565 @subsubsection Working with OpenDocument style files
11566 @cindex styles, custom
11567 @cindex template, custom
11569 This section explores the internals of the ODT exporter and the
11570 means by which it produces styled documents.  Read this section if you are
11571 interested in exploring the automatic and custom OpenDocument styles used by
11572 the exporter.
11574 @anchor{x-factory-styles}
11575 @subsubheading Factory styles
11577 The ODT exporter relies on two files for generating its output.
11578 These files are bundled with the distribution under the directory pointed to
11579 by the variable @code{org-odt-styles-dir}.  The two files are:
11581 @itemize
11582 @anchor{x-orgodtstyles-xml}
11583 @item
11584 @file{OrgOdtStyles.xml}
11586 This file contributes to the @file{styles.xml} file of the final @samp{ODT}
11587 document.  This file gets modified for the following purposes:
11588 @enumerate
11590 @item
11591 To control outline numbering based on user settings.
11593 @item
11594 To add styles generated by @file{htmlfontify.el} for fontification of code
11595 blocks.
11596 @end enumerate
11598 @anchor{x-orgodtcontenttemplate-xml}
11599 @item
11600 @file{OrgOdtContentTemplate.xml}
11602 This file contributes to the @file{content.xml} file of the final @samp{ODT}
11603 document.  The contents of the Org outline are inserted between the
11604 @samp{<office:text>}@dots{}@samp{</office:text>} elements of this file.
11606 Apart from serving as a template file for the final @file{content.xml}, the
11607 file serves the following purposes:
11608 @enumerate
11610 @item
11611 It contains automatic styles for formatting of tables which are referenced by
11612 the exporter.
11614 @item
11615 It contains @samp{<text:sequence-decl>}@dots{}@samp{</text:sequence-decl>}
11616 elements that control how various entities---tables, images, equations,
11617 etc.---are numbered.
11618 @end enumerate
11619 @end itemize
11621 @anchor{x-overriding-factory-styles}
11622 @subsubheading Overriding factory styles
11623 The following two variables control the location from which the ODT
11624 exporter picks up the custom styles and content template files.  You can
11625 customize these variables to override the factory styles used by the
11626 exporter.
11628 @itemize
11629 @anchor{x-org-export-odt-styles-file}
11630 @item
11631 @code{org-export-odt-styles-file}
11633 Use this variable to specify the @file{styles.xml} that will be used in the
11634 final output.  You can specify one of the following values:
11636 @enumerate
11637 @item A @file{styles.xml} file
11639 Use this file instead of the default @file{styles.xml}
11641 @item A @file{.odt} or @file{.ott} file
11643 Use the @file{styles.xml} contained in the specified OpenDocument Text or
11644 Template file
11646 @item A @file{.odt} or @file{.ott} file and a subset of files contained within them
11648 Use the @file{styles.xml} contained in the specified OpenDocument Text or
11649 Template file.  Additionally extract the specified member files and embed
11650 those within the final @samp{ODT} document.
11652 Use this option if the @file{styles.xml} file references additional files
11653 like header and footer images.
11655 @item @code{nil}
11657 Use the default @file{styles.xml}
11658 @end enumerate
11660 @anchor{x-org-export-odt-content-template-file}
11661 @item
11662 @code{org-export-odt-content-template-file}
11664 Use this variable to specify the blank @file{content.xml} that will be used
11665 in the final output.
11666 @end itemize
11668 @node Creating one-off styles, Customizing tables in ODT export, Working with OpenDocument style files, Advanced topics in ODT export
11669 @subsubsection Creating one-off styles
11671 There are times when you would want one-off formatting in the exported
11672 document.  You can achieve this by embedding raw OpenDocument XML in the Org
11673 file.  The use of this feature is better illustrated with couple of examples.
11675 @enumerate
11676 @item Embedding ODT tags as part of regular text
11678 You can include simple OpenDocument tags by prefixing them with
11679 @samp{@@}.  For example, to highlight a region of text do the following:
11681 @example
11682 @@<text:span text:style-name="Highlight">This is a
11683 highlighted text@@</text:span>.  But this is a
11684 regular text.
11685 @end example
11687 @strong{Hint:} To see the above example in action, edit your
11688 @file{styles.xml} (@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
11689 custom @samp{Highlight} style as shown below.
11691 @example
11692 <style:style style:name="Highlight" style:family="text">
11693   <style:text-properties fo:background-color="#ff0000"/>
11694 </style:style>
11695 @end example
11697 @item Embedding a one-line OpenDocument XML
11699 You can add a simple OpenDocument one-liner using the @code{#+ODT:}
11700 directive.  For example, to force a page break do the following:
11702 @example
11703 #+ODT: <text:p text:style-name="PageBreak"/>
11704 @end example
11706 @strong{Hint:} To see the above example in action, edit your
11707 @file{styles.xml} (@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
11708 custom @samp{PageBreak} style as shown below.
11710 @example
11711 <style:style style:name="PageBreak" style:family="paragraph"
11712              style:parent-style-name="Text_20_body">
11713   <style:paragraph-properties fo:break-before="page"/>
11714 </style:style>
11715 @end example
11717 @item Embedding a block of OpenDocument XML
11719 You can add a large block of OpenDocument XML using the
11720 @code{#+BEGIN_ODT}@dots{}@code{#+END_ODT} construct.
11722 For example, to create a one-off paragraph that uses bold text, do the
11723 following:
11725 @example
11726 #+BEGIN_ODT
11727 <text:p text:style-name="Text_20_body_20_bold">
11728 This paragraph is specially formatted and uses bold text.
11729 </text:p>
11730 #+END_ODT
11731 @end example
11733 @end enumerate
11735 @node Customizing tables in ODT export, Validating OpenDocument XML, Creating one-off styles, Advanced topics in ODT export
11736 @subsubsection Customizing tables in ODT export
11737 @cindex tables, in ODT export
11739 @cindex #+ATTR_ODT
11740 You can override the default formatting of the table by specifying a custom
11741 table style with the @code{#+ATTR_ODT} line.  For a discussion on default
11742 formatting of tables @pxref{Tables in ODT export}.
11744 This feature closely mimics the way table templates are defined in the
11745 OpenDocument-v1.2
11746 specification.@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
11747 OpenDocument-v1.2 Specification}}
11751 @subsubheading Custom table styles: an illustration
11753 To have a quick preview of this feature, install the below setting and export
11754 the table that follows.
11756 @lisp
11757 (setq org-export-odt-table-styles
11758       (append org-export-odt-table-styles
11759               '(("TableWithHeaderRowAndColumn" "Custom"
11760                  ((use-first-row-styles . t)
11761                   (use-first-column-styles . t)))
11762                 ("TableWithFirstRowandLastRow" "Custom"
11763                  ((use-first-row-styles . t)
11764                   (use-last-row-styles . t))))))
11765 @end lisp
11767 @example
11768 #+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
11769 | Name  | Phone | Age |
11770 | Peter |  1234 |  17 |
11771 | Anna  |  4321 |  25 |
11772 @end example
11774 In the above example, you used a template named @samp{Custom} and installed
11775 two table styles with the names @samp{TableWithHeaderRowAndColumn} and
11776 @samp{TableWithFirstRowandLastRow}.  (@strong{Important:} The OpenDocument
11777 styles needed for producing the above template have been pre-defined for you.
11778 These styles are available under the section marked @samp{Custom Table
11779 Template} in @file{OrgOdtContentTemplate.xml}
11780 (@pxref{x-orgodtcontenttemplate-xml,,Factory styles}).  If you need
11781 additional templates you have to define these styles yourselves.
11783 @subsubheading Custom table styles: the nitty-gritty
11784 To use this feature proceed as follows:
11786 @enumerate
11787 @item
11788 Create a table template@footnote{See the @code{<table:table-template>}
11789 element of the OpenDocument-v1.2 specification}
11791 A table template is nothing but a set of @samp{table-cell} and
11792 @samp{paragraph} styles for each of the following table cell categories:
11794 @itemize @minus
11795 @item Body
11796 @item First column
11797 @item Last column
11798 @item First row
11799 @item Last row
11800 @item Even row
11801 @item Odd row
11802 @item Even column
11803 @item Odd Column
11804 @end itemize
11806 The names for the above styles must be chosen based on the name of the table
11807 template using a well-defined convention.
11809 The naming convention is better illustrated with an example.  For a table
11810 template with the name @samp{Custom}, the needed style names are listed in
11811 the following table.
11813 @multitable  {Table cell type} {CustomEvenColumnTableCell} {CustomEvenColumnTableParagraph}
11814 @headitem Table cell type
11815 @tab @code{table-cell} style
11816 @tab @code{paragraph} style
11817 @item
11818 @tab
11819 @tab
11820 @item Body
11821 @tab @samp{CustomTableCell}
11822 @tab @samp{CustomTableParagraph}
11823 @item First column
11824 @tab @samp{CustomFirstColumnTableCell}
11825 @tab @samp{CustomFirstColumnTableParagraph}
11826 @item Last column
11827 @tab @samp{CustomLastColumnTableCell}
11828 @tab @samp{CustomLastColumnTableParagraph}
11829 @item First row
11830 @tab @samp{CustomFirstRowTableCell}
11831 @tab @samp{CustomFirstRowTableParagraph}
11832 @item Last row
11833 @tab @samp{CustomLastRowTableCell}
11834 @tab @samp{CustomLastRowTableParagraph}
11835 @item Even row
11836 @tab @samp{CustomEvenRowTableCell}
11837 @tab @samp{CustomEvenRowTableParagraph}
11838 @item Odd row
11839 @tab @samp{CustomOddRowTableCell}
11840 @tab @samp{CustomOddRowTableParagraph}
11841 @item Even column
11842 @tab @samp{CustomEvenColumnTableCell}
11843 @tab @samp{CustomEvenColumnTableParagraph}
11844 @item Odd column
11845 @tab @samp{CustomOddColumnTableCell}
11846 @tab @samp{CustomOddColumnTableParagraph}
11847 @end multitable
11849 To create a table template with the name @samp{Custom}, define the above
11850 styles in the
11851 @code{<office:automatic-styles>}...@code{</office:automatic-styles>} element
11852 of the content template file (@pxref{x-orgodtcontenttemplate-xml,,Factory
11853 styles}).
11855 @item
11856 Define a table style@footnote{See the attributes @code{table:template-name},
11857 @code{table:use-first-row-styles}, @code{table:use-last-row-styles},
11858 @code{table:use-first-column-styles}, @code{table:use-last-column-styles},
11859 @code{table:use-banding-rows-styles}, and
11860 @code{table:use-banding-column-styles} of the @code{<table:table>} element in
11861 the OpenDocument-v1.2 specification}
11863 @vindex org-export-odt-table-styles
11864 To define a table style, create an entry for the style in the variable
11865 @code{org-export-odt-table-styles} and specify the following:
11867 @itemize @minus
11868 @item the name of the table template created in step (1)
11869 @item the set of cell styles in that template that are to be activated
11870 @end itemize
11872 For example, the entry below defines two different table styles
11873 @samp{TableWithHeaderRowAndColumn} and @samp{TableWithFirstRowandLastRow}
11874 based on the same template @samp{Custom}.  The styles achieve their intended
11875 effect by selectively activating the individual cell styles in that template.
11877 @lisp
11878 (setq org-export-odt-table-styles
11879       (append org-export-odt-table-styles
11880               '(("TableWithHeaderRowAndColumn" "Custom"
11881                  ((use-first-row-styles . t)
11882                   (use-first-column-styles . t)))
11883                 ("TableWithFirstRowandLastRow" "Custom"
11884                  ((use-first-row-styles . t)
11885                   (use-last-row-styles . t))))))
11886 @end lisp
11888 @item
11889 Associate a table with the table style
11891 To do this, specify the table style created in step (2) as part of
11892 the @code{ATTR_ODT} line as shown below.
11894 @example
11895 #+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
11896 | Name  | Phone | Age |
11897 | Peter |  1234 |  17 |
11898 | Anna  |  4321 |  25 |
11899 @end example
11900 @end enumerate
11902 @node Validating OpenDocument XML,  , Customizing tables in ODT export, Advanced topics in ODT export
11903 @subsubsection Validating OpenDocument XML
11905 Occasionally, you will discover that the document created by the
11906 ODT exporter cannot be opened by your favorite application.  One of
11907 the common reasons for this is that the @file{.odt} file is corrupt.  In such
11908 cases, you may want to validate the document against the OpenDocument RELAX
11909 NG Compact Syntax (RNC) schema.
11911 For de-compressing the @file{.odt} file@footnote{@file{.odt} files are
11912 nothing but @samp{zip} archives}: @inforef{File Archives,,emacs}.  For
11913 general help with validation (and schema-sensitive editing) of XML files:
11914 @inforef{Introduction,,nxml-mode}.
11916 @vindex org-export-odt-schema-dir
11917 If you have ready access to OpenDocument @file{.rnc} files and the needed
11918 schema-locating rules in a single folder, you can customize the variable
11919 @code{org-export-odt-schema-dir} to point to that directory.  The
11920 ODT exporter will take care of updating the
11921 @code{rng-schema-locating-files} for you.
11923 @c end opendocument
11925 @node iCalendar export,  , OpenDocument Text export, Exporting
11926 @section iCalendar export
11927 @cindex iCalendar export
11929 @vindex org-icalendar-include-todo
11930 @vindex org-icalendar-use-deadline
11931 @vindex org-icalendar-use-scheduled
11932 @vindex org-icalendar-categories
11933 @vindex org-icalendar-alarm-time
11934 Some people use Org mode for keeping track of projects, but still prefer a
11935 standard calendar application for anniversaries and appointments.  In this
11936 case it can be useful to show deadlines and other time-stamped items in Org
11937 files in the calendar application.  Org mode can export calendar information
11938 in the standard iCalendar format.  If you also want to have TODO entries
11939 included in the export, configure the variable
11940 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
11941 and TODO items as VTODO@.  It will also create events from deadlines that are
11942 in non-TODO items.  Deadlines and scheduling dates in TODO items will be used
11943 to set the start and due dates for the TODO entry@footnote{See the variables
11944 @code{org-icalendar-use-deadline} and @code{org-icalendar-use-scheduled}.}.
11945 As categories, it will use the tags locally defined in the heading, and the
11946 file/tree category@footnote{To add inherited tags or the TODO state,
11947 configure the variable @code{org-icalendar-categories}.}.  See the variable
11948 @code{org-icalendar-alarm-time} for a way to assign alarms to entries with a
11949 time.
11951 @vindex org-icalendar-store-UID
11952 @cindex property, ID
11953 The iCalendar standard requires each entry to have a globally unique
11954 identifier (UID).  Org creates these identifiers during export.  If you set
11955 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
11956 @code{:ID:} property of the entry and re-used next time you report this
11957 entry.  Since a single entry can give rise to multiple iCalendar entries (as
11958 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
11959 prefixes to the UID, depending on what triggered the inclusion of the entry.
11960 In this way the UID remains unique, but a synchronization program can still
11961 figure out from which entry all the different instances originate.
11963 @table @kbd
11964 @orgcmd{C-c C-e i,org-export-icalendar-this-file}
11965 Create iCalendar entries for the current file and store them in the same
11966 directory, using a file extension @file{.ics}.
11967 @orgcmd{C-c C-e I, org-export-icalendar-all-agenda-files}
11968 @vindex org-agenda-files
11969 Like @kbd{C-c C-e i}, but do this for all files in
11970 @code{org-agenda-files}.  For each of these files, a separate iCalendar
11971 file will be written.
11972 @orgcmd{C-c C-e c,org-export-icalendar-combine-agenda-files}
11973 @vindex org-combined-agenda-icalendar-file
11974 Create a single large iCalendar file from all files in
11975 @code{org-agenda-files} and write it to the file given by
11976 @code{org-combined-agenda-icalendar-file}.
11977 @end table
11979 @vindex org-use-property-inheritance
11980 @vindex org-icalendar-include-body
11981 @cindex property, SUMMARY
11982 @cindex property, DESCRIPTION
11983 @cindex property, LOCATION
11984 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
11985 property can be inherited from higher in the hierarchy if you configure
11986 @code{org-use-property-inheritance} accordingly.} properties if the selected
11987 entries have them.  If not, the summary will be derived from the headline,
11988 and the description from the body (limited to
11989 @code{org-icalendar-include-body} characters).
11991 How this calendar is best read and updated, depends on the application
11992 you are using.  The FAQ covers this issue.
11994 @node Publishing, Working With Source Code, Exporting, Top
11995 @chapter Publishing
11996 @cindex publishing
11998 Org includes a publishing management system that allows you to configure
11999 automatic HTML conversion of @emph{projects} composed of interlinked org
12000 files.  You can also configure Org to automatically upload your exported HTML
12001 pages and related attachments, such as images and source code files, to a web
12002 server.
12004 You can also use Org to convert files into PDF, or even combine HTML and PDF
12005 conversion so that files are available in both formats on the server.
12007 Publishing has been contributed to Org by David O'Toole.
12009 @menu
12010 * Configuration::               Defining projects
12011 * Uploading files::             How to get files up on the server
12012 * Sample configuration::        Example projects
12013 * Triggering publication::      Publication commands
12014 @end menu
12016 @node Configuration, Uploading files, Publishing, Publishing
12017 @section Configuration
12019 Publishing needs significant configuration to specify files, destination
12020 and many other properties of a project.
12022 @menu
12023 * Project alist::               The central configuration variable
12024 * Sources and destinations::    From here to there
12025 * Selecting files::             What files are part of the project?
12026 * Publishing action::           Setting the function doing the publishing
12027 * Publishing options::          Tweaking HTML/@LaTeX{} export
12028 * Publishing links::            Which links keep working after publishing?
12029 * Sitemap::                     Generating a list of all pages
12030 * Generating an index::         An index that reaches across pages
12031 @end menu
12033 @node Project alist, Sources and destinations, Configuration, Configuration
12034 @subsection The variable @code{org-publish-project-alist}
12035 @cindex org-publish-project-alist
12036 @cindex projects, for publishing
12038 @vindex org-publish-project-alist
12039 Publishing is configured almost entirely through setting the value of one
12040 variable, called @code{org-publish-project-alist}.  Each element of the list
12041 configures one project, and may be in one of the two following forms:
12043 @lisp
12044    ("project-name" :property value :property value ...)
12045      @r{i.e., a well-formed property list with alternating keys and values}
12046 @r{or}
12047    ("project-name" :components ("project-name" "project-name" ...))
12049 @end lisp
12051 In both cases, projects are configured by specifying property values.  A
12052 project defines the set of files that will be published, as well as the
12053 publishing configuration to use when publishing those files.  When a project
12054 takes the second form listed above, the individual members of the
12055 @code{:components} property are taken to be sub-projects, which group
12056 together files requiring different publishing options.  When you publish such
12057 a ``meta-project'', all the components will also be published, in the
12058 sequence given.
12060 @node Sources and destinations, Selecting files, Project alist, Configuration
12061 @subsection Sources and destinations for files
12062 @cindex directories, for publishing
12064 Most properties are optional, but some should always be set.  In
12065 particular, Org needs to know where to look for source files,
12066 and where to put published files.
12068 @multitable @columnfractions 0.3 0.7
12069 @item @code{:base-directory}
12070 @tab Directory containing publishing source files
12071 @item @code{:publishing-directory}
12072 @tab Directory where output files will be published.  You can directly
12073 publish to a webserver using a file name syntax appropriate for
12074 the Emacs @file{tramp} package.  Or you can publish to a local directory and
12075 use external tools to upload your website (@pxref{Uploading files}).
12076 @item @code{:preparation-function}
12077 @tab Function or list of functions to be called before starting the
12078 publishing process, for example, to run @code{make} for updating files to be
12079 published.  The project property list is scoped into this call as the
12080 variable @code{project-plist}.
12081 @item @code{:completion-function}
12082 @tab Function or list of functions called after finishing the publishing
12083 process, for example, to change permissions of the resulting files.  The
12084 project property list is scoped into this call as the variable
12085 @code{project-plist}.
12086 @end multitable
12087 @noindent
12089 @node Selecting files, Publishing action, Sources and destinations, Configuration
12090 @subsection Selecting files
12091 @cindex files, selecting for publishing
12093 By default, all files with extension @file{.org} in the base directory
12094 are considered part of the project.  This can be modified by setting the
12095 properties
12096 @multitable @columnfractions 0.25 0.75
12097 @item @code{:base-extension}
12098 @tab Extension (without the dot!) of source files.  This actually is a
12099 regular expression.  Set this to the symbol @code{any} if you want to get all
12100 files in @code{:base-directory}, even without extension.
12102 @item @code{:exclude}
12103 @tab Regular expression to match file names that should not be
12104 published, even though they have been selected on the basis of their
12105 extension.
12107 @item @code{:include}
12108 @tab List of files to be included regardless of @code{:base-extension}
12109 and @code{:exclude}.
12111 @item @code{:recursive}
12112 @tab Non-nil means, check base-directory recursively for files to publish.
12113 @end multitable
12115 @node Publishing action, Publishing options, Selecting files, Configuration
12116 @subsection Publishing action
12117 @cindex action, for publishing
12119 Publishing means that a file is copied to the destination directory and
12120 possibly transformed in the process.  The default transformation is to export
12121 Org files as HTML files, and this is done by the function
12122 @code{org-html-publish-to-html} which calls the HTML exporter (@pxref{HTML
12123 export}).  But you also can publish your content as PDF files using
12124 @code{org-latex-publish-to-pdf}, or as @code{ascii}, @code{latin1} or
12125 @code{utf8} encoded files using the corresponding functions.  If you want to
12126 publish the Org file itself, but with @i{archived}, @i{commented}, and
12127 @i{tag-excluded} trees removed, use @code{org-org-publish-to-org} and set the
12128 parameters @code{:plain-source} and/or @code{:htmlized-source}.  This will
12129 produce @file{file.org} and @file{file.org.html} in the publishing
12130 directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
12131 source and publishing directories are equal.  Note that with this kind of
12132 setup, you need to add @code{:exclude "-source\\.org"} to the project
12133 definition in @code{org-publish-project-alist} to prevent the published
12134 source files from being considered as new org files the next time the project
12135 is published.}.  Other files like images only need to be copied to the
12136 publishing destination; for this you may use @code{org-publish-attachment}.
12137 For non-Org files, you always need to specify the publishing function:
12139 @multitable @columnfractions 0.3 0.7
12140 @item @code{:publishing-function}
12141 @tab Function executing the publication of a file.  This may also be a
12142 list of functions, which will all be called in turn.
12143 @item @code{:plain-source}
12144 @tab Non-nil means, publish plain source.
12145 @item @code{:htmlized-source}
12146 @tab Non-nil means, publish htmlized source.
12147 @end multitable
12149 The function must accept three arguments: a property list containing at least
12150 a @code{:publishing-directory} property, the name of the file to be
12151 published, and the path to the publishing directory of the output file.  It
12152 should take the specified file, make the necessary transformation (if any)
12153 and place the result into the destination folder.
12155 @node Publishing options, Publishing links, Publishing action, Configuration
12156 @subsection Options for the HTML/@LaTeX{} exporters
12157 @cindex options, for publishing
12159 The property list can be used to set many export options for the HTML
12160 and @LaTeX{} exporters.  In most cases, these properties correspond to user
12161 variables in Org.  The table below lists these properties along
12162 with the variable they belong to.  See the documentation string for the
12163 respective variable for details.
12165 @vindex org-html-link-up
12166 @vindex org-html-link-home
12167 @vindex org-export-default-language
12168 @vindex org-display-custom-times
12169 @vindex org-export-headline-levels
12170 @vindex org-export-with-section-numbers
12171 @vindex org-export-section-number-format
12172 @vindex org-export-with-toc
12173 @vindex org-export-preserve-breaks
12174 @vindex org-export-with-archived-trees
12175 @vindex org-export-with-emphasize
12176 @vindex org-export-with-sub-superscripts
12177 @vindex org-export-with-special-strings
12178 @vindex org-export-with-footnotes
12179 @vindex org-export-with-drawers
12180 @vindex org-export-with-tags
12181 @vindex org-export-with-todo-keywords
12182 @vindex org-export-with-tasks
12183 @vindex org-export-with-done-tasks
12184 @vindex org-export-with-priority
12185 @vindex org-export-with-TeX-macros
12186 @vindex org-export-with-LaTeX-fragments
12187 @vindex org-export-skip-text-before-1st-heading
12188 @vindex org-export-with-fixed-width
12189 @vindex org-export-with-timestamps
12190 @vindex org-export-author-info
12191 @vindex org-export-email-info
12192 @vindex org-export-creator-info
12193 @vindex org-export-time-stamp-file
12194 @vindex org-export-with-tables
12195 @vindex org-export-highlight-first-table-line
12196 @vindex org-html-style-include-default
12197 @vindex org-html-style-include-scripts
12198 @vindex org-html-style
12199 @vindex org-html-style-extra
12200 @vindex org-html-link-org-files-as-html
12201 @vindex org-html-inline-images
12202 @vindex org-html-extension
12203 @vindex org-html-table-tag
12204 @vindex org-export-publishing-directory
12205 @vindex org-html-preamble
12206 @vindex org-html-postamble
12207 @vindex user-full-name
12208 @vindex user-mail-address
12209 @vindex org-export-select-tags
12210 @vindex org-export-exclude-tags
12212 @multitable @columnfractions 0.32 0.68
12213 @item @code{:link-up}               @tab @code{org-html-link-up}
12214 @item @code{:link-home}             @tab @code{org-html-link-home}
12215 @item @code{:language}              @tab @code{org-export-default-language}
12216 @item @code{:customtime}            @tab @code{org-display-custom-times}
12217 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
12218 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
12219 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
12220 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
12221 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
12222 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
12223 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
12224 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
12225 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
12226 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
12227 @item @code{:drawers}               @tab @code{org-export-with-drawers}
12228 @item @code{:tags}                  @tab @code{org-export-with-tags}
12229 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
12230 @item @code{:tasks}                 @tab @code{org-export-with-tasks}
12231 @item @code{:priority}              @tab @code{org-export-with-priority}
12232 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
12233 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
12234 @item @code{:latex-listings}        @tab @code{org-latex-listings}
12235 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
12236 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
12237 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
12238 @item @code{:author}                @tab @code{user-full-name}
12239 @item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
12240 @item @code{:author-info}           @tab @code{org-export-author-info}
12241 @item @code{:email-info}            @tab @code{org-export-email-info}
12242 @item @code{:creator-info}          @tab @code{org-export-creator-info}
12243 @item @code{:tables}                @tab @code{org-export-with-tables}
12244 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
12245 @item @code{:style-include-default} @tab @code{org-html-style-include-default}
12246 @item @code{:style-include-scripts} @tab @code{org-html-style-include-scripts}
12247 @item @code{:style}                 @tab @code{org-html-style}
12248 @item @code{:style-extra}           @tab @code{org-html-style-extra}
12249 @item @code{:convert-org-links}     @tab @code{org-html-link-org-files-as-html}
12250 @item @code{:inline-images}         @tab @code{org-html-inline-images}
12251 @item @code{:html-extension}        @tab @code{org-html-extension}
12252 @item @code{:html-preamble}         @tab @code{org-html-preamble}
12253 @item @code{:html-postamble}        @tab @code{org-html-postamble}
12254 @item @code{:xml-declaration}       @tab @code{org-html-xml-declaration}
12255 @item @code{:html-table-tag}        @tab @code{org-html-table-tag}
12256 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
12257 @item @code{:select-tags}           @tab @code{org-export-select-tags}
12258 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
12259 @item @code{:latex-image-options}   @tab @code{org-latex-image-default-option}
12260 @end multitable
12262 Most of the @code{org-export-with-*} variables have the same effect in
12263 both HTML and @LaTeX{} exporters, except for @code{:TeX-macros} and
12264 @code{:LaTeX-fragments} options, respectively @code{nil} and @code{t} in the
12265 @LaTeX{} export.  See @code{org-export-plist-vars} to check this list of
12266 options.
12270 @vindex org-publish-project-alist
12271 When a property is given a value in @code{org-publish-project-alist},
12272 its setting overrides the value of the corresponding user variable (if
12273 any) during publishing.  Options set within a file (@pxref{Export
12274 options}), however, override everything.
12276 @node Publishing links, Sitemap, Publishing options, Configuration
12277 @subsection Links between published files
12278 @cindex links, publishing
12280 To create a link from one Org file to another, you would use
12281 something like @samp{[[file:foo.org][The foo]]} or simply
12282 @samp{file:foo.org.} (@pxref{Hyperlinks}).  When published, this link
12283 becomes a link to @file{foo.html}.  In this way, you can interlink the
12284 pages of your "org web" project and the links will work as expected when
12285 you publish them to HTML@.  If you also publish the Org source file and want
12286 to link to that, use an @code{http:} link instead of a @code{file:} link,
12287 because @code{file:} links are converted to link to the corresponding
12288 @file{html} file.
12290 You may also link to related files, such as images.  Provided you are careful
12291 with relative file names, and provided you have also configured Org to upload
12292 the related files, these links will work too.  See @ref{Complex example}, for
12293 an example of this usage.
12295 Sometimes an Org file to be published may contain links that are
12296 only valid in your production environment, but not in the publishing
12297 location.  In this case, use the property
12299 @multitable @columnfractions 0.4 0.6
12300 @item @code{:link-validation-function}
12301 @tab Function to validate links
12302 @end multitable
12304 @noindent
12305 to define a function for checking link validity.  This function must
12306 accept two arguments, the file name and a directory relative to which
12307 the file name is interpreted in the production environment.  If this
12308 function returns @code{nil}, then the HTML generator will only insert a
12309 description into the HTML file, but no link.  One option for this
12310 function is @code{org-publish-validate-link} which checks if the given
12311 file is part of any project in @code{org-publish-project-alist}.
12313 @node Sitemap, Generating an index, Publishing links, Configuration
12314 @subsection Generating a sitemap
12315 @cindex sitemap, of published pages
12317 The following properties may be used to control publishing of
12318 a map of files for a given project.
12320 @multitable @columnfractions 0.35 0.65
12321 @item @code{:auto-sitemap}
12322 @tab When non-nil, publish a sitemap during @code{org-publish-current-project}
12323 or @code{org-publish-all}.
12325 @item @code{:sitemap-filename}
12326 @tab Filename for output of sitemap.  Defaults to @file{sitemap.org} (which
12327 becomes @file{sitemap.html}).
12329 @item @code{:sitemap-title}
12330 @tab Title of sitemap page.  Defaults to name of file.
12332 @item @code{:sitemap-function}
12333 @tab Plug-in function to use for generation of the sitemap.
12334 Defaults to @code{org-publish-org-sitemap}, which generates a plain list
12335 of links to all files in the project.
12337 @item @code{:sitemap-sort-folders}
12338 @tab Where folders should appear in the sitemap.  Set this to @code{first}
12339 (default) or @code{last} to display folders first or last,
12340 respectively.  Any other value will mix files and folders.
12342 @item @code{:sitemap-sort-files}
12343 @tab How the files are sorted in the site map.  Set this to
12344 @code{alphabetically} (default), @code{chronologically} or
12345 @code{anti-chronologically}.  @code{chronologically} sorts the files with
12346 older date first while @code{anti-chronologically} sorts the files with newer
12347 date first.  @code{alphabetically} sorts the files alphabetically.  The date of
12348 a file is retrieved with @code{org-publish-find-date}.
12350 @item @code{:sitemap-ignore-case}
12351 @tab Should sorting be case-sensitive?  Default @code{nil}.
12353 @item @code{:sitemap-file-entry-format}
12354 @tab With this option one can tell how a sitemap's entry is formatted in the
12355 sitemap.  This is a format string with some escape sequences: @code{%t} stands
12356 for the title of the file, @code{%a} stands for the author of the file and
12357 @code{%d} stands for the date of the file.  The date is retrieved with the
12358 @code{org-publish-find-date} function and formatted with
12359 @code{org-publish-sitemap-date-format}.  Default @code{%t}.
12361 @item @code{:sitemap-date-format}
12362 @tab Format string for the @code{format-time-string} function that tells how
12363 a sitemap entry's date is to be formatted.  This property bypasses
12364 @code{org-publish-sitemap-date-format} which defaults to @code{%Y-%m-%d}.
12366 @item @code{:sitemap-sans-extension}
12367 @tab When non-nil, remove filenames' extensions from the generated sitemap.
12368 Useful to have cool URIs (see @uref{http://www.w3.org/Provider/Style/URI}).
12369 Defaults to @code{nil}.
12371 @end multitable
12373 @node Generating an index,  , Sitemap, Configuration
12374 @subsection Generating an index
12375 @cindex index, in a publishing project
12377 Org mode can generate an index across the files of a publishing project.
12379 @multitable @columnfractions 0.25 0.75
12380 @item @code{:makeindex}
12381 @tab When non-nil, generate in index in the file @file{theindex.org} and
12382 publish it as @file{theindex.html}.
12383 @end multitable
12385 The file will be created when first publishing a project with the
12386 @code{:makeindex} set.  The file only contains a statement @code{#+INCLUDE:
12387 "theindex.inc"}.  You can then build around this include statement by adding
12388 a title, style information, etc.
12390 @node Uploading files, Sample configuration, Configuration, Publishing
12391 @section Uploading files
12392 @cindex rsync
12393 @cindex unison
12395 For those people already utilizing third party sync tools such as
12396 @command{rsync} or @command{unison}, it might be preferable not to use the built in
12397 @i{remote} publishing facilities of Org mode which rely heavily on
12398 Tramp.  Tramp, while very useful and powerful, tends not to be
12399 so efficient for multiple file transfer and has been known to cause problems
12400 under heavy usage.
12402 Specialized synchronization utilities offer several advantages.  In addition
12403 to timestamp comparison, they also do content and permissions/attribute
12404 checks.  For this reason you might prefer to publish your web to a local
12405 directory (possibly even @i{in place} with your Org files) and then use
12406 @file{unison} or @file{rsync} to do the synchronization with the remote host.
12408 Since Unison (for example) can be configured as to which files to transfer to
12409 a certain remote destination, it can greatly simplify the project publishing
12410 definition.  Simply keep all files in the correct location, process your Org
12411 files with @code{org-publish} and let the synchronization tool do the rest.
12412 You do not need, in this scenario, to include attachments such as @file{jpg},
12413 @file{css} or @file{gif} files in the project definition since the 3rd party
12414 tool syncs them.
12416 Publishing to a local directory is also much faster than to a remote one, so
12417 that you can afford more easily to republish entire projects.  If you set
12418 @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the main
12419 benefit of re-including any changed external files such as source example
12420 files you might include with @code{#+INCLUDE:}.  The timestamp mechanism in
12421 Org is not smart enough to detect if included files have been modified.
12423 @node Sample configuration, Triggering publication, Uploading files, Publishing
12424 @section Sample configuration
12426 Below we provide two example configurations.  The first one is a simple
12427 project publishing only a set of Org files.  The second example is
12428 more complex, with a multi-component project.
12430 @menu
12431 * Simple example::              One-component publishing
12432 * Complex example::             A multi-component publishing example
12433 @end menu
12435 @node Simple example, Complex example, Sample configuration, Sample configuration
12436 @subsection Example: simple publishing configuration
12438 This example publishes a set of Org files to the @file{public_html}
12439 directory on the local machine.
12441 @lisp
12442 (setq org-publish-project-alist
12443       '(("org"
12444          :base-directory "~/org/"
12445          :publishing-directory "~/public_html"
12446          :section-numbers nil
12447          :table-of-contents nil
12448          :style "<link rel=\"stylesheet\"
12449                 href=\"../other/mystyle.css\"
12450                 type=\"text/css\"/>")))
12451 @end lisp
12453 @node Complex example,  , Simple example, Sample configuration
12454 @subsection Example: complex publishing configuration
12456 This more complicated example publishes an entire website, including
12457 Org files converted to HTML, image files, Emacs Lisp source code, and
12458 style sheets.  The publishing directory is remote and private files are
12459 excluded.
12461 To ensure that links are preserved, care should be taken to replicate
12462 your directory structure on the web server, and to use relative file
12463 paths.  For example, if your Org files are kept in @file{~/org} and your
12464 publishable images in @file{~/images}, you would link to an image with
12466 @example
12467 file:../images/myimage.png
12468 @end example
12470 On the web server, the relative path to the image should be the
12471 same.  You can accomplish this by setting up an "images" folder in the
12472 right place on the web server, and publishing images to it.
12474 @lisp
12475 (setq org-publish-project-alist
12476       '(("orgfiles"
12477           :base-directory "~/org/"
12478           :base-extension "org"
12479           :publishing-directory "/ssh:user@@host:~/html/notebook/"
12480           :publishing-function org-html-publish-to-html
12481           :exclude "PrivatePage.org"   ;; regexp
12482           :headline-levels 3
12483           :section-numbers nil
12484           :table-of-contents nil
12485           :style "<link rel=\"stylesheet\"
12486                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
12487           :html-preamble t)
12489          ("images"
12490           :base-directory "~/images/"
12491           :base-extension "jpg\\|gif\\|png"
12492           :publishing-directory "/ssh:user@@host:~/html/images/"
12493           :publishing-function org-publish-attachment)
12495          ("other"
12496           :base-directory "~/other/"
12497           :base-extension "css\\|el"
12498           :publishing-directory "/ssh:user@@host:~/html/other/"
12499           :publishing-function org-publish-attachment)
12500          ("website" :components ("orgfiles" "images" "other"))))
12501 @end lisp
12503 @node Triggering publication,  , Sample configuration, Publishing
12504 @section Triggering publication
12506 Once properly configured, Org can publish with the following commands:
12508 @table @kbd
12509 @orgcmd{C-c C-e X,org-publish}
12510 Prompt for a specific project and publish all files that belong to it.
12511 @orgcmd{C-c C-e P,org-publish-current-project}
12512 Publish the project containing the current file.
12513 @orgcmd{C-c C-e F,org-publish-current-file}
12514 Publish only the current file.
12515 @orgcmd{C-c C-e E,org-publish-all}
12516 Publish every project.
12517 @end table
12519 @vindex org-publish-use-timestamps-flag
12520 Org uses timestamps to track when a file has changed.  The above functions
12521 normally only publish changed files.  You can override this and force
12522 publishing of all files by giving a prefix argument to any of the commands
12523 above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
12524 This may be necessary in particular if files include other files via
12525 @code{#+SETUPFILE:} or @code{#+INCLUDE:}.
12527 @comment  node-name,  next,  previous,  up
12528 @comment Working With Source Code, Miscellaneous, Publishing, Top
12530 @node Working With Source Code, Miscellaneous, Publishing, Top
12531 @chapter Working with source code
12532 @cindex Schulte, Eric
12533 @cindex Davison, Dan
12534 @cindex source code, working with
12536 Source code can be included in Org mode documents using a @samp{src} block,
12537 e.g.:
12539 @example
12540 #+BEGIN_SRC emacs-lisp
12541   (defun org-xor (a b)
12542      "Exclusive or."
12543      (if a (not b) b))
12544 #+END_SRC
12545 @end example
12547 Org mode provides a number of features for working with live source code,
12548 including editing of code blocks in their native major-mode, evaluation of
12549 code blocks, converting code blocks into source files (known as @dfn{tangling}
12550 in literate programming), and exporting code blocks and their
12551 results in several formats.  This functionality was contributed by Eric
12552 Schulte and Dan Davison, and was originally named Org-babel.
12554 The following sections describe Org mode's code block handling facilities.
12556 @menu
12557 * Structure of code blocks::    Code block syntax described
12558 * Editing source code::         Language major-mode editing
12559 * Exporting code blocks::       Export contents and/or results
12560 * Extracting source code::      Create pure source code files
12561 * Evaluating code blocks::      Place results of evaluation in the Org mode buffer
12562 * Library of Babel::            Use and contribute to a library of useful code blocks
12563 * Languages::                   List of supported code block languages
12564 * Header arguments::            Configure code block functionality
12565 * Results of evaluation::       How evaluation results are handled
12566 * Noweb reference syntax::      Literate programming in Org mode
12567 * Key bindings and useful functions::  Work quickly with code blocks
12568 * Batch execution::             Call functions from the command line
12569 @end menu
12571 @comment  node-name,  next,  previous,  up
12572 @comment  Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
12574 @node Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
12575 @section Structure of code blocks
12576 @cindex code block, structure
12577 @cindex source code, block structure
12578 @cindex #+NAME
12579 @cindex #+BEGIN_SRC
12581 Live code blocks can be specified with a @samp{src} block or
12582 inline.@footnote{Note that @samp{src} blocks may be inserted using Org mode's
12583 @ref{Easy Templates} system}  The structure of a @samp{src} block is
12585 @example
12586 #+NAME: <name>
12587 #+BEGIN_SRC <language> <switches> <header arguments>
12588   <body>
12589 #+END_SRC
12590 @end example
12592 The @code{#+NAME:} line is optional, and can be used to name the code
12593 block.  Live code blocks require that a language be specified on the
12594 @code{#+BEGIN_SRC} line.  Switches and header arguments are optional.
12595 @cindex source code, inline
12597 Live code blocks can also be specified inline using
12599 @example
12600 src_<language>@{<body>@}
12601 @end example
12605 @example
12606 src_<language>[<header arguments>]@{<body>@}
12607 @end example
12609 @table @code
12610 @item <#+NAME: name>
12611 This line associates a name with the code block.  This is similar to the
12612 @code{#+TBLNAME: NAME} lines that can be used to name tables in Org mode
12613 files.  Referencing the name of a code block makes it possible to evaluate
12614 the block from other places in the file, from other files, or from Org mode
12615 table formulas (see @ref{The spreadsheet}).  Names are assumed to be unique
12616 and the behavior of Org mode when two or more blocks share the same name is
12617 undefined.
12618 @cindex #+NAME
12619 @item <language>
12620 The language of the code in the block (see @ref{Languages}).
12621 @cindex source code, language
12622 @item <switches>
12623 Optional switches control code block export (see the discussion of switches in
12624 @ref{Literal examples})
12625 @cindex source code, switches
12626 @item <header arguments>
12627 Optional header arguments control many aspects of evaluation, export and
12628 tangling of code blocks (see @ref{Header arguments}).
12629 Header arguments can also be set on a per-buffer or per-subtree
12630 basis using properties.
12631 @item source code, header arguments
12632 @item <body>
12633 Source code in the specified language.
12634 @end table
12636 @comment  node-name,  next,  previous,  up
12637 @comment  Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
12639 @node Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
12640 @section Editing source code
12641 @cindex code block, editing
12642 @cindex source code, editing
12644 @kindex C-c '
12645 Use @kbd{C-c '} to edit the current code block.  This brings up
12646 a language major-mode edit buffer containing the body of the code
12647 block.  Saving this buffer will write the new contents back to the Org
12648 buffer.  Use @kbd{C-c '} again to exit.
12650 The @code{org-src-mode} minor mode will be active in the edit buffer.  The
12651 following variables can be used to configure the behavior of the edit
12652 buffer.  See also the customization group @code{org-edit-structure} for
12653 further configuration options.
12655 @table @code
12656 @item org-src-lang-modes
12657 If an Emacs major-mode named @code{<lang>-mode} exists, where
12658 @code{<lang>} is the language named in the header line of the code block,
12659 then the edit buffer will be placed in that major-mode.  This variable
12660 can be used to map arbitrary language names to existing major modes.
12661 @item org-src-window-setup
12662 Controls the way Emacs windows are rearranged when the edit buffer is created.
12663 @item org-src-preserve-indentation
12664 This variable is especially useful for tangling languages such as
12665 Python, in which whitespace indentation in the output is critical.
12666 @item org-src-ask-before-returning-to-edit-buffer
12667 By default, Org will ask before returning to an open edit buffer.  Set this
12668 variable to nil to switch without asking.
12669 @end table
12671 To turn on native code fontification in the @emph{Org} buffer, configure the
12672 variable @code{org-src-fontify-natively}.
12674 @comment  node-name,  next,  previous,  up
12675 @comment  Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
12677 @node Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
12678 @section Exporting code blocks
12679 @cindex code block, exporting
12680 @cindex source code, exporting
12682 It is possible to export the @emph{code} of code blocks, the @emph{results}
12683 of code block evaluation, @emph{both} the code and the results of code block
12684 evaluation, or @emph{none}.  For most languages, the default exports code.
12685 However, for some languages (e.g., @code{ditaa}) the default exports the
12686 results of code block evaluation.  For information on exporting code block
12687 bodies, see @ref{Literal examples}.
12689 The @code{:exports} header argument can be used to specify export
12690 behavior:
12692 @subsubheading Header arguments:
12694 @table @code
12695 @item :exports code
12696 The default in most languages.  The body of the code block is exported, as
12697 described in @ref{Literal examples}.
12698 @item :exports results
12699 The code block will be evaluated and the results will be placed in the
12700 Org mode buffer for export, either updating previous results of the code
12701 block located anywhere in the buffer or, if no previous results exist,
12702 placing the results immediately after the code block.  The body of the code
12703 block will not be exported.
12704 @item :exports both
12705 Both the code block and its results will be exported.
12706 @item :exports none
12707 Neither the code block nor its results will be exported.
12708 @end table
12710 It is possible to inhibit the evaluation of code blocks during export.
12711 Setting the @code{org-export-babel-evaluate} variable to @code{nil} will
12712 ensure that no code blocks are evaluated as part of the export process.  This
12713 can be useful in situations where potentially untrusted Org mode files are
12714 exported in an automated fashion, for example when Org mode is used as the
12715 markup language for a wiki.
12717 @comment  node-name,  next,  previous,  up
12718 @comment  Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
12719 @node Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
12720 @section Extracting source code
12721 @cindex tangling
12722 @cindex source code, extracting
12723 @cindex code block, extracting source code
12725 Creating pure source code files by extracting code from source blocks is
12726 referred to as ``tangling''---a term adopted from the literate programming
12727 community.  During ``tangling'' of code blocks their bodies are expanded
12728 using @code{org-babel-expand-src-block} which can expand both variable and
12729 ``noweb'' style references  (see @ref{Noweb reference syntax}).
12731 @subsubheading Header arguments
12733 @table @code
12734 @item :tangle no
12735 The default.  The code block is not included in the tangled output.
12736 @item :tangle yes
12737 Include the code block in the tangled output.  The output file name is the
12738 name of the org file with the extension @samp{.org} replaced by the extension
12739 for the block language.
12740 @item :tangle filename
12741 Include the code block in the tangled output to file @samp{filename}.
12742 @end table
12744 @kindex  C-c C-v t
12745 @subsubheading Functions
12747 @table @code
12748 @item org-babel-tangle
12749 Tangle the current file.  Bound to @kbd{C-c C-v t}.
12751 With prefix argument only tangle the current code block.
12752 @item org-babel-tangle-file
12753 Choose a file to tangle.  Bound to @kbd{C-c C-v f}.
12754 @end table
12756 @subsubheading Hooks
12758 @table @code
12759 @item org-babel-post-tangle-hook
12760 This hook is run from within code files tangled by @code{org-babel-tangle}.
12761 Example applications could include post-processing, compilation or evaluation
12762 of tangled code files.
12763 @end table
12765 @node Evaluating code blocks, Library of Babel, Extracting source code, Working With Source Code
12766 @section Evaluating code blocks
12767 @cindex code block, evaluating
12768 @cindex source code, evaluating
12769 @cindex #+RESULTS
12771 Code blocks can be evaluated@footnote{Whenever code is evaluated there is a
12772 potential for that code to do harm.  Org mode provides safeguards to ensure
12773 that code is only evaluated after explicit confirmation from the user.  For
12774 information on these safeguards (and on how to disable them) see @ref{Code
12775 evaluation security}.} and the results of evaluation optionally placed in the
12776 Org mode buffer.  The results of evaluation are placed following a line that
12777 begins by default with @code{#+RESULTS} and optionally a cache identifier
12778 and/or the name of the evaluated code block.  The default value of
12779 @code{#+RESULTS} can be changed with the customizable variable
12780 @code{org-babel-results-keyword}.
12782 By default, the evaluation facility is only enabled for Lisp code blocks
12783 specified as @code{emacs-lisp}.  However, source code blocks in many languages
12784 can be evaluated within Org mode (see @ref{Languages} for a list of supported
12785 languages and @ref{Structure of code blocks} for information on the syntax
12786 used to define a code block).
12788 @kindex C-c C-c
12789 There are a number of ways to evaluate code blocks.  The simplest is to press
12790 @kbd{C-c C-c} or @kbd{C-c C-v e} with the point on a code block@footnote{The
12791 @code{org-babel-no-eval-on-ctrl-c-ctrl-c} variable can be used to remove code
12792 evaluation from the @kbd{C-c C-c} key binding.}.  This will call the
12793 @code{org-babel-execute-src-block} function to evaluate the block and insert
12794 its results into the Org mode buffer.
12795 @cindex #+CALL
12797 It is also possible to evaluate named code blocks from anywhere in an Org
12798 mode buffer or an Org mode table.  Live code blocks located in the current
12799 Org mode buffer or in the ``Library of Babel'' (see @ref{Library of Babel})
12800 can be executed.  Named code blocks can be executed with a separate
12801 @code{#+CALL:} line or inline within a block of text.
12803 The syntax of the @code{#+CALL:} line is
12805 @example
12806 #+CALL: <name>(<arguments>)
12807 #+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
12808 @end example
12810 The syntax for inline evaluation of named code blocks is
12812 @example
12813 ... call_<name>(<arguments>) ...
12814 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
12815 @end example
12817 @table @code
12818 @item <name>
12819 The name of the code block to be evaluated (see @ref{Structure of code blocks}).
12820 @item <arguments>
12821 Arguments specified in this section will be passed to the code block.  These
12822 arguments use standard function call syntax, rather than
12823 header argument syntax.  For example, a @code{#+CALL:} line that passes the
12824 number four to a code block named @code{double}, which declares the header
12825 argument @code{:var n=2}, would be written as @code{#+CALL: double(n=4)}.
12826 @item <inside header arguments>
12827 Inside header arguments are passed through and applied to the named code
12828 block.  These arguments use header argument syntax rather than standard
12829 function call syntax.  Inside header arguments affect how the code block is
12830 evaluated.  For example, @code{[:results output]} will collect the results of
12831 everything printed to @code{STDOUT} during execution of the code block.
12832 @item <end header arguments>
12833 End header arguments are applied to the calling instance and do not affect
12834 evaluation of the named code block.  They affect how the results are
12835 incorporated into the Org mode buffer and how the call line is exported.  For
12836 example, @code{:results html} will insert the results of the call line
12837 evaluation in the Org buffer, wrapped in a @code{BEGIN_HTML:} block.
12839 For more examples of passing header arguments to @code{#+CALL:} lines see
12840 @ref{Header arguments in function calls}.
12841 @end table
12843 @node Library of Babel, Languages, Evaluating code blocks, Working With Source Code
12844 @section Library of Babel
12845 @cindex babel, library of
12846 @cindex source code, library
12847 @cindex code block, library
12849 The ``Library of Babel'' consists of code blocks that can be called from any
12850 Org mode file.  Code blocks defined in the ``Library of Babel'' can be called
12851 remotely as if they were in the current Org mode buffer (see @ref{Evaluating
12852 code blocks} for information on the syntax of remote code block evaluation).
12855 The central repository of code blocks in the ``Library of Babel'' is housed
12856 in an Org mode file located in the @samp{contrib} directory of Org mode.
12858 Users can add code blocks they believe to be generally useful to their
12859 ``Library of Babel.''  The code blocks can be stored in any Org mode file and
12860 then loaded into the library with @code{org-babel-lob-ingest}.
12863 @kindex C-c C-v i
12864 Code blocks located in any Org mode file can be loaded into the ``Library of
12865 Babel'' with the @code{org-babel-lob-ingest} function, bound to @kbd{C-c C-v
12868 @node Languages, Header arguments, Library of Babel, Working With Source Code
12869 @section Languages
12870 @cindex babel, languages
12871 @cindex source code, languages
12872 @cindex code block, languages
12874 Code blocks in the following languages are supported.
12876 @multitable @columnfractions 0.28 0.3 0.22 0.2
12877 @item @b{Language} @tab @b{Identifier} @tab @b{Language} @tab @b{Identifier}
12878 @item Asymptote @tab asymptote @tab Awk @tab awk
12879 @item Emacs Calc @tab calc @tab C @tab C
12880 @item C++ @tab C++ @tab Clojure @tab clojure
12881 @item CSS @tab css @tab ditaa @tab ditaa
12882 @item Graphviz @tab dot @tab Emacs Lisp @tab emacs-lisp
12883 @item gnuplot @tab gnuplot @tab Haskell @tab haskell
12884 @item Java @tab java @tab @tab
12885 @item Javascript @tab js @tab LaTeX @tab latex
12886 @item Ledger @tab ledger @tab Lisp @tab lisp
12887 @item Lilypond @tab lilypond @tab MATLAB @tab matlab
12888 @item Mscgen @tab mscgen @tab Objective Caml @tab ocaml
12889 @item Octave @tab octave @tab Org mode @tab org
12890 @item Oz @tab oz @tab Perl @tab perl
12891 @item Plantuml @tab plantuml @tab Python @tab python
12892 @item R @tab R @tab Ruby @tab ruby
12893 @item Sass @tab sass @tab Scheme @tab scheme
12894 @item GNU Screen @tab screen @tab shell @tab sh
12895 @item SQL @tab sql @tab SQLite @tab sqlite
12896 @end multitable
12898 Language-specific documentation is available for some languages.  If
12899 available, it can be found at
12900 @uref{http://orgmode.org/worg/org-contrib/babel/languages.html}.
12902 The @code{org-babel-load-languages} controls which languages are enabled for
12903 evaluation (by default only @code{emacs-lisp} is enabled).  This variable can
12904 be set using the customization interface or by adding code like the following
12905 to your emacs configuration.
12907 @quotation
12908 The following disables @code{emacs-lisp} evaluation and enables evaluation of
12909 @code{R} code blocks.
12910 @end quotation
12912 @lisp
12913 (org-babel-do-load-languages
12914  'org-babel-load-languages
12915  '((emacs-lisp . nil)
12916    (R . t)))
12917 @end lisp
12919 It is also possible to enable support for a language by loading the related
12920 elisp file with @code{require}.
12922 @quotation
12923 The following adds support for evaluating @code{clojure} code blocks.
12924 @end quotation
12926 @lisp
12927 (require 'ob-clojure)
12928 @end lisp
12930 @node Header arguments, Results of evaluation, Languages, Working With Source Code
12931 @section Header arguments
12932 @cindex code block, header arguments
12933 @cindex source code, block header arguments
12935 Code block functionality can be configured with header arguments.  This
12936 section provides an overview of the use of header arguments, and then
12937 describes each header argument in detail.
12939 @menu
12940 * Using header arguments::      Different ways to set header arguments
12941 * Specific header arguments::   List of header arguments
12942 @end menu
12944 @node Using header arguments, Specific header arguments, Header arguments, Header arguments
12945 @subsection Using header arguments
12947 The values of header arguments can be set in six different ways, each more
12948 specific (and having higher priority) than the last.
12949 @menu
12950 * System-wide header arguments::  Set global default values
12951 * Language-specific header arguments::  Set default values by language
12952 * Buffer-wide header arguments::  Set default values for a specific buffer
12953 * Header arguments in Org mode properties::  Set default values for a buffer or heading
12954 * Code block specific header arguments::  The most common way to set values
12955 * Header arguments in function calls::  The most specific level
12956 @end menu
12959 @node System-wide header arguments, Language-specific header arguments, Using header arguments, Using header arguments
12960 @subsubheading System-wide header arguments
12961 @vindex org-babel-default-header-args
12962 System-wide values of header arguments can be specified by customizing the
12963 @code{org-babel-default-header-args} variable:
12965 @example
12966 :session    => "none"
12967 :results    => "replace"
12968 :exports    => "code"
12969 :cache      => "no"
12970 :noweb      => "no"
12971 @end example
12973 @c @example
12974 @c   org-babel-default-header-args is a variable defined in `org-babel.el'.
12975 @c   Its value is
12976 @c   ((:session . "none")
12977 @c    (:results . "replace")
12978 @c    (:exports . "code")
12979 @c    (:cache . "no")
12980 @c    (:noweb . "no"))
12983 @c   Documentation:
12984 @c   Default arguments to use when evaluating a code block.
12985 @c @end example
12987 For example, the following example could be used to set the default value of
12988 @code{:noweb} header arguments to @code{yes}.  This would have the effect of
12989 expanding @code{:noweb} references by default when evaluating source code
12990 blocks.
12992 @lisp
12993 (setq org-babel-default-header-args
12994       (cons '(:noweb . "yes")
12995             (assq-delete-all :noweb org-babel-default-header-args)))
12996 @end lisp
12998 @node Language-specific header arguments, Buffer-wide header arguments, System-wide header arguments, Using header arguments
12999 @subsubheading Language-specific header arguments
13000 Each language can define its own set of default header arguments.  See the
13001 language-specific documentation available online at
13002 @uref{http://orgmode.org/worg/org-contrib/babel}.
13004 @node Buffer-wide header arguments, Header arguments in Org mode properties, Language-specific header arguments, Using header arguments
13005 @subsubheading Buffer-wide header arguments
13006 Buffer-wide header arguments may be specified as properties through the use
13007 of @code{#+PROPERTY:} lines placed anywhere in an Org mode file (see
13008 @ref{Property syntax}).
13010 For example the following would set @code{session} to @code{*R*}, and
13011 @code{results} to @code{silent} for every code block in the buffer, ensuring
13012 that all execution took place in the same session, and no results would be
13013 inserted into the buffer.
13015 @example
13016 #+PROPERTY: session *R*
13017 #+PROPERTY: results silent
13018 @end example
13020 @node Header arguments in Org mode properties, Code block specific header arguments, Buffer-wide header arguments, Using header arguments
13021 @subsubheading Header arguments in Org mode properties
13023 Header arguments are also read from Org mode properties (see @ref{Property
13024 syntax}), which can be set on a buffer-wide or per-heading basis.  An example
13025 of setting a header argument for all code blocks in a buffer is
13027 @example
13028 #+PROPERTY: tangle yes
13029 @end example
13031 @vindex org-use-property-inheritance
13032 When properties are used to set default header arguments, they are looked up
13033 with inheritance, regardless of the value of
13034 @code{org-use-property-inheritance}.  In the following example the value of
13035 the @code{:cache} header argument will default to @code{yes} in all code
13036 blocks in the subtree rooted at the following heading:
13038 @example
13039 * outline header
13040   :PROPERTIES:
13041   :cache:    yes
13042   :END:
13043 @end example
13045 @kindex C-c C-x p
13046 @vindex org-babel-default-header-args
13047 Properties defined in this way override the properties set in
13048 @code{org-babel-default-header-args}.  It is convenient to use the
13049 @code{org-set-property} function bound to @kbd{C-c C-x p} to set properties
13050 in Org mode documents.
13052 @node Code block specific header arguments, Header arguments in function calls, Header arguments in Org mode properties, Using header arguments
13053 @subsubheading Code block specific header arguments
13055 The most common way to assign values to header arguments is at the
13056 code block level.  This can be done by listing a sequence of header
13057 arguments and their values as part of the @code{#+BEGIN_SRC} line.
13058 Properties set in this way override both the values of
13059 @code{org-babel-default-header-args} and header arguments specified as
13060 properties.  In the following example, the @code{:results} header argument
13061 is set to @code{silent}, meaning the results of execution will not be
13062 inserted in the buffer, and the @code{:exports} header argument is set to
13063 @code{code}, meaning only the body of the code block will be
13064 preserved on export to HTML or @LaTeX{}.
13066 @example
13067 #+NAME: factorial
13068 #+BEGIN_SRC haskell :results silent :exports code :var n=0
13069 fac 0 = 1
13070 fac n = n * fac (n-1)
13071 #+END_SRC
13072 @end example
13073 Similarly, it is possible to set header arguments for inline code blocks
13075 @example
13076 src_haskell[:exports both]@{fac 5@}
13077 @end example
13079 Code block header arguments can span multiple lines using @code{#+HEADER:} or
13080 @code{#+HEADERS:} lines preceding a code block or nested between the
13081 @code{#+NAME:} line and the @code{#+BEGIN_SRC} line of a named code block.
13082 @cindex #+HEADER:
13083 @cindex #+HEADERS:
13085 Multi-line header arguments on an un-named code block:
13087 @example
13088  #+HEADERS: :var data1=1
13089  #+BEGIN_SRC emacs-lisp :var data2=2
13090    (message "data1:%S, data2:%S" data1 data2)
13091  #+END_SRC
13093  #+RESULTS:
13094  : data1:1, data2:2
13095 @end example
13097 Multi-line header arguments on a named code block:
13099 @example
13100    #+NAME: named-block
13101    #+HEADER: :var data=2
13102    #+BEGIN_SRC emacs-lisp
13103      (message "data:%S" data)
13104    #+END_SRC
13106    #+RESULTS: named-block
13107    : data:2
13108 @end example
13110 @node Header arguments in function calls,  , Code block specific header arguments, Using header arguments
13111 @comment  node-name,  next,  previous,  up
13112 @subsubheading Header arguments in function calls
13114 At the most specific level, header arguments for ``Library of Babel'' or
13115 @code{#+CALL:} lines can be set as shown in the two examples below.  For more
13116 information on the structure of @code{#+CALL:} lines see @ref{Evaluating code
13117 blocks}.
13119 The following will apply the @code{:exports results} header argument to the
13120 evaluation of the @code{#+CALL:} line.
13122 @example
13123 #+CALL: factorial(n=5) :exports results
13124 @end example
13126 The following will apply the @code{:session special} header argument to the
13127 evaluation of the @code{factorial} code block.
13129 @example
13130 #+CALL: factorial[:session special](n=5)
13131 @end example
13133 @node Specific header arguments,  , Using header arguments, Header arguments
13134 @subsection Specific header arguments
13135 Header arguments consist of an initial colon followed by the name of the
13136 argument in lowercase letters.  The following header arguments are defined:
13138 @menu
13139 * var::                         Pass arguments to code blocks
13140 * results::                     Specify the type of results and how they will
13141                                 be collected and handled
13142 * file::                        Specify a path for file output
13143 * file-desc::                   Specify a description for file results
13144 * dir::                         Specify the default (possibly remote)
13145                                 directory for code block execution
13146 * exports::                     Export code and/or results
13147 * tangle::                      Toggle tangling and specify file name
13148 * mkdirp::                      Toggle creation of parent directories of target
13149                                 files during tangling
13150 * comments::                    Toggle insertion of comments in tangled
13151                                 code files
13152 * padline::                     Control insertion of padding lines in tangled
13153                                 code files
13154 * no-expand::                   Turn off variable assignment and noweb
13155                                 expansion during tangling
13156 * session::                     Preserve the state of code evaluation
13157 * noweb::                       Toggle expansion of noweb references
13158 * noweb-ref::                   Specify block's noweb reference resolution target
13159 * noweb-sep::                   String used to separate noweb references
13160 * cache::                       Avoid re-evaluating unchanged code blocks
13161 * sep::                         Delimiter for writing tabular results outside Org
13162 * hlines::                      Handle horizontal lines in tables
13163 * colnames::                    Handle column names in tables
13164 * rownames::                    Handle row names in tables
13165 * shebang::                     Make tangled files executable
13166 * eval::                        Limit evaluation of specific code blocks
13167 * wrap::                        Mark source block evaluation results
13168 @end menu
13170 Additional header arguments are defined on a language-specific basis, see
13171 @ref{Languages}.
13173 @node var, results, Specific header arguments, Specific header arguments
13174 @subsubsection @code{:var}
13175 The @code{:var} header argument is used to pass arguments to code blocks.
13176 The specifics of how arguments are included in a code block vary by language;
13177 these are addressed in the language-specific documentation.  However, the
13178 syntax used to specify arguments is the same across all languages.  In every
13179 case, variables require a default value when they are declared.
13181 The values passed to arguments can either be literal values, references, or
13182 Emacs Lisp code (see @ref{var, Emacs Lisp evaluation of variables}).  References
13183 include anything in the Org mode file that takes a @code{#+NAME:},
13184 @code{#+TBLNAME:}, or @code{#+RESULTS:} line.  This includes tables, lists,
13185 @code{#+BEGIN_EXAMPLE} blocks, other code blocks, and the results of other
13186 code blocks.
13188 Argument values can be indexed in a manner similar to arrays (see @ref{var,
13189 Indexable variable values}).
13191 The following syntax is used to pass arguments to code blocks using the
13192 @code{:var} header argument.
13194 @example
13195 :var name=assign
13196 @end example
13198 The argument, @code{assign}, can either be a literal value, such as a string
13199 @samp{"string"} or a number @samp{9}, or a reference to a table, a list, a
13200 literal example, another code block (with or without arguments), or the
13201 results of evaluating another code block.
13203 Here are examples of passing values by reference:
13205 @table @dfn
13207 @item table
13208 an Org mode table named with either a @code{#+NAME:} or @code{#+TBLNAME:} line
13210 @example
13211 #+TBLNAME: example-table
13212 | 1 |
13213 | 2 |
13214 | 3 |
13215 | 4 |
13217 #+NAME: table-length
13218 #+BEGIN_SRC emacs-lisp :var table=example-table
13219 (length table)
13220 #+END_SRC
13222 #+RESULTS: table-length
13223 : 4
13224 @end example
13226 @item list
13227 a simple list named with a @code{#+NAME:} line (note that nesting is not
13228 carried through to the source code block)
13230 @example
13231 #+NAME: example-list
13232   - simple
13233     - not
13234     - nested
13235   - list
13237 #+BEGIN_SRC emacs-lisp :var x=example-list
13238   (print x)
13239 #+END_SRC
13241 #+RESULTS:
13242 | simple | list |
13243 @end example
13245 @item code block without arguments
13246 a code block name (from the example above), as assigned by @code{#+NAME:},
13247 optionally followed by parentheses
13249 @example
13250 #+BEGIN_SRC emacs-lisp :var length=table-length()
13251 (* 2 length)
13252 #+END_SRC
13254 #+RESULTS:
13255 : 8
13256 @end example
13258 @item code block with arguments
13259 a code block name, as assigned by @code{#+NAME:}, followed by parentheses and
13260 optional arguments passed within the parentheses following the
13261 code block name using standard function call syntax
13263 @example
13264 #+NAME: double
13265 #+BEGIN_SRC emacs-lisp :var input=8
13266 (* 2 input)
13267 #+END_SRC
13269 #+RESULTS: double
13270 : 16
13272 #+NAME: squared
13273 #+BEGIN_SRC emacs-lisp :var input=double(input=1)
13274 (* input input)
13275 #+END_SRC
13277 #+RESULTS: squared
13278 : 4
13279 @end example
13281 @item literal example
13282 a literal example block named with a @code{#+NAME:} line
13284 @example
13285 #+NAME: literal-example
13286 #+BEGIN_EXAMPLE
13287 A literal example
13288 on two lines
13289 #+END_EXAMPLE
13291 #+NAME: read-literal-example
13292 #+BEGIN_SRC emacs-lisp :var x=literal-example
13293   (concatenate 'string x " for you.")
13294 #+END_SRC
13296 #+RESULTS: read-literal-example
13297 : A literal example
13298 : on two lines for you.
13300 @end example
13302 @end table
13304 @subsubheading Alternate argument syntax
13305 It is also possible to specify arguments in a potentially more natural way
13306 using the @code{#+NAME:} line of a code block.  As in the following
13307 example, arguments can be packed inside of parentheses, separated by commas,
13308 following the source name.
13310 @example
13311 #+NAME: double(input=0, x=2)
13312 #+BEGIN_SRC emacs-lisp
13313 (* 2 (+ input x))
13314 #+END_SRC
13315 @end example
13317 @subsubheading Indexable variable values
13318 It is possible to reference portions of variable values by ``indexing'' into
13319 the variables.  Indexes are 0 based with negative values counting back from
13320 the end.  If an index is separated by @code{,}s then each subsequent section
13321 will index into the next deepest nesting or dimension of the value.  Note
13322 that this indexing occurs @emph{before} other table related header arguments
13323 like @code{:hlines}, @code{:colnames} and @code{:rownames} are applied.  The
13324 following example assigns the last cell of the first row the table
13325 @code{example-table} to the variable @code{data}:
13327 @example
13328 #+NAME: example-table
13329 | 1 | a |
13330 | 2 | b |
13331 | 3 | c |
13332 | 4 | d |
13334 #+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
13335   data
13336 #+END_SRC
13338 #+RESULTS:
13339 : a
13340 @end example
13342 Ranges of variable values can be referenced using two integers separated by a
13343 @code{:}, in which case the entire inclusive range is referenced.  For
13344 example the following assigns the middle three rows of @code{example-table}
13345 to @code{data}.
13347 @example
13348 #+NAME: example-table
13349 | 1 | a |
13350 | 2 | b |
13351 | 3 | c |
13352 | 4 | d |
13353 | 5 | 3 |
13355 #+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
13356   data
13357 #+END_SRC
13359 #+RESULTS:
13360 | 2 | b |
13361 | 3 | c |
13362 | 4 | d |
13363 @end example
13365 Additionally, an empty index, or the single character @code{*}, are both
13366 interpreted to mean the entire range and as such are equivalent to
13367 @code{0:-1}, as shown in the following example in which the entire first
13368 column is referenced.
13370 @example
13371 #+NAME: example-table
13372 | 1 | a |
13373 | 2 | b |
13374 | 3 | c |
13375 | 4 | d |
13377 #+BEGIN_SRC emacs-lisp :var data=example-table[,0]
13378   data
13379 #+END_SRC
13381 #+RESULTS:
13382 | 1 | 2 | 3 | 4 |
13383 @end example
13385 It is possible to index into the results of code blocks as well as tables.
13386 Any number of dimensions can be indexed.  Dimensions are separated from one
13387 another by commas, as shown in the following example.
13389 @example
13390 #+NAME: 3D
13391 #+BEGIN_SRC emacs-lisp
13392   '(((1  2  3)  (4  5  6)  (7  8  9))
13393     ((10 11 12) (13 14 15) (16 17 18))
13394     ((19 20 21) (22 23 24) (25 26 27)))
13395 #+END_SRC
13397 #+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
13398   data
13399 #+END_SRC
13401 #+RESULTS:
13402 | 11 | 14 | 17 |
13403 @end example
13405 @subsubheading Emacs Lisp evaluation of variables
13407 Emacs lisp code can be used to initialize variable values.  When a variable
13408 value starts with @code{(}, @code{[}, @code{'} or @code{`} it will be
13409 evaluated as Emacs Lisp and the result of the evaluation will be assigned as
13410 the variable value.  The following example demonstrates use of this
13411 evaluation to reliably pass the file-name of the Org mode buffer to a code
13412 block---note that evaluation of header arguments is guaranteed to take place
13413 in the original Org mode file, while there is no such guarantee for
13414 evaluation of the code block body.
13416 @example
13417 #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
13418   wc -w $filename
13419 #+END_SRC
13420 @end example
13422 Note that values read from tables and lists will not be evaluated as
13423 Emacs Lisp, as shown in the following example.
13425 @example
13426 #+NAME: table
13427 | (a b c) |
13429 #+HEADERS: :var data=table[0,0]
13430 #+BEGIN_SRC perl
13431   $data
13432 #+END_SRC
13434 #+RESULTS:
13435 : (a b c)
13436 @end example
13438 @node results, file, var, Specific header arguments
13439 @subsubsection @code{:results}
13441 There are three classes of @code{:results} header argument.  Only one option
13442 per class may be supplied per code block.
13444 @itemize @bullet
13445 @item
13446 @b{collection} header arguments specify how the results should be collected
13447 from the code block
13448 @item
13449 @b{type} header arguments specify what type of result the code block will
13450 return---which has implications for how they will be inserted into the
13451 Org mode buffer
13452 @item
13453 @b{handling} header arguments specify how the results of evaluating the code
13454 block should be handled.
13455 @end itemize
13457 @subsubheading Collection
13458 The following options are mutually exclusive, and specify how the results
13459 should be collected from the code block.
13461 @itemize @bullet
13462 @item @code{value}
13463 This is the default.  The result is the value of the last statement in the
13464 code block.  This header argument places the evaluation in functional
13465 mode.  Note that in some languages, e.g., Python, use of this result type
13466 requires that a @code{return} statement be included in the body of the source
13467 code block.  E.g., @code{:results value}.
13468 @item @code{output}
13469 The result is the collection of everything printed to STDOUT during the
13470 execution of the code block.  This header argument places the
13471 evaluation in scripting mode.  E.g., @code{:results output}.
13472 @end itemize
13474 @subsubheading Type
13476 The following options are mutually exclusive and specify what type of results
13477 the code block will return.  By default, results are inserted as either a
13478 table or scalar depending on their value.
13480 @itemize @bullet
13481 @item @code{table}, @code{vector}
13482 The results should be interpreted as an Org mode table.  If a single value is
13483 returned, it will be converted into a table with one row and one column.
13484 E.g., @code{:results value table}.
13485 @item @code{list}
13486 The results should be interpreted as an Org mode list.  If a single scalar
13487 value is returned it will be converted into a list with only one element.
13488 @item @code{scalar}, @code{verbatim}
13489 The results should be interpreted literally---they will not be
13490 converted into a table.  The results will be inserted into the Org mode
13491 buffer as quoted text.  E.g., @code{:results value verbatim}.
13492 @item @code{file}
13493 The results will be interpreted as the path to a file, and will be inserted
13494 into the Org mode buffer as a file link.  E.g., @code{:results value file}.
13495 @item @code{raw}
13496 The results are interpreted as raw Org mode code and are inserted directly
13497 into the buffer.  If the results look like a table they will be aligned as
13498 such by Org mode.  E.g., @code{:results value raw}.
13499 @item @code{org}
13500 The results are will be enclosed in a @code{BEGIN_SRC org} block.
13501 They are not comma-escaped by default but they will be if you hit @kbd{TAB}
13502 in the block and/or if you export the file.  E.g., @code{:results value org}.
13503 @item @code{html}
13504 Results are assumed to be HTML and will be enclosed in a @code{BEGIN_HTML}
13505 block.  E.g., @code{:results value html}.
13506 @item @code{latex}
13507 Results assumed to be @LaTeX{} and are enclosed in a @code{BEGIN_LaTeX} block.
13508 E.g., @code{:results value latex}.
13509 @item @code{code}
13510 Result are assumed to be parsable code and are enclosed in a code block.
13511 E.g., @code{:results value code}.
13512 @item @code{pp}
13513 The result is converted to pretty-printed code and is enclosed in a code
13514 block.  This option currently supports Emacs Lisp, Python, and Ruby.  E.g.,
13515 @code{:results value pp}.
13516 @item @code{drawer}
13517 The result is wrapped in a RESULTS drawer.  This can be useful for
13518 inserting @code{raw} or @code{org} syntax results in such a way that their
13519 extent is known and they can be automatically removed or replaced.
13520 @end itemize
13522 @subsubheading Handling
13523 The following results options indicate what happens with the
13524 results once they are collected.
13526 @itemize @bullet
13527 @item @code{silent}
13528 The results will be echoed in the minibuffer but will not be inserted into
13529 the Org mode buffer.  E.g., @code{:results output silent}.
13530 @item @code{replace}
13531 The default value.  Any existing results will be removed, and the new results
13532 will be inserted into the Org mode buffer in their place.  E.g.,
13533 @code{:results output replace}.
13534 @item @code{append}
13535 If there are pre-existing results of the code block then the new results will
13536 be appended to the existing results.  Otherwise the new results will be
13537 inserted as with @code{replace}.
13538 @item @code{prepend}
13539 If there are pre-existing results of the code block then the new results will
13540 be prepended to the existing results.  Otherwise the new results will be
13541 inserted as with @code{replace}.
13542 @end itemize
13544 @node file, file-desc, results, Specific header arguments
13545 @subsubsection @code{:file}
13547 The header argument @code{:file} is used to specify an external file in which
13548 to save code block results.  After code block evaluation an Org mode style
13549 @code{[[file:]]} link (see @ref{Link format}) to the file will be inserted
13550 into the Org mode buffer.  Some languages including R, gnuplot, dot, and
13551 ditaa provide special handling of the @code{:file} header argument
13552 automatically wrapping the code block body in the boilerplate code required
13553 to save output to the specified file.  This is often useful for saving
13554 graphical output of a code block to the specified file.
13556 The argument to @code{:file} should be either a string specifying the path to
13557 a file, or a list of two strings in which case the first element of the list
13558 should be the path to a file and the second a description for the link.
13560 @node file-desc, dir, file, Specific header arguments
13561 @subsubsection @code{:file-desc}
13563 The value of the @code{:file-desc} header argument is used to provide a
13564 description for file code block results which are inserted as Org mode links
13565 (see @ref{Link format}).  If the @code{:file-desc} header argument is given
13566 with no value the link path will be placed in both the ``link'' and the
13567 ``description'' portion of the Org mode link.
13569 @node dir, exports, file-desc, Specific header arguments
13570 @subsubsection @code{:dir} and remote execution
13572 While the @code{:file} header argument can be used to specify the path to the
13573 output file, @code{:dir} specifies the default directory during code block
13574 execution.  If it is absent, then the directory associated with the current
13575 buffer is used.  In other words, supplying @code{:dir path} temporarily has
13576 the same effect as changing the current directory with @kbd{M-x cd path}, and
13577 then not supplying @code{:dir}.  Under the surface, @code{:dir} simply sets
13578 the value of the Emacs variable @code{default-directory}.
13580 When using @code{:dir}, you should supply a relative path for file output
13581 (e.g., @code{:file myfile.jpg} or @code{:file results/myfile.jpg}) in which
13582 case that path will be interpreted relative to the default directory.
13584 In other words, if you want your plot to go into a folder called @file{Work}
13585 in your home directory, you could use
13587 @example
13588 #+BEGIN_SRC R :file myplot.png :dir ~/Work
13589 matplot(matrix(rnorm(100), 10), type="l")
13590 #+END_SRC
13591 @end example
13593 @subsubheading Remote execution
13594 A directory on a remote machine can be specified using tramp file syntax, in
13595 which case the code will be evaluated on the remote machine.  An example is
13597 @example
13598 #+BEGIN_SRC R :file plot.png :dir /dand@@yakuba.princeton.edu:
13599 plot(1:10, main=system("hostname", intern=TRUE))
13600 #+END_SRC
13601 @end example
13603 Text results will be returned to the local Org mode buffer as usual, and file
13604 output will be created on the remote machine with relative paths interpreted
13605 relative to the remote directory.  An Org mode link to the remote file will be
13606 created.
13608 So, in the above example a plot will be created on the remote machine,
13609 and a link of the following form will be inserted in the org buffer:
13611 @example
13612 [[file:/scp:dand@@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
13613 @end example
13615 Most of this functionality follows immediately from the fact that @code{:dir}
13616 sets the value of the Emacs variable @code{default-directory}, thanks to
13617 tramp.  Those using XEmacs, or GNU Emacs prior to version 23 may need to
13618 install tramp separately in order for these features to work correctly.
13620 @subsubheading Further points
13622 @itemize @bullet
13623 @item
13624 If @code{:dir} is used in conjunction with @code{:session}, although it will
13625 determine the starting directory for a new session as expected, no attempt is
13626 currently made to alter the directory associated with an existing session.
13627 @item
13628 @code{:dir} should typically not be used to create files during export with
13629 @code{:exports results} or @code{:exports both}.  The reason is that, in order
13630 to retain portability of exported material between machines, during export
13631 links inserted into the buffer will @emph{not} be expanded against @code{default
13632 directory}.  Therefore, if @code{default-directory} is altered using
13633 @code{:dir}, it is probable that the file will be created in a location to
13634 which the link does not point.
13635 @end itemize
13637 @node exports, tangle, dir, Specific header arguments
13638 @subsubsection @code{:exports}
13640 The @code{:exports} header argument specifies what should be included in HTML
13641 or @LaTeX{} exports of the Org mode file.
13643 @itemize @bullet
13644 @item @code{code}
13645 The default.  The body of code is included into the exported file.  E.g.,
13646 @code{:exports code}.
13647 @item @code{results}
13648 The result of evaluating the code is included in the exported file.  E.g.,
13649 @code{:exports results}.
13650 @item @code{both}
13651 Both the code and results are included in the exported file.  E.g.,
13652 @code{:exports both}.
13653 @item @code{none}
13654 Nothing is included in the exported file.  E.g., @code{:exports none}.
13655 @end itemize
13657 @node tangle, mkdirp, exports, Specific header arguments
13658 @subsubsection @code{:tangle}
13660 The @code{:tangle} header argument specifies whether or not the code
13661 block should be included in tangled extraction of source code files.
13663 @itemize @bullet
13664 @item @code{tangle}
13665 The code block is exported to a source code file named after the full path
13666 (including the directory) and file name (w/o extension) of the Org mode file.
13667 E.g., @code{:tangle yes}.
13668 @item @code{no}
13669 The default.  The code block is not exported to a source code file.
13670 E.g., @code{:tangle no}.
13671 @item other
13672 Any other string passed to the @code{:tangle} header argument is interpreted
13673 as a path (directory and file name relative to the directory of the Org mode
13674 file) to which the block will be exported.  E.g., @code{:tangle path}.
13675 @end itemize
13677 @node mkdirp, comments, tangle, Specific header arguments
13678 @subsubsection @code{:mkdirp}
13680 The @code{:mkdirp} header argument can be used to create parent directories
13681 of tangled files when missing.  This can be set to @code{yes} to enable
13682 directory creation or to @code{no} to inhibit directory creation.
13684 @node comments, padline, mkdirp, Specific header arguments
13685 @subsubsection @code{:comments}
13686 By default code blocks are tangled to source-code files without any insertion
13687 of comments beyond those which may already exist in the body of the code
13688 block.  The @code{:comments} header argument can be set as follows to control
13689 the insertion of extra comments into the tangled code file.
13691 @itemize @bullet
13692 @item @code{no}
13693 The default.  No extra comments are inserted during tangling.
13694 @item @code{link}
13695 The code block is wrapped in comments which contain pointers back to the
13696 original Org file from which the code was tangled.
13697 @item @code{yes}
13698 A synonym for ``link'' to maintain backwards compatibility.
13699 @item @code{org}
13700 Include text from the Org mode file as a comment.
13701 The text is picked from the leading context of the tangled code and is
13702 limited by the nearest headline or source block as the case may be.
13703 @item @code{both}
13704 Turns on both the ``link'' and ``org'' comment options.
13705 @item @code{noweb}
13706 Turns on the ``link'' comment option, and additionally wraps expanded noweb
13707 references in the code block body in link comments.
13708 @end itemize
13710 @node padline, no-expand, comments, Specific header arguments
13711 @subsubsection @code{:padline}
13712 Control in insertion of padding lines around code block bodies in tangled
13713 code files.  The default value is @code{yes} which results in insertion of
13714 newlines before and after each tangled code block.  The following arguments
13715 are accepted.
13717 @itemize @bullet
13718 @item @code{yes}
13719 Insert newlines before and after each code block body in tangled code files.
13720 @item @code{no}
13721 Do not insert any newline padding in tangled output.
13722 @end itemize
13724 @node no-expand, session, padline, Specific header arguments
13725 @subsubsection @code{:no-expand}
13727 By default, code blocks are expanded with @code{org-babel-expand-src-block}
13728 during tangling.  This has the effect of assigning values to variables
13729 specified with @code{:var} (see @ref{var}), and of replacing ``noweb''
13730 references (see @ref{Noweb reference syntax}) with their targets.  The
13731 @code{:no-expand} header argument can be used to turn off this behavior.
13733 @node session, noweb, no-expand, Specific header arguments
13734 @subsubsection @code{:session}
13736 The @code{:session} header argument starts a session for an interpreted
13737 language where state is preserved.
13739 By default, a session is not started.
13741 A string passed to the @code{:session} header argument will give the session
13742 a name.  This makes it possible to run concurrent sessions for each
13743 interpreted language.
13745 @node noweb, noweb-ref, session, Specific header arguments
13746 @subsubsection @code{:noweb}
13748 The @code{:noweb} header argument controls expansion of ``noweb'' syntax
13749 references (see @ref{Noweb reference syntax}) when the code block is
13750 evaluated, tangled, or exported.  The @code{:noweb} header argument can have
13751 one of the five values: @code{no}, @code{yes}, @code{tangle}, or
13752 @code{no-export} @code{strip-export}.
13754 @itemize @bullet
13755 @item @code{no}
13756 The default.  ``Noweb'' syntax references in the body of the code block will
13757 not be expanded before the code block is evaluated, tangled or exported.
13758 @item @code{yes}
13759 ``Noweb'' syntax references in the body of the code block will be
13760 expanded before the code block is evaluated, tangled or exported.
13761 @item @code{tangle}
13762 ``Noweb'' syntax references in the body of the code block will be expanded
13763 before the code block is tangled.  However, ``noweb'' syntax references will
13764 not be expanded when the code block is evaluated or exported.
13765 @item @code{no-export}
13766 ``Noweb'' syntax references in the body of the code block will be expanded
13767 before the block is evaluated or tangled.  However, ``noweb'' syntax
13768 references will not be expanded when the code block is exported.
13769 @item @code{strip-export}
13770 ``Noweb'' syntax references in the body of the code block will be expanded
13771 before the block is evaluated or tangled.  However, ``noweb'' syntax
13772 references will not be removed when the code block is exported.
13773 @item @code{eval}
13774 ``Noweb'' syntax references in the body of the code block will only be
13775 expanded before the block is evaluated.
13776 @end itemize
13778 @subsubheading Noweb prefix lines
13779 Noweb insertions are now placed behind the line prefix of the
13780 @code{<<reference>>}.
13781 This behavior is illustrated in the following example.  Because the
13782 @code{<<example>>} noweb reference appears behind the SQL comment syntax,
13783 each line of the expanded noweb reference will be commented.
13785 This code block:
13787 @example
13788 -- <<example>>
13789 @end example
13791 expands to:
13793 @example
13794 -- this is the
13795 -- multi-line body of example
13796 @end example
13798 Note that noweb replacement text that does not contain any newlines will not
13799 be affected by this change, so it is still possible to use inline noweb
13800 references.
13802 @node noweb-ref, noweb-sep, noweb, Specific header arguments
13803 @subsubsection @code{:noweb-ref}
13804 When expanding ``noweb'' style references the bodies of all code block with
13805 @emph{either} a block name matching the reference name @emph{or} a
13806 @code{:noweb-ref} header argument matching the reference name will be
13807 concatenated together to form the replacement text.
13809 By setting this header argument at the sub-tree or file level, simple code
13810 block concatenation may be achieved.  For example, when tangling the
13811 following Org mode file, the bodies of code blocks will be concatenated into
13812 the resulting pure code file@footnote{(The example needs property inheritance
13813 to be turned on for the @code{noweb-ref} property, see @ref{Property
13814 inheritance}).}.
13816 @example
13817  #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
13818    <<fullest-disk>>
13819  #+END_SRC
13820  * the mount point of the fullest disk
13821    :PROPERTIES:
13822    :noweb-ref: fullest-disk
13823    :END:
13825  ** query all mounted disks
13826  #+BEGIN_SRC sh
13827    df \
13828  #+END_SRC
13830  ** strip the header row
13831  #+BEGIN_SRC sh
13832    |sed '1d' \
13833  #+END_SRC
13835  ** sort by the percent full
13836  #+BEGIN_SRC sh
13837    |awk '@{print $5 " " $6@}'|sort -n |tail -1 \
13838  #+END_SRC
13840  ** extract the mount point
13841  #+BEGIN_SRC sh
13842    |awk '@{print $2@}'
13843  #+END_SRC
13844 @end example
13846 The @code{:noweb-sep} (see @ref{noweb-sep}) header argument holds the string
13847 used to separate accumulate noweb references like those above.  By default a
13848 newline is used.
13850 @node noweb-sep, cache, noweb-ref, Specific header arguments
13851 @subsubsection @code{:noweb-sep}
13853 The @code{:noweb-sep} header argument holds the string used to separate
13854 accumulate noweb references (see @ref{noweb-ref}).  By default a newline is
13855 used.
13857 @node cache, sep, noweb-sep, Specific header arguments
13858 @subsubsection @code{:cache}
13860 The @code{:cache} header argument controls the use of in-buffer caching of
13861 the results of evaluating code blocks.  It can be used to avoid re-evaluating
13862 unchanged code blocks.  Note that the @code{:cache} header argument will not
13863 attempt to cache results when the @code{:session} header argument is used,
13864 because the results of the code block execution may be stored in the session
13865 outside of the Org mode buffer.  The @code{:cache} header argument can have
13866 one of two values: @code{yes} or @code{no}.
13868 @itemize @bullet
13869 @item @code{no}
13870 The default.  No caching takes place, and the code block will be evaluated
13871 every time it is called.
13872 @item @code{yes}
13873 Every time the code block is run a SHA1 hash of the code and arguments
13874 passed to the block will be generated.  This hash is packed into the
13875 @code{#+RESULTS:} line and will be checked on subsequent
13876 executions of the code block.  If the code block has not
13877 changed since the last time it was evaluated, it will not be re-evaluated.
13878 @end itemize
13880 Code block caches notice if the value of a variable argument
13881 to the code block has changed.  If this is the case, the cache is
13882 invalidated and the code block is re-run.  In the following example,
13883 @code{caller} will not be re-run unless the results of @code{random} have
13884 changed since it was last run.
13886 @example
13887  #+NAME: random
13888  #+BEGIN_SRC R :cache yes
13889  runif(1)
13890  #+END_SRC
13892  #+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
13893  0.4659510825295
13895  #+NAME: caller
13896  #+BEGIN_SRC emacs-lisp :var x=random :cache yes
13898  #+END_SRC
13900  #+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
13901  0.254227238707244
13902 @end example
13904 @node sep, hlines, cache, Specific header arguments
13905 @subsubsection @code{:sep}
13907 The @code{:sep} header argument can be used to control the delimiter used
13908 when writing tabular results out to files external to Org mode.  This is used
13909 either when opening tabular results of a code block by calling the
13910 @code{org-open-at-point} function bound to @kbd{C-c C-o} on the code block,
13911 or when writing code block results to an external file (see @ref{file})
13912 header argument.
13914 By default, when @code{:sep} is not specified output tables are tab
13915 delimited.
13917 @node hlines, colnames, sep, Specific header arguments
13918 @subsubsection @code{:hlines}
13920 Tables are frequently represented with one or more horizontal lines, or
13921 hlines.  The @code{:hlines} argument to a code block accepts the
13922 values @code{yes} or @code{no}, with a default value of @code{no}.
13924 @itemize @bullet
13925 @item @code{no}
13926 Strips horizontal lines from the input table.  In most languages this is the
13927 desired effect because an @code{hline} symbol is interpreted as an unbound
13928 variable and raises an error.  Setting @code{:hlines no} or relying on the
13929 default value yields the following results.  Note that the @code{:hline}
13930 header argument has no effect for Emacs Lisp code blocks.
13932 @example
13933 #+TBLNAME: many-cols
13934 | a | b | c |
13935 |---+---+---|
13936 | d | e | f |
13937 |---+---+---|
13938 | g | h | i |
13940 #+NAME: echo-table
13941 #+BEGIN_SRC python :var tab=many-cols
13942   return tab
13943 #+END_SRC
13945 #+RESULTS: echo-table
13946 | a | b | c |
13947 | d | e | f |
13948 | g | h | i |
13949 @end example
13951 @item @code{yes}
13952 Leaves hlines in the table.  Setting @code{:hlines yes} has this effect.
13954 @example
13955 #+TBLNAME: many-cols
13956 | a | b | c |
13957 |---+---+---|
13958 | d | e | f |
13959 |---+---+---|
13960 | g | h | i |
13962 #+NAME: echo-table
13963 #+BEGIN_SRC python :var tab=many-cols :hlines yes
13964   return tab
13965 #+END_SRC
13967 #+RESULTS: echo-table
13968 | a | b | c |
13969 |---+---+---|
13970 | d | e | f |
13971 |---+---+---|
13972 | g | h | i |
13973 @end example
13974 @end itemize
13976 @node colnames, rownames, hlines, Specific header arguments
13977 @subsubsection @code{:colnames}
13979 The @code{:colnames} header argument accepts the values @code{yes},
13980 @code{no}, or @code{nil} for unassigned.  The default value is @code{nil}.
13981 Note that the behavior of the @code{:colnames} header argument may differ
13982 across languages.  For example Emacs Lisp code blocks ignore the
13983 @code{:colnames} header argument entirely given the ease with which tables
13984 with column names may be handled directly in Emacs Lisp.
13986 @itemize @bullet
13987 @item @code{nil}
13988 If an input table looks like it has column names
13989 (because its second row is an hline), then the column
13990 names will be removed from the table before
13991 processing, then reapplied to the results.
13993 @example
13994 #+TBLNAME: less-cols
13995 | a |
13996 |---|
13997 | b |
13998 | c |
14000 #+NAME: echo-table-again
14001 #+BEGIN_SRC python :var tab=less-cols
14002   return [[val + '*' for val in row] for row in tab]
14003 #+END_SRC
14005 #+RESULTS: echo-table-again
14006 | a  |
14007 |----|
14008 | b* |
14009 | c* |
14010 @end example
14012 Please note that column names are not removed before the table is indexed
14013 using variable indexing @xref{var, Indexable variable values}.
14015 @item @code{no}
14016 No column name pre-processing takes place
14018 @item @code{yes}
14019 Column names are removed and reapplied as with @code{nil} even if the table
14020 does not ``look like'' it has column names (i.e., the second row is not an
14021 hline)
14022 @end itemize
14024 @node rownames, shebang, colnames, Specific header arguments
14025 @subsubsection @code{:rownames}
14027 The @code{:rownames} header argument can take on the values @code{yes} or
14028 @code{no}, with a default value of @code{no}.  Note that Emacs Lisp code
14029 blocks ignore the @code{:rownames} header argument entirely given the ease
14030 with which tables with row names may be handled directly in Emacs Lisp.
14032 @itemize @bullet
14033 @item @code{no}
14034 No row name pre-processing will take place.
14036 @item @code{yes}
14037 The first column of the table is removed from the table before processing,
14038 and is then reapplied to the results.
14040 @example
14041 #+TBLNAME: with-rownames
14042 | one | 1 | 2 | 3 | 4 |  5 |
14043 | two | 6 | 7 | 8 | 9 | 10 |
14045 #+NAME: echo-table-once-again
14046 #+BEGIN_SRC python :var tab=with-rownames :rownames yes
14047   return [[val + 10 for val in row] for row in tab]
14048 #+END_SRC
14050 #+RESULTS: echo-table-once-again
14051 | one | 11 | 12 | 13 | 14 | 15 |
14052 | two | 16 | 17 | 18 | 19 | 20 |
14053 @end example
14055 Please note that row names are not removed before the table is indexed using
14056 variable indexing @xref{var, Indexable variable values}.
14058 @end itemize
14060 @node shebang, eval, rownames, Specific header arguments
14061 @subsubsection @code{:shebang}
14063 Setting the @code{:shebang} header argument to a string value
14064 (e.g., @code{:shebang "#!/bin/bash"}) causes the string to be inserted as the
14065 first line of any tangled file holding the code block, and the file
14066 permissions of the tangled file are set to make it executable.
14068 @node eval, wrap, shebang, Specific header arguments
14069 @subsubsection @code{:eval}
14070 The @code{:eval} header argument can be used to limit the evaluation of
14071 specific code blocks.  The @code{:eval} header argument can be useful for
14072 protecting against the evaluation of dangerous code blocks or to ensure that
14073 evaluation will require a query regardless of the value of the
14074 @code{org-confirm-babel-evaluate} variable.  The possible values of
14075 @code{:eval} and their effects are shown below.
14077 @table @code
14078 @item never or no
14079 The code block will not be evaluated under any circumstances.
14080 @item query
14081 Evaluation of the code block will require a query.
14082 @item never-export or no-export
14083 The code block will not be evaluated during export but may still be called
14084 interactively.
14085 @item query-export
14086 Evaluation of the code block during export will require a query.
14087 @end table
14089 If this header argument is not set then evaluation is determined by the value
14090 of the @code{org-confirm-babel-evaluate} variable see @ref{Code evaluation
14091 security}.
14093 @node wrap,  , eval, Specific header arguments
14094 @subsubsection @code{:wrap}
14095 The @code{:wrap} header argument is used to mark the results of source block
14096 evaluation.  The header argument can be passed a string that will be appended
14097 to @code{#+BEGIN_} and @code{#+END_}, which will then be used to wrap the
14098 results.  If not string is specified then the results will be wrapped in a
14099 @code{#+BEGIN/END_RESULTS} block.
14101 @node Results of evaluation, Noweb reference syntax, Header arguments, Working With Source Code
14102 @section Results of evaluation
14103 @cindex code block, results of evaluation
14104 @cindex source code, results of evaluation
14106 The way in which results are handled depends on whether a session is invoked,
14107 as well as on whether @code{:results value} or @code{:results output} is
14108 used.  The following table shows the table possibilities.  For a full listing
14109 of the possible results header arguments see @ref{results}.
14111 @multitable @columnfractions 0.26 0.33 0.41
14112 @item @tab @b{Non-session} @tab @b{Session}
14113 @item @code{:results value} @tab value of last expression @tab value of last expression
14114 @item @code{:results output} @tab contents of STDOUT @tab concatenation of interpreter output
14115 @end multitable
14117 Note: With @code{:results value}, the result in both @code{:session} and
14118 non-session is returned to Org mode as a table (a one- or two-dimensional
14119 vector of strings or numbers) when appropriate.
14121 @subsection Non-session
14122 @subsubsection @code{:results value}
14123 This is the default.  Internally, the value is obtained by wrapping the code
14124 in a function definition in the external language, and evaluating that
14125 function.  Therefore, code should be written as if it were the body of such a
14126 function.  In particular, note that Python does not automatically return a
14127 value from a function unless a @code{return} statement is present, and so a
14128 @samp{return} statement will usually be required in Python.
14130 This is the only one of the four evaluation contexts in which the code is
14131 automatically wrapped in a function definition.
14133 @subsubsection @code{:results output}
14134 The code is passed to the interpreter as an external process, and the
14135 contents of the standard output stream are returned as text.  (In certain
14136 languages this also contains the error output stream; this is an area for
14137 future work.)
14139 @subsection Session
14140 @subsubsection @code{:results value}
14141 The code is passed to an interpreter running as an interactive Emacs inferior
14142 process.  Only languages which provide tools for interactive evaluation of
14143 code have session support, so some language (e.g., C and ditaa) do not
14144 support the @code{:session} header argument, and in other languages (e.g.,
14145 Python and Haskell) which have limitations on the code which may be entered
14146 into interactive sessions, those limitations apply to the code in code blocks
14147 using the @code{:session} header argument as well.
14149 Unless the @code{:results output} option is supplied (see below) the result
14150 returned is the result of the last evaluation performed by the
14151 interpreter.  (This is obtained in a language-specific manner: the value of
14152 the variable @code{_} in Python and Ruby, and the value of @code{.Last.value}
14153 in R).
14155 @subsubsection @code{:results output}
14156 The code is passed to the interpreter running as an interactive Emacs
14157 inferior process.  The result returned is the concatenation of the sequence of
14158 (text) output from the interactive interpreter.  Notice that this is not
14159 necessarily the same as what would be sent to @code{STDOUT} if the same code
14160 were passed to a non-interactive interpreter running as an external
14161 process.  For example, compare the following two blocks:
14163 @example
14164 #+BEGIN_SRC python :results output
14165  print "hello"
14167  print "bye"
14168 #+END_SRC
14170 #+RESULTS:
14171 : hello
14172 : bye
14173 @end example
14175 In non-session mode, the `2' is not printed and does not appear.
14177 @example
14178 #+BEGIN_SRC python :results output :session
14179  print "hello"
14181  print "bye"
14182 #+END_SRC
14184 #+RESULTS:
14185 : hello
14186 : 2
14187 : bye
14188 @end example
14190 But in @code{:session} mode, the interactive interpreter receives input `2'
14191 and prints out its value, `2'.  (Indeed, the other print statements are
14192 unnecessary here).
14194 @node Noweb reference syntax, Key bindings and useful functions, Results of evaluation, Working With Source Code
14195 @section Noweb reference syntax
14196 @cindex code block, noweb reference
14197 @cindex syntax, noweb
14198 @cindex source code, noweb reference
14200 The ``noweb'' (see @uref{http://www.cs.tufts.edu/~nr/noweb/}) Literate
14201 Programming system allows named blocks of code to be referenced by using the
14202 familiar Noweb syntax:
14204 @example
14205 <<code-block-name>>
14206 @end example
14208 When a code block is tangled or evaluated, whether or not ``noweb''
14209 references are expanded depends upon the value of the @code{:noweb} header
14210 argument.  If @code{:noweb yes}, then a Noweb reference is expanded before
14211 evaluation.  If @code{:noweb no}, the default, then the reference is not
14212 expanded before evaluation.  See the @ref{noweb-ref} header argument for
14213 a more flexible way to resolve noweb references.
14215 It is possible to include the @emph{results} of a code block rather than the
14216 body.  This is done by appending parenthesis to the code block name which may
14217 optionally contain arguments to the code block as shown below.
14219 @example
14220 <<code-block-name(optional arguments)>>
14221 @end example
14223 Note: the default value, @code{:noweb no}, was chosen to ensure that
14224 correct code is not broken in a language, such as Ruby, where
14225 @code{<<arg>>} is a syntactically valid construct.  If @code{<<arg>>} is not
14226 syntactically valid in languages that you use, then please consider setting
14227 the default value.
14229 Note: if noweb tangling is slow in large Org mode files consider setting the
14230 @code{*org-babel-use-quick-and-dirty-noweb-expansion*} variable to true.
14231 This will result in faster noweb reference resolution at the expense of not
14232 correctly resolving inherited values of the @code{:noweb-ref} header
14233 argument.
14235 @node Key bindings and useful functions, Batch execution, Noweb reference syntax, Working With Source Code
14236 @section Key bindings and useful functions
14237 @cindex code block, key bindings
14239 Many common Org mode key sequences are re-bound depending on
14240 the context.
14242 Within a code block, the following key bindings
14243 are active:
14245 @multitable @columnfractions 0.25 0.75
14246 @kindex C-c C-c
14247 @item @kbd{C-c C-c} @tab @code{org-babel-execute-src-block}
14248 @kindex C-c C-o
14249 @item @kbd{C-c C-o} @tab @code{org-babel-open-src-block-result}
14250 @kindex C-up
14251 @item @kbd{C-@key{up}}    @tab @code{org-babel-load-in-session}
14252 @kindex M-down
14253 @item @kbd{M-@key{down}}  @tab @code{org-babel-pop-to-session}
14254 @end multitable
14256 In an Org mode buffer, the following key bindings are active:
14258 @multitable @columnfractions 0.45 0.55
14259 @kindex C-c C-v p
14260 @kindex C-c C-v C-p
14261 @item @kbd{C-c C-v p} @ @ @r{or} @ @ @kbd{C-c C-v C-p} @tab @code{org-babel-previous-src-block}
14262 @kindex C-c C-v n
14263 @kindex C-c C-v C-n
14264 @item @kbd{C-c C-v n} @ @ @r{or} @ @ @kbd{C-c C-v C-n} @tab @code{org-babel-next-src-block}
14265 @kindex C-c C-v e
14266 @kindex C-c C-v C-e
14267 @item @kbd{C-c C-v e} @ @ @r{or} @ @ @kbd{C-c C-v C-e} @tab @code{org-babel-execute-maybe}
14268 @kindex C-c C-v o
14269 @kindex C-c C-v C-o
14270 @item @kbd{C-c C-v o} @ @ @r{or} @ @ @kbd{C-c C-v C-o} @tab @code{org-babel-open-src-block-result}
14271 @kindex C-c C-v v
14272 @kindex C-c C-v C-v
14273 @item @kbd{C-c C-v v} @ @ @r{or} @ @ @kbd{C-c C-v C-v} @tab @code{org-babel-expand-src-block}
14274 @kindex C-c C-v u
14275 @kindex C-c C-v C-u
14276 @item @kbd{C-c C-v u} @ @ @r{or} @ @ @kbd{C-c C-v C-u} @tab @code{org-babel-goto-src-block-head}
14277 @kindex C-c C-v g
14278 @kindex C-c C-v C-g
14279 @item @kbd{C-c C-v g} @ @ @r{or} @ @ @kbd{C-c C-v C-g} @tab @code{org-babel-goto-named-src-block}
14280 @kindex C-c C-v r
14281 @kindex C-c C-v C-r
14282 @item @kbd{C-c C-v r} @ @ @r{or} @ @ @kbd{C-c C-v C-r} @tab @code{org-babel-goto-named-result}
14283 @kindex C-c C-v b
14284 @kindex C-c C-v C-b
14285 @item @kbd{C-c C-v b} @ @ @r{or} @ @ @kbd{C-c C-v C-b} @tab @code{org-babel-execute-buffer}
14286 @kindex C-c C-v s
14287 @kindex C-c C-v C-s
14288 @item @kbd{C-c C-v s} @ @ @r{or} @ @ @kbd{C-c C-v C-s} @tab @code{org-babel-execute-subtree}
14289 @kindex C-c C-v d
14290 @kindex C-c C-v C-d
14291 @item @kbd{C-c C-v d} @ @ @r{or} @ @ @kbd{C-c C-v C-d} @tab @code{org-babel-demarcate-block}
14292 @kindex C-c C-v t
14293 @kindex C-c C-v C-t
14294 @item @kbd{C-c C-v t} @ @ @r{or} @ @ @kbd{C-c C-v C-t} @tab @code{org-babel-tangle}
14295 @kindex C-c C-v f
14296 @kindex C-c C-v C-f
14297 @item @kbd{C-c C-v f} @ @ @r{or} @ @ @kbd{C-c C-v C-f} @tab @code{org-babel-tangle-file}
14298 @kindex C-c C-v c
14299 @kindex C-c C-v C-c
14300 @item @kbd{C-c C-v c} @ @ @r{or} @ @ @kbd{C-c C-v C-c} @tab @code{org-babel-check-src-block}
14301 @kindex C-c C-v j
14302 @kindex C-c C-v C-j
14303 @item @kbd{C-c C-v j} @ @ @r{or} @ @ @kbd{C-c C-v C-j} @tab @code{org-babel-insert-header-arg}
14304 @kindex C-c C-v l
14305 @kindex C-c C-v C-l
14306 @item @kbd{C-c C-v l} @ @ @r{or} @ @ @kbd{C-c C-v C-l} @tab @code{org-babel-load-in-session}
14307 @kindex C-c C-v i
14308 @kindex C-c C-v C-i
14309 @item @kbd{C-c C-v i} @ @ @r{or} @ @ @kbd{C-c C-v C-i} @tab @code{org-babel-lob-ingest}
14310 @kindex C-c C-v I
14311 @kindex C-c C-v C-I
14312 @item @kbd{C-c C-v I} @ @ @r{or} @ @ @kbd{C-c C-v C-I} @tab @code{org-babel-view-src-block-info}
14313 @kindex C-c C-v z
14314 @kindex C-c C-v C-z
14315 @item @kbd{C-c C-v z} @ @ @r{or} @ @ @kbd{C-c C-v C-z} @tab @code{org-babel-switch-to-session-with-code}
14316 @kindex C-c C-v a
14317 @kindex C-c C-v C-a
14318 @item @kbd{C-c C-v a} @ @ @r{or} @ @ @kbd{C-c C-v C-a} @tab @code{org-babel-sha1-hash}
14319 @kindex C-c C-v h
14320 @kindex C-c C-v C-h
14321 @item @kbd{C-c C-v h} @ @ @r{or} @ @ @kbd{C-c C-v C-h} @tab @code{org-babel-describe-bindings}
14322 @kindex C-c C-v x
14323 @kindex C-c C-v C-x
14324 @item @kbd{C-c C-v x} @ @ @r{or} @ @ @kbd{C-c C-v C-x} @tab @code{org-babel-do-key-sequence-in-edit-buffer}
14325 @end multitable
14327 @c When possible these keybindings were extended to work when the control key is
14328 @c kept pressed, resulting in the following additional keybindings.
14330 @c @multitable @columnfractions 0.25 0.75
14331 @c @item @kbd{C-c C-v C-a} @tab @code{org-babel-sha1-hash}
14332 @c @item @kbd{C-c C-v C-b} @tab @code{org-babel-execute-buffer}
14333 @c @item @kbd{C-c C-v C-f} @tab @code{org-babel-tangle-file}
14334 @c @item @kbd{C-c C-v C-l} @tab @code{org-babel-lob-ingest}
14335 @c @item @kbd{C-c C-v C-p} @tab @code{org-babel-expand-src-block}
14336 @c @item @kbd{C-c C-v C-s} @tab @code{org-babel-execute-subtree}
14337 @c @item @kbd{C-c C-v C-t} @tab @code{org-babel-tangle}
14338 @c @item @kbd{C-c C-v C-z} @tab @code{org-babel-switch-to-session}
14339 @c @end multitable
14341 @node Batch execution,  , Key bindings and useful functions, Working With Source Code
14342 @section Batch execution
14343 @cindex code block, batch execution
14344 @cindex source code, batch execution
14346 It is possible to call functions from the command line.  This shell
14347 script calls @code{org-babel-tangle} on every one of its arguments.
14349 Be sure to adjust the paths to fit your system.
14351 @example
14352 #!/bin/sh
14353 # -*- mode: shell-script -*-
14355 # tangle files with org-mode
14357 DIR=`pwd`
14358 FILES=""
14360 # wrap each argument in the code required to call tangle on it
14361 for i in $@@; do
14362     FILES="$FILES \"$i\""
14363 done
14365 emacs -Q --batch \
14366 --eval "(progn
14367 (add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\"))
14368 (add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\" t))
14369 (require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle)
14370 (mapc (lambda (file)
14371        (find-file (expand-file-name file \"$DIR\"))
14372        (org-babel-tangle)
14373        (kill-buffer)) '($FILES)))" 2>&1 |grep tangled
14374 @end example
14376 @node Miscellaneous, Hacking, Working With Source Code, Top
14377 @chapter Miscellaneous
14379 @menu
14380 * Completion::                  M-TAB knows what you need
14381 * Easy Templates::              Quick insertion of structural elements
14382 * Speed keys::                  Electric commands at the beginning of a headline
14383 * Code evaluation security::    Org mode files evaluate inline code
14384 * Customization::               Adapting Org to your taste
14385 * In-buffer settings::          Overview of the #+KEYWORDS
14386 * The very busy C-c C-c key::   When in doubt, press C-c C-c
14387 * Clean view::                  Getting rid of leading stars in the outline
14388 * TTY keys::                    Using Org on a tty
14389 * Interaction::                 Other Emacs packages
14390 * org-crypt.el::                Encrypting Org files
14391 @end menu
14394 @node Completion, Easy Templates, Miscellaneous, Miscellaneous
14395 @section Completion
14396 @cindex completion, of @TeX{} symbols
14397 @cindex completion, of TODO keywords
14398 @cindex completion, of dictionary words
14399 @cindex completion, of option keywords
14400 @cindex completion, of tags
14401 @cindex completion, of property keys
14402 @cindex completion, of link abbreviations
14403 @cindex @TeX{} symbol completion
14404 @cindex TODO keywords completion
14405 @cindex dictionary word completion
14406 @cindex option keyword completion
14407 @cindex tag completion
14408 @cindex link abbreviations, completion of
14410 Emacs would not be Emacs without completion, and Org mode uses it whenever it
14411 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
14412 some of the completion prompts, you can specify your preference by setting at
14413 most one of the variables @code{org-completion-use-iswitchb}
14414 @code{org-completion-use-ido}.
14416 Org supports in-buffer completion.  This type of completion does
14417 not make use of the minibuffer.  You simply type a few letters into
14418 the buffer and use the key to complete text right there.
14420 @table @kbd
14421 @kindex M-@key{TAB}
14422 @item M-@key{TAB}
14423 Complete word at point
14424 @itemize @bullet
14425 @item
14426 At the beginning of a headline, complete TODO keywords.
14427 @item
14428 After @samp{\}, complete @TeX{} symbols supported by the exporter.
14429 @item
14430 After @samp{*}, complete headlines in the current buffer so that they
14431 can be used in search links like @samp{[[*find this headline]]}.
14432 @item
14433 After @samp{:} in a headline, complete tags.  The list of tags is taken
14434 from the variable @code{org-tag-alist} (possibly set through the
14435 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
14436 dynamically from all tags used in the current buffer.
14437 @item
14438 After @samp{:} and not in a headline, complete property keys.  The list
14439 of keys is constructed dynamically from all keys used in the current
14440 buffer.
14441 @item
14442 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
14443 @item
14444 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
14445 @samp{OPTIONS} which set file-specific options for Org mode.  When the
14446 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
14447 will insert example settings for this keyword.
14448 @item
14449 In the line after @samp{#+STARTUP: }, complete startup keywords,
14450 i.e., valid keys for this line.
14451 @item
14452 Elsewhere, complete dictionary words using Ispell.
14453 @end itemize
14454 @end table
14456 @node Easy Templates, Speed keys, Completion, Miscellaneous
14457 @section Easy Templates
14458 @cindex template insertion
14459 @cindex insertion, of templates
14461 Org mode supports insertion of empty structural elements (like
14462 @code{#+BEGIN_SRC} and @code{#+END_SRC} pairs) with just a few key
14463 strokes.  This is achieved through a native template expansion mechanism.
14464 Note that Emacs has several other template mechanisms which could be used in
14465 a similar way, for example @file{yasnippet}.
14467 To insert a structural element, type a @samp{<}, followed by a template
14468 selector and @kbd{@key{TAB}}.  Completion takes effect only when the above
14469 keystrokes are typed on a line by itself.
14471 The following template selectors are currently supported.
14473 @multitable @columnfractions 0.1 0.9
14474 @item @kbd{s} @tab @code{#+BEGIN_SRC     ... #+END_SRC}
14475 @item @kbd{e} @tab @code{#+BEGIN_EXAMPLE ... #+END_EXAMPLE}
14476 @item @kbd{q} @tab @code{#+BEGIN_QUOTE   ... #+END_QUOTE}
14477 @item @kbd{v} @tab @code{#+BEGIN_VERSE   ... #+END_VERSE}
14478 @item @kbd{c} @tab @code{#+BEGIN_CENTER  ... #+END_CENTER}
14479 @item @kbd{l} @tab @code{#+BEGIN_LaTeX   ... #+END_LaTeX}
14480 @item @kbd{L} @tab @code{#+LaTeX:}
14481 @item @kbd{h} @tab @code{#+BEGIN_HTML    ... #+END_HTML}
14482 @item @kbd{H} @tab @code{#+HTML:}
14483 @item @kbd{a} @tab @code{#+BEGIN_ASCII   ... #+END_ASCII}
14484 @item @kbd{A} @tab @code{#+ASCII:}
14485 @item @kbd{i} @tab @code{#+INDEX:} line
14486 @item @kbd{I} @tab @code{#+INCLUDE:} line
14487 @end multitable
14489 For example, on an empty line, typing "<e" and then pressing TAB, will expand
14490 into a complete EXAMPLE template.
14492 You can install additional templates by customizing the variable
14493 @code{org-structure-template-alist}.  See the docstring of the variable for
14494 additional details.
14496 @node Speed keys, Code evaluation security, Easy Templates, Miscellaneous
14497 @section Speed keys
14498 @cindex speed keys
14499 @vindex org-use-speed-commands
14500 @vindex org-speed-commands-user
14502 Single keys can be made to execute commands when the cursor is at the
14503 beginning of a headline, i.e., before the first star.  Configure the variable
14504 @code{org-use-speed-commands} to activate this feature.  There is a
14505 pre-defined list of commands, and you can add more such commands using the
14506 variable @code{org-speed-commands-user}.  Speed keys do not only speed up
14507 navigation and other commands, but they also provide an alternative way to
14508 execute commands bound to keys that are not or not easily available on a TTY,
14509 or on a small mobile device with a limited keyboard.
14511 To see which commands are available, activate the feature and press @kbd{?}
14512 with the cursor at the beginning of a headline.
14514 @node Code evaluation security, Customization, Speed keys, Miscellaneous
14515 @section Code evaluation and security issues
14517 Org provides tools to work with the code snippets, including evaluating them.
14519 Running code on your machine always comes with a security risk.  Badly
14520 written or malicious code can be executed on purpose or by accident.  Org has
14521 default settings which will only evaluate such code if you give explicit
14522 permission to do so, and as a casual user of these features you should leave
14523 these precautions intact.
14525 For people who regularly work with such code, the confirmation prompts can
14526 become annoying, and you might want to turn them off.  This can be done, but
14527 you must be aware of the risks that are involved.
14529 Code evaluation can happen under the following circumstances:
14531 @table @i
14532 @item Source code blocks
14533 Source code blocks can be evaluated during export, or when pressing @kbd{C-c
14534 C-c} in the block.  The most important thing to realize here is that Org mode
14535 files which contain code snippets are, in a certain sense, like executable
14536 files.  So you should accept them and load them into Emacs only from trusted
14537 sources---just like you would do with a program you install on your computer.
14539 Make sure you know what you are doing before customizing the variables
14540 which take off the default security brakes.
14542 @defopt org-confirm-babel-evaluate
14543 When t (the default), the user is asked before every code block evaluation.
14544 When nil, the user is not asked.  When set to a function, it is called with
14545 two arguments (language and body of the code block) and should return t to
14546 ask and nil not to ask.
14547 @end defopt
14549 For example, here is how to execute "ditaa" code (which is considered safe)
14550 without asking:
14552 @example
14553 (defun my-org-confirm-babel-evaluate (lang body)
14554   (not (string= lang "ditaa")))  ; don't ask for ditaa
14555 (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
14556 @end example
14558 @item Following @code{shell} and @code{elisp} links
14559 Org has two link types that can directly evaluate code (@pxref{External
14560 links}).  These links can be problematic because the code to be evaluated is
14561 not visible.
14563 @defopt org-confirm-shell-link-function
14564 Function to queries user about shell link execution.
14565 @end defopt
14566 @defopt org-confirm-elisp-link-function
14567 Functions to query user for Emacs Lisp link execution.
14568 @end defopt
14570 @item Formulas in tables
14571 Formulas in tables (@pxref{The spreadsheet}) are code that is evaluated
14572 either by the @i{calc} interpreter, or by the @i{Emacs Lisp} interpreter.
14573 @end table
14575 @node Customization, In-buffer settings, Code evaluation security, Miscellaneous
14576 @section Customization
14577 @cindex customization
14578 @cindex options, for customization
14579 @cindex variables, for customization
14581 There are more than 500 variables that can be used to customize
14582 Org.  For the sake of compactness of the manual, I am not
14583 describing the variables here.  A structured overview of customization
14584 variables is available with @kbd{M-x org-customize}.  Or select
14585 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
14586 settings can also be activated on a per-file basis, by putting special
14587 lines into the buffer (@pxref{In-buffer settings}).
14589 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
14590 @section Summary of in-buffer settings
14591 @cindex in-buffer settings
14592 @cindex special keywords
14594 Org mode uses special lines in the buffer to define settings on a
14595 per-file basis.  These lines start with a @samp{#+} followed by a
14596 keyword, a colon, and then individual words defining a setting.  Several
14597 setting words can be in the same line, but you can also have multiple
14598 lines for the keyword.  While these settings are described throughout
14599 the manual, here is a summary.  After changing any of those lines in the
14600 buffer, press @kbd{C-c C-c} with the cursor still in the line to
14601 activate the changes immediately.  Otherwise they become effective only
14602 when the file is visited again in a new Emacs session.
14604 @vindex org-archive-location
14605 @table @kbd
14606 @item #+ARCHIVE: %s_done::
14607 This line sets the archive location for the agenda file.  It applies for
14608 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
14609 of the file.  The first such line also applies to any entries before it.
14610 The corresponding variable is @code{org-archive-location}.
14611 @item #+CATEGORY:
14612 This line sets the category for the agenda file.  The category applies
14613 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
14614 end of the file.  The first such line also applies to any entries before it.
14615 @item #+COLUMNS: %25ITEM .....
14616 @cindex property, COLUMNS
14617 Set the default format for columns view.  This format applies when
14618 columns view is invoked in locations where no @code{COLUMNS} property
14619 applies.
14620 @item #+CONSTANTS: name1=value1 ...
14621 @vindex org-table-formula-constants
14622 @vindex org-table-formula
14623 Set file-local values for constants to be used in table formulas.  This
14624 line sets the local variable @code{org-table-formula-constants-local}.
14625 The global version of this variable is
14626 @code{org-table-formula-constants}.
14627 @item #+FILETAGS: :tag1:tag2:tag3:
14628 Set tags that can be inherited by any entry in the file, including the
14629 top-level entries.
14630 @item #+DRAWERS: NAME1 .....
14631 @vindex org-drawers
14632 Set the file-local set of additional drawers.  The corresponding global
14633 variable is @code{org-drawers}.
14634 @item #+LINK:  linkword replace
14635 @vindex org-link-abbrev-alist
14636 These lines (several are allowed) specify link abbreviations.
14637 @xref{Link abbreviations}.  The corresponding variable is
14638 @code{org-link-abbrev-alist}.
14639 @item #+PRIORITIES: highest lowest default
14640 @vindex org-highest-priority
14641 @vindex org-lowest-priority
14642 @vindex org-default-priority
14643 This line sets the limits and the default for the priorities.  All three
14644 must be either letters A--Z or numbers 0--9.  The highest priority must
14645 have a lower ASCII number than the lowest priority.
14646 @item #+PROPERTY: Property_Name Value
14647 This line sets a default inheritance value for entries in the current
14648 buffer, most useful for specifying the allowed values of a property.
14649 @cindex #+SETUPFILE
14650 @item #+SETUPFILE: file
14651 This line defines a file that holds more in-buffer setup.  Normally this is
14652 entirely ignored.  Only when the buffer is parsed for option-setting lines
14653 (i.e., when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
14654 settings line, or when exporting), then the contents of this file are parsed
14655 as if they had been included in the buffer.  In particular, the file can be
14656 any other Org mode file with internal setup.  You can visit the file the
14657 cursor is in the line with @kbd{C-c '}.
14658 @item #+STARTUP:
14659 @cindex #+STARTUP:
14660 This line sets options to be used at startup of Org mode, when an
14661 Org file is being visited.
14663 The first set of options deals with the initial visibility of the outline
14664 tree.  The corresponding variable for global default settings is
14665 @code{org-startup-folded}, with a default value @code{t}, which means
14666 @code{overview}.
14667 @vindex org-startup-folded
14668 @cindex @code{overview}, STARTUP keyword
14669 @cindex @code{content}, STARTUP keyword
14670 @cindex @code{showall}, STARTUP keyword
14671 @cindex @code{showeverything}, STARTUP keyword
14672 @example
14673 overview         @r{top-level headlines only}
14674 content          @r{all headlines}
14675 showall          @r{no folding of any entries}
14676 showeverything   @r{show even drawer contents}
14677 @end example
14679 @vindex org-startup-indented
14680 @cindex @code{indent}, STARTUP keyword
14681 @cindex @code{noindent}, STARTUP keyword
14682 Dynamic virtual indentation is controlled by the variable
14683 @code{org-startup-indented}@footnote{Emacs 23 and Org mode 6.29 are required}
14684 @example
14685 indent     @r{start with @code{org-indent-mode} turned on}
14686 noindent   @r{start with @code{org-indent-mode} turned off}
14687 @end example
14689 @vindex org-startup-align-all-tables
14690 Then there are options for aligning tables upon visiting a file.  This
14691 is useful in files containing narrowed table columns.  The corresponding
14692 variable is @code{org-startup-align-all-tables}, with a default value
14693 @code{nil}.
14694 @cindex @code{align}, STARTUP keyword
14695 @cindex @code{noalign}, STARTUP keyword
14696 @example
14697 align      @r{align all tables}
14698 noalign    @r{don't align tables on startup}
14699 @end example
14701 @vindex org-startup-with-inline-images
14702 When visiting a file, inline images can be automatically displayed.  The
14703 corresponding variable is @code{org-startup-with-inline-images}, with a
14704 default value @code{nil} to avoid delays when visiting a file.
14705 @cindex @code{inlineimages}, STARTUP keyword
14706 @cindex @code{noinlineimages}, STARTUP keyword
14707 @example
14708 inlineimages   @r{show inline images}
14709 noinlineimages @r{don't show inline images on startup}
14710 @end example
14712 @vindex org-startup-with-latex-preview
14713 When visiting a file, @LaTeX{} fragments can be converted to images
14714 automatically.  The variable @code{org-startup-with-latex-preview} which
14715 controls this behavior, is set to @code{nil} by default to avoid delays on
14716 startup.
14717 @cindex @code{latexpreview}, STARTUP keyword
14718 @cindex @code{nolatexpreview}, STARTUP keyword
14719 @example
14720 latexpreview   @r{preview @LaTeX{} fragments}
14721 nolatexpreview @r{don't preview @LaTeX{} fragments}
14722 @end example
14724 @vindex org-log-done
14725 @vindex org-log-note-clock-out
14726 @vindex org-log-repeat
14727 Logging the closing and reopening of TODO items and clock intervals can be
14728 configured using these options (see variables @code{org-log-done},
14729 @code{org-log-note-clock-out} and @code{org-log-repeat})
14730 @cindex @code{logdone}, STARTUP keyword
14731 @cindex @code{lognotedone}, STARTUP keyword
14732 @cindex @code{nologdone}, STARTUP keyword
14733 @cindex @code{lognoteclock-out}, STARTUP keyword
14734 @cindex @code{nolognoteclock-out}, STARTUP keyword
14735 @cindex @code{logrepeat}, STARTUP keyword
14736 @cindex @code{lognoterepeat}, STARTUP keyword
14737 @cindex @code{nologrepeat}, STARTUP keyword
14738 @cindex @code{logreschedule}, STARTUP keyword
14739 @cindex @code{lognotereschedule}, STARTUP keyword
14740 @cindex @code{nologreschedule}, STARTUP keyword
14741 @cindex @code{logredeadline}, STARTUP keyword
14742 @cindex @code{lognoteredeadline}, STARTUP keyword
14743 @cindex @code{nologredeadline}, STARTUP keyword
14744 @cindex @code{logrefile}, STARTUP keyword
14745 @cindex @code{lognoterefile}, STARTUP keyword
14746 @cindex @code{nologrefile}, STARTUP keyword
14747 @cindex @code{logdrawer}, STARTUP keyword
14748 @cindex @code{nologdrawer}, STARTUP keyword
14749 @cindex @code{logstatesreversed}, STARTUP keyword
14750 @cindex @code{nologstatesreversed}, STARTUP keyword
14751 @example
14752 logdone             @r{record a timestamp when an item is marked DONE}
14753 lognotedone         @r{record timestamp and a note when DONE}
14754 nologdone           @r{don't record when items are marked DONE}
14755 logrepeat           @r{record a time when reinstating a repeating item}
14756 lognoterepeat       @r{record a note when reinstating a repeating item}
14757 nologrepeat         @r{do not record when reinstating repeating item}
14758 lognoteclock-out    @r{record a note when clocking out}
14759 nolognoteclock-out  @r{don't record a note when clocking out}
14760 logreschedule       @r{record a timestamp when scheduling time changes}
14761 lognotereschedule   @r{record a note when scheduling time changes}
14762 nologreschedule     @r{do not record when a scheduling date changes}
14763 logredeadline       @r{record a timestamp when deadline changes}
14764 lognoteredeadline   @r{record a note when deadline changes}
14765 nologredeadline     @r{do not record when a deadline date changes}
14766 logrefile           @r{record a timestamp when refiling}
14767 lognoterefile       @r{record a note when refiling}
14768 nologrefile         @r{do not record when refiling}
14769 logdrawer           @r{store log into drawer}
14770 nologdrawer         @r{store log outside of drawer}
14771 logstatesreversed   @r{reverse the order of states notes}
14772 nologstatesreversed @r{do not reverse the order of states notes}
14773 @end example
14775 @vindex org-hide-leading-stars
14776 @vindex org-odd-levels-only
14777 Here are the options for hiding leading stars in outline headings, and for
14778 indenting outlines.  The corresponding variables are
14779 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
14780 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
14781 @cindex @code{hidestars}, STARTUP keyword
14782 @cindex @code{showstars}, STARTUP keyword
14783 @cindex @code{odd}, STARTUP keyword
14784 @cindex @code{even}, STARTUP keyword
14785 @example
14786 hidestars  @r{make all but one of the stars starting a headline invisible.}
14787 showstars  @r{show all stars starting a headline}
14788 indent     @r{virtual indentation according to outline level}
14789 noindent   @r{no virtual indentation according to outline level}
14790 odd        @r{allow only odd outline levels (1,3,...)}
14791 oddeven    @r{allow all outline levels}
14792 @end example
14794 @vindex org-put-time-stamp-overlays
14795 @vindex org-time-stamp-overlay-formats
14796 To turn on custom format overlays over timestamps (variables
14797 @code{org-put-time-stamp-overlays} and
14798 @code{org-time-stamp-overlay-formats}), use
14799 @cindex @code{customtime}, STARTUP keyword
14800 @example
14801 customtime @r{overlay custom time format}
14802 @end example
14804 @vindex constants-unit-system
14805 The following options influence the table spreadsheet (variable
14806 @code{constants-unit-system}).
14807 @cindex @code{constcgs}, STARTUP keyword
14808 @cindex @code{constSI}, STARTUP keyword
14809 @example
14810 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
14811 constSI    @r{@file{constants.el} should use the SI unit system}
14812 @end example
14814 @vindex org-footnote-define-inline
14815 @vindex org-footnote-auto-label
14816 @vindex org-footnote-auto-adjust
14817 To influence footnote settings, use the following keywords.  The
14818 corresponding variables are @code{org-footnote-define-inline},
14819 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
14820 @cindex @code{fninline}, STARTUP keyword
14821 @cindex @code{nofninline}, STARTUP keyword
14822 @cindex @code{fnlocal}, STARTUP keyword
14823 @cindex @code{fnprompt}, STARTUP keyword
14824 @cindex @code{fnauto}, STARTUP keyword
14825 @cindex @code{fnconfirm}, STARTUP keyword
14826 @cindex @code{fnplain}, STARTUP keyword
14827 @cindex @code{fnadjust}, STARTUP keyword
14828 @cindex @code{nofnadjust}, STARTUP keyword
14829 @example
14830 fninline    @r{define footnotes inline}
14831 fnnoinline  @r{define footnotes in separate section}
14832 fnlocal     @r{define footnotes near first reference, but not inline}
14833 fnprompt    @r{prompt for footnote labels}
14834 fnauto      @r{create @code{[fn:1]}-like labels automatically (default)}
14835 fnconfirm   @r{offer automatic label for editing or confirmation}
14836 fnplain     @r{create @code{[1]}-like labels automatically}
14837 fnadjust    @r{automatically renumber and sort footnotes}
14838 nofnadjust  @r{do not renumber and sort automatically}
14839 @end example
14841 @cindex org-hide-block-startup
14842 To hide blocks on startup, use these keywords.  The corresponding variable is
14843 @code{org-hide-block-startup}.
14844 @cindex @code{hideblocks}, STARTUP keyword
14845 @cindex @code{nohideblocks}, STARTUP keyword
14846 @example
14847 hideblocks   @r{Hide all begin/end blocks on startup}
14848 nohideblocks @r{Do not hide blocks on startup}
14849 @end example
14851 @cindex org-pretty-entities
14852 The display of entities as UTF-8 characters is governed by the variable
14853 @code{org-pretty-entities} and the keywords
14854 @cindex @code{entitiespretty}, STARTUP keyword
14855 @cindex @code{entitiesplain}, STARTUP keyword
14856 @example
14857 entitiespretty  @r{Show entities as UTF-8 characters where possible}
14858 entitiesplain   @r{Leave entities plain}
14859 @end example
14861 @item #+TAGS:  TAG1(c1) TAG2(c2)
14862 @vindex org-tag-alist
14863 These lines (several such lines are allowed) specify the valid tags in
14864 this file, and (potentially) the corresponding @emph{fast tag selection}
14865 keys.  The corresponding variable is @code{org-tag-alist}.
14866 @item #+TBLFM:
14867 This line contains the formulas for the table directly above the line.
14868 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
14869 @itemx #+OPTIONS:, #+BIND:,
14870 @itemx #+DESCRIPTION:, #+KEYWORDS:,
14871 @itemx #+LaTeX_HEADER:, #+HTML_HEAD:, #+HTML_LINK_UP:, #+HTML_LINK_HOME:,
14872 @itemx #+SELECT_TAGS:, #+EXCLUDE_TAGS:
14873 These lines provide settings for exporting files.  For more details see
14874 @ref{Export options}.
14875 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
14876 @vindex org-todo-keywords
14877 These lines set the TODO keywords and their interpretation in the
14878 current file.  The corresponding variable is @code{org-todo-keywords}.
14879 @end table
14881 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
14882 @section The very busy C-c C-c key
14883 @kindex C-c C-c
14884 @cindex C-c C-c, overview
14886 The key @kbd{C-c C-c} has many purposes in Org, which are all
14887 mentioned scattered throughout this manual.  One specific function of
14888 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
14889 other circumstances it means something like @emph{``Hey Org, look
14890 here and update according to what you see here''}.  Here is a summary of
14891 what this means in different contexts.
14893 @itemize @minus
14894 @item
14895 If there are highlights in the buffer from the creation of a sparse
14896 tree, or from clock display, remove these highlights.
14897 @item
14898 If the cursor is in one of the special @code{#+KEYWORD} lines, this
14899 triggers scanning the buffer for these lines and updating the
14900 information.
14901 @item
14902 If the cursor is inside a table, realign the table.  This command
14903 works even if the automatic table editor has been turned off.
14904 @item
14905 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
14906 the entire table.
14907 @item
14908 If the current buffer is a capture buffer, close the note and file it.
14909 With a prefix argument, file it, without further interaction, to the
14910 default location.
14911 @item
14912 If the cursor is on a @code{<<<target>>>}, update radio targets and
14913 corresponding links in this buffer.
14914 @item
14915 If the cursor is in a property line or at the start or end of a property
14916 drawer, offer property commands.
14917 @item
14918 If the cursor is at a footnote reference, go to the corresponding
14919 definition, and vice versa.
14920 @item
14921 If the cursor is on a statistics cookie, update it.
14922 @item
14923 If the cursor is in a plain list item with a checkbox, toggle the status
14924 of the checkbox.
14925 @item
14926 If the cursor is on a numbered item in a plain list, renumber the
14927 ordered list.
14928 @item
14929 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
14930 block is updated.
14931 @item
14932 If the cursor is at a timestamp, fix the day name in the timestamp.
14933 @end itemize
14935 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
14936 @section A cleaner outline view
14937 @cindex hiding leading stars
14938 @cindex dynamic indentation
14939 @cindex odd-levels-only outlines
14940 @cindex clean outline view
14942 Some people find it noisy and distracting that the Org headlines start with a
14943 potentially large number of stars, and that text below the headlines is not
14944 indented.  While this is no problem when writing a @emph{book-like} document
14945 where the outline headings are really section headings, in a more
14946 @emph{list-oriented} outline, indented structure is a lot cleaner:
14948 @example
14949 @group
14950 * Top level headline             |    * Top level headline
14951 ** Second level                  |      * Second level
14952 *** 3rd level                    |        * 3rd level
14953 some text                        |          some text
14954 *** 3rd level                    |        * 3rd level
14955 more text                        |          more text
14956 * Another top level headline     |    * Another top level headline
14957 @end group
14958 @end example
14960 @noindent
14962 If you are using at least Emacs 23.2@footnote{Emacs 23.1 can actually crash
14963 with @code{org-indent-mode}} and version 6.29 of Org, this kind of view can
14964 be achieved dynamically at display time using @code{org-indent-mode}.  In
14965 this minor mode, all lines are prefixed for display with the necessary amount
14966 of space@footnote{@code{org-indent-mode} also sets the @code{wrap-prefix}
14967 property, such that @code{visual-line-mode} (or purely setting
14968 @code{word-wrap}) wraps long lines (including headlines) correctly indented.
14969 }.  Also headlines are prefixed with additional stars, so that the amount of
14970 indentation shifts by two@footnote{See the variable
14971 @code{org-indent-indentation-per-level}.}  spaces per level.  All headline
14972 stars but the last one are made invisible using the @code{org-hide}
14973 face@footnote{Turning on @code{org-indent-mode} sets
14974 @code{org-hide-leading-stars} to @code{t} and @code{org-adapt-indentation} to
14975 @code{nil}.}; see below under @samp{2.} for more information on how this
14976 works.  You can turn on @code{org-indent-mode} for all files by customizing
14977 the variable @code{org-startup-indented}, or you can turn it on for
14978 individual files using
14980 @example
14981 #+STARTUP: indent
14982 @end example
14984 If you want a similar effect in an earlier version of Emacs and/or Org, or if
14985 you want the indentation to be hard space characters so that the plain text
14986 file looks as similar as possible to the Emacs display, Org supports you in
14987 the following way:
14989 @enumerate
14990 @item
14991 @emph{Indentation of text below headlines}@*
14992 You may indent text below each headline to make the left boundary line up
14993 with the headline, like
14995 @example
14996 *** 3rd level
14997     more text, now indented
14998 @end example
15000 @vindex org-adapt-indentation
15001 Org supports this with paragraph filling, line wrapping, and structure
15002 editing@footnote{See also the variable @code{org-adapt-indentation}.},
15003 preserving or adapting the indentation as appropriate.
15005 @item
15006 @vindex org-hide-leading-stars
15007 @emph{Hiding leading stars}@* You can modify the display in such a way that
15008 all leading stars become invisible.  To do this in a global way, configure
15009 the variable @code{org-hide-leading-stars} or change this on a per-file basis
15010 with
15012 @example
15013 #+STARTUP: hidestars
15014 #+STARTUP: showstars
15015 @end example
15017 With hidden stars, the tree becomes:
15019 @example
15020 @group
15021 * Top level headline
15022  * Second level
15023   * 3rd level
15024   ...
15025 @end group
15026 @end example
15028 @noindent
15029 @vindex org-hide @r{(face)}
15030 The leading stars are not truly replaced by whitespace, they are only
15031 fontified with the face @code{org-hide} that uses the background color as
15032 font color.  If you are not using either white or black background, you may
15033 have to customize this face to get the wanted effect.  Another possibility is
15034 to set this font such that the extra stars are @i{almost} invisible, for
15035 example using the color @code{grey90} on a white background.
15037 @item
15038 @vindex org-odd-levels-only
15039 Things become cleaner still if you skip all the even levels and use only odd
15040 levels 1, 3, 5..., effectively adding two stars to go from one outline level
15041 to the next@footnote{When you need to specify a level for a property search
15042 or refile targets, @samp{LEVEL=2} will correspond to 3 stars, etc.}.  In this
15043 way we get the outline view shown at the beginning of this section.  In order
15044 to make the structure editing and export commands handle this convention
15045 correctly, configure the variable @code{org-odd-levels-only}, or set this on
15046 a per-file basis with one of the following lines:
15048 @example
15049 #+STARTUP: odd
15050 #+STARTUP: oddeven
15051 @end example
15053 You can convert an Org file from single-star-per-level to the
15054 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
15055 RET} in that file.  The reverse operation is @kbd{M-x
15056 org-convert-to-oddeven-levels}.
15057 @end enumerate
15059 @node TTY keys, Interaction, Clean view, Miscellaneous
15060 @section Using Org on a tty
15061 @cindex tty key bindings
15063 Because Org contains a large number of commands, by default many of
15064 Org's core commands are bound to keys that are generally not
15065 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
15066 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
15067 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
15068 these commands on a tty when special keys are unavailable, the following
15069 alternative bindings can be used.  The tty bindings below will likely be
15070 more cumbersome; you may find for some of the bindings below that a
15071 customized workaround suits you better.  For example, changing a timestamp
15072 is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
15073 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
15075 @multitable @columnfractions 0.15 0.2 0.1 0.2
15076 @item @b{Default} @tab @b{Alternative 1} @tab @b{Speed key} @tab @b{Alternative 2}
15077 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab @kbd{C} @tab
15078 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{l} @tab @kbd{@key{Esc} @key{left}}
15079 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab @kbd{L} @tab
15080 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{r} @tab @kbd{@key{Esc} @key{right}}
15081 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab @kbd{R} @tab
15082 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{up}}
15083 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab @kbd{U} @tab
15084 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{down}}
15085 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab @kbd{D} @tab
15086 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab @kbd{ } @tab
15087 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{RET}}
15088 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab @kbd{ } @tab
15089 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab @kbd{ } @tab
15090 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab @kbd{ } @tab
15091 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab @kbd{ } @tab
15092 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab @kbd{ } @tab
15093 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab @kbd{ } @tab
15094 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab @kbd{ } @tab
15095 @end multitable
15098 @node Interaction, org-crypt.el, TTY keys, Miscellaneous
15099 @section Interaction with other packages
15100 @cindex packages, interaction with other
15101 Org lives in the world of GNU Emacs and interacts in various ways
15102 with other code out there.
15104 @menu
15105 * Cooperation::                 Packages Org cooperates with
15106 * Conflicts::                   Packages that lead to conflicts
15107 @end menu
15109 @node Cooperation, Conflicts, Interaction, Interaction
15110 @subsection Packages that Org cooperates with
15112 @table @asis
15113 @cindex @file{calc.el}
15114 @cindex Gillespie, Dave
15115 @item @file{calc.el} by Dave Gillespie
15116 Org uses the Calc package for implementing spreadsheet
15117 functionality in its tables (@pxref{The spreadsheet}).  Org
15118 checks for the availability of Calc by looking for the function
15119 @code{calc-eval} which will have been autoloaded during setup if Calc has
15120 been installed properly.  As of Emacs 22, Calc is part of the Emacs
15121 distribution.  Another possibility for interaction between the two
15122 packages is using Calc for embedded calculations.  @xref{Embedded Mode,
15123 , Embedded Mode, calc, GNU Emacs Calc Manual}.
15124 @item @file{constants.el} by Carsten Dominik
15125 @cindex @file{constants.el}
15126 @cindex Dominik, Carsten
15127 @vindex org-table-formula-constants
15128 In a table formula (@pxref{The spreadsheet}), it is possible to use
15129 names for natural constants or units.  Instead of defining your own
15130 constants in the variable @code{org-table-formula-constants}, install
15131 the @file{constants} package which defines a large number of constants
15132 and units, and lets you use unit prefixes like @samp{M} for
15133 @samp{Mega}, etc.  You will need version 2.0 of this package, available
15134 at @url{http://www.astro.uva.nl/~dominik/Tools}.  Org checks for
15135 the function @code{constants-get}, which has to be autoloaded in your
15136 setup.  See the installation instructions in the file
15137 @file{constants.el}.
15138 @item @file{cdlatex.el} by Carsten Dominik
15139 @cindex @file{cdlatex.el}
15140 @cindex Dominik, Carsten
15141 Org mode can make use of the CD@LaTeX{} package to efficiently enter
15142 @LaTeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
15143 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
15144 @cindex @file{imenu.el}
15145 Imenu allows menu access to an index of items in a file.  Org mode
15146 supports Imenu---all you need to do to get the index is the following:
15147 @lisp
15148 (add-hook 'org-mode-hook
15149           (lambda () (imenu-add-to-menubar "Imenu")))
15150 @end lisp
15151 @vindex org-imenu-depth
15152 By default the index is two levels deep---you can modify the depth using
15153 the option @code{org-imenu-depth}.
15154 @item @file{remember.el} by John Wiegley
15155 @cindex @file{remember.el}
15156 @cindex Wiegley, John
15157 Org used to use this package for capture, but no longer does.
15158 @item @file{speedbar.el} by Eric M. Ludlam
15159 @cindex @file{speedbar.el}
15160 @cindex Ludlam, Eric M.
15161 Speedbar is a package that creates a special frame displaying files and
15162 index items in files.  Org mode supports Speedbar and allows you to
15163 drill into Org files directly from the Speedbar.  It also allows you to
15164 restrict the scope of agenda commands to a file or a subtree by using
15165 the command @kbd{<} in the Speedbar frame.
15166 @cindex @file{table.el}
15167 @item @file{table.el} by Takaaki Ota
15168 @kindex C-c C-c
15169 @cindex table editor, @file{table.el}
15170 @cindex @file{table.el}
15171 @cindex Ota, Takaaki
15173 Complex ASCII tables with automatic line wrapping, column- and row-spanning,
15174 and alignment can be created using the Emacs table package by Takaaki Ota
15175 (@uref{http://sourceforge.net/projects/table}, and also part of Emacs 22).
15176 Org mode will recognize these tables and export them properly.  Because of
15177 interference with other Org mode functionality, you unfortunately cannot edit
15178 these tables directly in the buffer.  Instead, you need to use the command
15179 @kbd{C-c '} to edit them, similar to source code snippets.
15181 @table @kbd
15182 @orgcmd{C-c ',org-edit-special}
15183 Edit a @file{table.el} table.  Works when the cursor is in a table.el table.
15185 @orgcmd{C-c ~,org-table-create-with-table.el}
15186 Insert a @file{table.el} table.  If there is already a table at point, this
15187 command converts it between the @file{table.el} format and the Org mode
15188 format.  See the documentation string of the command
15189 @code{org-convert-table} for the restrictions under which this is
15190 possible.
15191 @end table
15192 @file{table.el} is part of Emacs since Emacs 22.
15193 @item @file{footnote.el} by Steven L. Baur
15194 @cindex @file{footnote.el}
15195 @cindex Baur, Steven L.
15196 Org mode recognizes numerical footnotes as provided by this package.
15197 However, Org mode also has its own footnote support (@pxref{Footnotes}),
15198 which makes using @file{footnote.el} unnecessary.
15199 @end table
15201 @node Conflicts,  , Cooperation, Interaction
15202 @subsection Packages that lead to conflicts with Org mode
15204 @table @asis
15206 @cindex @code{shift-selection-mode}
15207 @vindex org-support-shift-select
15208 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
15209 cursor motions combined with the shift key should start or enlarge regions.
15210 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
15211 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
15212 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
15213 special contexts don't do anything, but you can customize the variable
15214 @code{org-support-shift-select}.  Org mode then tries to accommodate shift
15215 selection by (i) using it outside of the special contexts where special
15216 commands apply, and by (ii) extending an existing active region even if the
15217 cursor moves across a special context.
15219 @item @file{CUA.el} by Kim. F. Storm
15220 @cindex @file{CUA.el}
15221 @cindex Storm, Kim. F.
15222 @vindex org-replace-disputed-keys
15223 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
15224 (as well as @code{pc-select-mode} and @code{s-region-mode}) to select and extend the
15225 region.  In fact, Emacs 23 has this built-in in the form of
15226 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
15227 23, you probably don't want to use another package for this purpose.  However,
15228 if you prefer to leave these keys to a different package while working in
15229 Org mode, configure the variable @code{org-replace-disputed-keys}.  When set,
15230 Org will move the following key bindings in Org files, and in the agenda
15231 buffer (but not during date selection).
15233 @example
15234 S-UP      @result{}  M-p             S-DOWN     @result{}  M-n
15235 S-LEFT    @result{}  M--             S-RIGHT    @result{}  M-+
15236 C-S-LEFT  @result{}  M-S--           C-S-RIGHT  @result{}  M-S-+
15237 @end example
15239 @vindex org-disputed-keys
15240 Yes, these are unfortunately more difficult to remember.  If you want
15241 to have other replacement keys, look at the variable
15242 @code{org-disputed-keys}.
15244 @item @file{filladapt.el} by Kyle Jones
15245 @cindex @file{filladapt.el}
15247 Org mode tries to do the right thing when filling paragraphs, list items and
15248 other elements.  Many users reported they had problems using both
15249 @file{filladapt.el} and Org mode, so a safe thing to do is to disable it like
15250 this:
15252 @lisp
15253 (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
15254 @end lisp
15256 @item @file{yasnippet.el}
15257 @cindex @file{yasnippet.el}
15258 The way Org mode binds the TAB key (binding to @code{[tab]} instead of
15259 @code{"\t"}) overrules YASnippet's access to this key.  The following code
15260 fixed this problem:
15262 @lisp
15263 (add-hook 'org-mode-hook
15264           (lambda ()
15265             (org-set-local 'yas/trigger-key [tab])
15266             (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
15267 @end lisp
15269 The latest version of yasnippet doesn't play well with Org mode.  If the
15270 above code does not fix the conflict, start by defining the following
15271 function:
15273 @lisp
15274 (defun yas/org-very-safe-expand ()
15275   (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
15276 @end lisp
15278 Then, tell Org mode what to do with the new function:
15280 @lisp
15281 (add-hook 'org-mode-hook
15282           (lambda ()
15283             (make-variable-buffer-local 'yas/trigger-key)
15284             (setq yas/trigger-key [tab])
15285             (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
15286             (define-key yas/keymap [tab] 'yas/next-field)))
15287 @end lisp
15289 @item @file{windmove.el} by Hovav Shacham
15290 @cindex @file{windmove.el}
15291 This package also uses the @kbd{S-<cursor>} keys, so everything written
15292 in the paragraph above about CUA mode also applies here.  If you want make
15293 the windmove function active in locations where Org mode does not have
15294 special functionality on @kbd{S-@key{cursor}}, add this to your
15295 configuration:
15297 @lisp
15298 ;; Make windmove work in org-mode:
15299 (add-hook 'org-shiftup-final-hook 'windmove-up)
15300 (add-hook 'org-shiftleft-final-hook 'windmove-left)
15301 (add-hook 'org-shiftdown-final-hook 'windmove-down)
15302 (add-hook 'org-shiftright-final-hook 'windmove-right)
15303 @end lisp
15305 @item @file{viper.el} by Michael Kifer
15306 @cindex @file{viper.el}
15307 @kindex C-c /
15308 Viper uses @kbd{C-c /} and therefore makes this key not access the
15309 corresponding Org mode command @code{org-sparse-tree}.  You need to find
15310 another key for this command, or override the key in
15311 @code{viper-vi-global-user-map} with
15313 @lisp
15314 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
15315 @end lisp
15317 @end table
15319 @node org-crypt.el,  , Interaction, Miscellaneous
15320 @section org-crypt.el
15321 @cindex @file{org-crypt.el}
15322 @cindex @code{org-decrypt-entry}
15324 Org-crypt will encrypt the text of an entry, but not the headline, or
15325 properties.  Org-crypt uses the Emacs EasyPG library to encrypt and decrypt
15326 files.
15328 Any text below a headline that has a @samp{:crypt:} tag will be automatically
15329 be encrypted when the file is saved.  If you want to use a different tag just
15330 customize the @code{org-crypt-tag-matcher} setting.
15332 To use org-crypt it is suggested that you have the following in your
15333 @file{.emacs}:
15335 @example
15336 (require 'org-crypt)
15337 (org-crypt-use-before-save-magic)
15338 (setq org-tags-exclude-from-inheritance (quote ("crypt")))
15340 (setq org-crypt-key nil)
15341   ;; GPG key to use for encryption
15342   ;; Either the Key ID or set to nil to use symmetric encryption.
15344 (setq auto-save-default nil)
15345   ;; Auto-saving does not cooperate with org-crypt.el: so you need
15346   ;; to turn it off if you plan to use org-crypt.el quite often.
15347   ;; Otherwise, you'll get an (annoying) message each time you
15348   ;; start Org.
15350   ;; To turn it off only locally, you can insert this:
15351   ;;
15352   ;; # -*- buffer-auto-save-file-name: nil; -*-
15353 @end example
15355 Excluding the crypt tag from inheritance prevents already encrypted text
15356 being encrypted again.
15358 @node Hacking, MobileOrg, Miscellaneous, Top
15359 @appendix Hacking
15360 @cindex hacking
15362 This appendix covers some aspects where users can extend the functionality of
15363 Org.
15365 @menu
15366 * Hooks::                       How to reach into Org's internals
15367 * Add-on packages::             Available extensions
15368 * Adding hyperlink types::      New custom link types
15369 * Context-sensitive commands::  How to add functionality to such commands
15370 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
15371 * Dynamic blocks::              Automatically filled blocks
15372 * Special agenda views::        Customized views
15373 * Speeding up your agendas::    Tips on how to speed up your agendas
15374 * Extracting agenda information::  Postprocessing of agenda information
15375 * Using the property API::      Writing programs that use entry properties
15376 * Using the mapping API::       Mapping over all or selected entries
15377 @end menu
15379 @node Hooks, Add-on packages, Hacking, Hacking
15380 @section Hooks
15381 @cindex hooks
15383 Org has a large number of hook variables that can be used to add
15384 functionality.  This appendix about hacking is going to illustrate the
15385 use of some of them.  A complete list of all hooks with documentation is
15386 maintained by the Worg project and can be found at
15387 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
15389 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
15390 @section Add-on packages
15391 @cindex add-on packages
15393 A large number of add-on packages have been written by various authors.
15394 These packages are not part of Emacs, but they are distributed as contributed
15395 packages with the separate release available at the Org mode home page at
15396 @uref{http://orgmode.org}.  The list of contributed packages, along with
15397 documentation about each package, is maintained by the Worg project at
15398 @uref{http://orgmode.org/worg/org-contrib/}.
15402 @node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
15403 @section Adding hyperlink types
15404 @cindex hyperlinks, adding new types
15406 Org has a large number of hyperlink types built-in
15407 (@pxref{Hyperlinks}).  If you would like to add new link types, Org
15408 provides an interface for doing so.  Let's look at an example file,
15409 @file{org-man.el}, that will add support for creating links like
15410 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
15411 Emacs:
15413 @lisp
15414 ;;; org-man.el - Support for links to manpages in Org
15416 (require 'org)
15418 (org-add-link-type "man" 'org-man-open)
15419 (add-hook 'org-store-link-functions 'org-man-store-link)
15421 (defcustom org-man-command 'man
15422   "The Emacs command to be used to display a man page."
15423   :group 'org-link
15424   :type '(choice (const man) (const woman)))
15426 (defun org-man-open (path)
15427   "Visit the manpage on PATH.
15428 PATH should be a topic that can be thrown at the man command."
15429   (funcall org-man-command path))
15431 (defun org-man-store-link ()
15432   "Store a link to a manpage."
15433   (when (memq major-mode '(Man-mode woman-mode))
15434     ;; This is a man page, we do make this link
15435     (let* ((page (org-man-get-page-name))
15436            (link (concat "man:" page))
15437            (description (format "Manpage for %s" page)))
15438       (org-store-link-props
15439        :type "man"
15440        :link link
15441        :description description))))
15443 (defun org-man-get-page-name ()
15444   "Extract the page name from the buffer name."
15445   ;; This works for both `Man-mode' and `woman-mode'.
15446   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
15447       (match-string 1 (buffer-name))
15448     (error "Cannot create link to this man page")))
15450 (provide 'org-man)
15452 ;;; org-man.el ends here
15453 @end lisp
15455 @noindent
15456 You would activate this new link type in @file{.emacs} with
15458 @lisp
15459 (require 'org-man)
15460 @end lisp
15462 @noindent
15463 Let's go through the file and see what it does.
15464 @enumerate
15465 @item
15466 It does @code{(require 'org)} to make sure that @file{org.el} has been
15467 loaded.
15468 @item
15469 The next line calls @code{org-add-link-type} to define a new link type
15470 with prefix @samp{man}.  The call also contains the name of a function
15471 that will be called to follow such a link.
15472 @item
15473 @vindex org-store-link-functions
15474 The next line adds a function to @code{org-store-link-functions}, in
15475 order to allow the command @kbd{C-c l} to record a useful link in a
15476 buffer displaying a man page.
15477 @end enumerate
15479 The rest of the file defines the necessary variables and functions.
15480 First there is a customization variable that determines which Emacs
15481 command should be used to display man pages.  There are two options,
15482 @code{man} and @code{woman}.  Then the function to follow a link is
15483 defined.  It gets the link path as an argument---in this case the link
15484 path is just a topic for the manual command.  The function calls the
15485 value of @code{org-man-command} to display the man page.
15487 Finally the function @code{org-man-store-link} is defined.  When you try
15488 to store a link with @kbd{C-c l}, this function will be called to
15489 try to make a link.  The function must first decide if it is supposed to
15490 create the link for this buffer type; we do this by checking the value
15491 of the variable @code{major-mode}.  If not, the function must exit and
15492 return the value @code{nil}.  If yes, the link is created by getting the
15493 manual topic from the buffer name and prefixing it with the string
15494 @samp{man:}.  Then it must call the command @code{org-store-link-props}
15495 and set the @code{:type} and @code{:link} properties.  Optionally you
15496 can also set the @code{:description} property to provide a default for
15497 the link description when the link is later inserted into an Org
15498 buffer with @kbd{C-c C-l}.
15500 When it makes sense for your new link type, you may also define a function
15501 @code{org-PREFIX-complete-link} that implements special (e.g., completion)
15502 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
15503 not accept any arguments, and return the full link with prefix.
15505 @node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
15506 @section Context-sensitive commands
15507 @cindex context-sensitive commands, hooks
15508 @cindex add-ons, context-sensitive commands
15509 @vindex org-ctrl-c-ctrl-c-hook
15511 Org has several commands that act differently depending on context.  The most
15512 important example is the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
15513 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
15515 Add-ons can tap into this functionality by providing a function that detects
15516 special context for that add-on and executes functionality appropriate for
15517 the context.  Here is an example from Dan Davison's @file{org-R.el} which
15518 allows you to evaluate commands based on the @file{R} programming language
15519 @footnote{@file{org-R.el} has been replaced by the Org mode functionality
15520 described in @ref{Working With Source Code} and is now obsolete.}.  For this
15521 package, special contexts are lines that start with @code{#+R:} or
15522 @code{#+RR:}.
15524 @lisp
15525 (defun org-R-apply-maybe ()
15526   "Detect if this is context for org-R and execute R commands."
15527   (if (save-excursion
15528         (beginning-of-line 1)
15529         (looking-at "#\\+RR?:"))
15530       (progn (call-interactively 'org-R-apply)
15531              t) ;; to signal that we took action
15532     nil)) ;; to signal that we did not
15534 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
15535 @end lisp
15537 The function first checks if the cursor is in such a line.  If that is the
15538 case, @code{org-R-apply} is called and the function returns @code{t} to
15539 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
15540 contexts.  If the function finds it should do nothing locally, it returns
15541 @code{nil} so that other, similar functions can have a try.
15544 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
15545 @section Tables and lists in arbitrary syntax
15546 @cindex tables, in other modes
15547 @cindex lists, in other modes
15548 @cindex Orgtbl mode
15550 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
15551 frequent feature request has been to make it work with native tables in
15552 specific languages, for example @LaTeX{}.  However, this is extremely
15553 hard to do in a general way, would lead to a customization nightmare,
15554 and would take away much of the simplicity of the Orgtbl mode table
15555 editor.
15557 This appendix describes a different approach.  We keep the Orgtbl mode
15558 table in its native format (the @i{source table}), and use a custom
15559 function to @i{translate} the table to the correct syntax, and to
15560 @i{install} it in the right location (the @i{target table}).  This puts
15561 the burden of writing conversion functions on the user, but it allows
15562 for a very flexible system.
15564 Bastien added the ability to do the same with lists, in Orgstruct mode.  You
15565 can use Org's facilities to edit and structure lists by turning
15566 @code{orgstruct-mode} on, then locally exporting such lists in another format
15567 (HTML, @LaTeX{} or Texinfo.)
15570 @menu
15571 * Radio tables::                Sending and receiving radio tables
15572 * A @LaTeX{} example::          Step by step, almost a tutorial
15573 * Translator functions::        Copy and modify
15574 * Radio lists::                 Doing the same for lists
15575 @end menu
15577 @node Radio tables, A @LaTeX{} example, Tables in arbitrary syntax, Tables in arbitrary syntax
15578 @subsection Radio tables
15579 @cindex radio tables
15581 To define the location of the target table, you first need to create two
15582 lines that are comments in the current mode, but contain magic words for
15583 Orgtbl mode to find.  Orgtbl mode will insert the translated table
15584 between these lines, replacing whatever was there before.  For example:
15586 @example
15587 /* BEGIN RECEIVE ORGTBL table_name */
15588 /* END RECEIVE ORGTBL table_name */
15589 @end example
15591 @noindent
15592 Just above the source table, we put a special line that tells
15593 Orgtbl mode how to translate this table and where to install it.  For
15594 example:
15595 @cindex #+ORGTBL
15596 @example
15597 #+ORGTBL: SEND table_name translation_function arguments....
15598 @end example
15600 @noindent
15601 @code{table_name} is the reference name for the table that is also used
15602 in the receiver lines.  @code{translation_function} is the Lisp function
15603 that does the translation.  Furthermore, the line can contain a list of
15604 arguments (alternating key and value) at the end.  The arguments will be
15605 passed as a property list to the translation function for
15606 interpretation.  A few standard parameters are already recognized and
15607 acted upon before the translation function is called:
15609 @table @code
15610 @item :skip N
15611 Skip the first N lines of the table.  Hlines do count as separate lines for
15612 this parameter!
15614 @item :skipcols (n1 n2 ...)
15615 List of columns that should be skipped.  If the table has a column with
15616 calculation marks, that column is automatically discarded as well.
15617 Please note that the translator function sees the table @emph{after} the
15618 removal of these columns, the function never knows that there have been
15619 additional columns.
15621 @item :no-escape t
15622 When non-nil, do not escape special characters @code{&%#_^} when exporting
15623 the table.  The default value is nil.
15624 @end table
15626 @noindent
15627 The one problem remaining is how to keep the source table in the buffer
15628 without disturbing the normal workings of the file, for example during
15629 compilation of a C file or processing of a @LaTeX{} file.  There are a
15630 number of different solutions:
15632 @itemize @bullet
15633 @item
15634 The table could be placed in a block comment if that is supported by the
15635 language.  For example, in C mode you could wrap the table between
15636 @samp{/*} and @samp{*/} lines.
15637 @item
15638 Sometimes it is possible to put the table after some kind of @i{END}
15639 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
15640 in @LaTeX{}.
15641 @item
15642 You can just comment the table line-by-line whenever you want to process
15643 the file, and uncomment it whenever you need to edit the table.  This
15644 only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment}
15645 makes this comment-toggling very easy, in particular if you bind it to a
15646 key.
15647 @end itemize
15649 @node A @LaTeX{} example, Translator functions, Radio tables, Tables in arbitrary syntax
15650 @subsection A @LaTeX{} example of radio tables
15651 @cindex @LaTeX{}, and Orgtbl mode
15653 The best way to wrap the source table in @LaTeX{} is to use the
15654 @code{comment} environment provided by @file{comment.sty}.  It has to be
15655 activated by placing @code{\usepackage@{comment@}} into the document
15656 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
15657 default this works only for @LaTeX{}, HTML, and Texinfo.  Configure the
15658 variable @code{orgtbl-radio-tables} to install templates for other
15659 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
15660 be prompted for a table name, let's say we use @samp{salesfigures}.  You
15661 will then get the following template:
15663 @cindex #+ORGTBL, SEND
15664 @example
15665 % BEGIN RECEIVE ORGTBL salesfigures
15666 % END RECEIVE ORGTBL salesfigures
15667 \begin@{comment@}
15668 #+ORGTBL: SEND salesfigures orgtbl-to-latex
15669 | | |
15670 \end@{comment@}
15671 @end example
15673 @noindent
15674 @vindex @LaTeX{}-verbatim-environments
15675 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
15676 @code{orgtbl-to-latex} to convert the table into @LaTeX{} and to put it
15677 into the receiver location with name @code{salesfigures}.  You may now
15678 fill in the table---feel free to use the spreadsheet features@footnote{If
15679 the @samp{#+TBLFM} line contains an odd number of dollar characters,
15680 this may cause problems with font-lock in @LaTeX{} mode.  As shown in the
15681 example you can fix this by adding an extra line inside the
15682 @code{comment} environment that is used to balance the dollar
15683 expressions.  If you are using AUC@TeX{} with the font-latex library, a
15684 much better solution is to add the @code{comment} environment to the
15685 variable @code{LaTeX-verbatim-environments}.}:
15687 @example
15688 % BEGIN RECEIVE ORGTBL salesfigures
15689 % END RECEIVE ORGTBL salesfigures
15690 \begin@{comment@}
15691 #+ORGTBL: SEND salesfigures orgtbl-to-latex
15692 | Month | Days | Nr sold | per day |
15693 |-------+------+---------+---------|
15694 | Jan   |   23 |      55 |     2.4 |
15695 | Feb   |   21 |      16 |     0.8 |
15696 | March |   22 |     278 |    12.6 |
15697 #+TBLFM: $4=$3/$2;%.1f
15698 % $ (optional extra dollar to keep font-lock happy, see footnote)
15699 \end@{comment@}
15700 @end example
15702 @noindent
15703 When you are done, press @kbd{C-c C-c} in the table to get the converted
15704 table inserted between the two marker lines.
15706 Now let's assume you want to make the table header by hand, because you
15707 want to control how columns are aligned, etc.  In this case we make sure
15708 that the table translator skips the first 2 lines of the source
15709 table, and tell the command to work as a @i{splice}, i.e., to not produce
15710 header and footer commands of the target table:
15712 @example
15713 \begin@{tabular@}@{lrrr@}
15714 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
15715 % BEGIN RECEIVE ORGTBL salesfigures
15716 % END RECEIVE ORGTBL salesfigures
15717 \end@{tabular@}
15719 \begin@{comment@}
15720 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
15721 | Month | Days | Nr sold | per day |
15722 |-------+------+---------+---------|
15723 | Jan   |   23 |      55 |     2.4 |
15724 | Feb   |   21 |      16 |     0.8 |
15725 | March |   22 |     278 |    12.6 |
15726 #+TBLFM: $4=$3/$2;%.1f
15727 \end@{comment@}
15728 @end example
15730 The @LaTeX{} translator function @code{orgtbl-to-latex} is already part of
15731 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
15732 and marks horizontal lines with @code{\hline}.  Furthermore, it
15733 interprets the following parameters (see also @pxref{Translator functions}):
15735 @table @code
15736 @item :splice nil/t
15737 When set to t, return only table body lines, don't wrap them into a
15738 tabular environment.  Default is nil.
15740 @item :fmt fmt
15741 A format to be used to wrap each field, it should contain @code{%s} for the
15742 original field value.  For example, to wrap each field value in dollars,
15743 you could use @code{:fmt "$%s$"}.  This may also be a property list with
15744 column numbers and formats, for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
15745 A function of one argument can be used in place of the strings; the
15746 function must return a formatted string.
15748 @item :efmt efmt
15749 Use this format to print numbers with exponentials.  The format should
15750 have @code{%s} twice for inserting mantissa and exponent, for example
15751 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
15752 may also be a property list with column numbers and formats, for example
15753 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
15754 @code{efmt} has been applied to a value, @code{fmt} will also be
15755 applied.  Similar to @code{fmt}, functions of two arguments can be
15756 supplied instead of strings.
15757 @end table
15759 @node Translator functions, Radio lists, A @LaTeX{} example, Tables in arbitrary syntax
15760 @subsection Translator functions
15761 @cindex HTML, and Orgtbl mode
15762 @cindex translator function
15764 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
15765 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
15766 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
15767 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
15768 code that produces tables during HTML export.}, these all use a generic
15769 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
15770 itself is a very short function that computes the column definitions for the
15771 @code{tabular} environment, defines a few field and line separators and then
15772 hands processing over to the generic translator.  Here is the entire code:
15774 @lisp
15775 @group
15776 (defun orgtbl-to-latex (table params)
15777   "Convert the Orgtbl mode TABLE to LaTeX."
15778   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
15779                                org-table-last-alignment ""))
15780          (params2
15781           (list
15782            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
15783            :tend "\\end@{tabular@}"
15784            :lstart "" :lend " \\\\" :sep " & "
15785            :efmt "%s\\,(%s)" :hline "\\hline")))
15786     (orgtbl-to-generic table (org-combine-plists params2 params))))
15787 @end group
15788 @end lisp
15790 As you can see, the properties passed into the function (variable
15791 @var{PARAMS}) are combined with the ones newly defined in the function
15792 (variable @var{PARAMS2}).  The ones passed into the function (i.e., the
15793 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
15794 would like to use the @LaTeX{} translator, but wanted the line endings to
15795 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
15796 overrule the default with
15798 @example
15799 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
15800 @end example
15802 For a new language, you can either write your own converter function in
15803 analogy with the @LaTeX{} translator, or you can use the generic function
15804 directly.  For example, if you have a language where a table is started
15805 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
15806 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
15807 separator is a TAB, you could call the generic translator like this (on
15808 a single line!):
15810 @example
15811 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
15812                               :lstart "!BL! " :lend " !EL!" :sep "\t"
15813 @end example
15815 @noindent
15816 Please check the documentation string of the function
15817 @code{orgtbl-to-generic} for a full list of parameters understood by
15818 that function, and remember that you can pass each of them into
15819 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
15820 using the generic function.
15822 Of course you can also write a completely new function doing complicated
15823 things the generic translator cannot do.  A translator function takes
15824 two arguments.  The first argument is the table, a list of lines, each
15825 line either the symbol @code{hline} or a list of fields.  The second
15826 argument is the property list containing all parameters specified in the
15827 @samp{#+ORGTBL: SEND} line.  The function must return a single string
15828 containing the formatted table.  If you write a generally useful
15829 translator, please post it on @email{emacs-orgmode@@gnu.org} so that
15830 others can benefit from your work.
15832 @node Radio lists,  , Translator functions, Tables in arbitrary syntax
15833 @subsection Radio lists
15834 @cindex radio lists
15835 @cindex org-list-insert-radio-list
15837 Sending and receiving radio lists works exactly the same way as sending and
15838 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
15839 insert radio list templates in HTML, @LaTeX{} and Texinfo modes by calling
15840 @code{org-list-insert-radio-list}.
15842 Here are the differences with radio tables:
15844 @itemize @minus
15845 @item
15846 Orgstruct mode must be active.
15847 @item
15848 Use the @code{ORGLST} keyword instead of @code{ORGTBL}.
15849 @item
15850 The available translation functions for radio lists don't take
15851 parameters.
15852 @item
15853 @kbd{C-c C-c} will work when pressed on the first item of the list.
15854 @end itemize
15856 Here is a @LaTeX{} example.  Let's say that you have this in your
15857 @LaTeX{} file:
15859 @cindex #+ORGLST
15860 @example
15861 % BEGIN RECEIVE ORGLST to-buy
15862 % END RECEIVE ORGLST to-buy
15863 \begin@{comment@}
15864 #+ORGLST: SEND to-buy org-list-to-latex
15865 - a new house
15866 - a new computer
15867   + a new keyboard
15868   + a new mouse
15869 - a new life
15870 \end@{comment@}
15871 @end example
15873 Pressing @kbd{C-c C-c} on @code{a new house} and will insert the converted
15874 @LaTeX{} list between the two marker lines.
15876 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
15877 @section Dynamic blocks
15878 @cindex dynamic blocks
15880 Org documents can contain @emph{dynamic blocks}.  These are
15881 specially marked regions that are updated by some user-written function.
15882 A good example for such a block is the clock table inserted by the
15883 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
15885 Dynamic blocks are enclosed by a BEGIN-END structure that assigns a name
15886 to the block and can also specify parameters for the function producing
15887 the content of the block.
15889 @cindex #+BEGIN:dynamic block
15890 @example
15891 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
15893 #+END:
15894 @end example
15896 Dynamic blocks are updated with the following commands
15898 @table @kbd
15899 @orgcmd{C-c C-x C-u,org-dblock-update}
15900 Update dynamic block at point.
15901 @orgkey{C-u C-c C-x C-u}
15902 Update all dynamic blocks in the current file.
15903 @end table
15905 Updating a dynamic block means to remove all the text between BEGIN and
15906 END, parse the BEGIN line for parameters and then call the specific
15907 writer function for this block to insert the new content.  If you want
15908 to use the original content in the writer function, you can use the
15909 extra parameter @code{:content}.
15911 For a block with name @code{myblock}, the writer function is
15912 @code{org-dblock-write:myblock} with as only parameter a property list
15913 with the parameters given in the begin line.  Here is a trivial example
15914 of a block that keeps track of when the block update function was last
15915 run:
15917 @example
15918 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
15920 #+END:
15921 @end example
15923 @noindent
15924 The corresponding block writer function could look like this:
15926 @lisp
15927 (defun org-dblock-write:block-update-time (params)
15928   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
15929     (insert "Last block update at: "
15930             (format-time-string fmt (current-time)))))
15931 @end lisp
15933 If you want to make sure that all dynamic blocks are always up-to-date,
15934 you could add the function @code{org-update-all-dblocks} to a hook, for
15935 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
15936 written in a way such that it does nothing in buffers that are not in
15937 @code{org-mode}.
15939 You can narrow the current buffer to the current dynamic block (like any
15940 other block) with @code{org-narrow-to-block}.
15942 @node Special agenda views, Speeding up your agendas, Dynamic blocks, Hacking
15943 @section Special agenda views
15944 @cindex agenda views, user-defined
15946 @vindex org-agenda-skip-function
15947 @vindex org-agenda-skip-function-global
15948 Org provides a special hook that can be used to narrow down the selection
15949 made by these agenda views: @code{agenda}, @code{agenda*}@footnote{The
15950 @code{agenda*} view is the same than @code{agenda} except that it only
15951 considers @emph{appointments}, i.e., scheduled and deadline items that have a
15952 time specification @code{[h]h:mm} in their time-stamps.}, @code{todo},
15953 @code{alltodo}, @code{tags}, @code{tags-todo}, @code{tags-tree}.  You may
15954 specify a function that is used at each match to verify if the match should
15955 indeed be part of the agenda view, and if not, how much should be skipped.
15956 You can specify a global condition that will be applied to all agenda views,
15957 this condition would be stored in the variable
15958 @code{org-agenda-skip-function-global}.  More commonly, such a definition is
15959 applied only to specific custom searches, using
15960 @code{org-agenda-skip-function}.
15962 Let's say you want to produce a list of projects that contain a WAITING
15963 tag anywhere in the project tree.  Let's further assume that you have
15964 marked all tree headings that define a project with the TODO keyword
15965 PROJECT@.  In this case you would run a TODO search for the keyword
15966 PROJECT, but skip the match unless there is a WAITING tag anywhere in
15967 the subtree belonging to the project line.
15969 To achieve this, you must write a function that searches the subtree for
15970 the tag.  If the tag is found, the function must return @code{nil} to
15971 indicate that this match should not be skipped.  If there is no such
15972 tag, return the location of the end of the subtree, to indicate that
15973 search should continue from there.
15975 @lisp
15976 (defun my-skip-unless-waiting ()
15977   "Skip trees that are not waiting"
15978   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
15979     (if (re-search-forward ":waiting:" subtree-end t)
15980         nil          ; tag found, do not skip
15981       subtree-end))) ; tag not found, continue after end of subtree
15982 @end lisp
15984 Now you may use this function in an agenda custom command, for example
15985 like this:
15987 @lisp
15988 (org-add-agenda-custom-command
15989  '("b" todo "PROJECT"
15990    ((org-agenda-skip-function 'my-skip-unless-waiting)
15991     (org-agenda-overriding-header "Projects waiting for something: "))))
15992 @end lisp
15994 @vindex org-agenda-overriding-header
15995 Note that this also binds @code{org-agenda-overriding-header} to get a
15996 meaningful header in the agenda view.
15998 @vindex org-odd-levels-only
15999 @vindex org-agenda-skip-function
16000 A general way to create custom searches is to base them on a search for
16001 entries with a certain level limit.  If you want to study all entries with
16002 your custom search function, simply do a search for
16003 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
16004 level number corresponds to order in the hierarchy, not to the number of
16005 stars.}, and then use @code{org-agenda-skip-function} to select the entries
16006 you really want to have.
16008 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
16009 particular, you may use the functions @code{org-agenda-skip-entry-if}
16010 and @code{org-agenda-skip-subtree-if} in this form, for example:
16012 @table @code
16013 @item (org-agenda-skip-entry-if 'scheduled)
16014 Skip current entry if it has been scheduled.
16015 @item (org-agenda-skip-entry-if 'notscheduled)
16016 Skip current entry if it has not been scheduled.
16017 @item (org-agenda-skip-entry-if 'deadline)
16018 Skip current entry if it has a deadline.
16019 @item (org-agenda-skip-entry-if 'scheduled 'deadline)
16020 Skip current entry if it has a deadline, or if it is scheduled.
16021 @item (org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))
16022 Skip current entry if the TODO keyword is TODO or WAITING.
16023 @item (org-agenda-skip-entry-if 'todo 'done)
16024 Skip current entry if the TODO keyword marks a DONE state.
16025 @item (org-agenda-skip-entry-if 'timestamp)
16026 Skip current entry if it has any timestamp, may also be deadline or scheduled.
16027 @anchor{x-agenda-skip-entry-regexp}
16028 @item (org-agenda-skip-entry-if 'regexp "regular expression")
16029 Skip current entry if the regular expression matches in the entry.
16030 @item (org-agenda-skip-entry-if 'notregexp "regular expression")
16031 Skip current entry unless the regular expression matches.
16032 @item (org-agenda-skip-subtree-if 'regexp "regular expression")
16033 Same as above, but check and skip the entire subtree.
16034 @end table
16036 Therefore we could also have written the search for WAITING projects
16037 like this, even without defining a special function:
16039 @lisp
16040 (org-add-agenda-custom-command
16041  '("b" todo "PROJECT"
16042    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
16043                                 'regexp ":waiting:"))
16044     (org-agenda-overriding-header "Projects waiting for something: "))))
16045 @end lisp
16047 @node Speeding up your agendas, Extracting agenda information, Special agenda views, Hacking
16048 @section Speeding up your agendas
16049 @cindex agenda views, optimization
16051 When your Org files grow in both number and size, agenda commands may start
16052 to become slow.  Below are some tips on how to speed up the agenda commands.
16054 @enumerate
16055 @item
16056 Reduce the number of Org agenda files: this will reduce the slowliness caused
16057 by accessing to a harddrive.
16058 @item
16059 Reduce the number of DONE and archived headlines: this way the agenda does
16060 not need to skip them.
16061 @item
16062 @vindex org-agenda-dim-blocked-tasks
16063 Inhibit the dimming of blocked tasks: 
16064 @lisp
16065 (setq org-agenda-dim-blocked-tasks nil)
16066 @end lisp
16067 @item
16068 @vindex org-startup-folded
16069 @vindex org-agenda-inhibit-startup
16070 Inhibit agenda files startup options:
16071 @lisp
16072 (setq org-agenda-inhibit-startup nil)
16073 @end lisp
16074 @item
16075 @vindex org-agenda-show-inherited-tags
16076 @vindex org-agenda-use-tag-inheritance
16077 Disable tag inheritance in agenda:
16078 @lisp
16079 (setq org-agenda-use-tag-inheritance nil)
16080 @end lisp
16081 @end enumerate
16083 You can set these options for specific agenda views only.  See the docstrings
16084 of these variables for details on why they affect the agenda generation, and
16085 this @uref{http://orgmode.org/worg/agenda-optimization.html, dedicated Worg
16086 page} for further explanations.
16088 @node Extracting agenda information, Using the property API, Speeding up your agendas, Hacking
16089 @section Extracting agenda information
16090 @cindex agenda, pipe
16091 @cindex Scripts, for agenda processing
16093 @vindex org-agenda-custom-commands
16094 Org provides commands to access agenda information for the command
16095 line in Emacs batch mode.  This extracted information can be sent
16096 directly to a printer, or it can be read by a program that does further
16097 processing of the data.  The first of these commands is the function
16098 @code{org-batch-agenda}, that produces an agenda view and sends it as
16099 ASCII text to STDOUT@.  The command takes a single string as parameter.
16100 If the string has length 1, it is used as a key to one of the commands
16101 you have configured in @code{org-agenda-custom-commands}, basically any
16102 key you can use after @kbd{C-c a}.  For example, to directly print the
16103 current TODO list, you could use
16105 @example
16106 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
16107 @end example
16109 If the parameter is a string with 2 or more characters, it is used as a
16110 tags/TODO match string.  For example, to print your local shopping list
16111 (all items with the tag @samp{shop}, but excluding the tag
16112 @samp{NewYork}), you could use
16114 @example
16115 emacs -batch -l ~/.emacs                                      \
16116       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
16117 @end example
16119 @noindent
16120 You may also modify parameters on the fly like this:
16122 @example
16123 emacs -batch -l ~/.emacs                                      \
16124    -eval '(org-batch-agenda "a"                               \
16125             org-agenda-span (quote month)                     \
16126             org-agenda-include-diary nil                      \
16127             org-agenda-files (quote ("~/org/project.org")))'  \
16128    | lpr
16129 @end example
16131 @noindent
16132 which will produce a 30-day agenda, fully restricted to the Org file
16133 @file{~/org/projects.org}, not even including the diary.
16135 If you want to process the agenda data in more sophisticated ways, you
16136 can use the command @code{org-batch-agenda-csv} to get a comma-separated
16137 list of values for each agenda item.  Each line in the output will
16138 contain a number of fields separated by commas.  The fields in a line
16139 are:
16141 @example
16142 category     @r{The category of the item}
16143 head         @r{The headline, without TODO keyword, TAGS and PRIORITY}
16144 type         @r{The type of the agenda entry, can be}
16145                 todo               @r{selected in TODO match}
16146                 tagsmatch          @r{selected in tags match}
16147                 diary              @r{imported from diary}
16148                 deadline           @r{a deadline}
16149                 scheduled          @r{scheduled}
16150                 timestamp          @r{appointment, selected by timestamp}
16151                 closed             @r{entry was closed on date}
16152                 upcoming-deadline  @r{warning about nearing deadline}
16153                 past-scheduled     @r{forwarded scheduled item}
16154                 block              @r{entry has date block including date}
16155 todo         @r{The TODO keyword, if any}
16156 tags         @r{All tags including inherited ones, separated by colons}
16157 date         @r{The relevant date, like 2007-2-14}
16158 time         @r{The time, like 15:00-16:50}
16159 extra        @r{String with extra planning info}
16160 priority-l   @r{The priority letter if any was given}
16161 priority-n   @r{The computed numerical priority}
16162 @end example
16164 @noindent
16165 Time and date will only be given if a timestamp (or deadline/scheduled)
16166 led to the selection of the item.
16168 A CSV list like this is very easy to use in a post-processing script.
16169 For example, here is a Perl program that gets the TODO list from
16170 Emacs/Org and prints all the items, preceded by a checkbox:
16172 @example
16173 #!/usr/bin/perl
16175 # define the Emacs command to run
16176 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
16178 # run it and capture the output
16179 $agenda = qx@{$cmd 2>/dev/null@};
16181 # loop over all lines
16182 foreach $line (split(/\n/,$agenda)) @{
16183   # get the individual values
16184   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
16185    $priority_l,$priority_n) = split(/,/,$line);
16186   # process and print
16187   print "[ ] $head\n";
16189 @end example
16191 @node Using the property API, Using the mapping API, Extracting agenda information, Hacking
16192 @section Using the property API
16193 @cindex API, for properties
16194 @cindex properties, API
16196 Here is a description of the functions that can be used to work with
16197 properties.
16199 @defun org-entry-properties &optional pom which
16200 Get all properties of the entry at point-or-marker POM.@*
16201 This includes the TODO keyword, the tags, time strings for deadline,
16202 scheduled, and clocking, and any additional properties defined in the
16203 entry.  The return value is an alist.  Keys may occur multiple times
16204 if the property key was used several times.@*
16205 POM may also be nil, in which case the current entry is used.
16206 If WHICH is nil or `all', get all properties.  If WHICH is
16207 `special' or `standard', only get that subclass.
16208 @end defun
16209 @vindex org-use-property-inheritance
16210 @findex org-insert-property-drawer
16211 @defun org-entry-get pom property &optional inherit
16212 Get value of PROPERTY for entry at point-or-marker POM@.  By default,
16213 this only looks at properties defined locally in the entry.  If INHERIT
16214 is non-nil and the entry does not have the property, then also check
16215 higher levels of the hierarchy.  If INHERIT is the symbol
16216 @code{selective}, use inheritance if and only if the setting of
16217 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
16218 @end defun
16220 @defun org-entry-delete pom property
16221 Delete the property PROPERTY from entry at point-or-marker POM.
16222 @end defun
16224 @defun org-entry-put pom property value
16225 Set PROPERTY to VALUE for entry at point-or-marker POM.
16226 @end defun
16228 @defun org-buffer-property-keys &optional include-specials
16229 Get all property keys in the current buffer.
16230 @end defun
16232 @defun org-insert-property-drawer
16233 Insert a property drawer for the current entry.  Also
16234 @end defun
16236 @defun org-entry-put-multivalued-property pom property &rest values
16237 Set PROPERTY at point-or-marker POM to VALUES@.  VALUES should be a list of
16238 strings.  They will be concatenated, with spaces as separators.
16239 @end defun
16241 @defun org-entry-get-multivalued-property pom property
16242 Treat the value of the property PROPERTY as a whitespace-separated list of
16243 values and return the values as a list of strings.
16244 @end defun
16246 @defun org-entry-add-to-multivalued-property pom property value
16247 Treat the value of the property PROPERTY as a whitespace-separated list of
16248 values and make sure that VALUE is in this list.
16249 @end defun
16251 @defun org-entry-remove-from-multivalued-property pom property value
16252 Treat the value of the property PROPERTY as a whitespace-separated list of
16253 values and make sure that VALUE is @emph{not} in this list.
16254 @end defun
16256 @defun org-entry-member-in-multivalued-property pom property value
16257 Treat the value of the property PROPERTY as a whitespace-separated list of
16258 values and check if VALUE is in this list.
16259 @end defun
16261 @defopt org-property-allowed-value-functions
16262 Hook for functions supplying allowed values for a specific property.
16263 The functions must take a single argument, the name of the property, and
16264 return a flat list of allowed values.  If @samp{:ETC} is one of
16265 the values, use the values as completion help, but allow also other values
16266 to be entered.  The functions must return @code{nil} if they are not
16267 responsible for this property.
16268 @end defopt
16270 @node Using the mapping API,  , Using the property API, Hacking
16271 @section Using the mapping API
16272 @cindex API, for mapping
16273 @cindex mapping entries, API
16275 Org has sophisticated mapping capabilities to find all entries satisfying
16276 certain criteria.  Internally, this functionality is used to produce agenda
16277 views, but there is also an API that can be used to execute arbitrary
16278 functions for each or selected entries.  The main entry point for this API
16281 @defun org-map-entries func &optional match scope &rest skip
16282 Call FUNC at each headline selected by MATCH in SCOPE.
16284 FUNC is a function or a Lisp form.  The function will be called without
16285 arguments, with the cursor positioned at the beginning of the headline.
16286 The return values of all calls to the function will be collected and
16287 returned as a list.
16289 The call to FUNC will be wrapped into a save-excursion form, so FUNC
16290 does not need to preserve point.  After evaluation, the cursor will be
16291 moved to the end of the line (presumably of the headline of the
16292 processed entry) and search continues from there.  Under some
16293 circumstances, this may not produce the wanted results.  For example,
16294 if you have removed (e.g., archived) the current (sub)tree it could
16295 mean that the next entry will be skipped entirely.  In such cases, you
16296 can specify the position from where search should continue by making
16297 FUNC set the variable `org-map-continue-from' to the desired buffer
16298 position.
16300 MATCH is a tags/property/todo match as it is used in the agenda match view.
16301 Only headlines that are matched by this query will be considered during
16302 the iteration.  When MATCH is nil or t, all headlines will be
16303 visited by the iteration.
16305 SCOPE determines the scope of this command.  It can be any of:
16307 @example
16308 nil     @r{the current buffer, respecting the restriction if any}
16309 tree    @r{the subtree started with the entry at point}
16310 region  @r{The entries within the active region, if any}
16311 file    @r{the current buffer, without restriction}
16312 file-with-archives
16313         @r{the current buffer, and any archives associated with it}
16314 agenda  @r{all agenda files}
16315 agenda-with-archives
16316         @r{all agenda files with any archive files associated with them}
16317 (file1 file2 ...)
16318         @r{if this is a list, all files in the list will be scanned}
16319 @end example
16320 @noindent
16321 The remaining args are treated as settings for the skipping facilities of
16322 the scanner.  The following items can be given here:
16324 @vindex org-agenda-skip-function
16325 @example
16326 archive   @r{skip trees with the archive tag}
16327 comment   @r{skip trees with the COMMENT keyword}
16328 function or Lisp form
16329           @r{will be used as value for @code{org-agenda-skip-function},}
16330           @r{so whenever the function returns t, FUNC}
16331           @r{will not be called for that entry and search will}
16332           @r{continue from the point where the function leaves it}
16333 @end example
16334 @end defun
16336 The function given to that mapping routine can really do anything you like.
16337 It can use the property API (@pxref{Using the property API}) to gather more
16338 information about the entry, or in order to change metadata in the entry.
16339 Here are a couple of functions that might be handy:
16341 @defun org-todo &optional arg
16342 Change the TODO state of the entry.  See the docstring of the functions for
16343 the many possible values for the argument ARG.
16344 @end defun
16346 @defun org-priority &optional action
16347 Change the priority of the entry.  See the docstring of this function for the
16348 possible values for ACTION.
16349 @end defun
16351 @defun org-toggle-tag tag &optional onoff
16352 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
16353 or @code{off} will not toggle tag, but ensure that it is either on or off.
16354 @end defun
16356 @defun org-promote
16357 Promote the current entry.
16358 @end defun
16360 @defun org-demote
16361 Demote the current entry.
16362 @end defun
16364 Here is a simple example that will turn all entries in the current file with
16365 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
16366 Entries in comment trees and in archive trees will be ignored.
16368 @lisp
16369 (org-map-entries
16370  '(org-todo "UPCOMING")
16371  "+TOMORROW" 'file 'archive 'comment)
16372 @end lisp
16374 The following example counts the number of entries with TODO keyword
16375 @code{WAITING}, in all agenda files.
16377 @lisp
16378 (length (org-map-entries t "/+WAITING" 'agenda))
16379 @end lisp
16381 @node MobileOrg, History and Acknowledgments, Hacking, Top
16382 @appendix MobileOrg
16383 @cindex iPhone
16384 @cindex MobileOrg
16386 @i{MobileOrg} is the name of the mobile companion app for Org mode, currently
16387 available for iOS and for Android.  @i{MobileOrg} offers offline viewing and
16388 capture support for an Org mode system rooted on a ``real'' computer.  It
16389 does also allow you to record changes to existing entries.
16390 The @uref{http://mobileorg.ncogni.to/, iOS implementation} for the
16391 @i{iPhone/iPod Touch/iPad} series of devices, was developed by Richard
16392 Moreland.  Android users should check out
16393 @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android}
16394 by Matt Jones.  The two implementations are not identical but offer similar
16395 features.
16397 This appendix describes the support Org has for creating agenda views in a
16398 format that can be displayed by @i{MobileOrg}, and for integrating notes
16399 captured and changes made by @i{MobileOrg} into the main system.
16401 For changing tags and TODO states in MobileOrg, you should have set up the
16402 customization variables @code{org-todo-keywords} and @code{org-tags-alist} to
16403 cover all important tags and TODO keywords, even if individual files use only
16404 part of these.  MobileOrg will also offer you states and tags set up with
16405 in-buffer settings, but it will understand the logistics of TODO state
16406 @i{sets} (@pxref{Per-file keywords}) and @i{mutually exclusive} tags
16407 (@pxref{Setting tags}) only for those set in these variables.
16409 @menu
16410 * Setting up the staging area::  Where to interact with the mobile device
16411 * Pushing to MobileOrg::        Uploading Org files and agendas
16412 * Pulling from MobileOrg::      Integrating captured and flagged items
16413 @end menu
16415 @node Setting up the staging area, Pushing to MobileOrg, MobileOrg, MobileOrg
16416 @section Setting up the staging area
16418 MobileOrg needs to interact with Emacs through a directory on a server.  If you
16419 are using a public server, you should consider to encrypt the files that are
16420 uploaded to the server.  This can be done with Org mode 7.02 and with
16421 @i{MobileOrg 1.5} (iPhone version), and you need an @file{openssl}
16422 installation on your system.  To turn on encryption, set a password in
16423 @i{MobileOrg} and, on the Emacs side, configure the variable
16424 @code{org-mobile-use-encryption}@footnote{If you can safely store the
16425 password in your Emacs setup, you might also want to configure
16426 @code{org-mobile-encryption-password}.  Please read the docstring of that
16427 variable.  Note that encryption will apply only to the contents of the
16428 @file{.org} files.  The file names themselves will remain visible.}.
16430 The easiest way to create that directory is to use a free
16431 @uref{http://dropbox.com,Dropbox.com} account@footnote{If you cannot use
16432 Dropbox, or if your version of MobileOrg does not support it, you can use a
16433 webdav server.  For more information, check out the documentation of MobileOrg and also this
16434 @uref{http://orgmode.org/worg/org-faq.html#mobileorg_webdav, FAQ entry}.}.
16435 When MobileOrg first connects to your Dropbox, it will create a directory
16436 @i{MobileOrg} inside the Dropbox.  After the directory has been created, tell
16437 Emacs about it:
16439 @lisp
16440 (setq org-mobile-directory "~/Dropbox/MobileOrg")
16441 @end lisp
16443 Org mode has commands to put files for @i{MobileOrg} into that directory,
16444 and to read captured notes from there.
16446 @node Pushing to MobileOrg, Pulling from MobileOrg, Setting up the staging area, MobileOrg
16447 @section Pushing to MobileOrg
16449 This operation copies all files currently listed in @code{org-mobile-files}
16450 to the directory @code{org-mobile-directory}.  By default this list contains
16451 all agenda files (as listed in @code{org-agenda-files}), but additional files
16452 can be included by customizing @code{org-mobile-files}.  File names will be
16453 staged with paths relative to @code{org-directory}, so all files should be
16454 inside this directory@footnote{Symbolic links in @code{org-directory} need to
16455 have the same name than their targets.}.
16457 The push operation also creates a special Org file @file{agendas.org} with
16458 all custom agenda view defined by the user@footnote{While creating the
16459 agendas, Org mode will force ID properties on all referenced entries, so that
16460 these entries can be uniquely identified if @i{MobileOrg} flags them for
16461 further action.  If you do not want to get these properties in so many
16462 entries, you can set the variable @code{org-mobile-force-id-on-agenda-items}
16463 to @code{nil}.  Org mode will then rely on outline paths, in the hope that
16464 these will be unique enough.}.
16466 Finally, Org writes the file @file{index.org}, containing links to all other
16467 files.  @i{MobileOrg} first reads this file from the server, and then
16468 downloads all agendas and Org files listed in it.  To speed up the download,
16469 MobileOrg will only read files whose checksums@footnote{Checksums are stored
16470 automatically in the file @file{checksums.dat}} have changed.
16472 @node Pulling from MobileOrg,  , Pushing to MobileOrg, MobileOrg
16473 @section Pulling from MobileOrg
16475 When @i{MobileOrg} synchronizes with the server, it not only pulls the Org
16476 files for viewing.  It also appends captured entries and pointers to flagged
16477 and changed entries to the file @file{mobileorg.org} on the server.  Org has
16478 a @emph{pull} operation that integrates this information into an inbox file
16479 and operates on the pointers to flagged entries.  Here is how it works:
16481 @enumerate
16482 @item
16483 Org moves all entries found in
16484 @file{mobileorg.org}@footnote{@file{mobileorg.org} will be empty after this
16485 operation.} and appends them to the file pointed to by the variable
16486 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing event
16487 will be a top-level entry in the inbox file.
16488 @item
16489 After moving the entries, Org will attempt to implement the changes made in
16490 @i{MobileOrg}.  Some changes are applied directly and without user
16491 interaction.  Examples are all changes to tags, TODO state, headline and body
16492 text that can be cleanly applied.  Entries that have been flagged for further
16493 action will receive a tag @code{:FLAGGED:}, so that they can be easily found
16494 again.  When there is a problem finding an entry or applying the change, the
16495 pointer entry will remain in the inbox and will be marked with an error
16496 message.  You need to later resolve these issues by hand.
16497 @item
16498 Org will then generate an agenda view with all flagged entries.  The user
16499 should then go through these entries and do whatever actions are necessary.
16500 If a note has been stored while flagging an entry in @i{MobileOrg}, that note
16501 will be displayed in the echo area when the cursor is on the corresponding
16502 agenda line.
16504 @table @kbd
16505 @kindex ?
16506 @item ?
16507 Pressing @kbd{?} in that special agenda will display the full flagging note in
16508 another window and also push it onto the kill ring.  So you could use @kbd{?
16509 z C-y C-c C-c} to store that flagging note as a normal note in the entry.
16510 Pressing @kbd{?} twice in succession will offer to remove the
16511 @code{:FLAGGED:} tag along with the recorded flagging note (which is stored
16512 in a property).  In this way you indicate that the intended processing for
16513 this flagged entry is finished.
16514 @end table
16515 @end enumerate
16517 @kindex C-c a ?
16518 If you are not able to process all flagged entries directly, you can always
16519 return to this agenda view@footnote{Note, however, that there is a subtle
16520 difference.  The view created automatically by @kbd{M-x org-mobile-pull
16521 @key{RET}} is guaranteed to search all files that have been addressed by the
16522 last pull.  This might include a file that is not currently in your list of
16523 agenda files.  If you later use @kbd{C-c a ?} to regenerate the view, only
16524 the current agenda files will be searched.} using @kbd{C-c a ?}.
16526 @node History and Acknowledgments, GNU Free Documentation License, MobileOrg, Top
16527 @appendix History and acknowledgments
16528 @cindex acknowledgments
16529 @cindex history
16530 @cindex thanks
16532 @section From Carsten
16534 Org was born in 2003, out of frustration over the user interface of the Emacs
16535 Outline mode.  I was trying to organize my notes and projects, and using
16536 Emacs seemed to be the natural way to go.  However, having to remember eleven
16537 different commands with two or three keys per command, only to hide and show
16538 parts of the outline tree, that seemed entirely unacceptable to me.  Also,
16539 when using outlines to take notes, I constantly wanted to restructure the
16540 tree, organizing it parallel to my thoughts and plans.  @emph{Visibility
16541 cycling} and @emph{structure editing} were originally implemented in the
16542 package @file{outline-magic.el}, but quickly moved to the more general
16543 @file{org.el}.  As this environment became comfortable for project planning,
16544 the next step was adding @emph{TODO entries}, basic @emph{timestamps}, and
16545 @emph{table support}.  These areas highlighted the two main goals that Org
16546 still has today: to be a new, outline-based, plain text mode with innovative
16547 and intuitive editing features, and to incorporate project planning
16548 functionality directly into a notes file.
16550 Since the first release, literally thousands of emails to me or to
16551 @email{emacs-orgmode@@gnu.org} have provided a constant stream of bug
16552 reports, feedback, new ideas, and sometimes patches and add-on code.
16553 Many thanks to everyone who has helped to improve this package.  I am
16554 trying to keep here a list of the people who had significant influence
16555 in shaping one or more aspects of Org.  The list may not be
16556 complete, if I have forgotten someone, please accept my apologies and
16557 let me know.
16559 Before I get to this list, a few special mentions are in order:
16561 @table @i
16562 @item Bastien Guerry
16563 Bastien has written a large number of extensions to Org (most of them
16564 integrated into the core by now), including the @LaTeX{} exporter and the plain
16565 list parser.  His support during the early days, when he basically acted as
16566 co-maintainer, was central to the success of this project.  Bastien also
16567 invented Worg, helped establishing the Web presence of Org, and sponsored
16568 hosting costs for the orgmode.org website.
16569 @item Eric Schulte and Dan Davison
16570 Eric and Dan are jointly responsible for the Org-babel system, which turns
16571 Org into a multi-language environment for evaluating code and doing literate
16572 programming and reproducible research.
16573 @item John Wiegley
16574 John has contributed a number of great ideas and patches directly to Org,
16575 including the attachment system (@file{org-attach.el}), integration with
16576 Apple Mail (@file{org-mac-message.el}), hierarchical dependencies of TODO
16577 items, habit tracking (@file{org-habits.el}), and encryption
16578 (@file{org-crypt.el}).  Also, the capture system is really an extended copy
16579 of his great @file{remember.el}.
16580 @item Sebastian Rose
16581 Without Sebastian, the HTML/XHTML publishing of Org would be the pitiful work
16582 of an ignorant amateur.  Sebastian has pushed this part of Org onto a much
16583 higher level.  He also wrote @file{org-info.js}, a Java script for displaying
16584 webpages derived from Org using an Info-like or a folding interface with
16585 single-key navigation.
16586 @end table
16588 @noindent See below for the full list of contributions!  Again, please
16589 let me know what I am missing here!
16591 @section From Bastien
16593 I (Bastien) have been maintaining Org since January 2011.  This appendix
16594 would not be complete without adding a few more acknowledgements and thanks
16595 to Carsten's ones above.
16597 I am first grateful to Carsten for his trust while handing me over the
16598 maintainership of Org.  His support as been great since day one of this new
16599 adventure, and it helped a lot.
16601 When I took over maintainership, I knew I would have to make Org more
16602 collaborative than ever, as I would have to rely on people that are more
16603 knowledgeable than I am on many parts of the code.  Here is a list of the
16604 persons I could rely on, they should really be considered co-maintainers,
16605 either of the code or the community:
16607 @table @i
16608 @item Eric Schulte
16609 Eric is maintaining the Babel parts of Org.  His reactivity here kept me away
16610 from worrying about possible bugs here and let me focus on other parts.
16612 @item Nicolas Goaziou
16613 Nicolas is maintaining the consistency of the deepest parts of Org.  His work
16614 on @file{org-element.el} and @file{org-export.el} has been outstanding, and
16615 opened the doors for many new ideas and features.
16617 @item Achim Gratz
16618 Achim rewrote the building process of Org, turning some @emph{ad hoc} tools
16619 into a flexible and conceptually clean process.  He patiently coped with the
16620 many hiccups that such a change can create for users.
16622 @item Nick Dokos
16623 The Org mode mailing list would not be such a nice place without Nick, who
16624 patiently helped users so many times.  It is impossible to overestimate such
16625 a great help, and the list would not be so active without him.
16626 @end table
16628 I received support from so many users that it is clearly impossible to be
16629 fair when shortlisting a few of them, but Org's history would not be
16630 complete if the ones above were not mentioned in this manual.
16632 @section List of contributions
16634 @itemize @bullet
16636 @item
16637 @i{Russel Adams} came up with the idea for drawers.
16638 @item
16639 @i{Suvayu Ali} has steadily helped on the mailing list, providing useful
16640 feedback on many features and several patches.
16641 @item
16642 @i{Luis Anaya} wrote @file{ox-man.el}.
16643 @item
16644 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
16645 @item
16646 @i{Michael Brand} helped by reporting many bugs and testing many features.
16647 He also implemented the distinction between empty fields and 0-value fields
16648 in Org's spreadsheets.
16649 @item
16650 @i{Christophe Bataillon} created the great unicorn logo that we use on the
16651 Org mode website.
16652 @item
16653 @i{Alex Bochannek} provided a patch for rounding timestamps.
16654 @item
16655 @i{Jan Böcker} wrote @file{org-docview.el}.
16656 @item
16657 @i{Brad Bozarth} showed how to pull RSS feed data into Org mode files.
16658 @item
16659 @i{Tom Breton} wrote @file{org-choose.el}.
16660 @item
16661 @i{Charles Cave}'s suggestion sparked the implementation of templates
16662 for Remember, which are now templates for capture.
16663 @item
16664 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
16665 specified time.
16666 @item
16667 @i{Gregory Chernov} patched support for Lisp forms into table
16668 calculations and improved XEmacs compatibility, in particular by porting
16669 @file{nouline.el} to XEmacs.
16670 @item
16671 @i{Sacha Chua} suggested copying some linking code from Planner.
16672 @item
16673 @i{Toby S. Cubitt} contributed to the code for clock formats.
16674 @item
16675 @i{Baoqiu Cui} contributed the DocBook exporter.  It has been deleted from
16676 Org 8.0: you can now export to Texinfo and export the @code{.texi} file to
16677 DocBook using @code{makeinfo}.
16678 @item
16679 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
16680 came up with the idea of properties, and that there should be an API for
16681 them.
16682 @item
16683 @i{Nick Dokos} tracked down several nasty bugs.
16684 @item
16685 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
16686 inspired some of the early development, including HTML export.  He also
16687 asked for a way to narrow wide table columns.
16688 @item
16689 @i{Thomas S. Dye} contributed documentation on Worg and helped integrating
16690 the Org-Babel documentation into the manual.
16691 @item
16692 @i{Christian Egli} converted the documentation into Texinfo format, inspired
16693 the agenda, patched CSS formatting into the HTML exporter, and wrote
16694 @file{org-taskjuggler.el}, which has been rewritten by Nicolas Goaziou as
16695 @file{ox-taskjuggler.el} for Org 8.0.
16696 @item
16697 @i{David Emery} provided a patch for custom CSS support in exported
16698 HTML agendas.
16699 @item
16700 @i{Nic Ferrier} contributed mailcap and XOXO support.
16701 @item
16702 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
16703 @item
16704 @i{John Foerch} figured out how to make incremental search show context
16705 around a match in a hidden outline tree.
16706 @item
16707 @i{Raimar Finken} wrote @file{org-git-line.el}.
16708 @item
16709 @i{Mikael Fornius} works as a mailing list moderator.
16710 @item
16711 @i{Austin Frank} works as a mailing list moderator.
16712 @item
16713 @i{Eric Fraga} drove the development of BEAMER export with ideas and
16714 testing.
16715 @item
16716 @i{Barry Gidden} did proofreading the manual in preparation for the book
16717 publication through Network Theory Ltd.
16718 @item
16719 @i{Niels Giesen} had the idea to automatically archive DONE trees.
16720 @item
16721 @i{Nicolas Goaziou} rewrote much of the plain list code.  He also wrote
16722 @file{org-element.el} and @file{org-export.el}, which was a huge step forward
16723 in implementing a clean framework for Org exporters.
16724 @item
16725 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
16726 @item
16727 @i{Brian Gough} of Network Theory Ltd publishes the Org mode manual as a
16728 book.
16729 @item
16730 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
16731 task state change logging, and the clocktable.  His clear explanations have
16732 been critical when we started to adopt the Git version control system.
16733 @item
16734 @i{Manuel Hermenegildo} has contributed various ideas, small fixes and
16735 patches.
16736 @item
16737 @i{Phil Jackson} wrote @file{org-irc.el}.
16738 @item
16739 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
16740 folded entries, and column view for properties.
16741 @item
16742 @i{Matt Jones} wrote @i{MobileOrg Android}.
16743 @item
16744 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
16745 @item
16746 @i{Jonathan Leech-Pepin} wrote @file{ox-texinfo.el}.
16747 @item
16748 @i{Shidai Liu} ("Leo") asked for embedded @LaTeX{} and tested it.  He also
16749 provided frequent feedback and some patches.
16750 @item
16751 @i{Matt Lundin} has proposed last-row references for table formulas and named
16752 invisible anchors.  He has also worked a lot on the FAQ.
16753 @item
16754 @i{David Maus} wrote @file{org-atom.el}, maintains the issues file for Org,
16755 and is a prolific contributor on the mailing list with competent replies,
16756 small fixes and patches.
16757 @item
16758 @i{Jason F. McBrayer} suggested agenda export to CSV format.
16759 @item
16760 @i{Max Mikhanosha} came up with the idea of refiling and sticky agendas.
16761 @item
16762 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
16763 basis.
16764 @item
16765 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
16766 happy.
16767 @item
16768 @i{Richard Moreland} wrote @i{MobileOrg} for the iPhone.
16769 @item
16770 @i{Rick Moynihan} proposed allowing multiple TODO sequences in a file
16771 and being able to quickly restrict the agenda to a subtree.
16772 @item
16773 @i{Todd Neal} provided patches for links to Info files and Elisp forms.
16774 @item
16775 @i{Greg Newman} refreshed the unicorn logo into its current form.
16776 @item
16777 @i{Tim O'Callaghan} suggested in-file links, search options for general
16778 file links, and TAGS.
16779 @item
16780 @i{Osamu Okano} wrote @file{orgcard2ref.pl}, a Perl program to create a text
16781 version of the reference card.
16782 @item
16783 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
16784 into Japanese.
16785 @item
16786 @i{Oliver Oppitz} suggested multi-state TODO items.
16787 @item
16788 @i{Scott Otterson} sparked the introduction of descriptive text for
16789 links, among other things.
16790 @item
16791 @i{Pete Phillips} helped during the development of the TAGS feature, and
16792 provided frequent feedback.
16793 @item
16794 @i{Francesco Pizzolante} provided patches that helped speeding up the agenda
16795 generation.
16796 @item
16797 @i{Martin Pohlack} provided the code snippet to bundle character insertion
16798 into bundles of 20 for undo.
16799 @item
16800 @i{T.V. Raman} reported bugs and suggested improvements.
16801 @item
16802 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
16803 control.
16804 @item
16805 @i{Paul Rivier} provided the basic implementation of named footnotes.  He
16806 also acted as mailing list moderator for some time.
16807 @item
16808 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
16809 @item
16810 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
16811 conflict with @file{allout.el}.
16812 @item
16813 @i{Jason Riedy} generalized the send-receive mechanism for Orgtbl tables with
16814 extensive patches.
16815 @item
16816 @i{Philip Rooke} created the Org reference card, provided lots
16817 of feedback, developed and applied standards to the Org documentation.
16818 @item
16819 @i{Christian Schlauer} proposed angular brackets around links, among
16820 other things.
16821 @item
16822 @i{Christopher Schmidt} reworked @code{orgstruct-mode} so that users can
16823 enjoy folding in non-org buffers by using Org headlines in comments.
16824 @item
16825 @i{Paul Sexton} wrote @file{org-ctags.el}.
16826 @item
16827 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
16828 @file{organizer-mode.el}.
16829 @item
16830 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
16831 examples, and remote highlighting for referenced code lines.
16832 @item
16833 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
16834 now packaged into Org's @file{contrib} directory.
16835 @item
16836 @i{Daniel Sinder} came up with the idea of internal archiving by locking
16837 subtrees.
16838 @item
16839 @i{Dale Smith} proposed link abbreviations.
16840 @item
16841 @i{James TD Smith} has contributed a large number of patches for useful
16842 tweaks and features.
16843 @item
16844 @i{Adam Spiers} asked for global linking commands, inspired the link
16845 extension system, added support for mairix, and proposed the mapping API.
16846 @item
16847 @i{Ulf Stegemann} created the table to translate special symbols to HTML,
16848 @LaTeX{}, UTF-8, Latin-1 and ASCII.
16849 @item
16850 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
16851 with links transformation to Org syntax.
16852 @item
16853 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
16854 chapter about publishing.
16855 @item
16856 @i{Jambunathan K} contributed the ODT exporter and rewrote the HTML exporter.
16857 @item
16858 @i{Sebastien Vauban} reported many issues with @LaTeX{} and BEAMER export and
16859 enabled source code highlighting in Gnus.
16860 @item
16861 @i{Stefan Vollmar} organized a video-recorded talk at the
16862 Max-Planck-Institute for Neurology.  He also inspired the creation of a
16863 concept index for HTML export.
16864 @item
16865 @i{J@"urgen Vollmer} contributed code generating the table of contents
16866 in HTML output.
16867 @item
16868 @i{Samuel Wales} has provided important feedback and bug reports.
16869 @item
16870 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
16871 keyword.
16872 @item
16873 @i{David Wainberg} suggested archiving, and improvements to the linking
16874 system.
16875 @item
16876 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
16877 linking to Gnus.
16878 @item
16879 @i{Roland Winkler} requested additional key bindings to make Org
16880 work on a tty.
16881 @item
16882 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
16883 and contributed various ideas and code snippets.
16884 @end itemize
16887 @node GNU Free Documentation License, Main Index, History and Acknowledgments, Top
16888 @appendix GNU Free Documentation License
16889 @include doclicense.texi
16892 @node Main Index, Key Index, GNU Free Documentation License, Top
16893 @unnumbered Concept index
16895 @printindex cp
16897 @node Key Index, Command and Function Index, Main Index, Top
16898 @unnumbered Key index
16900 @printindex ky
16902 @node Command and Function Index, Variable Index, Key Index, Top
16903 @unnumbered Command and function index
16905 @printindex fn
16907 @node Variable Index,  , Command and Function Index, Top
16908 @unnumbered Variable index
16910 This is not a complete index of variables and faces, only the ones that are
16911 mentioned in the manual.  For a more complete list, use @kbd{M-x
16912 org-customize @key{RET}} and then click yourself through the tree.
16914 @printindex vr
16916 @bye
16918 @c Local variables:
16919 @c fill-column: 77
16920 @c indent-tabs-mode: nil
16921 @c paragraph-start:    "\b\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|\f\\|[  ]*$"
16922 @c paragraph-separate: "\b\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|[       \f]*$"
16923 @c End:
16926 @c  LocalWords:  webdavhost pre