org.texi (Exporting, Export settings): Rephrasing
[org-mode.git] / doc / org.texi
blob56ccea7526b785671224cb3019ecdfa41640f51c
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 web page}
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
292 Davison, Eric Schulte, Thomas Dye, Jambunathan K and Nicolas Goaziou.
294 @c The following two commands start the copyright page.
295 @page
296 @vskip 0pt plus 1filll
297 @insertcopying
298 @end titlepage
300 @c Output the table of contents at the beginning.
301 @contents
303 @ifnottex
304 @c FIXME These hand-written next,prev,up node pointers make editing a lot
305 @c harder.  There should be no need for them, makeinfo can do it
306 @c automatically for any document with a normal structure.
307 @node Top, Introduction, (dir), (dir)
308 @top Org Mode Manual
310 @insertcopying
311 @end ifnottex
313 @menu
314 * Introduction::                Getting started
315 * Document Structure::          A tree works like your brain
316 * Tables::                      Pure magic for quick formatting
317 * Hyperlinks::                  Notes in context
318 * TODO Items::                  Every tree branch can be a TODO item
319 * Tags::                        Tagging headlines and matching sets of tags
320 * Properties and Columns::      Storing information about an entry
321 * Dates and Times::             Making items useful for planning
322 * Capture - Refile - Archive::  The ins and outs for projects
323 * Agenda Views::                Collecting information into views
324 * Markup::                      Prepare text for rich export
325 * Exporting::                   Sharing and publishing notes
326 * Publishing::                  Create a web site of linked Org files
327 * Working With Source Code::    Export, evaluate, and tangle code blocks
328 * Miscellaneous::               All the rest which did not fit elsewhere
329 * Hacking::                     How to hack your way around
330 * MobileOrg::                   Viewing and capture on a mobile device
331 * History and Acknowledgments::  How Org came into being
332 * GNU Free Documentation License::  The license for this documentation.
333 * Main Index::                  An index of Org's concepts and features
334 * Key Index::                   Key bindings and where they are described
335 * Command and Function Index::  Command names and some internal functions
336 * Variable Index::              Variables mentioned in the manual
338 @detailmenu
339  --- The Detailed Node Listing ---
341 Introduction
343 * Summary::                     Brief summary of what Org does
344 * Installation::                Installing Org
345 * Activation::                  How to activate Org for certain buffers
346 * Feedback::                    Bug reports, ideas, patches etc.
347 * Conventions::                 Typesetting conventions in the manual
349 Document structure
351 * Outlines::                    Org is based on Outline mode
352 * Headlines::                   How to typeset Org tree headlines
353 * Visibility cycling::          Show and hide, much simplified
354 * Motion::                      Jumping to other headlines
355 * Structure editing::           Changing sequence and level of headlines
356 * Sparse trees::                Matches embedded in context
357 * Plain lists::                 Additional structure within an entry
358 * Drawers::                     Tucking stuff away
359 * Blocks::                      Folding blocks
360 * Footnotes::                   How footnotes are defined in Org's syntax
361 * Orgstruct mode::              Structure editing outside Org
362 * Org syntax::                  Formal description of Org's syntax
364 Visibility cycling
366 * Global and local cycling::    Cycling through various visibility states
367 * Initial visibility::          Setting the initial visibility state
368 * Catching invisible edits::    Preventing mistakes when editing invisible parts
370 Global and local cycling
372 * Initial visibility::          Setting the initial visibility state
373 * Catching invisible edits::    Preventing mistakes when editing invisible parts
375 Tables
377 * Built-in table editor::       Simple tables
378 * Column width and alignment::  Overrule the automatic settings
379 * Column groups::               Grouping to trigger vertical lines
380 * Orgtbl mode::                 The table editor as minor mode
381 * The spreadsheet::             The table editor has spreadsheet capabilities
382 * Org-Plot::                    Plotting from org tables
384 The spreadsheet
386 * References::                  How to refer to another field or range
387 * Formula syntax for Calc::     Using Calc to compute stuff
388 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
389 * Durations and time values::   How to compute durations and time values
390 * Field and range formulas::    Formula for specific (ranges of) fields
391 * Column formulas::             Formulas valid for an entire column
392 * Lookup functions::            Lookup functions for searching tables
393 * Editing and debugging formulas::  Fixing formulas
394 * Updating the table::          Recomputing all dependent fields
395 * Advanced features::           Field and column names, parameters and automatic recalc
397 Hyperlinks
399 * Link format::                 How links in Org are formatted
400 * Internal links::              Links to other places in the current file
401 * External links::              URL-like links to the world
402 * Handling links::              Creating, inserting and following
403 * Using links outside Org::     Linking from my C source code?
404 * Link abbreviations::          Shortcuts for writing complex links
405 * Search options::              Linking to a specific location
406 * Custom searches::             When the default search is not enough
408 Internal links
410 * Radio targets::               Make targets trigger links in plain text
412 TODO items
414 * TODO basics::                 Marking and displaying TODO entries
415 * TODO extensions::             Workflow and assignments
416 * Progress logging::            Dates and notes for progress
417 * Priorities::                  Some things are more important than others
418 * Breaking down tasks::         Splitting a task into manageable pieces
419 * Checkboxes::                  Tick-off lists
421 Extended use of TODO keywords
423 * Workflow states::             From TODO to DONE in steps
424 * TODO types::                  I do this, Fred does the rest
425 * Multiple sets in one file::   Mixing it all, and still finding your way
426 * Fast access to TODO states::  Single letter selection of a state
427 * Per-file keywords::           Different files, different requirements
428 * Faces for TODO keywords::     Highlighting states
429 * TODO dependencies::           When one task needs to wait for others
431 Progress logging
433 * Closing items::               When was this entry marked DONE?
434 * Tracking TODO state changes::  When did the status change?
435 * Tracking your habits::        How consistent have you been?
437 Tags
439 * Tag inheritance::             Tags use the tree structure of the outline
440 * Setting tags::                How to assign tags to a headline
441 * Tag groups::                  Use one tag to search for several tags
442 * Tag searches::                Searching for combinations of tags
444 Properties and columns
446 * Property syntax::             How properties are spelled out
447 * Special properties::          Access to other Org mode features
448 * Property searches::           Matching property values
449 * Property inheritance::        Passing values down the tree
450 * Column view::                 Tabular viewing and editing
451 * Property API::                Properties for Lisp programmers
453 Column view
455 * Defining columns::            The COLUMNS format property
456 * Using column view::           How to create and use column view
457 * Capturing column view::       A dynamic block for column view
459 Defining columns
461 * Scope of column definitions::  Where defined, where valid?
462 * Column attributes::           Appearance and content of a column
464 Dates and times
466 * Timestamps::                  Assigning a time to a tree entry
467 * Creating timestamps::         Commands which insert timestamps
468 * Deadlines and scheduling::    Planning your work
469 * Clocking work time::          Tracking how long you spend on a task
470 * Effort estimates::            Planning work effort in advance
471 * Relative timer::              Notes with a running timer
472 * Countdown timer::             Starting a countdown timer for a task
474 Creating timestamps
476 * The date/time prompt::        How Org mode helps you entering date and time
477 * Custom time format::          Making dates look different
479 Deadlines and scheduling
481 * Inserting deadline/schedule::  Planning items
482 * Repeated tasks::              Items that show up again and again
484 Clocking work time
486 * Clocking commands::           Starting and stopping a clock
487 * The clock table::             Detailed reports
488 * Resolving idle time::         Resolving time when you've been idle
490 Capture - Refile - Archive
492 * Capture::                     Capturing new stuff
493 * Attachments::                 Add files to tasks
494 * RSS Feeds::                   Getting input from RSS feeds
495 * Protocols::                   External (e.g., Browser) access to Emacs and Org
496 * Refile and copy::             Moving/copying a tree from one place to another
497 * Archiving::                   What to do with finished projects
499 Capture
501 * Setting up capture::          Where notes will be stored
502 * Using capture::               Commands to invoke and terminate capture
503 * Capture templates::           Define the outline of different note types
505 Capture templates
507 * Template elements::           What is needed for a complete template entry
508 * Template expansion::          Filling in information about time and context
509 * Templates in contexts::       Only show a template in a specific context
511 Archiving
513 * Moving subtrees::             Moving a tree to an archive file
514 * Internal archiving::          Switch off a tree but keep it in the file
516 Agenda views
518 * Agenda files::                Files being searched for agenda information
519 * Agenda dispatcher::           Keyboard access to agenda views
520 * Built-in agenda views::       What is available out of the box?
521 * Presentation and sorting::    How agenda items are prepared for display
522 * Agenda commands::             Remote editing of Org trees
523 * Custom agenda views::         Defining special searches and views
524 * Exporting Agenda Views::      Writing a view to a file
525 * Agenda column view::          Using column view for collected entries
527 The built-in agenda views
529 * Weekly/daily agenda::         The calendar page with current tasks
530 * Global TODO list::            All unfinished action items
531 * Matching tags and properties::  Structured information with fine-tuned search
532 * Timeline::                    Time-sorted view for single file
533 * Search view::                 Find entries by searching for text
534 * Stuck projects::              Find projects you need to review
536 Presentation and sorting
538 * Categories::                  Not all tasks are equal
539 * Time-of-day specifications::  How the agenda knows the time
540 * Sorting agenda items::        The order of things
541 * Filtering/limiting agenda items:: Dynamically narrow the agenda
543 Custom agenda views
545 * Storing searches::            Type once, use often
546 * Block agenda::                All the stuff you need in a single buffer
547 * Setting Options::             Changing the rules
549 Markup for rich export
551 * Structural markup elements::  The basic structure as seen by the exporter
552 * Images and tables::           Images, tables and caption mechanism
553 * Literal examples::            Source code examples with special formatting
554 * Include files::               Include additional files into a document
555 * Index entries::               Making an index
556 * Macro replacement::           Use macros to create templates
557 * Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
558 * Special blocks::              Containers targeted at export back-ends
560 Structural markup elements
562 * Document title::              Where the title is taken from
563 * Headings and sections::       The document structure as seen by the exporter
564 * Table of contents::           The if and where of the table of contents
565 * Lists::                       Lists
566 * Paragraphs::                  Paragraphs
567 * Footnote markup::             Footnotes
568 * Emphasis and monospace::      Bold, italic, etc.
569 * Horizontal rules::            Make a line
570 * Comment lines::               What will *not* be exported
572 Embedded @LaTeX{}
574 * Special symbols::             Greek letters and other symbols
575 * Subscripts and superscripts::  Simple syntax for raising/lowering text
576 * @LaTeX{} fragments::          Complex formulas made easy
577 * Previewing @LaTeX{} fragments::  What will this snippet look like?
578 * CDLaTeX mode::                Speed up entering of formulas
580 Exporting
582 * The Export Dispatcher::       The main exporter interface
583 * Export formats::              Available export formats
584 * Export settings::             Generic export settings
585 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
586 * Beamer export::               Turning the file into a presentation
587 * HTML export::                 Exporting to HTML
588 * @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
589 * Markdown export::             Exporting to Markdown
590 * OpenDocument Text export::    Exporting to OpenDocument Text
591 * iCalendar export::            Exporting to iCalendar
593 HTML export
595 * HTML Export commands::        How to invoke HTML export
596 * HTML preamble and postamble::  How to insert a preamble and a postamble
597 * Quoting HTML tags::           Using direct HTML in Org mode
598 * Links in HTML export::        How links will be interpreted and formatted
599 * Tables in HTML export::       How to modify the formatting of tables
600 * Images in HTML export::       How to insert figures into HTML output
601 * Math formatting in HTML export::  Beautiful math also on the web
602 * Text areas in HTML export::   An alternative way to show an example
603 * CSS support::                 Changing the appearance of the output
604 * JavaScript support::          Info and Folding in a web browser
606 @LaTeX{} and PDF export
608 * @LaTeX{}/PDF export commands::
609 * Header and sectioning::       Setting up the export file structure
610 * Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
611 * @LaTeX{} specific attributes::   Controlling @LaTeX{} output
613 OpenDocument Text export
615 * Pre-requisites for ODT export::  What packages ODT exporter relies on
616 * ODT export commands::         How to invoke ODT export
617 * Extending ODT export::        How to produce @samp{doc}, @samp{pdf} files
618 * Applying custom styles::      How to apply custom styles to the output
619 * Links in ODT export::         How links will be interpreted and formatted
620 * Tables in ODT export::        How Tables are exported
621 * Images in ODT export::        How to insert images
622 * Math formatting in ODT export::  How @LaTeX{} fragments are formatted
623 * Labels and captions in ODT export::  How captions are rendered
624 * Literal examples in ODT export::  How source and example blocks are formatted
625 * Advanced topics in ODT export::  Read this if you are a power user
627 Math formatting in ODT export
629 * Working with @LaTeX{} math snippets::  How to embed @LaTeX{} math fragments
630 * Working with MathML or OpenDocument formula files::  How to embed equations in native format
632 Advanced topics in ODT export
634 * Configuring a document converter::  How to register a document converter
635 * Working with OpenDocument style files::  Explore the internals
636 * Creating one-off styles::     How to produce custom highlighting etc
637 * Customizing tables in ODT export::  How to define and use Table templates
638 * Validating OpenDocument XML::  How to debug corrupt OpenDocument files
640 Publishing
642 * Configuration::               Defining projects
643 * Uploading files::             How to get files up on the server
644 * Sample configuration::        Example projects
645 * Triggering publication::      Publication commands
647 Configuration
649 * Project alist::               The central configuration variable
650 * Sources and destinations::    From here to there
651 * Selecting files::             What files are part of the project?
652 * Publishing action::           Setting the function doing the publishing
653 * Publishing options::          Tweaking HTML/@LaTeX{} export
654 * Publishing links::            Which links keep working after publishing?
655 * Sitemap::                     Generating a list of all pages
656 * Generating an index::         An index that reaches across pages
658 Sample configuration
660 * Simple example::              One-component publishing
661 * Complex example::             A multi-component publishing example
663 Working with source code
665 * Structure of code blocks::    Code block syntax described
666 * Editing source code::         Language major-mode editing
667 * Exporting code blocks::       Export contents and/or results
668 * Extracting source code::      Create pure source code files
669 * Evaluating code blocks::      Place results of evaluation in the Org mode buffer
670 * Library of Babel::            Use and contribute to a library of useful code blocks
671 * Languages::                   List of supported code block languages
672 * Header arguments::            Configure code block functionality
673 * Results of evaluation::       How evaluation results are handled
674 * Noweb reference syntax::      Literate programming in Org mode
675 * Key bindings and useful functions::  Work quickly with code blocks
676 * Batch execution::             Call functions from the command line
678 Header arguments
680 * Using header arguments::      Different ways to set header arguments
681 * Specific header arguments::   List of header arguments
683 Using header arguments
685 * System-wide header arguments::  Set global default values
686 * Language-specific header arguments::  Set default values by language
687 * Buffer-wide header arguments::  Set default values for a specific buffer
688 * Header arguments in Org mode properties::  Set default values for a buffer or heading
689 * Code block specific header arguments::  The most common way to set values
690 * Header arguments in function calls::  The most specific level
692 Specific header arguments
694 * var::                         Pass arguments to code blocks
695 * results::                     Specify the type of results and how they will
696                                 be collected and handled
697 * file::                        Specify a path for file output
698 * file-desc::                   Specify a description for file results
699 * dir::                         Specify the default (possibly remote)
700                                 directory for code block execution
701 * exports::                     Export code and/or results
702 * tangle::                      Toggle tangling and specify file name
703 * mkdirp::                      Toggle creation of parent directories of target
704                                 files during tangling
705 * comments::                    Toggle insertion of comments in tangled
706                                 code files
707 * padline::                     Control insertion of padding lines in tangled
708                                 code files
709 * no-expand::                   Turn off variable assignment and noweb
710                                 expansion during tangling
711 * session::                     Preserve the state of code evaluation
712 * noweb::                       Toggle expansion of noweb references
713 * noweb-ref::                   Specify block's noweb reference resolution target
714 * noweb-sep::                   String used to separate noweb references
715 * cache::                       Avoid re-evaluating unchanged code blocks
716 * sep::                         Delimiter for writing tabular results outside Org
717 * hlines::                      Handle horizontal lines in tables
718 * colnames::                    Handle column names in tables
719 * rownames::                    Handle row names in tables
720 * shebang::                     Make tangled files executable
721 * eval::                        Limit evaluation of specific code blocks
722 * wrap::                        Mark source block evaluation results
723 * post::                        Post processing of code block results
725 Miscellaneous
727 * Completion::                  M-TAB knows what you need
728 * Easy Templates::              Quick insertion of structural elements
729 * Speed keys::                  Electric commands at the beginning of a headline
730 * Code evaluation security::    Org mode files evaluate inline code
731 * Customization::               Adapting Org to your taste
732 * In-buffer settings::          Overview of the #+KEYWORDS
733 * The very busy C-c C-c key::   When in doubt, press C-c C-c
734 * Clean view::                  Getting rid of leading stars in the outline
735 * TTY keys::                    Using Org on a tty
736 * Interaction::                 Other Emacs packages
737 * org-crypt.el::                Encrypting Org files
739 Interaction with other packages
741 * Cooperation::                 Packages Org cooperates with
742 * Conflicts::                   Packages that lead to conflicts
744 Hacking
746 * Hooks::                       How to reach into Org's internals
747 * Add-on packages::             Available extensions
748 * Adding hyperlink types::      New custom link types
749 * Adding export back-ends::     How to write new export back-ends
750 * Context-sensitive commands::  How to add functionality to such commands
751 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
752 * Dynamic blocks::              Automatically filled blocks
753 * Special agenda views::        Customized views
754 * Speeding up your agendas::    Tips on how to speed up your agendas
755 * Extracting agenda information::  Post-processing of agenda information
756 * Using the property API::      Writing programs that use entry properties
757 * Using the mapping API::       Mapping over all or selected entries
759 Tables and lists in arbitrary syntax
761 * Radio tables::                Sending and receiving radio tables
762 * A @LaTeX{} example::          Step by step, almost a tutorial
763 * Translator functions::        Copy and modify
764 * Radio lists::                 Sending and receiving lists
766 MobileOrg
768 * Setting up the staging area::  Where to interact with the mobile device
769 * Pushing to MobileOrg::        Uploading Org files and agendas
770 * Pulling from MobileOrg::      Integrating captured and flagged items
772 @end detailmenu
773 @end menu
775 @node Introduction, Document Structure, Top, Top
776 @chapter Introduction
777 @cindex introduction
779 @menu
780 * Summary::                     Brief summary of what Org does
781 * Installation::                Installing Org
782 * Activation::                  How to activate Org for certain buffers
783 * Feedback::                    Bug reports, ideas, patches etc.
784 * Conventions::                 Typesetting conventions in the manual
785 @end menu
787 @node Summary, Installation, Introduction, Introduction
788 @section Summary
789 @cindex summary
791 Org is a mode for keeping notes, maintaining TODO lists, and doing
792 project planning with a fast and effective plain-text system.
794 Org develops organizational tasks around NOTES files that contain
795 lists or information about projects as plain text.  Org is
796 implemented on top of Outline mode, which makes it possible to keep the
797 content of large files well structured.  Visibility cycling and
798 structure editing help to work with the tree.  Tables are easily created
799 with a built-in table editor.  Org supports TODO items, deadlines,
800 timestamps, and scheduling.  It dynamically compiles entries into an
801 agenda that utilizes and smoothly integrates much of the Emacs calendar
802 and diary.  Plain text URL-like links connect to websites, emails,
803 Usenet messages, BBDB entries, and any files related to the projects.
804 For printing and sharing notes, an Org file can be exported as a
805 structured ASCII file, as HTML, or (TODO and agenda items only) as an
806 iCalendar file.  It can also serve as a publishing tool for a set of
807 linked web pages.
809 As a project planning environment, Org works by adding metadata to outline
810 nodes.  Based on this data, specific entries can be extracted in queries and
811 create dynamic @i{agenda views}.
813 Org mode contains the Org Babel environment which allows you to work with
814 embedded source code blocks in a file, to facilitate code evaluation,
815 documentation, and literate programming techniques.
817 Org's automatic, context-sensitive table editor with spreadsheet
818 capabilities can be integrated into any major mode by activating the
819 minor Orgtbl mode.  Using a translation step, it can be used to maintain
820 tables in arbitrary file types, for example in @LaTeX{}.  The structure
821 editing and list creation capabilities can be used outside Org with
822 the minor Orgstruct mode.
824 Org keeps simple things simple.  When first fired up, it should
825 feel like a straightforward, easy to use outliner.  Complexity is not
826 imposed, but a large amount of functionality is available when you need
827 it.  Org is a toolbox and can be used in different ways and for different
828 ends, for example:
830 @example
831 @r{@bullet{} an outline extension with visibility cycling and structure editing}
832 @r{@bullet{} an ASCII system and table editor for taking structured notes}
833 @r{@bullet{} a TODO list editor}
834 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
835 @pindex GTD, Getting Things Done
836 @r{@bullet{} an environment in which to implement David Allen's GTD system}
837 @r{@bullet{} a simple hypertext system, with HTML and @LaTeX{} export}
838 @r{@bullet{} a publishing tool to create a set of interlinked web pages}
839 @r{@bullet{} an environment for literate programming}
840 @end example
842 @cindex FAQ
843 There is a website for Org which provides links to the newest
844 version of Org, as well as additional information, frequently asked
845 questions (FAQ), links to tutorials, etc.  This page is located at
846 @uref{http://orgmode.org}.
848 @cindex print edition
849 The version 7.3 of this manual is available as a
850 @uref{http://www.network-theory.co.uk/org/manual/, paperback book from Network
851 Theory Ltd.}
853 @page
856 @node Installation, Activation, Summary, Introduction
857 @section Installation
858 @cindex installation
859 @cindex XEmacs
861 Org is part of recent distributions of GNU Emacs, so you normally don't need
862 to install it.  If, for one reason or another, you want to install Org on top
863 of this pre-packaged version, there are three ways to do it:
865 @itemize @bullet
866 @item By using Emacs package system.
867 @item By downloading Org as an archive.
868 @item By using Org's git repository.
869 @end itemize
871 We @b{strongly recommend} to stick to a single installation method.
873 @subsubheading Using Emacs packaging system
875 Recent Emacs distributions include a packaging system which lets you install
876 Elisp libraries.  You can install Org with @kbd{M-x package-install RET org}.
877 You need to do this in a session where no @code{.org} file has been visited.
878 Then, to make sure your Org configuration is taken into account, initialize
879 the package system with @code{(package-initialize)} in your @file{.emacs}
880 before setting any Org option.  If you want to use Org's package repository,
881 check out the @uref{http://orgmode.org/elpa.html, Org ELPA page}.
883 @subsubheading Downloading Org as an archive
885 You can download Org latest release from @uref{http://orgmode.org/, Org's
886 website}.  In this case, make sure you set the load-path correctly in your
887 @file{.emacs}:
889 @lisp
890 (add-to-list 'load-path "~/path/to/orgdir/lisp")
891 @end lisp
893 The downloaded archive contains contributed libraries that are not included
894 in Emacs.  If you want to use them, add the @file{contrib} directory to your
895 load-path:
897 @lisp
898 (add-to-list 'load-path "~/path/to/orgdir/contrib/lisp" t)
899 @end lisp
901 Optionally, you can compile the files and/or install them in your system.
902 Run @code{make help} to list compilation and installation options.
904 @subsubheading Using Org's git repository
906 You can clone Org's repository and install Org like this:
908 @example
909 $ cd ~/src/
910 $ git clone git://orgmode.org/org-mode.git
911 $ make autoloads
912 @end example
914 Note that in this case, @code{make autoloads} is mandatory: it defines Org's
915 version in @file{org-version.el} and Org's autoloads in
916 @file{org-loaddefs.el}.
918 Remember to add the correct load-path as described in the method above.
920 You can also compile with @code{make}, generate the documentation with
921 @code{make doc}, create a local configuration with @code{make config} and
922 install Org with @code{make install}.  Please run @code{make help} to get
923 the list of compilation/installation options.
925 For more detailed explanations on Org's build system, please check the Org
926 Build System page on @uref{http://orgmode.org/worg/dev/org-build-system.html,
927 Worg}.
929 @node Activation, Feedback, Installation, Introduction
930 @section Activation
931 @cindex activation
932 @cindex autoload
933 @cindex ELPA
934 @cindex global key bindings
935 @cindex key bindings, global
936 @findex org-agenda
937 @findex org-capture
938 @findex org-store-link
939 @findex org-iswitchb
941 Since Emacs 22.2, files with the @file{.org} extension use Org mode by
942 default.  If you are using an earlier version of Emacs, add this line to your
943 @file{.emacs} file:
945 @lisp
946 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
947 @end lisp
949 Org mode buffers need font-lock to be turned on: this is the default in
950 Emacs@footnote{If you don't use font-lock globally, turn it on in Org buffer
951 with @code{(add-hook 'org-mode-hook 'turn-on-font-lock)}}.
953 There are compatibility issues between Org mode and some other Elisp
954 packages, please take the time to check the list (@pxref{Conflicts}).
956 The four Org commands @command{org-store-link}, @command{org-capture},
957 @command{org-agenda}, and @command{org-iswitchb} should be accessible through
958 global keys (i.e., anywhere in Emacs, not just in Org buffers).  Here are
959 suggested bindings for these keys, please modify the keys to your own
960 liking.
961 @lisp
962 (global-set-key "\C-cl" 'org-store-link)
963 (global-set-key "\C-cc" 'org-capture)
964 (global-set-key "\C-ca" 'org-agenda)
965 (global-set-key "\C-cb" 'org-iswitchb)
966 @end lisp
968 @cindex Org mode, turning on
969 With this setup, all files with extension @samp{.org} will be put
970 into Org mode.  As an alternative, make the first line of a file look
971 like this:
973 @example
974 MY PROJECTS    -*- mode: org; -*-
975 @end example
977 @vindex org-insert-mode-line-in-empty-file
978 @noindent which will select Org mode for this buffer no matter what
979 the file's name is.  See also the variable
980 @code{org-insert-mode-line-in-empty-file}.
982 Many commands in Org work on the region if the region is @i{active}.  To make
983 use of this, you need to have @code{transient-mark-mode}
984 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
985 in Emacs 22 you need to do this yourself with
986 @lisp
987 (transient-mark-mode 1)
988 @end lisp
989 @noindent If you do not like @code{transient-mark-mode}, you can create an
990 active region by using the mouse to select a region, or pressing
991 @kbd{C-@key{SPC}} twice before moving the cursor.
993 @node Feedback, Conventions, Activation, Introduction
994 @section Feedback
995 @cindex feedback
996 @cindex bug reports
997 @cindex maintainer
998 @cindex author
1000 If you find problems with Org, or if you have questions, remarks, or ideas
1001 about it, please mail to the Org mailing list @email{emacs-orgmode@@gnu.org}.
1002 If you are not a member of the mailing list, your mail will be passed to the
1003 list after a moderator has approved it@footnote{Please consider subscribing
1004 to the mailing list, in order to minimize the work the mailing list
1005 moderators have to do.}.
1007 For bug reports, please first try to reproduce the bug with the latest
1008 version of Org available---if you are running an outdated version, it is
1009 quite possible that the bug has been fixed already.  If the bug persists,
1010 prepare a report and provide as much information as possible, including the
1011 version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
1012 (@kbd{M-x org-version RET}), as well as the Org related setup in
1013 @file{.emacs}.  The easiest way to do this is to use the command
1014 @example
1015 @kbd{M-x org-submit-bug-report RET}
1016 @end example
1017 @noindent which will put all this information into an Emacs mail buffer so
1018 that you only need to add your description.  If you re not sending the Email
1019 from within Emacs, please copy and paste the content into your Email program.
1021 Sometimes you might face a problem due to an error in your Emacs or Org mode
1022 setup.  Before reporting a bug, it is very helpful to start Emacs with minimal
1023 customizations and reproduce the problem.  Doing so often helps you determine
1024 if the problem is with your customization or with Org mode itself.  You can
1025 start a typical minimal session with a command like the example below.
1027 @example
1028 $ emacs -Q -l /path/to/minimal-org.el
1029 @end example
1031 However if you are using Org mode as distributed with Emacs, a minimal setup
1032 is not necessary.  In that case it is sufficient to start Emacs as
1033 @code{emacs -Q}.  The @code{minimal-org.el} setup file can have contents as
1034 shown below.
1036 @lisp
1037 ;;; Minimal setup to load latest `org-mode'
1039 ;; activate debugging
1040 (setq debug-on-error t
1041       debug-on-signal nil
1042       debug-on-quit nil)
1044 ;; add latest org-mode to load path
1045 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
1046 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
1047 @end lisp
1049 If an error occurs, a backtrace can be very useful (see below on how to
1050 create one).  Often a small example file helps, along with clear information
1051 about:
1053 @enumerate
1054 @item What exactly did you do?
1055 @item What did you expect to happen?
1056 @item What happened instead?
1057 @end enumerate
1058 @noindent Thank you for helping to improve this program.
1060 @subsubheading How to create a useful backtrace
1062 @cindex backtrace of an error
1063 If working with Org produces an error with a message you don't
1064 understand, you may have hit a bug.  The best way to report this is by
1065 providing, in addition to what was mentioned above, a @emph{backtrace}.
1066 This is information from the built-in debugger about where and how the
1067 error occurred.  Here is how to produce a useful backtrace:
1069 @enumerate
1070 @item
1071 Reload uncompiled versions of all Org mode Lisp files.  The backtrace
1072 contains much more information if it is produced with uncompiled code.
1073 To do this, use
1074 @example
1075 @kbd{C-u M-x org-reload RET}
1076 @end example
1077 @noindent
1078 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
1079 menu.
1080 @item
1081 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
1082 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
1083 @item
1084 Do whatever you have to do to hit the error.  Don't forget to
1085 document the steps you take.
1086 @item
1087 When you hit the error, a @file{*Backtrace*} buffer will appear on the
1088 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
1089 attach it to your bug report.
1090 @end enumerate
1092 @node Conventions,  , Feedback, Introduction
1093 @section Typesetting conventions used in this manual
1095 @subsubheading TODO keywords, tags, properties, etc.
1097 Org mainly uses three types of keywords: TODO keywords, tags and property
1098 names.  In this manual we use the following conventions:
1100 @table @code
1101 @item TODO
1102 @itemx WAITING
1103 TODO keywords are written with all capitals, even if they are
1104 user-defined.
1105 @item boss
1106 @itemx ARCHIVE
1107 User-defined tags are written in lowercase; built-in tags with special
1108 meaning are written with all capitals.
1109 @item Release
1110 @itemx PRIORITY
1111 User-defined properties are capitalized; built-in properties with
1112 special meaning are written with all capitals.
1113 @end table
1115 Moreover, Org uses @i{option keywords} (like @code{#+TITLE} to set the title)
1116 and @i{environment keywords} (like @code{#+BEGIN_HTML} to start a @code{HTML}
1117 environment).  They are written in uppercase in the manual to enhance its
1118 readability, but you can use lowercase in your Org files@footnote{Easy
1119 templates insert lowercase keywords and Babel dynamically inserts
1120 @code{#+results}.}
1122 @subsubheading Keybindings and commands
1123 @kindex C-c a
1124 @findex org-agenda
1125 @kindex C-c c
1126 @findex org-capture
1128 The manual suggests two global keybindings: @kbd{C-c a} for @code{org-agenda}
1129 and @kbd{C-c c} for @code{org-capture}.  These are only suggestions, but the
1130 rest of the manual assumes that you are using these keybindings.
1132 Also, the manual lists both the keys and the corresponding commands for
1133 accessing a functionality.  Org mode often uses the same key for different
1134 functions, depending on context.  The command that is bound to such keys has
1135 a generic name, like @code{org-metaright}.  In the manual we will, wherever
1136 possible, give the function that is internally called by the generic command.
1137 For example, in the chapter on document structure, @kbd{M-@key{right}} will
1138 be listed to call @code{org-do-demote}, while in the chapter on tables, it
1139 will be listed to call @code{org-table-move-column-right}.  If you prefer,
1140 you can compile the manual without the command names by unsetting the flag
1141 @code{cmdnames} in @file{org.texi}.
1143 @node Document Structure, Tables, Introduction, Top
1144 @chapter Document structure
1145 @cindex document structure
1146 @cindex structure of document
1148 Org is based on Outline mode and provides flexible commands to
1149 edit the structure of the document.
1151 @menu
1152 * Outlines::                    Org is based on Outline mode
1153 * Headlines::                   How to typeset Org tree headlines
1154 * Visibility cycling::          Show and hide, much simplified
1155 * Motion::                      Jumping to other headlines
1156 * Structure editing::           Changing sequence and level of headlines
1157 * Sparse trees::                Matches embedded in context
1158 * Plain lists::                 Additional structure within an entry
1159 * Drawers::                     Tucking stuff away
1160 * Blocks::                      Folding blocks
1161 * Footnotes::                   How footnotes are defined in Org's syntax
1162 * Orgstruct mode::              Structure editing outside Org
1163 * Org syntax::                  Formal description of Org's syntax
1164 @end menu
1166 @node Outlines, Headlines, Document Structure, Document Structure
1167 @section Outlines
1168 @cindex outlines
1169 @cindex Outline mode
1171 Org is implemented on top of Outline mode.  Outlines allow a
1172 document to be organized in a hierarchical structure, which (at least
1173 for me) is the best representation of notes and thoughts.  An overview
1174 of this structure is achieved by folding (hiding) large parts of the
1175 document to show only the general document structure and the parts
1176 currently being worked on.  Org greatly simplifies the use of
1177 outlines by compressing the entire show/hide functionality into a single
1178 command, @command{org-cycle}, which is bound to the @key{TAB} key.
1180 @node Headlines, Visibility cycling, Outlines, Document Structure
1181 @section Headlines
1182 @cindex headlines
1183 @cindex outline tree
1184 @vindex org-special-ctrl-a/e
1185 @vindex org-special-ctrl-k
1186 @vindex org-ctrl-k-protect-subtree
1188 Headlines define the structure of an outline tree.  The headlines in Org
1189 start with one or more stars, on the left margin@footnote{See the variables
1190 @code{org-special-ctrl-a/e}, @code{org-special-ctrl-k}, and
1191 @code{org-ctrl-k-protect-subtree} to configure special behavior of @kbd{C-a},
1192 @kbd{C-e}, and @kbd{C-k} in headlines.} @footnote{Clocking only works with
1193 headings indented less then 30 stars.}.  For example:
1195 @example
1196 * Top level headline
1197 ** Second level
1198 *** 3rd level
1199     some text
1200 *** 3rd level
1201     more text
1203 * Another top level headline
1204 @end example
1206 @noindent Some people find the many stars too noisy and would prefer an
1207 outline that has whitespace followed by a single star as headline
1208 starters.  @ref{Clean view}, describes a setup to realize this.
1210 @vindex org-cycle-separator-lines
1211 An empty line after the end of a subtree is considered part of it and
1212 will be hidden when the subtree is folded.  However, if you leave at
1213 least two empty lines, one empty line will remain visible after folding
1214 the subtree, in order to structure the collapsed view.  See the
1215 variable @code{org-cycle-separator-lines} to modify this behavior.
1217 @node Visibility cycling, Motion, Headlines, Document Structure
1218 @section Visibility cycling
1219 @cindex cycling, visibility
1220 @cindex visibility cycling
1221 @cindex trees, visibility
1222 @cindex show hidden text
1223 @cindex hide text
1225 @menu
1226 * Global and local cycling::    Cycling through various visibility states
1227 * Initial visibility::          Setting the initial visibility state
1228 * Catching invisible edits::    Preventing mistakes when editing invisible parts
1229 @end menu
1231 @node Global and local cycling, Initial visibility, Visibility cycling, Visibility cycling
1232 @subsection Global and local cycling
1234 Outlines make it possible to hide parts of the text in the buffer.
1235 Org uses just two commands, bound to @key{TAB} and
1236 @kbd{S-@key{TAB}} to change the visibility in the buffer.
1238 @cindex subtree visibility states
1239 @cindex subtree cycling
1240 @cindex folded, subtree visibility state
1241 @cindex children, subtree visibility state
1242 @cindex subtree, subtree visibility state
1243 @table @asis
1244 @orgcmd{@key{TAB},org-cycle}
1245 @emph{Subtree cycling}: Rotate current subtree among the states
1247 @example
1248 ,-> FOLDED -> CHILDREN -> SUBTREE --.
1249 '-----------------------------------'
1250 @end example
1252 @vindex org-cycle-emulate-tab
1253 @vindex org-cycle-global-at-bob
1254 The cursor must be on a headline for this to work@footnote{see, however,
1255 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
1256 beginning of the buffer and the first line is not a headline, then
1257 @key{TAB} actually runs global cycling (see below)@footnote{see the
1258 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
1259 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
1261 @cindex global visibility states
1262 @cindex global cycling
1263 @cindex overview, global visibility state
1264 @cindex contents, global visibility state
1265 @cindex show all, global visibility state
1266 @orgcmd{S-@key{TAB},org-global-cycle}
1267 @itemx C-u @key{TAB}
1268 @emph{Global cycling}: Rotate the entire buffer among the states
1270 @example
1271 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
1272 '--------------------------------------'
1273 @end example
1275 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
1276 CONTENTS view up to headlines of level N will be shown.  Note that inside
1277 tables, @kbd{S-@key{TAB}} jumps to the previous field.
1279 @cindex show all, command
1280 @orgcmd{C-u C-u C-u @key{TAB},show-all}
1281 Show all, including drawers.
1282 @cindex revealing context
1283 @orgcmd{C-c C-r,org-reveal}
1284 Reveal context around point, showing the current entry, the following heading
1285 and the hierarchy above.  Useful for working near a location that has been
1286 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
1287 (@pxref{Agenda commands}).  With a prefix argument show, on each
1288 level, all sibling headings.  With a double prefix argument, also show the
1289 entire subtree of the parent.
1290 @cindex show branches, command
1291 @orgcmd{C-c C-k,show-branches}
1292 Expose all the headings of the subtree, CONTENT view for just one subtree.
1293 @cindex show children, command
1294 @orgcmd{C-c @key{TAB},show-children}
1295 Expose all direct children of the subtree.  With a numeric prefix argument N,
1296 expose all children down to level N@.
1297 @orgcmd{C-c C-x b,org-tree-to-indirect-buffer}
1298 Show the current subtree in an indirect buffer@footnote{The indirect
1299 buffer
1300 @ifinfo
1301 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
1302 @end ifinfo
1303 @ifnotinfo
1304 (see the Emacs manual for more information about indirect buffers)
1305 @end ifnotinfo
1306 will contain the entire buffer, but will be narrowed to the current
1307 tree.  Editing the indirect buffer will also change the original buffer,
1308 but without affecting visibility in that buffer.}.  With a numeric
1309 prefix argument N, go up to level N and then take that tree.  If N is
1310 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
1311 the previously used indirect buffer.
1312 @orgcmd{C-c C-x v,org-copy-visible}
1313 Copy the @i{visible} text in the region into the kill ring.
1314 @end table
1316 @menu
1317 * Initial visibility::          Setting the initial visibility state
1318 * Catching invisible edits::    Preventing mistakes when editing invisible parts
1319 @end menu
1321 @node Initial visibility, Catching invisible edits, Global and local cycling, Visibility cycling
1322 @subsection Initial visibility
1324 @cindex visibility, initialize
1325 @vindex org-startup-folded
1326 @vindex org-agenda-inhibit-startup
1327 @cindex @code{overview}, STARTUP keyword
1328 @cindex @code{content}, STARTUP keyword
1329 @cindex @code{showall}, STARTUP keyword
1330 @cindex @code{showeverything}, STARTUP keyword
1332 When Emacs first visits an Org file, the global state is set to OVERVIEW,
1333 i.e., only the top level headlines are visible@footnote{When
1334 @code{org-agenda-inhibit-startup} is non-nil, Org will not honor the default
1335 visibility state when first opening a file for the agenda (@pxref{Speeding up
1336 your agendas}).}  This can be configured through the variable
1337 @code{org-startup-folded}, or on a per-file basis by adding one of the
1338 following lines anywhere in the buffer:
1340 @example
1341 #+STARTUP: overview
1342 #+STARTUP: content
1343 #+STARTUP: showall
1344 #+STARTUP: showeverything
1345 @end example
1347 The startup visibility options are ignored when the file is open for the
1348 first time during the agenda generation: if you want the agenda to honor
1349 the startup visibility, set @code{org-agenda-inhibit-startup} to nil.
1351 @cindex property, VISIBILITY
1352 @noindent
1353 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
1354 and Columns}) will get their visibility adapted accordingly.  Allowed values
1355 for this property are @code{folded}, @code{children}, @code{content}, and
1356 @code{all}.
1358 @table @asis
1359 @orgcmd{C-u C-u @key{TAB},org-set-startup-visibility}
1360 Switch back to the startup visibility of the buffer, i.e., whatever is
1361 requested by startup options and @samp{VISIBILITY} properties in individual
1362 entries.
1363 @end table
1365 @node Catching invisible edits,  , Initial visibility, Visibility cycling
1366 @subsection Catching invisible edits
1368 @vindex org-catch-invisible-edits
1369 @cindex edits, catching invisible
1370 Sometimes you may inadvertently edit an invisible part of the buffer and be
1371 confused on what as been edited and how to undo the mistake.  Setting
1372 @code{org-catch-invisible-edits} to non-nil will help prevent this.  See the
1373 docstring of this option on how Org should catch invisible edits and process
1374 them.
1376 @node Motion, Structure editing, Visibility cycling, Document Structure
1377 @section Motion
1378 @cindex motion, between headlines
1379 @cindex jumping, to headlines
1380 @cindex headline navigation
1381 The following commands jump to other headlines in the buffer.
1383 @table @asis
1384 @orgcmd{C-c C-n,outline-next-visible-heading}
1385 Next heading.
1386 @orgcmd{C-c C-p,outline-previous-visible-heading}
1387 Previous heading.
1388 @orgcmd{C-c C-f,org-forward-same-level}
1389 Next heading same level.
1390 @orgcmd{C-c C-b,org-backward-same-level}
1391 Previous heading same level.
1392 @orgcmd{C-c C-u,outline-up-heading}
1393 Backward to higher level heading.
1394 @orgcmd{C-c C-j,org-goto}
1395 Jump to a different place without changing the current outline
1396 visibility.  Shows the document structure in a temporary buffer, where
1397 you can use the following keys to find your destination:
1398 @vindex org-goto-auto-isearch
1399 @example
1400 @key{TAB}         @r{Cycle visibility.}
1401 @key{down} / @key{up}   @r{Next/previous visible headline.}
1402 @key{RET}         @r{Select this location.}
1403 @kbd{/}           @r{Do a Sparse-tree search}
1404 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
1405 n / p        @r{Next/previous visible headline.}
1406 f / b        @r{Next/previous headline same level.}
1407 u            @r{One level up.}
1408 0-9          @r{Digit argument.}
1409 q            @r{Quit}
1410 @end example
1411 @vindex org-goto-interface
1412 @noindent
1413 See also the variable @code{org-goto-interface}.
1414 @end table
1416 @node Structure editing, Sparse trees, Motion, Document Structure
1417 @section Structure editing
1418 @cindex structure editing
1419 @cindex headline, promotion and demotion
1420 @cindex promotion, of subtrees
1421 @cindex demotion, of subtrees
1422 @cindex subtree, cut and paste
1423 @cindex pasting, of subtrees
1424 @cindex cutting, of subtrees
1425 @cindex copying, of subtrees
1426 @cindex sorting, of subtrees
1427 @cindex subtrees, cut and paste
1429 @table @asis
1430 @orgcmd{M-@key{RET},org-insert-heading}
1431 @vindex org-M-RET-may-split-line
1432 Insert a new heading/item with the same level than the one at point.
1433 If the cursor is in a plain list item, a new item is created
1434 (@pxref{Plain lists}).  To prevent this behavior in lists, call the
1435 command with a prefix argument.  When this command is used in the
1436 middle of a line, the line is split and the rest of the line becomes
1437 the new item or headline@footnote{If you do not want the line to be
1438 split, customize the variable @code{org-M-RET-may-split-line}.}.  If
1439 the command is used at the @emph{beginning} of a headline, the new
1440 headline is created before the current line.  If the command is used
1441 at the @emph{end} of a folded subtree (i.e., behind the ellipses at
1442 the end of a headline), then a headline like the current one will be
1443 inserted after the end of the subtree.  Calling this command with
1444 @kbd{C-u C-u} will unconditionally respect the headline's content and
1445 create a new item at the end of the parent subtree.
1446 @orgcmd{C-@key{RET},org-insert-heading-respect-content}
1447 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
1448 current heading, the new heading is placed after the body instead of before
1449 it.  This command works from anywhere in the entry.
1450 @orgcmd{M-S-@key{RET},org-insert-todo-heading}
1451 @vindex org-treat-insert-todo-heading-as-state-change
1452 Insert new TODO entry with same level as current heading.  See also the
1453 variable @code{org-treat-insert-todo-heading-as-state-change}.
1454 @orgcmd{C-S-@key{RET},org-insert-todo-heading-respect-content}
1455 Insert new TODO entry with same level as current heading.  Like
1456 @kbd{C-@key{RET}}, the new headline will be inserted after the current
1457 subtree.
1458 @orgcmd{@key{TAB},org-cycle}
1459 In a new entry with no text yet, the first @key{TAB} demotes the entry to
1460 become a child of the previous one.  The next @key{TAB} makes it a parent,
1461 and so on, all the way to top level.  Yet another @key{TAB}, and you are back
1462 to the initial level.
1463 @orgcmd{M-@key{left},org-do-promote}
1464 Promote current heading by one level.
1465 @orgcmd{M-@key{right},org-do-demote}
1466 Demote current heading by one level.
1467 @orgcmd{M-S-@key{left},org-promote-subtree}
1468 Promote the current subtree by one level.
1469 @orgcmd{M-S-@key{right},org-demote-subtree}
1470 Demote the current subtree by one level.
1471 @orgcmd{M-S-@key{up},org-move-subtree-up}
1472 Move subtree up (swap with previous subtree of same
1473 level).
1474 @orgcmd{M-S-@key{down},org-move-subtree-down}
1475 Move subtree down (swap with next subtree of same level).
1476 @orgcmd{M-h,org-mark-element}
1477 Mark the element at point.  Hitting repeatedly will mark subsequent elements
1478 of the one just marked.  E.g., hitting @key{M-h} on a paragraph will mark it,
1479 hitting @key{M-h} immediately again will mark the next one.
1480 @orgcmd{C-c @@,org-mark-subtree}
1481 Mark the subtree at point.  Hitting repeatedly will mark subsequent subtrees
1482 of the same level than the marked subtree.
1483 @orgcmd{C-c C-x C-w,org-cut-subtree}
1484 Kill subtree, i.e., remove it from buffer but save in kill ring.
1485 With a numeric prefix argument N, kill N sequential subtrees.
1486 @orgcmd{C-c C-x M-w,org-copy-subtree}
1487 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
1488 sequential subtrees.
1489 @orgcmd{C-c C-x C-y,org-paste-subtree}
1490 Yank subtree from kill ring.  This does modify the level of the subtree to
1491 make sure the tree fits in nicely at the yank position.  The yank level can
1492 also be specified with a numeric prefix argument, or by yanking after a
1493 headline marker like @samp{****}.
1494 @orgcmd{C-y,org-yank}
1495 @vindex org-yank-adjusted-subtrees
1496 @vindex org-yank-folded-subtrees
1497 Depending on the variables @code{org-yank-adjusted-subtrees} and
1498 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
1499 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
1500 C-x C-y}.  With the default settings, no level adjustment will take place,
1501 but the yanked tree will be folded unless doing so would swallow text
1502 previously visible.  Any prefix argument to this command will force a normal
1503 @code{yank} to be executed, with the prefix passed along.  A good way to
1504 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
1505 yank, it will yank previous kill items plainly, without adjustment and
1506 folding.
1507 @orgcmd{C-c C-x c,org-clone-subtree-with-time-shift}
1508 Clone a subtree by making a number of sibling copies of it.  You will be
1509 prompted for the number of copies to make, and you can also specify if any
1510 timestamps in the entry should be shifted.  This can be useful, for example,
1511 to create a number of tasks related to a series of lectures to prepare.  For
1512 more details, see the docstring of the command
1513 @code{org-clone-subtree-with-time-shift}.
1514 @orgcmd{C-c C-w,org-refile}
1515 Refile entry or region to a different location.  @xref{Refile and copy}.
1516 @orgcmd{C-c ^,org-sort}
1517 Sort same-level entries.  When there is an active region, all entries in the
1518 region will be sorted.  Otherwise the children of the current headline are
1519 sorted.  The command prompts for the sorting method, which can be
1520 alphabetically, numerically, by time (first timestamp with active preferred,
1521 creation time, scheduled time, deadline time), by priority, by TODO keyword
1522 (in the sequence the keywords have been defined in the setup) or by the value
1523 of a property.  Reverse sorting is possible as well.  You can also supply
1524 your own function to extract the sorting key.  With a @kbd{C-u} prefix,
1525 sorting will be case-sensitive.
1526 @orgcmd{C-x n s,org-narrow-to-subtree}
1527 Narrow buffer to current subtree.
1528 @orgcmd{C-x n b,org-narrow-to-block}
1529 Narrow buffer to current block.
1530 @orgcmd{C-x n w,widen}
1531 Widen buffer to remove narrowing.
1532 @orgcmd{C-c *,org-toggle-heading}
1533 Turn a normal line or plain list item into a headline (so that it becomes a
1534 subheading at its location).  Also turn a headline into a normal line by
1535 removing the stars.  If there is an active region, turn all lines in the
1536 region into headlines.  If the first line in the region was an item, turn
1537 only the item lines into headlines.  Finally, if the first line is a
1538 headline, remove the stars from all headlines in the region.
1539 @end table
1541 @cindex region, active
1542 @cindex active region
1543 @cindex transient mark mode
1544 When there is an active region (Transient Mark mode), promotion and
1545 demotion work on all headlines in the region.  To select a region of
1546 headlines, it is best to place both point and mark at the beginning of a
1547 line, mark at the beginning of the first headline, and point at the line
1548 just after the last headline to change.  Note that when the cursor is
1549 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1550 functionality.
1553 @node Sparse trees, Plain lists, Structure editing, Document Structure
1554 @section Sparse trees
1555 @cindex sparse trees
1556 @cindex trees, sparse
1557 @cindex folding, sparse trees
1558 @cindex occur, command
1560 @vindex org-show-hierarchy-above
1561 @vindex org-show-following-heading
1562 @vindex org-show-siblings
1563 @vindex org-show-entry-below
1564 An important feature of Org mode is the ability to construct @emph{sparse
1565 trees} for selected information in an outline tree, so that the entire
1566 document is folded as much as possible, but the selected information is made
1567 visible along with the headline structure above it@footnote{See also the
1568 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1569 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1570 control on how much context is shown around each match.}.  Just try it out
1571 and you will see immediately how it works.
1573 Org mode contains several commands creating such trees, all these
1574 commands can be accessed through a dispatcher:
1576 @table @asis
1577 @orgcmd{C-c /,org-sparse-tree}
1578 This prompts for an extra key to select a sparse-tree creating command.
1579 @orgcmd{C-c / r,org-occur}
1580 @vindex org-remove-highlights-with-change
1581 Prompts for a regexp and shows a sparse tree with all matches.  If
1582 the match is in a headline, the headline is made visible.  If the match is in
1583 the body of an entry, headline and body are made visible.  In order to
1584 provide minimal context, also the full hierarchy of headlines above the match
1585 is shown, as well as the headline following the match.  Each match is also
1586 highlighted; the highlights disappear when the buffer is changed by an
1587 editing command@footnote{This depends on the option
1588 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1589 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1590 so several calls to this command can be stacked.
1591 @orgcmdkkc{M-g n,M-g M-n,next-error}
1592 Jump to the next sparse tree match in this buffer.
1593 @orgcmdkkc{M-g p,M-g M-p,previous-error}
1594 Jump to the previous sparse tree match in this buffer.
1595 @end table
1598 @noindent
1599 @vindex org-agenda-custom-commands
1600 For frequently used sparse trees of specific search strings, you can
1601 use the variable @code{org-agenda-custom-commands} to define fast
1602 keyboard access to specific sparse trees.  These commands will then be
1603 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1604 For example:
1606 @lisp
1607 (setq org-agenda-custom-commands
1608       '(("f" occur-tree "FIXME")))
1609 @end lisp
1611 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1612 a sparse tree matching the string @samp{FIXME}.
1614 The other sparse tree commands select headings based on TODO keywords,
1615 tags, or properties and will be discussed later in this manual.
1617 @kindex C-c C-e C-v
1618 @cindex printing sparse trees
1619 @cindex visible text, printing
1620 To print a sparse tree, you can use the Emacs command
1621 @code{ps-print-buffer-with-faces} which does not print invisible parts
1622 of the document @footnote{This does not work under XEmacs, because
1623 XEmacs uses selective display for outlining, not text properties.}.
1624 Or you can use @kbd{C-c C-e C-v} to export only the visible part of
1625 the document and print the resulting file.
1627 @node Plain lists, Drawers, Sparse trees, Document Structure
1628 @section Plain lists
1629 @cindex plain lists
1630 @cindex lists, plain
1631 @cindex lists, ordered
1632 @cindex ordered lists
1634 Within an entry of the outline tree, hand-formatted lists can provide
1635 additional structure.  They also provide a way to create lists of checkboxes
1636 (@pxref{Checkboxes}).  Org supports editing such lists, and every exporter
1637 (@pxref{Exporting}) can parse and format them.
1639 Org knows ordered lists, unordered lists, and description lists.
1640 @itemize @bullet
1641 @item
1642 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1643 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1644 they will be seen as top-level headlines.  Also, when you are hiding leading
1645 stars to get a clean outline view, plain list items starting with a star may
1646 be hard to distinguish from true headlines.  In short: even though @samp{*}
1647 is supported, it may be better to not use it for plain list items.}  as
1648 bullets.
1649 @item
1650 @vindex org-plain-list-ordered-item-terminator
1651 @vindex org-list-allow-alphabetical
1652 @emph{Ordered} list items start with a numeral followed by either a period or
1653 a right parenthesis@footnote{You can filter out any of them by configuring
1654 @code{org-plain-list-ordered-item-terminator}.}, such as @samp{1.} or
1655 @samp{1)}@footnote{You can also get @samp{a.}, @samp{A.}, @samp{a)} and
1656 @samp{A)} by configuring @code{org-list-allow-alphabetical}.  To minimize
1657 confusion with normal text, those are limited to one character only.  Beyond
1658 that limit, bullets will automatically fallback to numbers.}.  If you want a
1659 list to start with a different value (e.g., 20), start the text of the item
1660 with @code{[@@20]}@footnote{If there's a checkbox in the item, the cookie
1661 must be put @emph{before} the checkbox.  If you have activated alphabetical
1662 lists, you can also use counters like @code{[@@b]}.}.  Those constructs can
1663 be used in any item of the list in order to enforce a particular numbering.
1664 @item
1665 @emph{Description} list items are unordered list items, and contain the
1666 separator @samp{ :: } to distinguish the description @emph{term} from the
1667 description.
1668 @end itemize
1670 Items belonging to the same list must have the same indentation on the first
1671 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1672 2--digit numbers must be written left-aligned with the other numbers in the
1673 list.  An item ends before the next line that is less or equally indented
1674 than its bullet/number.
1676 @vindex org-list-empty-line-terminates-plain-lists
1677 A list ends whenever every item has ended, which means before any line less
1678 or equally indented than items at top level.  It also ends before two blank
1679 lines@footnote{See also @code{org-list-empty-line-terminates-plain-lists}.}.
1680 In that case, all items are closed.  Here is an example:
1682 @example
1683 @group
1684 ** Lord of the Rings
1685    My favorite scenes are (in this order)
1686    1. The attack of the Rohirrim
1687    2. Eowyn's fight with the witch king
1688       + this was already my favorite scene in the book
1689       + I really like Miranda Otto.
1690    3. Peter Jackson being shot by Legolas
1691       - on DVD only
1692       He makes a really funny face when it happens.
1693    But in the end, no individual scenes matter but the film as a whole.
1694    Important actors in this film are:
1695    - @b{Elijah Wood} :: He plays Frodo
1696    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1697      him very well from his role as Mikey Walsh in @i{The Goonies}.
1698 @end group
1699 @end example
1701 Org supports these lists by tuning filling and wrapping commands to deal with
1702 them correctly@footnote{Org only changes the filling settings for Emacs.  For
1703 XEmacs, you should use Kyle E. Jones' @file{filladapt.el}.  To turn this on,
1704 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
1705 properly (@pxref{Exporting}).  Since indentation is what governs the
1706 structure of these lists, many structural constructs like @code{#+BEGIN_...}
1707 blocks can be indented to signal that they belong to a particular item.
1709 @vindex org-list-demote-modify-bullet
1710 @vindex org-list-indent-offset
1711 If you find that using a different bullet for a sub-list (than that used for
1712 the current list-level) improves readability, customize the variable
1713 @code{org-list-demote-modify-bullet}.  To get a greater difference of
1714 indentation between items and theirs sub-items, customize
1715 @code{org-list-indent-offset}.
1717 @vindex org-list-automatic-rules
1718 The following commands act on items when the cursor is in the first line of
1719 an item (the line with the bullet or number).  Some of them imply the
1720 application of automatic rules to keep list structure intact.  If some of
1721 these actions get in your way, configure @code{org-list-automatic-rules}
1722 to disable them individually.
1724 @table @asis
1725 @orgcmd{@key{TAB},org-cycle}
1726 @cindex cycling, in plain lists
1727 @vindex org-cycle-include-plain-lists
1728 Items can be folded just like headline levels.  Normally this works only if
1729 the cursor is on a plain list item.  For more details, see the variable
1730 @code{org-cycle-include-plain-lists}.  If this variable is set to
1731 @code{integrate}, plain list items will be treated like low-level
1732 headlines.  The level of an item is then given by the indentation of the
1733 bullet/number.  Items are always subordinate to real headlines, however; the
1734 hierarchies remain completely separated.  In a new item with no text yet, the
1735 first @key{TAB} demotes the item to become a child of the previous
1736 one.  Subsequent @key{TAB}s move the item to meaningful levels in the list
1737 and eventually get it back to its initial position.
1738 @orgcmd{M-@key{RET},org-insert-heading}
1739 @vindex org-M-RET-may-split-line
1740 @vindex org-list-automatic-rules
1741 Insert new item at current level.  With a prefix argument, force a new
1742 heading (@pxref{Structure editing}).  If this command is used in the middle
1743 of an item, that item is @emph{split} in two, and the second part becomes the
1744 new item@footnote{If you do not want the item to be split, customize the
1745 variable @code{org-M-RET-may-split-line}.}.  If this command is executed
1746 @emph{before item's body}, the new item is created @emph{before} the current
1747 one.
1748 @end table
1750 @table @kbd
1751 @kindex M-S-@key{RET}
1752 @item M-S-RET
1753 Insert a new item with a checkbox (@pxref{Checkboxes}).
1754 @kindex S-@key{down}
1755 @item S-up
1756 @itemx S-down
1757 @cindex shift-selection-mode
1758 @vindex org-support-shift-select
1759 @vindex org-list-use-circular-motion
1760 Jump to the previous/next item in the current list@footnote{If you want to
1761 cycle around items that way, you may customize
1762 @code{org-list-use-circular-motion}.}, but only if
1763 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1764 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1765 similar effect.
1766 @kindex M-@key{up}
1767 @kindex M-@key{down}
1768 @item M-up
1769 @itemx M-down
1770 Move the item including subitems up/down@footnote{See
1771 @code{org-list-use-circular-motion} for a cyclic behavior.} (swap with
1772 previous/next item of same indentation).  If the list is ordered, renumbering
1773 is automatic.
1774 @kindex M-@key{left}
1775 @kindex M-@key{right}
1776 @item M-left
1777 @itemx M-right
1778 Decrease/increase the indentation of an item, leaving children alone.
1779 @kindex M-S-@key{left}
1780 @kindex M-S-@key{right}
1781 @item M-S-left
1782 @itemx M-S-right
1783 Decrease/increase the indentation of the item, including subitems.
1784 Initially, the item tree is selected based on current indentation.  When
1785 these commands are executed several times in direct succession, the initially
1786 selected region is used, even if the new indentation would imply a different
1787 hierarchy.  To use the new hierarchy, break the command chain with a cursor
1788 motion or so.
1790 As a special case, using this command on the very first item of a list will
1791 move the whole list.  This behavior can be disabled by configuring
1792 @code{org-list-automatic-rules}.  The global indentation of a list has no
1793 influence on the text @emph{after} the list.
1794 @kindex C-c C-c
1795 @item C-c C-c
1796 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1797 state of the checkbox.  In any case, verify bullets and indentation
1798 consistency in the whole list.
1799 @kindex C-c -
1800 @vindex org-plain-list-ordered-item-terminator
1801 @item C-c -
1802 Cycle the entire list level through the different itemize/enumerate bullets
1803 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}) or a subset of them,
1804 depending on @code{org-plain-list-ordered-item-terminator}, the type of list,
1805 and its indentation.  With a numeric prefix argument N, select the Nth bullet
1806 from this list.  If there is an active region when calling this, selected
1807 text will be changed into an item.  With a prefix argument, all lines will be
1808 converted to list items.  If the first line already was a list item, any item
1809 marker will be removed from the list.  Finally, even without an active
1810 region, a normal line will be converted into a list item.
1811 @kindex C-c *
1812 @item C-c *
1813 Turn a plain list item into a headline (so that it becomes a subheading at
1814 its location).  @xref{Structure editing}, for a detailed explanation.
1815 @kindex C-c C-*
1816 @item C-c C-*
1817 Turn the whole plain list into a subtree of the current heading.  Checkboxes
1818 (@pxref{Checkboxes}) will become TODO (resp. DONE) keywords when unchecked
1819 (resp. checked).
1820 @kindex S-@key{left}
1821 @kindex S-@key{right}
1822 @item S-left/right
1823 @vindex org-support-shift-select
1824 This command also cycles bullet styles when the cursor in on the bullet or
1825 anywhere in an item line, details depending on
1826 @code{org-support-shift-select}.
1827 @kindex C-c ^
1828 @item C-c ^
1829 Sort the plain list.  You will be prompted for the sorting method:
1830 numerically, alphabetically, by time, or by custom function.
1831 @end table
1833 @node Drawers, Blocks, Plain lists, Document Structure
1834 @section Drawers
1835 @cindex drawers
1836 @cindex #+DRAWERS
1837 @cindex visibility cycling, drawers
1839 @vindex org-drawers
1840 @cindex org-insert-drawer
1841 @kindex C-c C-x d
1842 Sometimes you want to keep information associated with an entry, but you
1843 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1844 Drawers need to be configured with the variable
1845 @code{org-drawers}@footnote{You can define additional drawers on a
1846 per-file basis with a line like @code{#+DRAWERS: HIDDEN STATE}}.  Drawers
1847 look like this:
1849 @example
1850 ** This is a headline
1851    Still outside the drawer
1852    :DRAWERNAME:
1853    This is inside the drawer.
1854    :END:
1855    After the drawer.
1856 @end example
1858 You can interactively insert drawers at point by calling
1859 @code{org-insert-drawer}, which is bound to @key{C-c C-x d}.  With an active
1860 region, this command will put the region inside the drawer.  With a prefix
1861 argument, this command calls @code{org-insert-property-drawer} and add a
1862 property drawer right below the current headline.  Completion over drawer
1863 keywords is also possible using @key{M-TAB}.
1865 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1866 show the entry, but keep the drawer collapsed to a single line.  In order to
1867 look inside the drawer, you need to move the cursor to the drawer line and
1868 press @key{TAB} there.  Org mode uses the @code{PROPERTIES} drawer for
1869 storing properties (@pxref{Properties and Columns}), and you can also arrange
1870 for state change notes (@pxref{Tracking TODO state changes}) and clock times
1871 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.  If you
1872 want to store a quick note in the LOGBOOK drawer, in a similar way to state changes, use
1874 @table @kbd
1875 @kindex C-c C-z
1876 @item C-c C-z
1877 Add a time-stamped note to the LOGBOOK drawer.
1878 @end table
1880 @vindex org-export-with-drawers
1881 You can select the name of the drawers which should be exported with
1882 @var{org-export-with-drawers}.  In that case, drawer contents will appear in
1883 export output.  Property drawers are not affected by this variable and are
1884 never exported.
1886 @node Blocks, Footnotes, Drawers, Document Structure
1887 @section Blocks
1889 @vindex org-hide-block-startup
1890 @cindex blocks, folding
1891 Org mode uses begin...end blocks for various purposes from including source
1892 code examples (@pxref{Literal examples}) to capturing time logging
1893 information (@pxref{Clocking work time}).  These blocks can be folded and
1894 unfolded by pressing TAB in the begin line.  You can also get all blocks
1895 folded at startup by configuring the variable @code{org-hide-block-startup}
1896 or on a per-file basis by using
1898 @cindex @code{hideblocks}, STARTUP keyword
1899 @cindex @code{nohideblocks}, STARTUP keyword
1900 @example
1901 #+STARTUP: hideblocks
1902 #+STARTUP: nohideblocks
1903 @end example
1905 @node Footnotes, Orgstruct mode, Blocks, Document Structure
1906 @section Footnotes
1907 @cindex footnotes
1909 Org mode supports the creation of footnotes.  In contrast to the
1910 @file{footnote.el} package, Org mode's footnotes are designed for work on
1911 a larger document, not only for one-off documents like emails.
1913 A footnote is started by a footnote marker in square brackets in column 0, no
1914 indentation allowed.  It ends at the next footnote definition, headline, or
1915 after two consecutive empty lines.  The footnote reference is simply the
1916 marker in square brackets, inside text.  For example:
1918 @example
1919 The Org homepage[fn:1] now looks a lot better than it used to.
1921 [fn:1] The link is: http://orgmode.org
1922 @end example
1924 Org mode extends the number-based syntax to @emph{named} footnotes and
1925 optional inline definition.  Using plain numbers as markers (as
1926 @file{footnote.el} does) is supported for backward compatibility, but not
1927 encouraged because of possible conflicts with @LaTeX{} snippets (@pxref{Embedded
1928 @LaTeX{}}).  Here are the valid references:
1930 @table @code
1931 @item [1]
1932 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
1933 recommended because something like @samp{[1]} could easily be part of a code
1934 snippet.
1935 @item [fn:name]
1936 A named footnote reference, where @code{name} is a unique label word, or, for
1937 simplicity of automatic creation, a number.
1938 @item [fn:: This is the inline definition of this footnote]
1939 A @LaTeX{}-like anonymous footnote where the definition is given directly at the
1940 reference point.
1941 @item [fn:name: a definition]
1942 An inline definition of a footnote, which also specifies a name for the note.
1943 Since Org allows multiple references to the same note, you can then use
1944 @code{[fn:name]} to create additional references.
1945 @end table
1947 @vindex org-footnote-auto-label
1948 Footnote labels can be created automatically, or you can create names yourself.
1949 This is handled by the variable @code{org-footnote-auto-label} and its
1950 corresponding @code{#+STARTUP} keywords.  See the docstring of that variable
1951 for details.
1953 @noindent The following command handles footnotes:
1955 @table @kbd
1956 @kindex C-c C-x f
1957 @item C-c C-x f
1958 The footnote action command.
1960 When the cursor is on a footnote reference, jump to the definition.  When it
1961 is at a definition, jump to the (first) reference.
1963 @vindex org-footnote-define-inline
1964 @vindex org-footnote-section
1965 @vindex org-footnote-auto-adjust
1966 Otherwise, create a new footnote.  Depending on the variable
1967 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1968 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1969 definition will be placed right into the text as part of the reference, or
1970 separately into the location determined by the variable
1971 @code{org-footnote-section}.
1973 When this command is called with a prefix argument, a menu of additional
1974 options is offered:
1975 @example
1976 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1977     @r{Org makes no effort to sort footnote definitions into a particular}
1978     @r{sequence.  If you want them sorted, use this command, which will}
1979     @r{also move entries according to @code{org-footnote-section}.  Automatic}
1980     @r{sorting after each insertion/deletion can be configured using the}
1981     @r{variable @code{org-footnote-auto-adjust}.}
1982 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
1983     @r{after each insertion/deletion can be configured using the variable}
1984     @r{@code{org-footnote-auto-adjust}.}
1985 S   @r{Short for first @code{r}, then @code{s} action.}
1986 n   @r{Normalize the footnotes by collecting all definitions (including}
1987     @r{inline definitions) into a special section, and then numbering them}
1988     @r{in sequence.  The references will then also be numbers.  This is}
1989     @r{meant to be the final step before finishing a document (e.g., sending}
1990     @r{off an email).}
1991 d   @r{Delete the footnote at point, and all definitions of and references}
1992     @r{to it.}
1993 @end example
1994 Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
1995 corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
1996 renumbering and sorting footnotes can be automatic after each insertion or
1997 deletion.
1999 @kindex C-c C-c
2000 @item C-c C-c
2001 If the cursor is on a footnote reference, jump to the definition.  If it is a
2002 the definition, jump back to the reference.  When called at a footnote
2003 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
2004 @kindex C-c C-o
2005 @kindex mouse-1
2006 @kindex mouse-2
2007 @item C-c C-o  @r{or} mouse-1/2
2008 Footnote labels are also links to the corresponding definition/reference, and
2009 you can use the usual commands to follow these links.
2010 @end table
2012 @node Orgstruct mode, Org syntax, Footnotes, Document Structure
2013 @section The Orgstruct minor mode
2014 @cindex Orgstruct mode
2015 @cindex minor mode for structure editing
2017 If you like the intuitive way the Org mode structure editing and list
2018 formatting works, you might want to use these commands in other modes like
2019 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
2020 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode RET}, or
2021 turn it on by default, for example in Message mode, with one of:
2023 @lisp
2024 (add-hook 'message-mode-hook 'turn-on-orgstruct)
2025 (add-hook 'message-mode-hook 'turn-on-orgstruct++)
2026 @end lisp
2028 When this mode is active and the cursor is on a line that looks to Org like a
2029 headline or the first line of a list item, most structure editing commands
2030 will work, even if the same keys normally have different functionality in the
2031 major mode you are using.  If the cursor is not in one of those special
2032 lines, Orgstruct mode lurks silently in the shadows.
2034 When you use @code{orgstruct++-mode}, Org will also export indentation and
2035 autofill settings into that mode, and detect item context after the first
2036 line of an item.
2038 @vindex orgstruct-heading-prefix-regexp
2039 You can also use Org structure editing to fold and unfold headlines in
2040 @emph{any} file, provided you defined @var{orgstruct-heading-prefix-regexp}:
2041 the regular expression must match the local prefix to use before Org's
2042 headlines.  For example, if you set this variable to @code{"^;; "} in Emacs
2043 Lisp files, you will be able to fold and unfold headlines in Emacs Lisp
2044 commented lines.  Some commands like @code{org-demote} are disabled when the
2045 prefix is set, but folding/unfolding will work correctly.
2047 @node Org syntax,  , Orgstruct mode, Document Structure
2048 @section Org syntax
2049 @cindex Org syntax
2051 A reference document providing a formal description of Org's syntax is
2052 available as @uref{http://orgmode.org/worg/dev/org-syntax.html, a draft on
2053 Worg}, written and maintained by Nicolas Goaziou.  It defines Org's core
2054 internal concepts such as @code{headlines}, @code{sections}, @code{affiliated
2055 keywords}, @code{(greater) elements} and @code{objects}.  Each part of an Org
2056 file falls into one of the categories above.
2058 To explore the abstract structure of an Org buffer, run this in a buffer:
2060 @lisp
2061 M-: (org-element-parse-buffer) RET
2062 @end lisp
2064 It will output a list containing the buffer's content represented as an
2065 abstract structure.  The export engine relies on the information stored in
2066 this list.  Most interactive commands (e.g., for structure editing) also
2067 rely on the syntactic meaning of the surrounding context.
2069 @node Tables, Hyperlinks, Document Structure, Top
2070 @chapter Tables
2071 @cindex tables
2072 @cindex editing tables
2074 Org comes with a fast and intuitive table editor.  Spreadsheet-like
2075 calculations are supported using the Emacs @file{calc} package
2076 (@pxref{Top, Calc, , calc, Gnu Emacs Calculator Manual}).
2078 @menu
2079 * Built-in table editor::       Simple tables
2080 * Column width and alignment::  Overrule the automatic settings
2081 * Column groups::               Grouping to trigger vertical lines
2082 * Orgtbl mode::                 The table editor as minor mode
2083 * The spreadsheet::             The table editor has spreadsheet capabilities
2084 * Org-Plot::                    Plotting from org tables
2085 @end menu
2087 @node Built-in table editor, Column width and alignment, Tables, Tables
2088 @section The built-in table editor
2089 @cindex table editor, built-in
2091 Org makes it easy to format tables in plain ASCII@.  Any line with @samp{|} as
2092 the first non-whitespace character is considered part of a table.  @samp{|}
2093 is also the column separator@footnote{To insert a vertical bar into a table
2094 field, use @code{\vert} or, inside a word @code{abc\vert@{@}def}.}.  A table
2095 might look like this:
2097 @example
2098 | Name  | Phone | Age |
2099 |-------+-------+-----|
2100 | Peter |  1234 |  17 |
2101 | Anna  |  4321 |  25 |
2102 @end example
2104 A table is re-aligned automatically each time you press @key{TAB} or
2105 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
2106 the next field (@key{RET} to the next row) and creates new table rows
2107 at the end of the table or before horizontal lines.  The indentation
2108 of the table is set by the first line.  Any line starting with
2109 @samp{|-} is considered as a horizontal separator line and will be
2110 expanded on the next re-align to span the whole table width.  So, to
2111 create the above table, you would only type
2113 @example
2114 |Name|Phone|Age|
2116 @end example
2118 @noindent and then press @key{TAB} to align the table and start filling in
2119 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
2120 @kbd{C-c @key{RET}}.
2122 @vindex org-enable-table-editor
2123 @vindex org-table-auto-blank-field
2124 When typing text into a field, Org treats @key{DEL},
2125 @key{Backspace}, and all character keys in a special way, so that
2126 inserting and deleting avoids shifting other fields.  Also, when
2127 typing @emph{immediately after the cursor was moved into a new field
2128 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
2129 field is automatically made blank.  If this behavior is too
2130 unpredictable for you, configure the variables
2131 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
2133 @table @kbd
2134 @tsubheading{Creation and conversion}
2135 @orgcmd{C-c |,org-table-create-or-convert-from-region}
2136 Convert the active region to table.  If every line contains at least one
2137 TAB character, the function assumes that the material is tab separated.
2138 If every line contains a comma, comma-separated values (CSV) are assumed.
2139 If not, lines are split at whitespace into fields.  You can use a prefix
2140 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
2141 C-u} forces TAB, and a numeric argument N indicates that at least N
2142 consecutive spaces, or alternatively a TAB will be the separator.
2144 If there is no active region, this command creates an empty Org
2145 table.  But it is easier just to start typing, like
2146 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
2148 @tsubheading{Re-aligning and field motion}
2149 @orgcmd{C-c C-c,org-table-align}
2150 Re-align the table and don't move to another field.
2152 @orgcmd{<TAB>,org-table-next-field}
2153 Re-align the table, move to the next field.  Creates a new row if
2154 necessary.
2156 @orgcmd{S-@key{TAB},org-table-previous-field}
2157 Re-align, move to previous field.
2159 @orgcmd{@key{RET},org-table-next-row}
2160 Re-align the table and move down to next row.  Creates a new row if
2161 necessary.  At the beginning or end of a line, @key{RET} still does
2162 NEWLINE, so it can be used to split a table.
2164 @orgcmd{M-a,org-table-beginning-of-field}
2165 Move to beginning of the current table field, or on to the previous field.
2166 @orgcmd{M-e,org-table-end-of-field}
2167 Move to end of the current table field, or on to the next field.
2169 @tsubheading{Column and row editing}
2170 @orgcmdkkcc{M-@key{left},M-@key{right},org-table-move-column-left,org-table-move-column-right}
2171 Move the current column left/right.
2173 @orgcmd{M-S-@key{left},org-table-delete-column}
2174 Kill the current column.
2176 @orgcmd{M-S-@key{right},org-table-insert-column}
2177 Insert a new column to the left of the cursor position.
2179 @orgcmdkkcc{M-@key{up},M-@key{down},org-table-move-row-up,org-table-move-row-down}
2180 Move the current row up/down.
2182 @orgcmd{M-S-@key{up},org-table-kill-row}
2183 Kill the current row or horizontal line.
2185 @orgcmd{M-S-@key{down},org-table-insert-row}
2186 Insert a new row above the current row.  With a prefix argument, the line is
2187 created below the current one.
2189 @orgcmd{C-c -,org-table-insert-hline}
2190 Insert a horizontal line below current row.  With a prefix argument, the line
2191 is created above the current line.
2193 @orgcmd{C-c @key{RET},org-table-hline-and-move}
2194 Insert a horizontal line below current row, and move the cursor into the row
2195 below that line.
2197 @orgcmd{C-c ^,org-table-sort-lines}
2198 Sort the table lines in the region.  The position of point indicates the
2199 column to be used for sorting, and the range of lines is the range
2200 between the nearest horizontal separator lines, or the entire table.  If
2201 point is before the first column, you will be prompted for the sorting
2202 column.  If there is an active region, the mark specifies the first line
2203 and the sorting column, while point should be in the last line to be
2204 included into the sorting.  The command prompts for the sorting type
2205 (alphabetically, numerically, or by time).  When called with a prefix
2206 argument, alphabetic sorting will be case-sensitive.
2208 @tsubheading{Regions}
2209 @orgcmd{C-c C-x M-w,org-table-copy-region}
2210 Copy a rectangular region from a table to a special clipboard.  Point and
2211 mark determine edge fields of the rectangle.  If there is no active region,
2212 copy just the current field.  The process ignores horizontal separator lines.
2214 @orgcmd{C-c C-x C-w,org-table-cut-region}
2215 Copy a rectangular region from a table to a special clipboard, and
2216 blank all fields in the rectangle.  So this is the ``cut'' operation.
2218 @orgcmd{C-c C-x C-y,org-table-paste-rectangle}
2219 Paste a rectangular region into a table.
2220 The upper left corner ends up in the current field.  All involved fields
2221 will be overwritten.  If the rectangle does not fit into the present table,
2222 the table is enlarged as needed.  The process ignores horizontal separator
2223 lines.
2225 @orgcmd{M-@key{RET},org-table-wrap-region}
2226 Split the current field at the cursor position and move the rest to the line
2227 below.  If there is an active region, and both point and mark are in the same
2228 column, the text in the column is wrapped to minimum width for the given
2229 number of lines.  A numeric prefix argument may be used to change the number
2230 of desired lines.  If there is no region, but you specify a prefix argument,
2231 the current field is made blank, and the content is appended to the field
2232 above.
2234 @tsubheading{Calculations}
2235 @cindex formula, in tables
2236 @cindex calculations, in tables
2237 @cindex region, active
2238 @cindex active region
2239 @cindex transient mark mode
2240 @orgcmd{C-c +,org-table-sum}
2241 Sum the numbers in the current column, or in the rectangle defined by
2242 the active region.  The result is shown in the echo area and can
2243 be inserted with @kbd{C-y}.
2245 @orgcmd{S-@key{RET},org-table-copy-down}
2246 @vindex org-table-copy-increment
2247 When current field is empty, copy from first non-empty field above.  When not
2248 empty, copy current field down to next row and move cursor along with it.
2249 Depending on the variable @code{org-table-copy-increment}, integer field
2250 values will be incremented during copy.  Integers that are too large will not
2251 be incremented.  Also, a @code{0} prefix argument temporarily disables the
2252 increment.  This key is also used by shift-selection and related modes
2253 (@pxref{Conflicts}).
2255 @tsubheading{Miscellaneous}
2256 @orgcmd{C-c `,org-table-edit-field}
2257 Edit the current field in a separate window.  This is useful for fields that
2258 are not fully visible (@pxref{Column width and alignment}).  When called with
2259 a @kbd{C-u} prefix, just make the full field visible, so that it can be
2260 edited in place.  When called with two @kbd{C-u} prefixes, make the editor
2261 window follow the cursor through the table and always show the current
2262 field.  The follow mode exits automatically when the cursor leaves the table,
2263 or when you repeat this command with @kbd{C-u C-u C-c `}.
2265 @item M-x org-table-import RET
2266 Import a file as a table.  The table should be TAB or whitespace
2267 separated.  Use, for example, to import a spreadsheet table or data
2268 from a database, because these programs generally can write
2269 TAB-separated text files.  This command works by inserting the file into
2270 the buffer and then converting the region to a table.  Any prefix
2271 argument is passed on to the converter, which uses it to determine the
2272 separator.
2273 @orgcmd{C-c |,org-table-create-or-convert-from-region}
2274 Tables can also be imported by pasting tabular text into the Org
2275 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
2276 @kbd{C-c |} command (see above under @i{Creation and conversion}).
2278 @item M-x org-table-export RET
2279 @findex org-table-export
2280 @vindex org-table-export-default-format
2281 Export the table, by default as a TAB-separated file.  Use for data
2282 exchange with, for example, spreadsheet or database programs.  The format
2283 used to export the file can be configured in the variable
2284 @code{org-table-export-default-format}.  You may also use properties
2285 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
2286 name and the format for table export in a subtree.  Org supports quite
2287 general formats for exported tables.  The exporter format is the same as the
2288 format used by Orgtbl radio tables, see @ref{Translator functions}, for a
2289 detailed description.
2290 @end table
2292 If you don't like the automatic table editor because it gets in your
2293 way on lines which you would like to start with @samp{|}, you can turn
2294 it off with
2296 @lisp
2297 (setq org-enable-table-editor nil)
2298 @end lisp
2300 @noindent Then the only table command that still works is
2301 @kbd{C-c C-c} to do a manual re-align.
2303 @node Column width and alignment, Column groups, Built-in table editor, Tables
2304 @section Column width and alignment
2305 @cindex narrow columns in tables
2306 @cindex alignment in tables
2308 The width of columns is automatically determined by the table editor.  And
2309 also the alignment of a column is determined automatically from the fraction
2310 of number-like versus non-number fields in the column.
2312 Sometimes a single field or a few fields need to carry more text, leading to
2313 inconveniently wide columns.  Or maybe you want to make a table with several
2314 columns having a fixed width, regardless of content.  To set@footnote{This
2315 feature does not work on XEmacs.} the width of a column, one field anywhere
2316 in the column may contain just the string @samp{<N>} where @samp{N} is an
2317 integer specifying the width of the column in characters.  The next re-align
2318 will then set the width of this column to this value.
2320 @example
2321 @group
2322 |---+------------------------------|               |---+--------|
2323 |   |                              |               |   | <6>    |
2324 | 1 | one                          |               | 1 | one    |
2325 | 2 | two                          |     ----\     | 2 | two    |
2326 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
2327 | 4 | four                         |               | 4 | four   |
2328 |---+------------------------------|               |---+--------|
2329 @end group
2330 @end example
2332 @noindent
2333 Fields that are wider become clipped and end in the string @samp{=>}.
2334 Note that the full text is still in the buffer but is hidden.
2335 To see the full text, hold the mouse over the field---a tool-tip window
2336 will show the full content.  To edit such a field, use the command
2337 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
2338 open a new window with the full field.  Edit it and finish with @kbd{C-c
2339 C-c}.
2341 @vindex org-startup-align-all-tables
2342 When visiting a file containing a table with narrowed columns, the
2343 necessary character hiding has not yet happened, and the table needs to
2344 be aligned before it looks nice.  Setting the option
2345 @code{org-startup-align-all-tables} will realign all tables in a file
2346 upon visiting, but also slow down startup.  You can also set this option
2347 on a per-file basis with:
2349 @example
2350 #+STARTUP: align
2351 #+STARTUP: noalign
2352 @end example
2354 If you would like to overrule the automatic alignment of number-rich columns
2355 to the right and of string-rich column to the left, you can use @samp{<r>},
2356 @samp{<c>}@footnote{Centering does not work inside Emacs, but it does have an
2357 effect when exporting to HTML.} or @samp{<l>} in a similar fashion.  You may
2358 also combine alignment and field width like this: @samp{<r10>}.
2360 Lines which only contain these formatting cookies will be removed
2361 automatically when exporting the document.
2363 @node Column groups, Orgtbl mode, Column width and alignment, Tables
2364 @section Column groups
2365 @cindex grouping columns in tables
2367 When Org exports tables, it does so by default without vertical
2368 lines because that is visually more satisfying in general.  Occasionally
2369 however, vertical lines can be useful to structure a table into groups
2370 of columns, much like horizontal lines can do for groups of rows.  In
2371 order to specify column groups, you can use a special row where the
2372 first field contains only @samp{/}.  The further fields can either
2373 contain @samp{<} to indicate that this column should start a group,
2374 @samp{>} to indicate the end of a column, or @samp{<>} (no space between @samp{<}
2375 and @samp{>}) to make a column
2376 a group of its own.  Boundaries between column groups will upon export be
2377 marked with vertical lines.  Here is an example:
2379 @example
2380 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2381 |---+-----+-----+-----+---------+------------|
2382 | / |   < |     |   > |       < |          > |
2383 | 1 |   1 |   1 |   1 |       1 |          1 |
2384 | 2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
2385 | 3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
2386 |---+-----+-----+-----+---------+------------|
2387 #+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
2388 @end example
2390 It is also sufficient to just insert the column group starters after
2391 every vertical line you would like to have:
2393 @example
2394 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2395 |----+-----+-----+-----+---------+------------|
2396 | /  | <   |     |     | <       |            |
2397 @end example
2399 @node Orgtbl mode, The spreadsheet, Column groups, Tables
2400 @section The Orgtbl minor mode
2401 @cindex Orgtbl mode
2402 @cindex minor mode for tables
2404 If you like the intuitive way the Org table editor works, you
2405 might also want to use it in other modes like Text mode or Mail mode.
2406 The minor mode Orgtbl mode makes this possible.  You can always toggle
2407 the mode with @kbd{M-x orgtbl-mode RET}.  To turn it on by default, for
2408 example in Message mode, use
2410 @lisp
2411 (add-hook 'message-mode-hook 'turn-on-orgtbl)
2412 @end lisp
2414 Furthermore, with some special setup, it is possible to maintain tables
2415 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
2416 construct @LaTeX{} tables with the underlying ease and power of
2417 Orgtbl mode, including spreadsheet capabilities.  For details, see
2418 @ref{Tables in arbitrary syntax}.
2420 @node The spreadsheet, Org-Plot, Orgtbl mode, Tables
2421 @section The spreadsheet
2422 @cindex calculations, in tables
2423 @cindex spreadsheet capabilities
2424 @cindex @file{calc} package
2426 The table editor makes use of the Emacs @file{calc} package to implement
2427 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
2428 derive fields from other fields.  While fully featured, Org's implementation
2429 is not identical to other spreadsheets.  For example, Org knows the concept
2430 of a @emph{column formula} that will be applied to all non-header fields in a
2431 column without having to copy the formula to each relevant field.  There is
2432 also a formula debugger, and a formula editor with features for highlighting
2433 fields in the table corresponding to the references at the point in the
2434 formula, moving these references by arrow keys
2436 @menu
2437 * References::                  How to refer to another field or range
2438 * Formula syntax for Calc::     Using Calc to compute stuff
2439 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
2440 * Durations and time values::   How to compute durations and time values
2441 * Field and range formulas::    Formula for specific (ranges of) fields
2442 * Column formulas::             Formulas valid for an entire column
2443 * Lookup functions::            Lookup functions for searching tables
2444 * Editing and debugging formulas::  Fixing formulas
2445 * Updating the table::          Recomputing all dependent fields
2446 * Advanced features::           Field and column names, parameters and automatic recalc
2447 @end menu
2449 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
2450 @subsection References
2451 @cindex references
2453 To compute fields in the table from other fields, formulas must
2454 reference other fields or ranges.  In Org, fields can be referenced
2455 by name, by absolute coordinates, and by relative coordinates.  To find
2456 out what the coordinates of a field are, press @kbd{C-c ?} in that
2457 field, or press @kbd{C-c @}} to toggle the display of a grid.
2459 @subsubheading Field references
2460 @cindex field references
2461 @cindex references, to fields
2463 Formulas can reference the value of another field in two ways.  Like in
2464 any other spreadsheet, you may reference fields with a letter/number
2465 combination like @code{B3}, meaning the 2nd field in the 3rd row.
2466 @vindex org-table-use-standard-references
2467 However, Org prefers@footnote{Org will understand references typed by the
2468 user as @samp{B4}, but it will not use this syntax when offering a formula
2469 for editing.  You can customize this behavior using the variable
2470 @code{org-table-use-standard-references}.}  to use another, more general
2471 representation that looks like this:
2472 @example
2473 @@@var{row}$@var{column}
2474 @end example
2476 Column specifications can be absolute like @code{$1},
2477 @code{$2},...@code{$@var{N}}, or relative to the current column (i.e., the
2478 column of the field which is being computed) like @code{$+1} or @code{$-2}.
2479 @code{$<} and @code{$>} are immutable references to the first and last
2480 column, respectively, and you can use @code{$>>>} to indicate the third
2481 column from the right.
2483 The row specification only counts data lines and ignores horizontal separator
2484 lines (hlines).  Like with columns, you can use absolute row numbers
2485 @code{@@1}, @code{@@2},...@code{@@@var{N}}, and row numbers relative to the
2486 current row like @code{@@+3} or @code{@@-1}.  @code{@@<} and @code{@@>} are
2487 immutable references the first and last@footnote{For backward compatibility
2488 you can also use special names like @code{$LR5} and @code{$LR12} to refer in
2489 a stable way to the 5th and 12th field in the last row of the table.
2490 However, this syntax is deprecated, it should not be used for new documents.
2491 Use @code{@@>$} instead.} row in the table, respectively.  You may also
2492 specify the row relative to one of the hlines: @code{@@I} refers to the first
2493 hline, @code{@@II} to the second, etc.  @code{@@-I} refers to the first such
2494 line above the current line, @code{@@+I} to the first such line below the
2495 current line.  You can also write @code{@@III+2} which is the second data line
2496 after the third hline in the table.
2498 @code{@@0} and @code{$0} refer to the current row and column, respectively,
2499 i.e., to the row/column for the field being computed.  Also, if you omit
2500 either the column or the row part of the reference, the current row/column is
2501 implied.
2503 Org's references with @emph{unsigned} numbers are fixed references
2504 in the sense that if you use the same reference in the formula for two
2505 different fields, the same field will be referenced each time.
2506 Org's references with @emph{signed} numbers are floating
2507 references because the same reference operator can reference different
2508 fields depending on the field being calculated by the formula.
2510 Here are a few examples:
2512 @example
2513 @@2$3      @r{2nd row, 3rd column (same as @code{C2})}
2514 $5        @r{column 5 in the current row (same as @code{E&})}
2515 @@2        @r{current column, row 2}
2516 @@-1$-3    @r{the field one row up, three columns to the left}
2517 @@-I$2     @r{field just under hline above current row, column 2}
2518 @@>$5      @r{field in the last row, in column 5}
2519 @end example
2521 @subsubheading Range references
2522 @cindex range references
2523 @cindex references, to ranges
2525 You may reference a rectangular range of fields by specifying two field
2526 references connected by two dots @samp{..}.  If both fields are in the
2527 current row, you may simply use @samp{$2..$7}, but if at least one field
2528 is in a different row, you need to use the general @code{@@row$column}
2529 format at least for the first field (i.e the reference must start with
2530 @samp{@@} in order to be interpreted correctly).  Examples:
2532 @example
2533 $1..$3        @r{first three fields in the current row}
2534 $P..$Q        @r{range, using column names (see under Advanced)}
2535 $<<<..$>>     @r{start in third column, continue to the one but last}
2536 @@2$1..@@4$3    @r{6 fields between these two fields (same as @code{A2..C4})}
2537 @@-1$-2..@@-1   @r{3 fields in the row above, starting from 2 columns on the left}
2538 @@I..II        @r{between first and second hline, short for @code{@@I..@@II}}
2539 @end example
2541 @noindent Range references return a vector of values that can be fed
2542 into Calc vector functions.  Empty fields in ranges are normally
2543 suppressed, so that the vector contains only the non-empty fields (but
2544 see the @samp{E} mode switch below).  If there are no non-empty fields,
2545 @samp{[0]} is returned to avoid syntax errors in formulas.
2547 @subsubheading Field coordinates in formulas
2548 @cindex field coordinates
2549 @cindex coordinates, of field
2550 @cindex row, of field coordinates
2551 @cindex column, of field coordinates
2553 For Calc formulas and Lisp formulas @code{@@#} and @code{$#} can be used to
2554 get the row or column number of the field where the formula result goes.
2555 The traditional Lisp formula equivalents are @code{org-table-current-dline}
2556 and @code{org-table-current-column}.  Examples:
2558 @example
2559 if(@@# % 2, $#, string(""))   @r{column number on odd lines only}
2560 $3 = remote(FOO, @@@@#$2)      @r{copy column 2 from table FOO into}
2561                              @r{column 3 of the current table}
2562 @end example
2564 @noindent For the second example, table FOO must have at least as many rows
2565 as the current table.  Note that this is inefficient@footnote{The computation time scales as
2566 O(N^2) because table FOO is parsed for each field to be copied.} for large
2567 number of rows.
2569 @subsubheading Named references
2570 @cindex named references
2571 @cindex references, named
2572 @cindex name, of column or field
2573 @cindex constants, in calculations
2574 @cindex #+CONSTANTS
2576 @vindex org-table-formula-constants
2577 @samp{$name} is interpreted as the name of a column, parameter or
2578 constant.  Constants are defined globally through the variable
2579 @code{org-table-formula-constants}, and locally (for the file) through a
2580 line like
2582 @example
2583 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2584 @end example
2586 @noindent
2587 @vindex constants-unit-system
2588 @pindex constants.el
2589 Also properties (@pxref{Properties and Columns}) can be used as
2590 constants in table formulas: for a property @samp{:Xyz:} use the name
2591 @samp{$PROP_Xyz}, and the property will be searched in the current
2592 outline entry and in the hierarchy above it.  If you have the
2593 @file{constants.el} package, it will also be used to resolve constants,
2594 including natural constants like @samp{$h} for Planck's constant, and
2595 units like @samp{$km} for kilometers@footnote{@file{constants.el} can
2596 supply the values of constants in two different unit systems, @code{SI}
2597 and @code{cgs}.  Which one is used depends on the value of the variable
2598 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2599 @code{constSI} and @code{constcgs} to set this value for the current
2600 buffer.}.  Column names and parameters can be specified in special table
2601 lines.  These are described below, see @ref{Advanced features}.  All
2602 names must start with a letter, and further consist of letters and
2603 numbers.
2605 @subsubheading Remote references
2606 @cindex remote references
2607 @cindex references, remote
2608 @cindex references, to a different table
2609 @cindex name, of column or field
2610 @cindex constants, in calculations
2611 @cindex #+NAME, for table
2613 You may also reference constants, fields and ranges from a different table,
2614 either in the current file or even in a different file.  The syntax is
2616 @example
2617 remote(NAME-OR-ID,REF)
2618 @end example
2620 @noindent
2621 where NAME can be the name of a table in the current file as set by a
2622 @code{#+NAME: Name} line before the table.  It can also be the ID of an
2623 entry, even in a different file, and the reference then refers to the first
2624 table in that entry.  REF is an absolute field or range reference as
2625 described above for example @code{@@3$3} or @code{$somename}, valid in the
2626 referenced table.
2628 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2629 @subsection Formula syntax for Calc
2630 @cindex formula syntax, Calc
2631 @cindex syntax, of formulas
2633 A formula can be any algebraic expression understood by the Emacs
2634 @file{Calc} package.  @b{Note that @file{calc} has the
2635 non-standard convention that @samp{/} has lower precedence than
2636 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2637 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2638 Your Programs, calc-eval, Calling Calc from Your Lisp Programs, calc, GNU
2639 Emacs Calc Manual}),
2640 variable substitution takes place according to the rules described above.
2641 @cindex vectors, in table calculations
2642 The range vectors can be directly fed into the Calc vector functions
2643 like @samp{vmean} and @samp{vsum}.
2645 @cindex format specifier
2646 @cindex mode, for @file{calc}
2647 @vindex org-calc-default-modes
2648 A formula can contain an optional mode string after a semicolon.  This
2649 string consists of flags to influence Calc and other modes during
2650 execution.  By default, Org uses the standard Calc modes (precision
2651 12, angular units degrees, fraction and symbolic modes off).  The display
2652 format, however, has been changed to @code{(float 8)} to keep tables
2653 compact.  The default settings can be configured using the variable
2654 @code{org-calc-default-modes}.
2656 @example
2657 p20           @r{set the internal Calc calculation precision to 20 digits}
2658 n3 s3 e2 f4   @r{Normal, scientific, engineering, or fixed}
2659               @r{format of the result of Calc passed back to Org.}
2660               @r{Calc formatting is unlimited in precision as}
2661               @r{long as the Calc calculation precision is greater.}
2662 D R           @r{angle modes: degrees, radians}
2663 F S           @r{fraction and symbolic modes}
2664 E             @r{keep empty fields in ranges and use nan (not a number)}
2665               @r{in Calc formulas for empty fields in range references and}
2666               @r{for empty field references; else suppress empty fields in}
2667               @r{range references and use 0 for empty field references, see}
2668               @r{also the notes for `Range references' in @pxref{References}}
2669 N             @r{interpret all fields as numbers, use 0 for non-numbers;}
2670               @r{N has higher precedence than E (for the value of the field)}
2671 L             @r{literal, for Lisp formulas only}
2672 @end example
2674 @noindent
2675 Unless you use large integer numbers or high-precision-calculation
2676 and -display for floating point numbers you may alternatively provide a
2677 @code{printf} format specifier to reformat the Calc result after it has been
2678 passed back to Org instead of letting Calc already do the
2679 formatting@footnote{The @code{printf} reformatting is limited in precision
2680 because the value passed to it is converted into an @code{integer} or
2681 @code{double}.  The @code{integer} is limited in size by truncating the
2682 signed value to 32 bits.  The @code{double} is limited in precision to 64
2683 bits overall which leaves approximately 16 significant decimal digits.}.
2684 A few examples:
2686 @example
2687 $1+$2                @r{Sum of first and second field}
2688 $1+$2;%.2f           @r{Same, format result to two decimals}
2689 exp($2)+exp($1)      @r{Math functions can be used}
2690 $0;%.1f              @r{Reformat current cell to 1 decimal}
2691 ($3-32)*5/9          @r{Degrees F -> C conversion}
2692 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2693 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2694 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2695 vmean($2..$7)        @r{Compute column range mean, suppress empty fields}
2696 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2697 taylor($3,x=7,2)     @r{Taylor series of $3, at x=7, second degree}
2698 @end example
2700 Calc also contains a complete set of logical operations.  For example
2702 @example
2703 if($1 < 20, teen, string(""))
2704                      @r{"teen" if age $1 is less than 20, else empty}
2705 if("$1" = "nan" || "$2" = "nan", string(""), $1 + $2); E
2706                      @r{sum of first two columns unless one or both empty}
2707 @end example
2709 Note that you can also use two org-specific flags @code{T} and @code{t} for
2710 durations computations @ref{Durations and time values}.
2712 You can add your own Calc functions defined in Emacs Lisp with @code{defmath}
2713 and use them in formula syntax for Calc.
2715 @node Formula syntax for Lisp, Durations and time values, Formula syntax for Calc, The spreadsheet
2716 @subsection Emacs Lisp forms as formulas
2717 @cindex Lisp forms, as table formulas
2719 It is also possible to write a formula in Emacs Lisp.  This can be useful
2720 for string manipulation and control structures, if Calc's functionality is
2721 not enough.
2723 If a formula starts with a single-quote followed by an opening parenthesis,
2724 then it is evaluated as a Lisp form.  The evaluation should return either a
2725 string or a number.  Just as with @file{calc} formulas, you can specify modes
2726 and a printf format after a semicolon.
2728 With Emacs Lisp forms, you need to be conscious about the way field
2729 references are interpolated into the form.  By default, a reference will be
2730 interpolated as a Lisp string (in double-quotes) containing the field.  If
2731 you provide the @samp{N} mode switch, all referenced elements will be numbers
2732 (non-number fields will be zero) and interpolated as Lisp numbers, without
2733 quotes.  If you provide the @samp{L} flag, all fields will be interpolated
2734 literally, without quotes.  I.e., if you want a reference to be interpreted
2735 as a string by the Lisp form, enclose the reference operator itself in
2736 double-quotes, like @code{"$3"}.  Ranges are inserted as space-separated
2737 fields, so you can embed them in list or vector syntax.
2739 Here are a few examples---note how the @samp{N} mode is used when we do
2740 computations in Lisp:
2742 @example
2743 @r{Swap the first two characters of the content of column 1}
2744   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2745 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2746   '(+ $1 $2);N
2747 @r{Compute the sum of columns 1--4, like Calc's @code{vsum($1..$4)}}
2748   '(apply '+ '($1..$4));N
2749 @end example
2751 @node Durations and time values, Field and range formulas, Formula syntax for Lisp, The spreadsheet
2752 @subsection Durations and time values
2753 @cindex Duration, computing
2754 @cindex Time, computing
2755 @vindex org-table-duration-custom-format
2757 If you want to compute time values use the @code{T} flag, either in Calc
2758 formulas or Elisp formulas:
2760 @example
2761 @group
2762   |  Task 1 |   Task 2 |    Total |
2763   |---------+----------+----------|
2764   |    2:12 |     1:47 | 03:59:00 |
2765   | 3:02:20 | -2:07:00 |     0.92 |
2766   #+TBLFM: @@2$3=$1+$2;T::@@3$3=$1+$2;t
2767 @end group
2768 @end example
2770 Input duration values must be of the form @code{[HH:MM[:SS]}, where seconds
2771 are optional.  With the @code{T} flag, computed durations will be displayed
2772 as @code{HH:MM:SS} (see the first formula above).  With the @code{t} flag,
2773 computed durations will be displayed according to the value of the variable
2774 @code{org-table-duration-custom-format}, which defaults to @code{'hours} and
2775 will display the result as a fraction of hours (see the second formula in the
2776 example above).
2778 Negative duration values can be manipulated as well, and integers will be
2779 considered as seconds in addition and subtraction.
2781 @node Field and range formulas, Column formulas, Durations and time values, The spreadsheet
2782 @subsection Field and range formulas
2783 @cindex field formula
2784 @cindex range formula
2785 @cindex formula, for individual table field
2786 @cindex formula, for range of fields
2788 To assign a formula to a particular field, type it directly into the field,
2789 preceded by @samp{:=}, for example @samp{:=vsum(@@II..III)}.  When you press
2790 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2791 the formula will be stored as the formula for this field, evaluated, and the
2792 current field will be replaced with the result.
2794 @cindex #+TBLFM
2795 Formulas are stored in a special line starting with @samp{#+TBLFM:} directly
2796 below the table.  If you type the equation in the 4th field of the 3rd data
2797 line in the table, the formula will look like @samp{@@3$4=$1+$2}.  When
2798 inserting/deleting/swapping column and rows with the appropriate commands,
2799 @i{absolute references} (but not relative ones) in stored formulas are
2800 modified in order to still reference the same field.  To avoid this from
2801 happening, in particular in range references, anchor ranges at the table
2802 borders (using @code{@@<}, @code{@@>}, @code{$<}, @code{$>}), or at hlines
2803 using the @code{@@I} notation.  Automatic adaptation of field references does
2804 of course not happen if you edit the table structure with normal editing
2805 commands---then you must fix the equations yourself.
2807 Instead of typing an equation into the field, you may also use the following
2808 command
2810 @table @kbd
2811 @orgcmd{C-u C-c =,org-table-eval-formula}
2812 Install a new formula for the current field.  The command prompts for a
2813 formula with default taken from the @samp{#+TBLFM:} line, applies
2814 it to the current field, and stores it.
2815 @end table
2817 The left-hand side of a formula can also be a special expression in order to
2818 assign the formula to a number of different fields.  There is no keyboard
2819 shortcut to enter such range formulas.  To add them, use the formula editor
2820 (@pxref{Editing and debugging formulas}) or edit the @code{#+TBLFM:} line
2821 directly.
2823 @table @code
2824 @item $2=
2825 Column formula, valid for the entire column.  This is so common that Org
2826 treats these formulas in a special way, see @ref{Column formulas}.
2827 @item @@3=
2828 Row formula, applies to all fields in the specified row.  @code{@@>=} means
2829 the last row.
2830 @item @@1$2..@@4$3=
2831 Range formula, applies to all fields in the given rectangular range.  This
2832 can also be used to assign a formula to some but not all fields in a row.
2833 @item $name=
2834 Named field, see @ref{Advanced features}.
2835 @end table
2837 @node Column formulas, Lookup functions, Field and range formulas, The spreadsheet
2838 @subsection Column formulas
2839 @cindex column formula
2840 @cindex formula, for table column
2842 When you assign a formula to a simple column reference like @code{$3=}, the
2843 same formula will be used in all fields of that column, with the following
2844 very convenient exceptions: (i) If the table contains horizontal separator
2845 hlines with rows above and below, everything before the first such hline is
2846 considered part of the table @emph{header} and will not be modified by column
2847 formulas.  Therefore a header is mandatory when you use column formulas and
2848 want to add hlines to group rows, like for example to separate a total row at
2849 the bottom from the summand rows above.  (ii) Fields that already get a value
2850 from a field/range formula will be left alone by column formulas.  These
2851 conditions make column formulas very easy to use.
2853 To assign a formula to a column, type it directly into any field in the
2854 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2855 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2856 the formula will be stored as the formula for the current column, evaluated
2857 and the current field replaced with the result.  If the field contains only
2858 @samp{=}, the previously stored formula for this column is used.  For each
2859 column, Org will only remember the most recently used formula.  In the
2860 @samp{#+TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The
2861 left-hand side of a column formula can not be the name of column, it must be
2862 the numeric column reference or @code{$>}.
2864 Instead of typing an equation into the field, you may also use the
2865 following command:
2867 @table @kbd
2868 @orgcmd{C-c =,org-table-eval-formula}
2869 Install a new formula for the current column and replace current field with
2870 the result of the formula.  The command prompts for a formula, with default
2871 taken from the @samp{#+TBLFM} line, applies it to the current field and
2872 stores it.  With a numeric prefix argument(e.g., @kbd{C-5 C-c =}) the command
2873 will apply it to that many consecutive fields in the current column.
2874 @end table
2876 @node Lookup functions, Editing and debugging formulas, Column formulas, The spreadsheet
2877 @subsection Lookup functions
2878 @cindex lookup functions in tables
2879 @cindex table lookup functions
2881 Org has three predefined Emacs Lisp functions for lookups in tables.
2882 @table @code
2883 @item (org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)
2884 @findex org-lookup-first
2885 Searches for the first element @code{S} in list @code{S-LIST} for which
2886 @lisp
2887 (PREDICATE VAL S)
2888 @end lisp
2889 is @code{t}; returns the value from the corresponding position in list
2890 @code{R-LIST}.  The default @code{PREDICATE} is @code{equal}.  Note that the
2891 parameters @code{VAL} and @code{S} are passed to @code{PREDICATE} in the same
2892 order as the corresponding parameters are in the call to
2893 @code{org-lookup-first}, where @code{VAL} precedes @code{S-LIST}.  If
2894 @code{R-LIST} is @code{nil}, the matching element @code{S} of @code{S-LIST}
2895 is returned.
2896 @item (org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)
2897 @findex org-lookup-last
2898 Similar to @code{org-lookup-first} above, but searches for the @i{last}
2899 element for which @code{PREDICATE} is @code{t}.
2900 @item (org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)
2901 @findex org-lookup-all
2902 Similar to @code{org-lookup-first}, but searches for @i{all} elements for
2903 which @code{PREDICATE} is @code{t}, and returns @i{all} corresponding
2904 values.  This function can not be used by itself in a formula, because it
2905 returns a list of values.  However, powerful lookups can be built when this
2906 function is combined with other Emacs Lisp functions.
2907 @end table
2909 If the ranges used in these functions contain empty fields, the @code{E} mode
2910 for the formula should usually be specified: otherwise empty fields will not be
2911 included in @code{S-LIST} and/or @code{R-LIST} which can, for example, result
2912 in an incorrect mapping from an element of @code{S-LIST} to the corresponding
2913 element of @code{R-LIST}.
2915 These three functions can be used to implement associative arrays, count
2916 matching cells, rank results, group data etc.  For practical examples
2917 see @uref{http://orgmode.org/worg/org-tutorials/org-lookups.html, this
2918 tutorial on Worg}.
2920 @node Editing and debugging formulas, Updating the table, Lookup functions, The spreadsheet
2921 @subsection Editing and debugging formulas
2922 @cindex formula editing
2923 @cindex editing, of table formulas
2925 @vindex org-table-use-standard-references
2926 You can edit individual formulas in the minibuffer or directly in the
2927 field.  Org can also prepare a special buffer with all active
2928 formulas of a table.  When offering a formula for editing, Org
2929 converts references to the standard format (like @code{B3} or @code{D&})
2930 if possible.  If you prefer to only work with the internal format (like
2931 @code{@@3$2} or @code{$4}), configure the variable
2932 @code{org-table-use-standard-references}.
2934 @table @kbd
2935 @orgcmdkkc{C-c =,C-u C-c =,org-table-eval-formula}
2936 Edit the formula associated with the current column/field in the
2937 minibuffer.  See @ref{Column formulas}, and @ref{Field and range formulas}.
2938 @orgcmd{C-u C-u C-c =,org-table-eval-formula}
2939 Re-insert the active formula (either a
2940 field formula, or a column formula) into the current field, so that you
2941 can edit it directly in the field.  The advantage over editing in the
2942 minibuffer is that you can use the command @kbd{C-c ?}.
2943 @orgcmd{C-c ?,org-table-field-info}
2944 While editing a formula in a table field, highlight the field(s)
2945 referenced by the reference at the cursor position in the formula.
2946 @kindex C-c @}
2947 @findex org-table-toggle-coordinate-overlays
2948 @item C-c @}
2949 Toggle the display of row and column numbers for a table, using overlays
2950 (@command{org-table-toggle-coordinate-overlays}).  These are updated each
2951 time the table is aligned; you can force it with @kbd{C-c C-c}.
2952 @kindex C-c @{
2953 @findex org-table-toggle-formula-debugger
2954 @item C-c @{
2955 Toggle the formula debugger on and off
2956 (@command{org-table-toggle-formula-debugger}).  See below.
2957 @orgcmd{C-c ',org-table-edit-formulas}
2958 Edit all formulas for the current table in a special buffer, where the
2959 formulas will be displayed one per line.  If the current field has an
2960 active formula, the cursor in the formula editor will mark it.
2961 While inside the special buffer, Org will automatically highlight
2962 any field or range reference at the cursor position.  You may edit,
2963 remove and add formulas, and use the following commands:
2965 @table @kbd
2966 @orgcmdkkc{C-c C-c,C-x C-s,org-table-fedit-finish}
2967 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2968 prefix, also apply the new formulas to the entire table.
2969 @orgcmd{C-c C-q,org-table-fedit-abort}
2970 Exit the formula editor without installing changes.
2971 @orgcmd{C-c C-r,org-table-fedit-toggle-ref-type}
2972 Toggle all references in the formula editor between standard (like
2973 @code{B3}) and internal (like @code{@@3$2}).
2974 @orgcmd{@key{TAB},org-table-fedit-lisp-indent}
2975 Pretty-print or indent Lisp formula at point.  When in a line containing
2976 a Lisp formula, format the formula according to Emacs Lisp rules.
2977 Another @key{TAB} collapses the formula back again.  In the open
2978 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
2979 @orgcmd{M-@key{TAB},lisp-complete-symbol}
2980 Complete Lisp symbols, just like in Emacs Lisp mode.
2981 @kindex S-@key{up}
2982 @kindex S-@key{down}
2983 @kindex S-@key{left}
2984 @kindex S-@key{right}
2985 @findex org-table-fedit-ref-up
2986 @findex org-table-fedit-ref-down
2987 @findex org-table-fedit-ref-left
2988 @findex org-table-fedit-ref-right
2989 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2990 Shift the reference at point.  For example, if the reference is
2991 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2992 This also works for relative references and for hline references.
2993 @orgcmdkkcc{M-S-@key{up},M-S-@key{down},org-table-fedit-line-up,org-table-fedit-line-down}
2994 Move the test line for column formulas in the Org buffer up and
2995 down.
2996 @orgcmdkkcc{M-@key{up},M-@key{down},org-table-fedit-scroll-down,org-table-fedit-scroll-up}
2997 Scroll the window displaying the table.
2998 @kindex C-c @}
2999 @findex org-table-toggle-coordinate-overlays
3000 @item C-c @}
3001 Turn the coordinate grid in the table on and off.
3002 @end table
3003 @end table
3005 Making a table field blank does not remove the formula associated with
3006 the field, because that is stored in a different line (the @samp{#+TBLFM}
3007 line)---during the next recalculation the field will be filled again.
3008 To remove a formula from a field, you have to give an empty reply when
3009 prompted for the formula, or to edit the @samp{#+TBLFM} line.
3011 @kindex C-c C-c
3012 You may edit the @samp{#+TBLFM} directly and re-apply the changed
3013 equations with @kbd{C-c C-c} in that line or with the normal
3014 recalculation commands in the table.
3016 @anchor{Using multiple #+TBLFM lines}
3017 @subsubheading Using multiple #+TBLFM lines
3018 @cindex #+TBLFM line, multiple
3019 @cindex #+TBLFM
3020 @cindex #+TBLFM, switching
3021 @kindex C-c C-c
3023 You may apply the formula temporarily.  This is useful when you
3024 switch the formula.  Place multiple @samp{#+TBLFM} lines right
3025 after the table, and then press @kbd{C-c C-c} on the formula to
3026 apply.  Here is an example:
3028 @example
3029 | x | y |
3030 |---+---|
3031 | 1 |   |
3032 | 2 |   |
3033 #+TBLFM: $2=$1*1
3034 #+TBLFM: $2=$1*2
3035 @end example
3037 @noindent
3038 Pressing @kbd{C-c C-c} in the line of @samp{#+TBLFM: $2=$1*2} yields:
3040 @example
3041 | x | y |
3042 |---+---|
3043 | 1 | 2 |
3044 | 2 | 4 |
3045 #+TBLFM: $2=$1*1
3046 #+TBLFM: $2=$1*2
3047 @end example
3049 @noindent
3050 Note: If you recalculate this table (with @kbd{C-u C-c *}, for example), you
3051 will get the following result of applying only the first @samp{#+TBLFM} line.
3053 @example
3054 | x | y |
3055 |---+---|
3056 | 1 | 1 |
3057 | 2 | 2 |
3058 #+TBLFM: $2=$1*1
3059 #+TBLFM: $2=$1*2
3060 @end example
3062 @subsubheading Debugging formulas
3063 @cindex formula debugging
3064 @cindex debugging, of table formulas
3065 When the evaluation of a formula leads to an error, the field content
3066 becomes the string @samp{#ERROR}.  If you would like see what is going
3067 on during variable substitution and calculation in order to find a bug,
3068 turn on formula debugging in the @code{Tbl} menu and repeat the
3069 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
3070 field.  Detailed information will be displayed.
3072 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
3073 @subsection Updating the table
3074 @cindex recomputing table fields
3075 @cindex updating, table
3077 Recalculation of a table is normally not automatic, but needs to be
3078 triggered by a command.  See @ref{Advanced features}, for a way to make
3079 recalculation at least semi-automatic.
3081 In order to recalculate a line of a table or the entire table, use the
3082 following commands:
3084 @table @kbd
3085 @orgcmd{C-c *,org-table-recalculate}
3086 Recalculate the current row by first applying the stored column formulas
3087 from left to right, and all field/range formulas in the current row.
3089 @kindex C-u C-c *
3090 @item C-u C-c *
3091 @kindex C-u C-c C-c
3092 @itemx C-u C-c C-c
3093 Recompute the entire table, line by line.  Any lines before the first
3094 hline are left alone, assuming that these are part of the table header.
3096 @orgcmdkkc{C-u C-u C-c *,C-u C-u C-c C-c,org-table-iterate}
3097 Iterate the table by recomputing it until no further changes occur.
3098 This may be necessary if some computed fields use the value of other
3099 fields that are computed @i{later} in the calculation sequence.
3100 @item M-x org-table-recalculate-buffer-tables RET
3101 @findex org-table-recalculate-buffer-tables
3102 Recompute all tables in the current buffer.
3103 @item M-x org-table-iterate-buffer-tables RET
3104 @findex org-table-iterate-buffer-tables
3105 Iterate all tables in the current buffer, in order to converge table-to-table
3106 dependencies.
3107 @end table
3109 @node Advanced features,  , Updating the table, The spreadsheet
3110 @subsection Advanced features
3112 If you want the recalculation of fields to happen automatically, or if you
3113 want to be able to assign @i{names}@footnote{Such names must start by an
3114 alphabetic character and use only alphanumeric/underscore characters.} to
3115 fields and columns, you need to reserve the first column of the table for
3116 special marking characters.
3118 @table @kbd
3119 @orgcmd{C-#,org-table-rotate-recalc-marks}
3120 Rotate the calculation mark in first column through the states @samp{ },
3121 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
3122 change all marks in the region.
3123 @end table
3125 Here is an example of a table that collects exam results of students and
3126 makes use of these features:
3128 @example
3129 @group
3130 |---+---------+--------+--------+--------+-------+------|
3131 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
3132 |---+---------+--------+--------+--------+-------+------|
3133 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
3134 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
3135 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
3136 |---+---------+--------+--------+--------+-------+------|
3137 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
3138 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
3139 |---+---------+--------+--------+--------+-------+------|
3140 |   | Average |        |        |        |  25.0 |      |
3141 | ^ |         |        |        |        |    at |      |
3142 | $ | max=50  |        |        |        |       |      |
3143 |---+---------+--------+--------+--------+-------+------|
3144 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
3145 @end group
3146 @end example
3148 @noindent @b{Important}: please note that for these special tables,
3149 recalculating the table with @kbd{C-u C-c *} will only affect rows that
3150 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
3151 to the field itself.  The column formulas are not applied in rows with
3152 empty first field.
3154 @cindex marking characters, tables
3155 The marking characters have the following meaning:
3157 @table @samp
3158 @item !
3159 The fields in this line define names for the columns, so that you may
3160 refer to a column as @samp{$Tot} instead of @samp{$6}.
3161 @item ^
3162 This row defines names for the fields @emph{above} the row.  With such
3163 a definition, any formula in the table may use @samp{$m1} to refer to
3164 the value @samp{10}.  Also, if you assign a formula to a names field, it
3165 will be stored as @samp{$name=...}.
3166 @item _
3167 Similar to @samp{^}, but defines names for the fields in the row
3168 @emph{below}.
3169 @item $
3170 Fields in this row can define @emph{parameters} for formulas.  For
3171 example, if a field in a @samp{$} row contains @samp{max=50}, then
3172 formulas in this table can refer to the value 50 using @samp{$max}.
3173 Parameters work exactly like constants, only that they can be defined on
3174 a per-table basis.
3175 @item #
3176 Fields in this row are automatically recalculated when pressing
3177 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
3178 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
3179 lines will be left alone by this command.
3180 @item *
3181 Selects this line for global recalculation with @kbd{C-u C-c *}, but
3182 not for automatic recalculation.  Use this when automatic
3183 recalculation slows down editing too much.
3184 @item @w{ }
3185 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
3186 All lines that should be recalculated should be marked with @samp{#}
3187 or @samp{*}.
3188 @item /
3189 Do not export this line.  Useful for lines that contain the narrowing
3190 @samp{<N>} markers or column group markers.
3191 @end table
3193 Finally, just to whet your appetite for what can be done with the
3194 fantastic @file{calc.el} package, here is a table that computes the Taylor
3195 series of degree @code{n} at location @code{x} for a couple of
3196 functions.
3198 @example
3199 @group
3200 |---+-------------+---+-----+--------------------------------------|
3201 |   | Func        | n | x   | Result                               |
3202 |---+-------------+---+-----+--------------------------------------|
3203 | # | exp(x)      | 1 | x   | 1 + x                                |
3204 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
3205 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
3206 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
3207 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
3208 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
3209 |---+-------------+---+-----+--------------------------------------|
3210 #+TBLFM: $5=taylor($2,$4,$3);n3
3211 @end group
3212 @end example
3214 @node Org-Plot,  , The spreadsheet, Tables
3215 @section Org-Plot
3216 @cindex graph, in tables
3217 @cindex plot tables using Gnuplot
3218 @cindex #+PLOT
3220 Org-Plot can produce 2D and 3D graphs of information stored in org tables
3221 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
3222 @uref{http://xafs.org/BruceRavel/GnuplotMode}.  To see this in action, ensure
3223 that you have both Gnuplot and Gnuplot mode installed on your system, then
3224 call @code{org-plot/gnuplot} on the following table.
3226 @example
3227 @group
3228 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
3229 | Sede      | Max cites | H-index |
3230 |-----------+-----------+---------|
3231 | Chile     |    257.72 |   21.39 |
3232 | Leeds     |    165.77 |   19.68 |
3233 | Sao Paolo |     71.00 |   11.50 |
3234 | Stockholm |    134.19 |   14.33 |
3235 | Morelia   |    257.56 |   17.67 |
3236 @end group
3237 @end example
3239 Notice that Org Plot is smart enough to apply the table's headers as labels.
3240 Further control over the labels, type, content, and appearance of plots can
3241 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
3242 for a complete list of Org-plot options.  For more information and examples
3243 see the Org-plot tutorial at
3244 @uref{http://orgmode.org/worg/org-tutorials/org-plot.html}.
3246 @subsubheading Plot Options
3248 @table @code
3249 @item set
3250 Specify any @command{gnuplot} option to be set when graphing.
3252 @item title
3253 Specify the title of the plot.
3255 @item ind
3256 Specify which column of the table to use as the @code{x} axis.
3258 @item deps
3259 Specify the columns to graph as a Lisp style list, surrounded by parentheses
3260 and separated by spaces for example @code{dep:(3 4)} to graph the third and
3261 fourth columns (defaults to graphing all other columns aside from the @code{ind}
3262 column).
3264 @item type
3265 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
3267 @item with
3268 Specify a @code{with} option to be inserted for every col being plotted
3269 (e.g., @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
3270 Defaults to @code{lines}.
3272 @item file
3273 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
3275 @item labels
3276 List of labels to be used for the @code{deps} (defaults to the column headers
3277 if they exist).
3279 @item line
3280 Specify an entire line to be inserted in the Gnuplot script.
3282 @item map
3283 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
3284 flat mapping rather than a @code{3d} slope.
3286 @item timefmt
3287 Specify format of Org mode timestamps as they will be parsed by Gnuplot.
3288 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
3290 @item script
3291 If you want total control, you can specify a script file (place the file name
3292 between double-quotes) which will be used to plot.  Before plotting, every
3293 instance of @code{$datafile} in the specified script will be replaced with
3294 the path to the generated data file.  Note: even if you set this option, you
3295 may still want to specify the plot type, as that can impact the content of
3296 the data file.
3297 @end table
3299 @node Hyperlinks, TODO Items, Tables, Top
3300 @chapter Hyperlinks
3301 @cindex hyperlinks
3303 Like HTML, Org provides links inside a file, external links to
3304 other files, Usenet articles, emails, and much more.
3306 @menu
3307 * Link format::                 How links in Org are formatted
3308 * Internal links::              Links to other places in the current file
3309 * External links::              URL-like links to the world
3310 * Handling links::              Creating, inserting and following
3311 * Using links outside Org::     Linking from my C source code?
3312 * Link abbreviations::          Shortcuts for writing complex links
3313 * Search options::              Linking to a specific location
3314 * Custom searches::             When the default search is not enough
3315 @end menu
3317 @node Link format, Internal links, Hyperlinks, Hyperlinks
3318 @section Link format
3319 @cindex link format
3320 @cindex format, of links
3322 Org will recognize plain URL-like links and activate them as
3323 clickable links.  The general link format, however, looks like this:
3325 @example
3326 [[link][description]]       @r{or alternatively}           [[link]]
3327 @end example
3329 @noindent
3330 Once a link in the buffer is complete (all brackets present), Org
3331 will change the display so that @samp{description} is displayed instead
3332 of @samp{[[link][description]]} and @samp{link} is displayed instead of
3333 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
3334 which by default is an underlined face.  You can directly edit the
3335 visible part of a link.  Note that this can be either the @samp{link}
3336 part (if there is no description) or the @samp{description} part.  To
3337 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
3338 cursor on the link.
3340 If you place the cursor at the beginning or just behind the end of the
3341 displayed text and press @key{BACKSPACE}, you will remove the
3342 (invisible) bracket at that location.  This makes the link incomplete
3343 and the internals are again displayed as plain text.  Inserting the
3344 missing bracket hides the link internals again.  To show the
3345 internal structure of all links, use the menu entry
3346 @code{Org->Hyperlinks->Literal links}.
3348 @node Internal links, External links, Link format, Hyperlinks
3349 @section Internal links
3350 @cindex internal links
3351 @cindex links, internal
3352 @cindex targets, for links
3354 @cindex property, CUSTOM_ID
3355 If the link does not look like a URL, it is considered to be internal in the
3356 current file.  The most important case is a link like
3357 @samp{[[#my-custom-id]]} which will link to the entry with the
3358 @code{CUSTOM_ID} property @samp{my-custom-id}.  You are responsible yourself
3359 to make sure these custom IDs are unique in a file.
3361 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
3362 lead to a text search in the current file.
3364 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
3365 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
3366 point to the corresponding headline.  The preferred match for a text link is
3367 a @i{dedicated target}: the same string in double angular brackets, like
3368 @samp{<<My Target>>}.
3370 @cindex #+NAME
3371 If no dedicated target exists, the link will then try to match the exact name
3372 of an element within the buffer.  Naming is done with the @code{#+NAME}
3373 keyword, which has to be put the line before the element it refers to, as in
3374 the following example
3376 @example
3377 #+NAME: My Target
3378 | a  | table      |
3379 |----+------------|
3380 | of | four cells |
3381 @end example
3383 If none of the above succeeds, Org will search for a headline that is exactly
3384 the link text but may also include a TODO keyword and tags@footnote{To insert
3385 a link targeting a headline, in-buffer completion can be used.  Just type
3386 a star followed by a few optional letters into the buffer and press
3387 @kbd{M-@key{TAB}}.  All headlines in the current buffer will be offered as
3388 completions.}.
3390 During export, internal links will be used to mark objects and assign them
3391 a number.  Marked objects will then be referenced by links pointing to them.
3392 In particular, links without a description will appear as the number assigned
3393 to the marked object@footnote{When targeting a @code{#+NAME} keyword,
3394 @code{#+CAPTION} keyword is mandatory in order to get proper numbering
3395 (@pxref{Images and tables}).}.  In the following excerpt from an Org buffer
3397 @example
3398 - one item
3399 - <<target>>another item
3400 Here we refer to item [[target]].
3401 @end example
3403 @noindent
3404 The last sentence will appear as @samp{Here we refer to item 2} when
3405 exported.
3407 In non-Org files, the search will look for the words in the link text.  In
3408 the above example the search would be for @samp{my target}.
3410 Following a link pushes a mark onto Org's own mark ring.  You can
3411 return to the previous position with @kbd{C-c &}.  Using this command
3412 several times in direct succession goes back to positions recorded
3413 earlier.
3415 @menu
3416 * Radio targets::               Make targets trigger links in plain text
3417 @end menu
3419 @node Radio targets,  , Internal links, Internal links
3420 @subsection Radio targets
3421 @cindex radio targets
3422 @cindex targets, radio
3423 @cindex links, radio targets
3425 Org can automatically turn any occurrences of certain target names
3426 in normal text into a link.  So without explicitly creating a link, the
3427 text connects to the target radioing its position.  Radio targets are
3428 enclosed by triple angular brackets.  For example, a target @samp{<<<My
3429 Target>>>} causes each occurrence of @samp{my target} in normal text to
3430 become activated as a link.  The Org file is scanned automatically
3431 for radio targets only when the file is first loaded into Emacs.  To
3432 update the target list during editing, press @kbd{C-c C-c} with the
3433 cursor on or at a target.
3435 @node External links, Handling links, Internal links, Hyperlinks
3436 @section External links
3437 @cindex links, external
3438 @cindex external links
3439 @cindex links, external
3440 @cindex Gnus links
3441 @cindex BBDB links
3442 @cindex IRC links
3443 @cindex URL links
3444 @cindex file links
3445 @cindex VM links
3446 @cindex RMAIL links
3447 @cindex WANDERLUST links
3448 @cindex MH-E links
3449 @cindex USENET links
3450 @cindex SHELL links
3451 @cindex Info links
3452 @cindex Elisp links
3454 Org supports links to files, websites, Usenet and email messages,
3455 BBDB database entries and links to both IRC conversations and their
3456 logs.  External links are URL-like locators.  They start with a short
3457 identifying string followed by a colon.  There can be no space after
3458 the colon.  The following list shows examples for each link type.
3460 @example
3461 http://www.astro.uva.nl/~dominik          @r{on the web}
3462 doi:10.1000/182                           @r{DOI for an electronic resource}
3463 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
3464 /home/dominik/images/jupiter.jpg          @r{same as above}
3465 file:papers/last.pdf                      @r{file, relative path}
3466 ./papers/last.pdf                         @r{same as above}
3467 file:/myself@@some.where:papers/last.pdf   @r{file, path on remote machine}
3468 /myself@@some.where:papers/last.pdf        @r{same as above}
3469 file:sometextfile::NNN                    @r{file, jump to line number}
3470 file:projects.org                         @r{another Org file}
3471 file:projects.org::some words             @r{text search in Org file}@footnote{
3472 The actual behavior of the search will depend on the value of
3473 the variable @code{org-link-search-must-match-exact-headline}.  If its value
3474 is nil, then a fuzzy text search will be done.  If it is t, then only the
3475 exact headline will be matched.  If the value is @code{'query-to-create},
3476 then an exact headline will be searched; if it is not found, then the user
3477 will be queried to create it.}
3478 file:projects.org::*task title            @r{heading search in Org file}
3479 file+sys:/path/to/file                    @r{open via OS, like double-click}
3480 file+emacs:/path/to/file                  @r{force opening by Emacs}
3481 docview:papers/last.pdf::NNN              @r{open in doc-view mode at page}
3482 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
3483 news:comp.emacs                           @r{Usenet link}
3484 mailto:adent@@galaxy.net                   @r{Mail link}
3485 vm:folder                                 @r{VM folder link}
3486 vm:folder#id                              @r{VM message link}
3487 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
3488 vm-imap:account:folder                    @r{VM IMAP folder link}
3489 vm-imap:account:folder#id                 @r{VM IMAP message link}
3490 wl:folder                                 @r{WANDERLUST folder link}
3491 wl:folder#id                              @r{WANDERLUST message link}
3492 mhe:folder                                @r{MH-E folder link}
3493 mhe:folder#id                             @r{MH-E message link}
3494 rmail:folder                              @r{RMAIL folder link}
3495 rmail:folder#id                           @r{RMAIL message link}
3496 gnus:group                                @r{Gnus group link}
3497 gnus:group#id                             @r{Gnus article link}
3498 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
3499 irc:/irc.com/#emacs/bob                   @r{IRC link}
3500 info:org#External links                   @r{Info node link}
3501 shell:ls *.org                            @r{A shell command}
3502 elisp:org-agenda                          @r{Interactive Elisp command}
3503 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
3504 @end example
3506 For customizing Org to add new link types @ref{Adding hyperlink types}.
3508 A link should be enclosed in double brackets and may contain a
3509 descriptive text to be displayed instead of the URL (@pxref{Link
3510 format}), for example:
3512 @example
3513 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3514 @end example
3516 @noindent
3517 If the description is a file name or URL that points to an image, HTML
3518 export (@pxref{HTML export}) will inline the image as a clickable
3519 button.  If there is no description at all and the link points to an
3520 image,
3521 that image will be inlined into the exported HTML file.
3523 @cindex square brackets, around links
3524 @cindex plain text external links
3525 Org also finds external links in the normal text and activates them
3526 as links.  If spaces must be part of the link (for example in
3527 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
3528 about the end of the link, enclose them in square brackets.
3530 @node Handling links, Using links outside Org, External links, Hyperlinks
3531 @section Handling links
3532 @cindex links, handling
3534 Org provides methods to create a link in the correct syntax, to
3535 insert it into an Org file, and to follow the link.
3537 @table @kbd
3538 @orgcmd{C-c l,org-store-link}
3539 @cindex storing links
3540 Store a link to the current location.  This is a @emph{global} command (you
3541 must create the key binding yourself) which can be used in any buffer to
3542 create a link.  The link will be stored for later insertion into an Org
3543 buffer (see below).  What kind of link will be created depends on the current
3544 buffer:
3546 @b{Org mode buffers}@*
3547 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
3548 to the target.  Otherwise it points to the current headline, which will also
3549 be the description@footnote{If the headline contains a timestamp, it will be
3550 removed from the link and result in a wrong link---you should avoid putting
3551 timestamp in the headline.}.
3553 @vindex org-id-link-to-org-use-id
3554 @cindex property, CUSTOM_ID
3555 @cindex property, ID
3556 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
3557 will be stored.  In addition or alternatively (depending on the value of
3558 @code{org-id-link-to-org-use-id}), a globally unique @code{ID} property will
3559 be created and/or used to construct a link@footnote{The library @code{org-id}
3560 must first be loaded, either through @code{org-customize} by enabling
3561 @code{id} in @code{org-modules} , or by adding @code{(require 'org-id)} in
3562 your @file{.emacs}.}. So using this command in Org
3563 buffers will potentially create two links: a human-readable from the custom
3564 ID, and one that is globally unique and works even if the entry is moved from
3565 file to file.  Later, when inserting the link, you need to decide which one
3566 to use.
3568 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
3569 Pretty much all Emacs mail clients are supported.  The link will point to the
3570 current article, or, in some GNUS buffers, to the group.  The description is
3571 constructed from the author and the subject.
3573 @b{Web browsers: W3 and W3M}@*
3574 Here the link will be the current URL, with the page title as description.
3576 @b{Contacts: BBDB}@*
3577 Links created in a BBDB buffer will point to the current entry.
3579 @b{Chat: IRC}@*
3580 @vindex org-irc-link-to-logs
3581 For IRC links, if you set the variable @code{org-irc-link-to-logs} to
3582 @code{t}, a @samp{file:/} style link to the relevant point in the logs for
3583 the current conversation is created.  Otherwise an @samp{irc:/} style link to
3584 the user/channel/server under the point will be stored.
3586 @b{Other files}@*
3587 For any other files, the link will point to the file, with a search string
3588 (@pxref{Search options}) pointing to the contents of the current line.  If
3589 there is an active region, the selected words will form the basis of the
3590 search string.  If the automatically created link is not working correctly or
3591 accurately enough, you can write custom functions to select the search string
3592 and to do the search for particular file types---see @ref{Custom searches}.
3593 The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
3595 @b{Agenda view}@*
3596 When the cursor is in an agenda view, the created link points to the
3597 entry referenced by the current line.
3600 @orgcmd{C-c C-l,org-insert-link}
3601 @cindex link completion
3602 @cindex completion, of links
3603 @cindex inserting links
3604 @vindex org-keep-stored-link-after-insertion
3605 Insert a link@footnote{ Note that you don't have to use this command to
3606 insert a link.  Links in Org are plain text, and you can type or paste them
3607 straight into the buffer.  By using this command, the links are automatically
3608 enclosed in double brackets, and you will be asked for the optional
3609 descriptive text.}.  This prompts for a link to be inserted into the buffer.
3610 You can just type a link, using text for an internal link, or one of the link
3611 type prefixes mentioned in the examples above.  The link will be inserted
3612 into the buffer@footnote{After insertion of a stored link, the link will be
3613 removed from the list of stored links.  To keep it in the list later use, use
3614 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
3615 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
3616 If some text was selected when this command is called, the selected text
3617 becomes the default description.
3619 @b{Inserting stored links}@*
3620 All links stored during the
3621 current session are part of the history for this prompt, so you can access
3622 them with @key{up} and @key{down} (or @kbd{M-p/n}).
3624 @b{Completion support}@* Completion with @key{TAB} will help you to insert
3625 valid link prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
3626 defined through link abbreviations (@pxref{Link abbreviations}).  If you
3627 press @key{RET} after inserting only the @var{prefix}, Org will offer
3628 specific completion support for some link types@footnote{This works by
3629 calling a special function @code{org-PREFIX-complete-link}.}  For
3630 example, if you type @kbd{file @key{RET}}, file name completion (alternative
3631 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
3632 @key{RET}} you can complete contact names.
3633 @orgkey C-u C-c C-l
3634 @cindex file name completion
3635 @cindex completion, of file names
3636 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
3637 a file will be inserted and you may use file name completion to select
3638 the name of the file.  The path to the file is inserted relative to the
3639 directory of the current Org file, if the linked file is in the current
3640 directory or in a sub-directory of it, or if the path is written relative
3641 to the current directory using @samp{../}.  Otherwise an absolute path
3642 is used, if possible with @samp{~/} for your home directory.  You can
3643 force an absolute path with two @kbd{C-u} prefixes.
3645 @item C-c C-l @ @r{(with cursor on existing link)}
3646 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
3647 link and description parts of the link.
3649 @cindex following links
3650 @orgcmd{C-c C-o,org-open-at-point}
3651 @vindex org-file-apps
3652 @vindex org-link-frame-setup
3653 Open link at point.  This will launch a web browser for URLs (using
3654 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
3655 the corresponding links, and execute the command in a shell link.  When the
3656 cursor is on an internal link, this command runs the corresponding search.
3657 When the cursor is on a TAG list in a headline, it creates the corresponding
3658 TAGS view.  If the cursor is on a timestamp, it compiles the agenda for that
3659 date.  Furthermore, it will visit text and remote files in @samp{file:} links
3660 with Emacs and select a suitable application for local non-text files.
3661 Classification of files is based on file extension only.  See option
3662 @code{org-file-apps}.  If you want to override the default application and
3663 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
3664 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
3665 If the cursor is on a headline, but not on a link, offer all links in the
3666 headline and entry text.  If you want to setup the frame configuration for
3667 following links, customize @code{org-link-frame-setup}.
3669 @orgkey @key{RET}
3670 @vindex org-return-follows-link
3671 When @code{org-return-follows-link} is set, @kbd{@key{RET}} will also follow
3672 the link at point.
3674 @kindex mouse-2
3675 @kindex mouse-1
3676 @item mouse-2
3677 @itemx mouse-1
3678 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
3679 would.  Under Emacs 22 and later, @kbd{mouse-1} will also follow a link.
3681 @kindex mouse-3
3682 @item mouse-3
3683 @vindex org-display-internal-link-with-indirect-buffer
3684 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
3685 internal links to be displayed in another window@footnote{See the
3686 variable @code{org-display-internal-link-with-indirect-buffer}}.
3688 @orgcmd{C-c C-x C-v,org-toggle-inline-images}
3689 @cindex inlining images
3690 @cindex images, inlining
3691 @vindex org-startup-with-inline-images
3692 @cindex @code{inlineimages}, STARTUP keyword
3693 @cindex @code{noinlineimages}, STARTUP keyword
3694 Toggle the inline display of linked images.  Normally this will only inline
3695 images that have no description part in the link, i.e., images that will also
3696 be inlined during export.  When called with a prefix argument, also display
3697 images that do have a link description.  You can ask for inline images to be
3698 displayed at startup by configuring the variable
3699 @code{org-startup-with-inline-images}@footnote{with corresponding
3700 @code{#+STARTUP} keywords @code{inlineimages} and @code{inlineimages}}.
3701 @orgcmd{C-c %,org-mark-ring-push}
3702 @cindex mark ring
3703 Push the current position onto the mark ring, to be able to return
3704 easily.  Commands following an internal link do this automatically.
3706 @orgcmd{C-c &,org-mark-ring-goto}
3707 @cindex links, returning to
3708 Jump back to a recorded position.  A position is recorded by the
3709 commands following internal links, and by @kbd{C-c %}.  Using this
3710 command several times in direct succession moves through a ring of
3711 previously recorded positions.
3713 @orgcmdkkcc{C-c C-x C-n,C-c C-x C-p,org-next-link,org-previous-link}
3714 @cindex links, finding next/previous
3715 Move forward/backward to the next link in the buffer.  At the limit of
3716 the buffer, the search fails once, and then wraps around.  The key
3717 bindings for this are really too long; you might want to bind this also
3718 to @kbd{C-n} and @kbd{C-p}
3719 @lisp
3720 (add-hook 'org-load-hook
3721   (lambda ()
3722     (define-key org-mode-map "\C-n" 'org-next-link)
3723     (define-key org-mode-map "\C-p" 'org-previous-link)))
3724 @end lisp
3725 @end table
3727 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
3728 @section Using links outside Org
3730 You can insert and follow links that have Org syntax not only in
3731 Org, but in any Emacs buffer.  For this, you should create two
3732 global commands, like this (please select suitable global keys
3733 yourself):
3735 @lisp
3736 (global-set-key "\C-c L" 'org-insert-link-global)
3737 (global-set-key "\C-c o" 'org-open-at-point-global)
3738 @end lisp
3740 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
3741 @section Link abbreviations
3742 @cindex link abbreviations
3743 @cindex abbreviation, links
3745 Long URLs can be cumbersome to type, and often many similar links are
3746 needed in a document.  For this you can use link abbreviations.  An
3747 abbreviated link looks like this
3749 @example
3750 [[linkword:tag][description]]
3751 @end example
3753 @noindent
3754 @vindex org-link-abbrev-alist
3755 where the tag is optional.
3756 The @i{linkword} must be a word, starting with a letter, followed by
3757 letters, numbers, @samp{-}, and @samp{_}.  Abbreviations are resolved
3758 according to the information in the variable @code{org-link-abbrev-alist}
3759 that relates the linkwords to replacement text.  Here is an example:
3761 @smalllisp
3762 @group
3763 (setq org-link-abbrev-alist
3764   '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3765     ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
3766     ("google"    . "http://www.google.com/search?q=")
3767     ("gmap"      . "http://maps.google.com/maps?q=%s")
3768     ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
3769     ("ads"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
3770 @end group
3771 @end smalllisp
3773 If the replacement text contains the string @samp{%s}, it will be
3774 replaced with the tag.  Using @samp{%h} instead of @samp{%s} will
3775 url-encode the tag (see the example above, where we need to encode
3776 the URL parameter.)  Using @samp{%(my-function)} will pass the tag
3777 to a custom function, and replace it by the resulting string.
3779 If the replacement text don't contain any specifier, it will simply
3780 be appended to the string in order to create the link.
3782 Instead of a string, you may also specify a function that will be
3783 called with the tag as the only argument to create the link.
3785 With the above setting, you could link to a specific bug with
3786 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
3787 @code{[[google:OrgMode]]}, show the map location of the Free Software
3788 Foundation @code{[[gmap:51 Franklin Street, Boston]]} or of Carsten office
3789 @code{[[omap:Science Park 904, Amsterdam, The Netherlands]]} and find out
3790 what the Org author is doing besides Emacs hacking with
3791 @code{[[ads:Dominik,C]]}.
3793 If you need special abbreviations just for a single Org buffer, you
3794 can define them in the file with
3796 @cindex #+LINK
3797 @example
3798 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3799 #+LINK: google    http://www.google.com/search?q=%s
3800 @end example
3802 @noindent
3803 In-buffer completion (@pxref{Completion}) can be used after @samp{[} to
3804 complete link abbreviations.  You may also define a function
3805 @code{org-PREFIX-complete-link} that implements special (e.g., completion)
3806 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
3807 not accept any arguments, and return the full link with prefix.
3809 @node Search options, Custom searches, Link abbreviations, Hyperlinks
3810 @section Search options in file links
3811 @cindex search option in file links
3812 @cindex file links, searching
3814 File links can contain additional information to make Emacs jump to a
3815 particular location in the file when following a link.  This can be a
3816 line number or a search option after a double@footnote{For backward
3817 compatibility, line numbers can also follow a single colon.} colon.  For
3818 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
3819 links}) to a file, it encodes the words in the current line as a search
3820 string that can be used to find this line back later when following the
3821 link with @kbd{C-c C-o}.
3823 Here is the syntax of the different ways to attach a search to a file
3824 link, together with an explanation:
3826 @example
3827 [[file:~/code/main.c::255]]
3828 [[file:~/xx.org::My Target]]
3829 [[file:~/xx.org::*My Target]]
3830 [[file:~/xx.org::#my-custom-id]]
3831 [[file:~/xx.org::/regexp/]]
3832 @end example
3834 @table @code
3835 @item 255
3836 Jump to line 255.
3837 @item My Target
3838 Search for a link target @samp{<<My Target>>}, or do a text search for
3839 @samp{my target}, similar to the search in internal links, see
3840 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3841 link will become a HTML reference to the corresponding named anchor in
3842 the linked file.
3843 @item *My Target
3844 In an Org file, restrict search to headlines.
3845 @item #my-custom-id
3846 Link to a heading with a @code{CUSTOM_ID} property
3847 @item /regexp/
3848 Do a regular expression search for @code{regexp}.  This uses the Emacs
3849 command @code{occur} to list all matches in a separate window.  If the
3850 target file is in Org mode, @code{org-occur} is used to create a
3851 sparse tree with the matches.
3852 @c If the target file is a directory,
3853 @c @code{grep} will be used to search all files in the directory.
3854 @end table
3856 As a degenerate case, a file link with an empty file name can be used
3857 to search the current file.  For example, @code{[[file:::find me]]} does
3858 a search for @samp{find me} in the current file, just as
3859 @samp{[[find me]]} would.
3861 @node Custom searches,  , Search options, Hyperlinks
3862 @section Custom Searches
3863 @cindex custom search strings
3864 @cindex search strings, custom
3866 The default mechanism for creating search strings and for doing the
3867 actual search related to a file link may not work correctly in all
3868 cases.  For example, Bib@TeX{} database files have many entries like
3869 @samp{year="1993"} which would not result in good search strings,
3870 because the only unique identification for a Bib@TeX{} entry is the
3871 citation key.
3873 @vindex org-create-file-search-functions
3874 @vindex org-execute-file-search-functions
3875 If you come across such a problem, you can write custom functions to set
3876 the right search string for a particular file type, and to do the search
3877 for the string in the file.  Using @code{add-hook}, these functions need
3878 to be added to the hook variables
3879 @code{org-create-file-search-functions} and
3880 @code{org-execute-file-search-functions}.  See the docstring for these
3881 variables for more information.  Org actually uses this mechanism
3882 for Bib@TeX{} database files, and you can use the corresponding code as
3883 an implementation example.  See the file @file{org-bibtex.el}.
3885 @node TODO Items, Tags, Hyperlinks, Top
3886 @chapter TODO items
3887 @cindex TODO items
3889 Org mode does not maintain TODO lists as separate documents@footnote{Of
3890 course, you can make a document that contains only long lists of TODO items,
3891 but this is not required.}.  Instead, TODO items are an integral part of the
3892 notes file, because TODO items usually come up while taking notes!  With Org
3893 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3894 information is not duplicated, and the entire context from which the TODO
3895 item emerged is always present.
3897 Of course, this technique for managing TODO items scatters them
3898 throughout your notes file.  Org mode compensates for this by providing
3899 methods to give you an overview of all the things that you have to do.
3901 @menu
3902 * TODO basics::                 Marking and displaying TODO entries
3903 * TODO extensions::             Workflow and assignments
3904 * Progress logging::            Dates and notes for progress
3905 * Priorities::                  Some things are more important than others
3906 * Breaking down tasks::         Splitting a task into manageable pieces
3907 * Checkboxes::                  Tick-off lists
3908 @end menu
3910 @node TODO basics, TODO extensions, TODO Items, TODO Items
3911 @section Basic TODO functionality
3913 Any headline becomes a TODO item when it starts with the word
3914 @samp{TODO}, for example:
3916 @example
3917 *** TODO Write letter to Sam Fortune
3918 @end example
3920 @noindent
3921 The most important commands to work with TODO entries are:
3923 @table @kbd
3924 @orgcmd{C-c C-t,org-todo}
3925 @cindex cycling, of TODO states
3926 @vindex org-use-fast-todo-selection
3928 Rotate the TODO state of the current item among
3930 @example
3931 ,-> (unmarked) -> TODO -> DONE --.
3932 '--------------------------------'
3933 @end example
3935 If TODO keywords have fast access keys (see @ref{Fast access to TODO
3936 states}), you will be prompted for a TODO keyword through the fast selection
3937 interface; this is the default behavior when
3938 @var{org-use-fast-todo-selection} is non-nil.
3940 The same rotation can also be done ``remotely'' from the timeline and agenda
3941 buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3943 @orgkey{C-u C-c C-t}
3944 When TODO keywords have no selection keys, select a specific keyword using
3945 completion; otherwise force cycling through TODO states with no prompt.  When
3946 @var{org-use-fast-todo-selection} is set to @code{prefix}, use the fast
3947 selection interface.
3949 @kindex S-@key{right}
3950 @kindex S-@key{left}
3951 @item S-@key{right} @ @r{/} @ S-@key{left}
3952 @vindex org-treat-S-cursor-todo-selection-as-state-change
3953 Select the following/preceding TODO state, similar to cycling.  Useful
3954 mostly if more than two TODO states are possible (@pxref{TODO
3955 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
3956 with @code{shift-selection-mode}.  See also the variable
3957 @code{org-treat-S-cursor-todo-selection-as-state-change}.
3958 @orgcmd{C-c / t,org-show-todo-tree}
3959 @cindex sparse tree, for TODO
3960 @vindex org-todo-keywords
3961 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3962 entire buffer, but shows all TODO items (with not-DONE state) and the
3963 headings hierarchy above them.  With a prefix argument (or by using @kbd{C-c
3964 / T}), search for a specific TODO@.  You will be prompted for the keyword, and
3965 you can also give a list of keywords like @code{KWD1|KWD2|...} to list
3966 entries that match any one of these keywords.  With a numeric prefix argument
3967 N, show the tree for the Nth keyword in the variable
3968 @code{org-todo-keywords}.  With two prefix arguments, find all TODO states,
3969 both un-done and done.
3970 @orgcmd{C-c a t,org-todo-list}
3971 Show the global TODO list.  Collects the TODO items (with not-DONE states)
3972 from all agenda files (@pxref{Agenda Views}) into a single buffer.  The new
3973 buffer will be in @code{agenda-mode}, which provides commands to examine and
3974 manipulate the TODO entries from the new buffer (@pxref{Agenda commands}).
3975 @xref{Global TODO list}, for more information.
3976 @orgcmd{S-M-@key{RET},org-insert-todo-heading}
3977 Insert a new TODO entry below the current one.
3978 @end table
3980 @noindent
3981 @vindex org-todo-state-tags-triggers
3982 Changing a TODO state can also trigger tag changes.  See the docstring of the
3983 option @code{org-todo-state-tags-triggers} for details.
3985 @node TODO extensions, Progress logging, TODO basics, TODO Items
3986 @section Extended use of TODO keywords
3987 @cindex extended TODO keywords
3989 @vindex org-todo-keywords
3990 By default, marked TODO entries have one of only two states: TODO and
3991 DONE@.  Org mode allows you to classify TODO items in more complex ways
3992 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3993 special setup, the TODO keyword system can work differently in different
3994 files.
3996 Note that @i{tags} are another way to classify headlines in general and
3997 TODO items in particular (@pxref{Tags}).
3999 @menu
4000 * Workflow states::             From TODO to DONE in steps
4001 * TODO types::                  I do this, Fred does the rest
4002 * Multiple sets in one file::   Mixing it all, and still finding your way
4003 * Fast access to TODO states::  Single letter selection of a state
4004 * Per-file keywords::           Different files, different requirements
4005 * Faces for TODO keywords::     Highlighting states
4006 * TODO dependencies::           When one task needs to wait for others
4007 @end menu
4009 @node Workflow states, TODO types, TODO extensions, TODO extensions
4010 @subsection TODO keywords as workflow states
4011 @cindex TODO workflow
4012 @cindex workflow states as TODO keywords
4014 You can use TODO keywords to indicate different @emph{sequential} states
4015 in the process of working on an item, for example@footnote{Changing
4016 this variable only becomes effective after restarting Org mode in a
4017 buffer.}:
4019 @lisp
4020 (setq org-todo-keywords
4021   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
4022 @end lisp
4024 The vertical bar separates the TODO keywords (states that @emph{need
4025 action}) from the DONE states (which need @emph{no further action}).  If
4026 you don't provide the separator bar, the last state is used as the DONE
4027 state.
4028 @cindex completion, of TODO keywords
4029 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
4030 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED@.  You may
4031 also use a numeric prefix argument to quickly select a specific state.  For
4032 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY@.
4033 Or you can use @kbd{S-@key{left}} to go backward through the sequence.  If you
4034 define many keywords, you can use in-buffer completion
4035 (@pxref{Completion}) or even a special one-key selection scheme
4036 (@pxref{Fast access to TODO states}) to insert these words into the
4037 buffer.  Changing a TODO state can be logged with a timestamp, see
4038 @ref{Tracking TODO state changes}, for more information.
4040 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
4041 @subsection TODO keywords as types
4042 @cindex TODO types
4043 @cindex names as TODO keywords
4044 @cindex types as TODO keywords
4046 The second possibility is to use TODO keywords to indicate different
4047 @emph{types} of action items.  For example, you might want to indicate
4048 that items are for ``work'' or ``home''.  Or, when you work with several
4049 people on a single project, you might want to assign action items
4050 directly to persons, by using their names as TODO keywords.  This would
4051 be set up like this:
4053 @lisp
4054 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
4055 @end lisp
4057 In this case, different keywords do not indicate a sequence, but rather
4058 different types.  So the normal work flow would be to assign a task to a
4059 person, and later to mark it DONE@.  Org mode supports this style by adapting
4060 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
4061 @kbd{t} command in the timeline and agenda buffers.}.  When used several
4062 times in succession, it will still cycle through all names, in order to first
4063 select the right type for a task.  But when you return to the item after some
4064 time and execute @kbd{C-c C-t} again, it will switch from any name directly
4065 to DONE@.  Use prefix arguments or completion to quickly select a specific
4066 name.  You can also review the items of a specific TODO type in a sparse tree
4067 by using a numeric prefix to @kbd{C-c / t}.  For example, to see all things
4068 Lucy has to do, you would use @kbd{C-3 C-c / t}.  To collect Lucy's items
4069 from all agenda files into a single buffer, you would use the numeric prefix
4070 argument as well when creating the global TODO list: @kbd{C-3 C-c a t}.
4072 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
4073 @subsection Multiple keyword sets in one file
4074 @cindex TODO keyword sets
4076 Sometimes you may want to use different sets of TODO keywords in
4077 parallel.  For example, you may want to have the basic
4078 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
4079 separate state indicating that an item has been canceled (so it is not
4080 DONE, but also does not require action).  Your setup would then look
4081 like this:
4083 @lisp
4084 (setq org-todo-keywords
4085       '((sequence "TODO" "|" "DONE")
4086         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
4087         (sequence "|" "CANCELED")))
4088 @end lisp
4090 The keywords should all be different, this helps Org mode to keep track
4091 of which subsequence should be used for a given entry.  In this setup,
4092 @kbd{C-c C-t} only operates within a subsequence, so it switches from
4093 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
4094 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
4095 select the correct sequence.  Besides the obvious ways like typing a
4096 keyword or using completion, you may also apply the following commands:
4098 @table @kbd
4099 @kindex C-S-@key{right}
4100 @kindex C-S-@key{left}
4101 @kindex C-u C-u C-c C-t
4102 @item C-u C-u C-c C-t
4103 @itemx C-S-@key{right}
4104 @itemx C-S-@key{left}
4105 These keys jump from one TODO subset to the next.  In the above example,
4106 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
4107 @code{DONE} to @code{REPORT}, and any of the words in the second row to
4108 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
4109 @code{shift-selection-mode} (@pxref{Conflicts}).
4110 @kindex S-@key{right}
4111 @kindex S-@key{left}
4112 @item S-@key{right}
4113 @itemx S-@key{left}
4114 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
4115 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
4116 from @code{DONE} to @code{REPORT} in the example above.  See also
4117 @ref{Conflicts}, for a discussion of the interaction with
4118 @code{shift-selection-mode}.
4119 @end table
4121 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
4122 @subsection Fast access to TODO states
4124 If you would like to quickly change an entry to an arbitrary TODO state
4125 instead of cycling through the states, you can set up keys for single-letter
4126 access to the states.  This is done by adding the selection character after
4127 each keyword, in parentheses@footnote{All characters are allowed except
4128 @code{@@^!}, which have a special meaning here.}.  For example:
4130 @lisp
4131 (setq org-todo-keywords
4132       '((sequence "TODO(t)" "|" "DONE(d)")
4133         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
4134         (sequence "|" "CANCELED(c)")))
4135 @end lisp
4137 @vindex org-fast-tag-selection-include-todo
4138 If you then press @kbd{C-c C-t} followed by the selection key, the entry
4139 will be switched to this state.  @kbd{SPC} can be used to remove any TODO
4140 keyword from an entry.@footnote{Check also the variable
4141 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
4142 state through the tags interface (@pxref{Setting tags}), in case you like to
4143 mingle the two concepts.  Note that this means you need to come up with
4144 unique keys across both sets of keywords.}
4146 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
4147 @subsection Setting up keywords for individual files
4148 @cindex keyword options
4149 @cindex per-file keywords
4150 @cindex #+TODO
4151 @cindex #+TYP_TODO
4152 @cindex #+SEQ_TODO
4154 It can be very useful to use different aspects of the TODO mechanism in
4155 different files.  For file-local settings, you need to add special lines
4156 to the file which set the keywords and interpretation for that file
4157 only.  For example, to set one of the two examples discussed above, you
4158 need one of the following lines, starting in column zero anywhere in the
4159 file:
4161 @example
4162 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
4163 @end example
4164 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
4165 interpretation, but it means the same as @code{#+TODO}), or
4166 @example
4167 #+TYP_TODO: Fred Sara Lucy Mike | DONE
4168 @end example
4170 A setup for using several sets in parallel would be:
4172 @example
4173 #+TODO: TODO | DONE
4174 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
4175 #+TODO: | CANCELED
4176 @end example
4178 @cindex completion, of option keywords
4179 @kindex M-@key{TAB}
4180 @noindent To make sure you are using the correct keyword, type
4181 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
4183 @cindex DONE, final TODO keyword
4184 Remember that the keywords after the vertical bar (or the last keyword
4185 if no bar is there) must always mean that the item is DONE (although you
4186 may use a different word).  After changing one of these lines, use
4187 @kbd{C-c C-c} with the cursor still in the line to make the changes
4188 known to Org mode@footnote{Org mode parses these lines only when
4189 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
4190 cursor in a line starting with @samp{#+} is simply restarting Org mode
4191 for the current buffer.}.
4193 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
4194 @subsection Faces for TODO keywords
4195 @cindex faces, for TODO keywords
4197 @vindex org-todo @r{(face)}
4198 @vindex org-done @r{(face)}
4199 @vindex org-todo-keyword-faces
4200 Org mode highlights TODO keywords with special faces: @code{org-todo}
4201 for keywords indicating that an item still has to be acted upon, and
4202 @code{org-done} for keywords indicating that an item is finished.  If
4203 you are using more than 2 different states, you might want to use
4204 special faces for some of them.  This can be done using the variable
4205 @code{org-todo-keyword-faces}.  For example:
4207 @lisp
4208 @group
4209 (setq org-todo-keyword-faces
4210       '(("TODO" . org-warning) ("STARTED" . "yellow")
4211         ("CANCELED" . (:foreground "blue" :weight bold))))
4212 @end group
4213 @end lisp
4215 While using a list with face properties as shown for CANCELED @emph{should}
4216 work, this does not always seem to be the case.  If necessary, define a
4217 special face and use that.  A string is interpreted as a color.  The variable
4218 @code{org-faces-easy-properties} determines if that color is interpreted as a
4219 foreground or a background color.
4221 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
4222 @subsection TODO dependencies
4223 @cindex TODO dependencies
4224 @cindex dependencies, of TODO states
4226 @vindex org-enforce-todo-dependencies
4227 @cindex property, ORDERED
4228 The structure of Org files (hierarchy and lists) makes it easy to define TODO
4229 dependencies.  Usually, a parent TODO task should not be marked DONE until
4230 all subtasks (defined as children tasks) are marked as DONE@.  And sometimes
4231 there is a logical sequence to a number of (sub)tasks, so that one task
4232 cannot be acted upon before all siblings above it are done.  If you customize
4233 the variable @code{org-enforce-todo-dependencies}, Org will block entries
4234 from changing state to DONE while they have children that are not DONE@.
4235 Furthermore, if an entry has a property @code{ORDERED}, each of its children
4236 will be blocked until all earlier siblings are marked DONE@.  Here is an
4237 example:
4239 @example
4240 * TODO Blocked until (two) is done
4241 ** DONE one
4242 ** TODO two
4244 * Parent
4245   :PROPERTIES:
4246   :ORDERED: t
4247   :END:
4248 ** TODO a
4249 ** TODO b, needs to wait for (a)
4250 ** TODO c, needs to wait for (a) and (b)
4251 @end example
4253 @table @kbd
4254 @orgcmd{C-c C-x o,org-toggle-ordered-property}
4255 @vindex org-track-ordered-property-with-tag
4256 @cindex property, ORDERED
4257 Toggle the @code{ORDERED} property of the current entry.  A property is used
4258 for this behavior because this should be local to the current entry, not
4259 inherited like a tag.  However, if you would like to @i{track} the value of
4260 this property with a tag for better visibility, customize the variable
4261 @code{org-track-ordered-property-with-tag}.
4262 @orgkey{C-u C-u C-u C-c C-t}
4263 Change TODO state, circumventing any state blocking.
4264 @end table
4266 @vindex org-agenda-dim-blocked-tasks
4267 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
4268 that cannot be closed because of such dependencies will be shown in a dimmed
4269 font or even made invisible in agenda views (@pxref{Agenda Views}).
4271 @cindex checkboxes and TODO dependencies
4272 @vindex org-enforce-todo-dependencies
4273 You can also block changes of TODO states by looking at checkboxes
4274 (@pxref{Checkboxes}).  If you set the variable
4275 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
4276 checkboxes will be blocked from switching to DONE.
4278 If you need more complex dependency structures, for example dependencies
4279 between entries in different trees or files, check out the contributed
4280 module @file{org-depend.el}.
4282 @page
4283 @node Progress logging, Priorities, TODO extensions, TODO Items
4284 @section Progress logging
4285 @cindex progress logging
4286 @cindex logging, of progress
4288 Org mode can automatically record a timestamp and possibly a note when
4289 you mark a TODO item as DONE, or even each time you change the state of
4290 a TODO item.  This system is highly configurable; settings can be on a
4291 per-keyword basis and can be localized to a file or even a subtree.  For
4292 information on how to clock working time for a task, see @ref{Clocking
4293 work time}.
4295 @menu
4296 * Closing items::               When was this entry marked DONE?
4297 * Tracking TODO state changes::  When did the status change?
4298 * Tracking your habits::        How consistent have you been?
4299 @end menu
4301 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
4302 @subsection Closing items
4304 The most basic logging is to keep track of @emph{when} a certain TODO
4305 item was finished.  This is achieved with@footnote{The corresponding
4306 in-buffer setting is: @code{#+STARTUP: logdone}}
4308 @lisp
4309 (setq org-log-done 'time)
4310 @end lisp
4312 @noindent
4313 Then each time you turn an entry from a TODO (not-done) state into any
4314 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
4315 just after the headline.  If you turn the entry back into a TODO item
4316 through further state cycling, that line will be removed again.  If you
4317 want to record a note along with the timestamp, use@footnote{The
4318 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
4320 @lisp
4321 (setq org-log-done 'note)
4322 @end lisp
4324 @noindent
4325 You will then be prompted for a note, and that note will be stored below
4326 the entry with a @samp{Closing Note} heading.
4328 In the timeline (@pxref{Timeline}) and in the agenda
4329 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
4330 display the TODO items with a @samp{CLOSED} timestamp on each day,
4331 giving you an overview of what has been done.
4333 @node Tracking TODO state changes, Tracking your habits, Closing items, Progress logging
4334 @subsection Tracking TODO state changes
4335 @cindex drawer, for state change recording
4337 @vindex org-log-states-order-reversed
4338 @vindex org-log-into-drawer
4339 @cindex property, LOG_INTO_DRAWER
4340 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
4341 might want to keep track of when a state change occurred and maybe take a
4342 note about this change.  You can either record just a timestamp, or a
4343 time-stamped note for a change.  These records will be inserted after the
4344 headline as an itemized list, newest first@footnote{See the variable
4345 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
4346 want to get the notes out of the way into a drawer (@pxref{Drawers}).
4347 Customize the variable @code{org-log-into-drawer} to get this behavior---the
4348 recommended drawer for this is called @code{LOGBOOK}@footnote{Note that the
4349 @code{LOGBOOK} drawer is unfolded when pressing @key{SPC} in the agenda to
4350 show an entry---use @key{C-u SPC} to keep it folded here}.  You can also
4351 overrule the setting of this variable for a subtree by setting a
4352 @code{LOG_INTO_DRAWER} property.
4354 Since it is normally too much to record a note for every state, Org mode
4355 expects configuration on a per-keyword basis for this.  This is achieved by
4356 adding special markers @samp{!} (for a timestamp) or @samp{@@} (for a note
4357 with timestamp) in parentheses after each keyword.  For example, with the
4358 setting
4360 @lisp
4361 (setq org-todo-keywords
4362   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
4363 @end lisp
4365 To record a timestamp without a note for TODO keywords configured with
4366 @samp{@@}, just type @kbd{C-c C-c} to enter a blank note when prompted.
4368 @noindent
4369 @vindex org-log-done
4370 you not only define global TODO keywords and fast access keys, but also
4371 request that a time is recorded when the entry is set to
4372 DONE@footnote{It is possible that Org mode will record two timestamps
4373 when you are using both @code{org-log-done} and state change logging.
4374 However, it will never prompt for two notes---if you have configured
4375 both, the state change recording note will take precedence and cancel
4376 the @samp{Closing Note}.}, and that a note is recorded when switching to
4377 WAIT or CANCELED@.  The setting for WAIT is even more special: the
4378 @samp{!} after the slash means that in addition to the note taken when
4379 entering the state, a timestamp should be recorded when @i{leaving} the
4380 WAIT state, if and only if the @i{target} state does not configure
4381 logging for entering it.  So it has no effect when switching from WAIT
4382 to DONE, because DONE is configured to record a timestamp only.  But
4383 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
4384 setting now triggers a timestamp even though TODO has no logging
4385 configured.
4387 You can use the exact same syntax for setting logging preferences local
4388 to a buffer:
4389 @example
4390 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
4391 @end example
4393 @cindex property, LOGGING
4394 In order to define logging settings that are local to a subtree or a
4395 single item, define a LOGGING property in this entry.  Any non-empty
4396 LOGGING property resets all logging settings to nil.  You may then turn
4397 on logging for this specific tree using STARTUP keywords like
4398 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
4399 settings like @code{TODO(!)}.  For example
4401 @example
4402 * TODO Log each state with only a time
4403   :PROPERTIES:
4404   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4405   :END:
4406 * TODO Only log when switching to WAIT, and when repeating
4407   :PROPERTIES:
4408   :LOGGING: WAIT(@@) logrepeat
4409   :END:
4410 * TODO No logging at all
4411   :PROPERTIES:
4412   :LOGGING: nil
4413   :END:
4414 @end example
4416 @node Tracking your habits,  , Tracking TODO state changes, Progress logging
4417 @subsection Tracking your habits
4418 @cindex habits
4420 Org has the ability to track the consistency of a special category of TODOs,
4421 called ``habits''.  A habit has the following properties:
4423 @enumerate
4424 @item
4425 You have enabled the @code{habits} module by customizing the variable
4426 @code{org-modules}.
4427 @item
4428 The habit is a TODO item, with a TODO keyword representing an open state.
4429 @item
4430 The property @code{STYLE} is set to the value @code{habit}.
4431 @item
4432 The TODO has a scheduled date, usually with a @code{.+} style repeat
4433 interval.  A @code{++} style may be appropriate for habits with time
4434 constraints, e.g., must be done on weekends, or a @code{+} style for an
4435 unusual habit that can have a backlog, e.g., weekly reports.
4436 @item
4437 The TODO may also have minimum and maximum ranges specified by using the
4438 syntax @samp{.+2d/3d}, which says that you want to do the task at least every
4439 three days, but at most every two days.
4440 @item
4441 You must also have state logging for the @code{DONE} state enabled
4442 (@pxref{Tracking TODO state changes}), in order for historical data to be
4443 represented in the consistency graph.  If it is not enabled it is not an
4444 error, but the consistency graphs will be largely meaningless.
4445 @end enumerate
4447 To give you an idea of what the above rules look like in action, here's an
4448 actual habit with some history:
4450 @example
4451 ** TODO Shave
4452    SCHEDULED: <2009-10-17 Sat .+2d/4d>
4453    - State "DONE"       from "TODO"       [2009-10-15 Thu]
4454    - State "DONE"       from "TODO"       [2009-10-12 Mon]
4455    - State "DONE"       from "TODO"       [2009-10-10 Sat]
4456    - State "DONE"       from "TODO"       [2009-10-04 Sun]
4457    - State "DONE"       from "TODO"       [2009-10-02 Fri]
4458    - State "DONE"       from "TODO"       [2009-09-29 Tue]
4459    - State "DONE"       from "TODO"       [2009-09-25 Fri]
4460    - State "DONE"       from "TODO"       [2009-09-19 Sat]
4461    - State "DONE"       from "TODO"       [2009-09-16 Wed]
4462    - State "DONE"       from "TODO"       [2009-09-12 Sat]
4463    :PROPERTIES:
4464    :STYLE:    habit
4465    :LAST_REPEAT: [2009-10-19 Mon 00:36]
4466    :END:
4467 @end example
4469 What this habit says is: I want to shave at most every 2 days (given by the
4470 @code{SCHEDULED} date and repeat interval) and at least every 4 days.  If
4471 today is the 15th, then the habit first appears in the agenda on Oct 17,
4472 after the minimum of 2 days has elapsed, and will appear overdue on Oct 19,
4473 after four days have elapsed.
4475 What's really useful about habits is that they are displayed along with a
4476 consistency graph, to show how consistent you've been at getting that task
4477 done in the past.  This graph shows every day that the task was done over the
4478 past three weeks, with colors for each day.  The colors used are:
4480 @table @code
4481 @item Blue
4482 If the task wasn't to be done yet on that day.
4483 @item Green
4484 If the task could have been done on that day.
4485 @item Yellow
4486 If the task was going to be overdue the next day.
4487 @item Red
4488 If the task was overdue on that day.
4489 @end table
4491 In addition to coloring each day, the day is also marked with an asterisk if
4492 the task was actually done that day, and an exclamation mark to show where
4493 the current day falls in the graph.
4495 There are several configuration variables that can be used to change the way
4496 habits are displayed in the agenda.
4498 @table @code
4499 @item org-habit-graph-column
4500 The buffer column at which the consistency graph should be drawn.  This will
4501 overwrite any text in that column, so it is a good idea to keep your habits'
4502 titles brief and to the point.
4503 @item org-habit-preceding-days
4504 The amount of history, in days before today, to appear in consistency graphs.
4505 @item org-habit-following-days
4506 The number of days after today that will appear in consistency graphs.
4507 @item org-habit-show-habits-only-for-today
4508 If non-nil, only show habits in today's agenda view.  This is set to true by
4509 default.
4510 @end table
4512 Lastly, pressing @kbd{K} in the agenda buffer will cause habits to
4513 temporarily be disabled and they won't appear at all.  Press @kbd{K} again to
4514 bring them back.  They are also subject to tag filtering, if you have habits
4515 which should only be done in certain contexts, for example.
4517 @node Priorities, Breaking down tasks, Progress logging, TODO Items
4518 @section Priorities
4519 @cindex priorities
4521 If you use Org mode extensively, you may end up with enough TODO items that
4522 it starts to make sense to prioritize them.  Prioritizing can be done by
4523 placing a @emph{priority cookie} into the headline of a TODO item, like this
4525 @example
4526 *** TODO [#A] Write letter to Sam Fortune
4527 @end example
4529 @noindent
4530 @vindex org-priority-faces
4531 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
4532 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie is
4533 treated just like priority @samp{B}.  Priorities make a difference only for
4534 sorting in the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they
4535 have no inherent meaning to Org mode.  The cookies can be highlighted with
4536 special faces by customizing the variable @code{org-priority-faces}.
4538 Priorities can be attached to any outline node; they do not need to be TODO
4539 items.
4541 @table @kbd
4542 @item @kbd{C-c ,}
4543 @kindex @kbd{C-c ,}
4544 @findex org-priority
4545 Set the priority of the current headline (@command{org-priority}).  The
4546 command prompts for a priority character @samp{A}, @samp{B} or @samp{C}.
4547 When you press @key{SPC} instead, the priority cookie is removed from the
4548 headline.  The priorities can also be changed ``remotely'' from the timeline
4549 and agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
4551 @orgcmdkkcc{S-@key{up},S-@key{down},org-priority-up,org-priority-down}
4552 @vindex org-priority-start-cycle-with-default
4553 Increase/decrease priority of current headline@footnote{See also the option
4554 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
4555 also used to modify timestamps (@pxref{Creating timestamps}).  See also
4556 @ref{Conflicts}, for a discussion of the interaction with
4557 @code{shift-selection-mode}.
4558 @end table
4560 @vindex org-highest-priority
4561 @vindex org-lowest-priority
4562 @vindex org-default-priority
4563 You can change the range of allowed priorities by setting the variables
4564 @code{org-highest-priority}, @code{org-lowest-priority}, and
4565 @code{org-default-priority}.  For an individual buffer, you may set
4566 these values (highest, lowest, default) like this (please make sure that
4567 the highest priority is earlier in the alphabet than the lowest
4568 priority):
4570 @cindex #+PRIORITIES
4571 @example
4572 #+PRIORITIES: A C B
4573 @end example
4575 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
4576 @section Breaking tasks down into subtasks
4577 @cindex tasks, breaking down
4578 @cindex statistics, for TODO items
4580 @vindex org-agenda-todo-list-sublevels
4581 It is often advisable to break down large tasks into smaller, manageable
4582 subtasks.  You can do this by creating an outline tree below a TODO item,
4583 with detailed subtasks on the tree@footnote{To keep subtasks out of the
4584 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
4585 the overview over the fraction of subtasks that are already completed, insert
4586 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
4587 be updated each time the TODO status of a child changes, or when pressing
4588 @kbd{C-c C-c} on the cookie.  For example:
4590 @example
4591 * Organize Party [33%]
4592 ** TODO Call people [1/2]
4593 *** TODO Peter
4594 *** DONE Sarah
4595 ** TODO Buy food
4596 ** DONE Talk to neighbor
4597 @end example
4599 @cindex property, COOKIE_DATA
4600 If a heading has both checkboxes and TODO children below it, the meaning of
4601 the statistics cookie become ambiguous.  Set the property
4602 @code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
4603 this issue.
4605 @vindex org-hierarchical-todo-statistics
4606 If you would like to have the statistics cookie count any TODO entries in the
4607 subtree (not just direct children), configure the variable
4608 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
4609 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
4610 property.
4612 @example
4613 * Parent capturing statistics [2/20]
4614   :PROPERTIES:
4615   :COOKIE_DATA: todo recursive
4616   :END:
4617 @end example
4619 If you would like a TODO entry to automatically change to DONE
4620 when all children are done, you can use the following setup:
4622 @example
4623 (defun org-summary-todo (n-done n-not-done)
4624   "Switch entry to DONE when all subentries are done, to TODO otherwise."
4625   (let (org-log-done org-log-states)   ; turn off logging
4626     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4628 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4629 @end example
4632 Another possibility is the use of checkboxes to identify (a hierarchy of) a
4633 large number of subtasks (@pxref{Checkboxes}).
4636 @node Checkboxes,  , Breaking down tasks, TODO Items
4637 @section Checkboxes
4638 @cindex checkboxes
4640 @vindex org-list-automatic-rules
4641 Every item in a plain list@footnote{With the exception of description
4642 lists.  But you can allow it by modifying @code{org-list-automatic-rules}
4643 accordingly.} (@pxref{Plain lists}) can be made into a checkbox by starting
4644 it with the string @samp{[ ]}.  This feature is similar to TODO items
4645 (@pxref{TODO Items}), but is more lightweight.  Checkboxes are not included
4646 in the global TODO list, so they are often great to split a task into a
4647 number of simple steps.  Or you can use them in a shopping list.  To toggle a
4648 checkbox, use @kbd{C-c C-c}, or use the mouse (thanks to Piotr Zielinski's
4649 @file{org-mouse.el}).
4651 Here is an example of a checkbox list.
4653 @example
4654 * TODO Organize party [2/4]
4655   - [-] call people [1/3]
4656     - [ ] Peter
4657     - [X] Sarah
4658     - [ ] Sam
4659   - [X] order food
4660   - [ ] think about what music to play
4661   - [X] talk to the neighbors
4662 @end example
4664 Checkboxes work hierarchically, so if a checkbox item has children that
4665 are checkboxes, toggling one of the children checkboxes will make the
4666 parent checkbox reflect if none, some, or all of the children are
4667 checked.
4669 @cindex statistics, for checkboxes
4670 @cindex checkbox statistics
4671 @cindex property, COOKIE_DATA
4672 @vindex org-checkbox-hierarchical-statistics
4673 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
4674 indicating how many checkboxes present in this entry have been checked off,
4675 and the total number of checkboxes present.  This can give you an idea on how
4676 many checkboxes remain, even without opening a folded entry.  The cookies can
4677 be placed into a headline or into (the first line of) a plain list item.
4678 Each cookie covers checkboxes of direct children structurally below the
4679 headline/item on which the cookie appears@footnote{Set the variable
4680 @code{org-checkbox-hierarchical-statistics} if you want such cookies to
4681 count all checkboxes below the cookie, not just those belonging to direct
4682 children.}.  You have to insert the cookie yourself by typing either
4683 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
4684 result, as in the examples above.  With @samp{[%]} you get information about
4685 the percentage of checkboxes checked (in the above example, this would be
4686 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
4687 count either checkboxes below the heading or TODO states of children, and it
4688 will display whatever was changed last.  Set the property @code{COOKIE_DATA}
4689 to either @samp{checkbox} or @samp{todo} to resolve this issue.
4691 @cindex blocking, of checkboxes
4692 @cindex checkbox blocking
4693 @cindex property, ORDERED
4694 If the current outline node has an @code{ORDERED} property, checkboxes must
4695 be checked off in sequence, and an error will be thrown if you try to check
4696 off a box while there are unchecked boxes above it.
4698 @noindent The following commands work with checkboxes:
4700 @table @kbd
4701 @orgcmd{C-c C-c,org-toggle-checkbox}
4702 Toggle checkbox status or (with prefix arg) checkbox presence at point.
4703 With a single prefix argument, add an empty checkbox or remove the current
4704 one@footnote{@kbd{C-u C-c C-c} on the @emph{first} item of a list with no checkbox
4705 will add checkboxes to the rest of the list.}.  With a double prefix argument, set it to @samp{[-]}, which is
4706 considered to be an intermediate state.
4707 @orgcmd{C-c C-x C-b,org-toggle-checkbox}
4708 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
4709 double prefix argument, set it to @samp{[-]}, which is considered to be an
4710 intermediate state.
4711 @itemize @minus
4712 @item
4713 If there is an active region, toggle the first checkbox in the region
4714 and set all remaining boxes to the same status as the first.  With a prefix
4715 arg, add or remove the checkbox for all items in the region.
4716 @item
4717 If the cursor is in a headline, toggle checkboxes in the region between
4718 this headline and the next (so @emph{not} the entire subtree).
4719 @item
4720 If there is no active region, just toggle the checkbox at point.
4721 @end itemize
4722 @orgcmd{M-S-@key{RET},org-insert-todo-heading}
4723 Insert a new item with a checkbox.  This works only if the cursor is already
4724 in a plain list item (@pxref{Plain lists}).
4725 @orgcmd{C-c C-x o,org-toggle-ordered-property}
4726 @vindex org-track-ordered-property-with-tag
4727 @cindex property, ORDERED
4728 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
4729 be checked off in sequence.  A property is used for this behavior because
4730 this should be local to the current entry, not inherited like a tag.
4731 However, if you would like to @i{track} the value of this property with a tag
4732 for better visibility, customize the variable
4733 @code{org-track-ordered-property-with-tag}.
4734 @orgcmd{C-c #,org-update-statistics-cookies}
4735 Update the statistics cookie in the current outline entry.  When called with
4736 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
4737 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
4738 new ones with @kbd{M-S-@key{RET}}.  TODO statistics cookies update when
4739 changing TODO states.  If you delete boxes/entries or add/change them by
4740 hand, use this command to get things back into sync.
4741 @end table
4743 @node Tags, Properties and Columns, TODO Items, Top
4744 @chapter Tags
4745 @cindex tags
4746 @cindex headline tagging
4747 @cindex matching, tags
4748 @cindex sparse tree, tag based
4750 An excellent way to implement labels and contexts for cross-correlating
4751 information is to assign @i{tags} to headlines.  Org mode has extensive
4752 support for tags.
4754 @vindex org-tag-faces
4755 Every headline can contain a list of tags; they occur at the end of the
4756 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
4757 @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
4758 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
4759 Tags will by default be in bold face with the same color as the headline.
4760 You may specify special faces for specific tags using the variable
4761 @code{org-tag-faces}, in much the same way as you can for TODO keywords
4762 (@pxref{Faces for TODO keywords}).
4764 @menu
4765 * Tag inheritance::             Tags use the tree structure of the outline
4766 * Setting tags::                How to assign tags to a headline
4767 * Tag groups::                  Use one tag to search for several tags
4768 * Tag searches::                Searching for combinations of tags
4769 @end menu
4771 @node Tag inheritance, Setting tags, Tags, Tags
4772 @section Tag inheritance
4773 @cindex tag inheritance
4774 @cindex inheritance, of tags
4775 @cindex sublevels, inclusion into tags match
4777 @i{Tags} make use of the hierarchical structure of outline trees.  If a
4778 heading has a certain tag, all subheadings will inherit the tag as
4779 well.  For example, in the list
4781 @example
4782 * Meeting with the French group      :work:
4783 ** Summary by Frank                  :boss:notes:
4784 *** TODO Prepare slides for him      :action:
4785 @end example
4787 @noindent
4788 the final heading will have the tags @samp{:work:}, @samp{:boss:},
4789 @samp{:notes:}, and @samp{:action:} even though the final heading is not
4790 explicitly marked with those tags.  You can also set tags that all entries in
4791 a file should inherit just as if these tags were defined in a hypothetical
4792 level zero that surrounds the entire file.  Use a line like this@footnote{As
4793 with all these in-buffer settings, pressing @kbd{C-c C-c} activates any
4794 changes in the line.}:
4796 @cindex #+FILETAGS
4797 @example
4798 #+FILETAGS: :Peter:Boss:Secret:
4799 @end example
4801 @noindent
4802 @vindex org-use-tag-inheritance
4803 @vindex org-tags-exclude-from-inheritance
4804 To limit tag inheritance to specific tags, use @code{org-tags-exclude-from-inheritance}.
4805 To turn it off entirely, use @code{org-use-tag-inheritance}.
4807 @vindex org-tags-match-list-sublevels
4808 When a headline matches during a tags search while tag inheritance is turned
4809 on, all the sublevels in the same tree will (for a simple match form) match
4810 as well@footnote{This is only true if the search does not involve more
4811 complex tests including properties (@pxref{Property searches}).}.  The list
4812 of matches may then become very long.  If you only want to see the first tags
4813 match in a subtree, configure the variable
4814 @code{org-tags-match-list-sublevels} (not recommended).
4816 @vindex org-agenda-use-tag-inheritance
4817 Tag inheritance is relevant when the agenda search tries to match a tag,
4818 either in the @code{tags} or @code{tags-todo} agenda types.  In other agenda
4819 types, @code{org-use-tag-inheritance} has no effect.  Still, you may want to
4820 have your tags correctly set in the agenda, so that tag filtering works fine,
4821 with inherited tags.  Set @code{org-agenda-use-tag-inheritance} to control
4822 this: the default value includes all agenda types, but setting this to nil
4823 can really speed up agenda generation.
4825 @node Setting tags, Tag groups, Tag inheritance, Tags
4826 @section Setting tags
4827 @cindex setting tags
4828 @cindex tags, setting
4830 @kindex M-@key{TAB}
4831 Tags can simply be typed into the buffer at the end of a headline.
4832 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
4833 also a special command for inserting tags:
4835 @table @kbd
4836 @orgcmd{C-c C-q,org-set-tags-command}
4837 @cindex completion, of tags
4838 @vindex org-tags-column
4839 Enter new tags for the current headline.  Org mode will either offer
4840 completion or a special single-key interface for setting tags, see
4841 below.  After pressing @key{RET}, the tags will be inserted and aligned
4842 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
4843 tags in the current buffer will be aligned to that column, just to make
4844 things look nice.  TAGS are automatically realigned after promotion,
4845 demotion, and TODO state changes (@pxref{TODO basics}).
4847 @orgcmd{C-c C-c,org-set-tags-command}
4848 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
4849 @end table
4851 @vindex org-tag-alist
4852 Org supports tag insertion based on a @emph{list of tags}.  By
4853 default this list is constructed dynamically, containing all tags
4854 currently used in the buffer.  You may also globally specify a hard list
4855 of tags with the variable @code{org-tag-alist}.  Finally you can set
4856 the default tags for a given file with lines like
4858 @cindex #+TAGS
4859 @example
4860 #+TAGS: @@work @@home @@tennisclub
4861 #+TAGS: laptop car pc sailboat
4862 @end example
4864 If you have globally defined your preferred set of tags using the
4865 variable @code{org-tag-alist}, but would like to use a dynamic tag list
4866 in a specific file, add an empty TAGS option line to that file:
4868 @example
4869 #+TAGS:
4870 @end example
4872 @vindex org-tag-persistent-alist
4873 If you have a preferred set of tags that you would like to use in every file,
4874 in addition to those defined on a per-file basis by TAGS option lines, then
4875 you may specify a list of tags with the variable
4876 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
4877 by adding a STARTUP option line to that file:
4879 @example
4880 #+STARTUP: noptag
4881 @end example
4883 By default Org mode uses the standard minibuffer completion facilities for
4884 entering tags.  However, it also implements another, quicker, tag selection
4885 method called @emph{fast tag selection}.  This allows you to select and
4886 deselect tags with just a single key press.  For this to work well you should
4887 assign unique letters to most of your commonly used tags.  You can do this
4888 globally by configuring the variable @code{org-tag-alist} in your
4889 @file{.emacs} file.  For example, you may find the need to tag many items in
4890 different files with @samp{:@@home:}.  In this case you can set something
4891 like:
4893 @lisp
4894 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
4895 @end lisp
4897 @noindent If the tag is only relevant to the file you are working on, then you
4898 can instead set the TAGS option line as:
4900 @example
4901 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
4902 @end example
4904 @noindent The tags interface will show the available tags in a splash
4905 window.  If you want to start a new line after a specific tag, insert
4906 @samp{\n} into the tag list
4908 @example
4909 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
4910 @end example
4912 @noindent or write them in two lines:
4914 @example
4915 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
4916 #+TAGS: laptop(l)  pc(p)
4917 @end example
4919 @noindent
4920 You can also group together tags that are mutually exclusive by using
4921 braces, as in:
4923 @example
4924 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
4925 @end example
4927 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
4928 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
4930 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
4931 these lines to activate any changes.
4933 @noindent
4934 To set these mutually exclusive groups in the variable @code{org-tags-alist},
4935 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
4936 of the braces.  Similarly, you can use @code{:newline} to indicate a line
4937 break.  The previous example would be set globally by the following
4938 configuration:
4940 @lisp
4941 (setq org-tag-alist '((:startgroup . nil)
4942                       ("@@work" . ?w) ("@@home" . ?h)
4943                       ("@@tennisclub" . ?t)
4944                       (:endgroup . nil)
4945                       ("laptop" . ?l) ("pc" . ?p)))
4946 @end lisp
4948 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
4949 automatically present you with a special interface, listing inherited tags,
4950 the tags of the current headline, and a list of all valid tags with
4951 corresponding keys@footnote{Keys will automatically be assigned to tags which
4952 have no configured keys.}.  In this interface, you can use the following
4953 keys:
4955 @table @kbd
4956 @item a-z...
4957 Pressing keys assigned to tags will add or remove them from the list of
4958 tags in the current line.  Selecting a tag in a group of mutually
4959 exclusive tags will turn off any other tags from that group.
4960 @kindex @key{TAB}
4961 @item @key{TAB}
4962 Enter a tag in the minibuffer, even if the tag is not in the predefined
4963 list.  You will be able to complete on all tags present in the buffer.
4964 You can also add several tags: just separate them with a comma.
4966 @kindex @key{SPC}
4967 @item @key{SPC}
4968 Clear all tags for this line.
4969 @kindex @key{RET}
4970 @item @key{RET}
4971 Accept the modified set.
4972 @item C-g
4973 Abort without installing changes.
4974 @item q
4975 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
4976 @item !
4977 Turn off groups of mutually exclusive tags.  Use this to (as an
4978 exception) assign several tags from such a group.
4979 @item C-c
4980 Toggle auto-exit after the next change (see below).
4981 If you are using expert mode, the first @kbd{C-c} will display the
4982 selection window.
4983 @end table
4985 @noindent
4986 This method lets you assign tags to a headline with very few keys.  With
4987 the above setup, you could clear the current tags and set @samp{@@home},
4988 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
4989 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
4990 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
4991 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
4992 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
4993 @key{RET} @key{RET}}.
4995 @vindex org-fast-tag-selection-single-key
4996 If you find that most of the time you need only a single key press to
4997 modify your list of tags, set @code{org-fast-tag-selection-single-key}.
4998 Then you no longer have to press @key{RET} to exit fast tag selection---it
4999 will immediately exit after the first change.  If you then occasionally
5000 need more keys, press @kbd{C-c} to turn off auto-exit for the current tag
5001 selection process (in effect: start selection with @kbd{C-c C-c C-c}
5002 instead of @kbd{C-c C-c}).  If you set the variable to the value
5003 @code{expert}, the special window is not even shown for single-key tag
5004 selection, it comes up only when you press an extra @kbd{C-c}.
5006 @node Tag groups, Tag searches, Setting tags, Tags
5007 @section Tag groups
5009 @cindex group tags
5010 @cindex tags, groups
5011 In a set of mutually exclusive tags, the first tag can be defined as a
5012 @emph{group tag}.  When you search for a group tag, it will return matches
5013 for all members in the group.  In an agenda view, filtering by a group tag
5014 will display headlines tagged with at least one of the members of the
5015 group.  This makes tag searches and filters even more flexible.
5017 You can set group tags by inserting a colon between the group tag and other
5018 tags---beware that all whitespaces are mandatory so that Org can parse this
5019 line correctly:
5021 @example
5022 #+TAGS: @{ @@read : @@read_book  @@read_ebook @}
5023 @end example
5025 In this example, @samp{@@read} is a @emph{group tag} for a set of three
5026 tags: @samp{@@read}, @samp{@@read_book} and @samp{@@read_ebook}.
5028 You can also use the @code{:grouptags} keyword directly when setting
5029 @var{org-tag-alist}:
5031 @lisp
5032 (setq org-tag-alist '((:startgroup . nil)
5033                       ("@@read" . nil)
5034                       (:grouptags . nil)
5035                       ("@@read_book" . nil)
5036                       ("@@read_ebook" . nil)
5037                       (:endgroup . nil)))
5038 @end lisp
5040 You cannot nest group tags or use a group tag as a tag in another group.
5042 @kindex C-c C-x q
5043 @vindex org-group-tags
5044 If you want to ignore group tags temporarily, toggle group tags support
5045 with @command{org-toggle-tags-groups}, bound to @kbd{C-c C-x q}.  If you
5046 want to disable tag groups completely, set @var{org-group-tags} to nil.
5048 @node Tag searches,  , Tag groups, Tags
5049 @section Tag searches
5050 @cindex tag searches
5051 @cindex searching for tags
5053 Once a system of tags has been set up, it can be used to collect related
5054 information into special lists.
5056 @table @kbd
5057 @orgcmdkkc{C-c / m,C-c \\,org-match-sparse-tree}
5058 Create a sparse tree with all headlines matching a tags search.  With a
5059 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
5060 @orgcmd{C-c a m,org-tags-view}
5061 Create a global list of tag matches from all agenda files.
5062 @xref{Matching tags and properties}.
5063 @orgcmd{C-c a M,org-tags-view}
5064 @vindex org-tags-match-list-sublevels
5065 Create a global list of tag matches from all agenda files, but check
5066 only TODO items and force checking subitems (see variable
5067 @code{org-tags-match-list-sublevels}).
5068 @end table
5070 These commands all prompt for a match string which allows basic Boolean logic
5071 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
5072 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
5073 which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of the search
5074 string is rich and allows also matching against TODO keywords, entry levels
5075 and properties.  For a complete description with many examples, see
5076 @ref{Matching tags and properties}.
5079 @node Properties and Columns, Dates and Times, Tags, Top
5080 @chapter Properties and columns
5081 @cindex properties
5083 A property is a key-value pair associated with an entry.  Properties can be
5084 set so they are associated with a single entry, with every entry in a tree,
5085 or with every entry in an Org mode file.
5087 There are two main applications for properties in Org mode.  First,
5088 properties are like tags, but with a value.  Imagine maintaining a file where
5089 you document bugs and plan releases for a piece of software.  Instead of
5090 using tags like @code{:release_1:}, @code{:release_2:}, you can use a
5091 property, say @code{:Release:}, that in different subtrees has different
5092 values, such as @code{1.0} or @code{2.0}.  Second, you can use properties to
5093 implement (very basic) database capabilities in an Org buffer.  Imagine
5094 keeping track of your music CDs, where properties could be things such as the
5095 album, artist, date of release, number of tracks, and so on.
5097 Properties can be conveniently edited and viewed in column view
5098 (@pxref{Column view}).
5100 @menu
5101 * Property syntax::             How properties are spelled out
5102 * Special properties::          Access to other Org mode features
5103 * Property searches::           Matching property values
5104 * Property inheritance::        Passing values down the tree
5105 * Column view::                 Tabular viewing and editing
5106 * Property API::                Properties for Lisp programmers
5107 @end menu
5109 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
5110 @section Property syntax
5111 @cindex property syntax
5112 @cindex drawer, for properties
5114 Properties are key-value pairs.  When they are associated with a single entry
5115 or with a tree they need to be inserted into a special
5116 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
5117 is specified on a single line, with the key (surrounded by colons)
5118 first, and the value after it.  Here is an example:
5120 @example
5121 * CD collection
5122 ** Classic
5123 *** Goldberg Variations
5124     :PROPERTIES:
5125     :Title:     Goldberg Variations
5126     :Composer:  J.S. Bach
5127     :Artist:    Glen Gould
5128     :Publisher: Deutsche Grammophon
5129     :NDisks:    1
5130     :END:
5131 @end example
5133 Depending on the value of @code{org-use-property-inheritance}, a property set
5134 this way will either be associated with a single entry, or the sub-tree
5135 defined by the entry, see @ref{Property inheritance}.
5137 You may define the allowed values for a particular property @samp{:Xyz:}
5138 by setting a property @samp{:Xyz_ALL:}.  This special property is
5139 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
5140 the entire tree.  When allowed values are defined, setting the
5141 corresponding property becomes easier and is less prone to typing
5142 errors.  For the example with the CD collection, we can predefine
5143 publishers and the number of disks in a box like this:
5145 @example
5146 * CD collection
5147   :PROPERTIES:
5148   :NDisks_ALL:  1 2 3 4
5149   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
5150   :END:
5151 @end example
5153 If you want to set properties that can be inherited by any entry in a
5154 file, use a line like
5155 @cindex property, _ALL
5156 @cindex #+PROPERTY
5157 @example
5158 #+PROPERTY: NDisks_ALL 1 2 3 4
5159 @end example
5161 Contrary to properties set from a special drawer, you have to refresh the
5162 buffer with @kbd{C-c C-c} to activate this changes.
5164 If you want to add to the value of an existing property, append a @code{+} to
5165 the property name.  The following results in the property @code{var} having
5166 the value ``foo=1 bar=2''.
5167 @cindex property, +
5168 @example
5169 #+PROPERTY: var  foo=1
5170 #+PROPERTY: var+ bar=2
5171 @end example
5173 It is also possible to add to the values of inherited properties.  The
5174 following results in the @code{genres} property having the value ``Classic
5175 Baroque'' under the @code{Goldberg Variations} subtree.
5176 @cindex property, +
5177 @example
5178 * CD collection
5179 ** Classic
5180     :PROPERTIES:
5181     :GENRES: Classic
5182     :END:
5183 *** Goldberg Variations
5184     :PROPERTIES:
5185     :Title:     Goldberg Variations
5186     :Composer:  J.S. Bach
5187     :Artist:    Glen Gould
5188     :Publisher: Deutsche Grammophon
5189     :NDisks:    1
5190     :GENRES+:   Baroque
5191     :END:
5192 @end example
5193 Note that a property can only have one entry per Drawer.
5195 @vindex org-global-properties
5196 Property values set with the global variable
5197 @code{org-global-properties} can be inherited by all entries in all
5198 Org files.
5200 @noindent
5201 The following commands help to work with properties:
5203 @table @kbd
5204 @orgcmd{M-@key{TAB},pcomplete}
5205 After an initial colon in a line, complete property keys.  All keys used
5206 in the current file will be offered as possible completions.
5207 @orgcmd{C-c C-x p,org-set-property}
5208 Set a property.  This prompts for a property name and a value.  If
5209 necessary, the property drawer is created as well.
5210 @item C-u M-x org-insert-drawer RET
5211 @cindex org-insert-drawer
5212 Insert a property drawer into the current entry.  The drawer will be
5213 inserted early in the entry, but after the lines with planning
5214 information like deadlines.
5215 @orgcmd{C-c C-c,org-property-action}
5216 With the cursor in a property drawer, this executes property commands.
5217 @orgcmd{C-c C-c s,org-set-property}
5218 Set a property in the current entry.  Both the property and the value
5219 can be inserted using completion.
5220 @orgcmdkkcc{S-@key{right},S-@key{left},org-property-next-allowed-value,org-property-previous-allowed-value}
5221 Switch property at point to the next/previous allowed value.
5222 @orgcmd{C-c C-c d,org-delete-property}
5223 Remove a property from the current entry.
5224 @orgcmd{C-c C-c D,org-delete-property-globally}
5225 Globally remove a property, from all entries in the current file.
5226 @orgcmd{C-c C-c c,org-compute-property-at-point}
5227 Compute the property at point, using the operator and scope from the
5228 nearest column format definition.
5229 @end table
5231 @node Special properties, Property searches, Property syntax, Properties and Columns
5232 @section Special properties
5233 @cindex properties, special
5235 Special properties provide an alternative access method to Org mode features,
5236 like the TODO state or the priority of an entry, discussed in the previous
5237 chapters.  This interface exists so that you can include these states in a
5238 column view (@pxref{Column view}), or to use them in queries.  The following
5239 property names are special and (except for @code{:CATEGORY:}) should not be
5240 used as keys in the properties drawer:
5242 @cindex property, special, ID
5243 @cindex property, special, TODO
5244 @cindex property, special, TAGS
5245 @cindex property, special, ALLTAGS
5246 @cindex property, special, CATEGORY
5247 @cindex property, special, PRIORITY
5248 @cindex property, special, DEADLINE
5249 @cindex property, special, SCHEDULED
5250 @cindex property, special, CLOSED
5251 @cindex property, special, TIMESTAMP
5252 @cindex property, special, TIMESTAMP_IA
5253 @cindex property, special, CLOCKSUM
5254 @cindex property, special, CLOCKSUM_T
5255 @cindex property, special, BLOCKED
5256 @c guessing that ITEM is needed in this area; also, should this list be sorted?
5257 @cindex property, special, ITEM
5258 @cindex property, special, FILE
5259 @example
5260 ID           @r{A globally unique ID used for synchronization during}
5261              @r{iCalendar or MobileOrg export.}
5262 TODO         @r{The TODO keyword of the entry.}
5263 TAGS         @r{The tags defined directly in the headline.}
5264 ALLTAGS      @r{All tags, including inherited ones.}
5265 CATEGORY     @r{The category of an entry.}
5266 PRIORITY     @r{The priority of the entry, a string with a single letter.}
5267 DEADLINE     @r{The deadline time string, without the angular brackets.}
5268 SCHEDULED    @r{The scheduling timestamp, without the angular brackets.}
5269 CLOSED       @r{When was this entry closed?}
5270 TIMESTAMP    @r{The first keyword-less timestamp in the entry.}
5271 TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
5272 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
5273              @r{must be run first to compute the values in the current buffer.}
5274 CLOCKSUM_T   @r{The sum of CLOCK intervals in the subtree for today.}
5275              @r{@code{org-clock-sum-today} must be run first to compute the}
5276              @r{values in the current buffer.}
5277 BLOCKED      @r{"t" if task is currently blocked by children or siblings}
5278 ITEM         @r{The headline of the entry.}
5279 FILE         @r{The filename the entry is located in.}
5280 @end example
5282 @node Property searches, Property inheritance, Special properties, Properties and Columns
5283 @section Property searches
5284 @cindex properties, searching
5285 @cindex searching, of properties
5287 To create sparse trees and special lists with selection based on properties,
5288 the same commands are used as for tag searches (@pxref{Tag searches}).
5290 @table @kbd
5291 @orgcmdkkc{C-c / m,C-c \\,org-match-sparse-tree}
5292 Create a sparse tree with all matching entries.  With a
5293 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
5294 @orgcmd{C-c a m,org-tags-view}
5295 Create a global list of tag/property  matches from all agenda files.
5296 @xref{Matching tags and properties}.
5297 @orgcmd{C-c a M,org-tags-view}
5298 @vindex org-tags-match-list-sublevels
5299 Create a global list of tag matches from all agenda files, but check
5300 only TODO items and force checking of subitems (see variable
5301 @code{org-tags-match-list-sublevels}).
5302 @end table
5304 The syntax for the search string is described in @ref{Matching tags and
5305 properties}.
5307 There is also a special command for creating sparse trees based on a
5308 single property:
5310 @table @kbd
5311 @orgkey{C-c / p}
5312 Create a sparse tree based on the value of a property.  This first
5313 prompts for the name of a property, and then for a value.  A sparse tree
5314 is created with all entries that define this property with the given
5315 value.  If you enclose the value in curly braces, it is interpreted as
5316 a regular expression and matched against the property values.
5317 @end table
5319 @node Property inheritance, Column view, Property searches, Properties and Columns
5320 @section Property Inheritance
5321 @cindex properties, inheritance
5322 @cindex inheritance, of properties
5324 @vindex org-use-property-inheritance
5325 The outline structure of Org mode documents lends itself to an
5326 inheritance model of properties: if the parent in a tree has a certain
5327 property, the children can inherit this property.  Org mode does not
5328 turn this on by default, because it can slow down property searches
5329 significantly and is often not needed.  However, if you find inheritance
5330 useful, you can turn it on by setting the variable
5331 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
5332 all properties inherited from the parent, to a list of properties
5333 that should be inherited, or to a regular expression that matches
5334 inherited properties.  If a property has the value @samp{nil}, this is
5335 interpreted as an explicit undefine of the property, so that inheritance
5336 search will stop at this value and return @code{nil}.
5338 Org mode has a few properties for which inheritance is hard-coded, at
5339 least for the special applications for which they are used:
5341 @cindex property, COLUMNS
5342 @table @code
5343 @item COLUMNS
5344 The @code{:COLUMNS:} property defines the format of column view
5345 (@pxref{Column view}).  It is inherited in the sense that the level
5346 where a @code{:COLUMNS:} property is defined is used as the starting
5347 point for a column view table, independently of the location in the
5348 subtree from where columns view is turned on.
5349 @item CATEGORY
5350 @cindex property, CATEGORY
5351 For agenda view, a category set through a @code{:CATEGORY:} property
5352 applies to the entire subtree.
5353 @item ARCHIVE
5354 @cindex property, ARCHIVE
5355 For archiving, the @code{:ARCHIVE:} property may define the archive
5356 location for the entire subtree (@pxref{Moving subtrees}).
5357 @item LOGGING
5358 @cindex property, LOGGING
5359 The LOGGING property may define logging settings for an entry or a
5360 subtree (@pxref{Tracking TODO state changes}).
5361 @end table
5363 @node Column view, Property API, Property inheritance, Properties and Columns
5364 @section Column view
5366 A great way to view and edit properties in an outline tree is
5367 @emph{column view}.  In column view, each outline node is turned into a
5368 table row.  Columns in this table provide access to properties of the
5369 entries.  Org mode implements columns by overlaying a tabular structure
5370 over the headline of each item.  While the headlines have been turned
5371 into a table row, you can still change the visibility of the outline
5372 tree.  For example, you get a compact table by switching to CONTENTS
5373 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
5374 is active), but you can still open, read, and edit the entry below each
5375 headline.  Or, you can switch to column view after executing a sparse
5376 tree command and in this way get a table only for the selected items.
5377 Column view also works in agenda buffers (@pxref{Agenda Views}) where
5378 queries have collected selected items, possibly from a number of files.
5380 @menu
5381 * Defining columns::            The COLUMNS format property
5382 * Using column view::           How to create and use column view
5383 * Capturing column view::       A dynamic block for column view
5384 @end menu
5386 @node Defining columns, Using column view, Column view, Column view
5387 @subsection Defining columns
5388 @cindex column view, for properties
5389 @cindex properties, column view
5391 Setting up a column view first requires defining the columns.  This is
5392 done by defining a column format line.
5394 @menu
5395 * Scope of column definitions::  Where defined, where valid?
5396 * Column attributes::           Appearance and content of a column
5397 @end menu
5399 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
5400 @subsubsection Scope of column definitions
5402 To define a column format for an entire file, use a line like
5404 @cindex #+COLUMNS
5405 @example
5406 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5407 @end example
5409 To specify a format that only applies to a specific tree, add a
5410 @code{:COLUMNS:} property to the top node of that tree, for example:
5412 @example
5413 ** Top node for columns view
5414    :PROPERTIES:
5415    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5416    :END:
5417 @end example
5419 If a @code{:COLUMNS:} property is present in an entry, it defines columns
5420 for the entry itself, and for the entire subtree below it.  Since the
5421 column definition is part of the hierarchical structure of the document,
5422 you can define columns on level 1 that are general enough for all
5423 sublevels, and more specific columns further down, when you edit a
5424 deeper part of the tree.
5426 @node Column attributes,  , Scope of column definitions, Defining columns
5427 @subsubsection Column attributes
5428 A column definition sets the attributes of a column.  The general
5429 definition looks like this:
5431 @example
5432  %[@var{width}]@var{property}[(@var{title})][@{@var{summary-type}@}]
5433 @end example
5435 @noindent
5436 Except for the percent sign and the property name, all items are
5437 optional.  The individual parts have the following meaning:
5439 @example
5440 @var{width}           @r{An integer specifying the width of the column in characters.}
5441                 @r{If omitted, the width will be determined automatically.}
5442 @var{property}        @r{The property that should be edited in this column.}
5443                 @r{Special properties representing meta data are allowed here}
5444                 @r{as well (@pxref{Special properties})}
5445 @var{title}           @r{The header text for the column.  If omitted, the property}
5446                 @r{name is used.}
5447 @{@var{summary-type}@}  @r{The summary type.  If specified, the column values for}
5448                 @r{parent nodes are computed from the children.}
5449                 @r{Supported summary types are:}
5450                 @{+@}       @r{Sum numbers in this column.}
5451                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
5452                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
5453                 @{:@}       @r{Sum times, HH:MM, plain numbers are hours.}
5454                 @{X@}       @r{Checkbox status, @samp{[X]} if all children are @samp{[X]}.}
5455                 @{X/@}      @r{Checkbox status, @samp{[n/m]}.}
5456                 @{X%@}      @r{Checkbox status, @samp{[n%]}.}
5457                 @{min@}     @r{Smallest number in column.}
5458                 @{max@}     @r{Largest number.}
5459                 @{mean@}    @r{Arithmetic mean of numbers.}
5460                 @{:min@}    @r{Smallest time value in column.}
5461                 @{:max@}    @r{Largest time value.}
5462                 @{:mean@}   @r{Arithmetic mean of time values.}
5463                 @{@@min@}    @r{Minimum age (in days/hours/mins/seconds).}
5464                 @{@@max@}    @r{Maximum age (in days/hours/mins/seconds).}
5465                 @{@@mean@}   @r{Arithmetic mean of ages (in days/hours/mins/seconds).}
5466                 @{est+@}    @r{Add low-high estimates.}
5467 @end example
5469 @noindent
5470 Be aware that you can only have one summary type for any property you
5471 include.  Subsequent columns referencing the same property will all display the
5472 same summary information.
5474 The @code{est+} summary type requires further explanation.  It is used for
5475 combining estimates, expressed as low-high ranges.  For example, instead
5476 of estimating a particular task will take 5 days, you might estimate it as
5477 5--6 days if you're fairly confident you know how much work is required, or
5478 1--10 days if you don't really know what needs to be done.  Both ranges
5479 average at 5.5 days, but the first represents a more predictable delivery.
5481 When combining a set of such estimates, simply adding the lows and highs
5482 produces an unrealistically wide result.  Instead, @code{est+} adds the
5483 statistical mean and variance of the sub-tasks, generating a final estimate
5484 from the sum.  For example, suppose you had ten tasks, each of which was
5485 estimated at 0.5 to 2 days of work.  Straight addition produces an estimate
5486 of 5 to 20 days, representing what to expect if everything goes either
5487 extremely well or extremely poorly.  In contrast, @code{est+} estimates the
5488 full job more realistically, at 10--15 days.
5490 Here is an example for a complete columns definition, along with allowed
5491 values.
5493 @example
5494 :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.}
5495                    %10Time_Estimate@{:@} %CLOCKSUM %CLOCKSUM_T
5496 :Owner_ALL:    Tammy Mark Karl Lisa Don
5497 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
5498 :Approved_ALL: "[ ]" "[X]"
5499 @end example
5501 @noindent
5502 The first column, @samp{%25ITEM}, means the first 25 characters of the
5503 item itself, i.e., of the headline.  You probably always should start the
5504 column definition with the @samp{ITEM} specifier.  The other specifiers
5505 create columns @samp{Owner} with a list of names as allowed values, for
5506 @samp{Status} with four different possible values, and for a checkbox
5507 field @samp{Approved}.  When no width is given after the @samp{%}
5508 character, the column will be exactly as wide as it needs to be in order
5509 to fully display all values.  The @samp{Approved} column does have a
5510 modified title (@samp{Approved?}, with a question mark).  Summaries will
5511 be created for the @samp{Time_Estimate} column by adding time duration
5512 expressions like HH:MM, and for the @samp{Approved} column, by providing
5513 an @samp{[X]} status if all children have been checked.  The
5514 @samp{CLOCKSUM} and @samp{CLOCKSUM_T} columns are special, they lists the
5515 sums of CLOCK intervals in the subtree, either for all clocks or just for
5516 today.
5518 @node Using column view, Capturing column view, Defining columns, Column view
5519 @subsection Using column view
5521 @table @kbd
5522 @tsubheading{Turning column view on and off}
5523 @orgcmd{C-c C-x C-c,org-columns}
5524 @vindex org-columns-default-format
5525 Turn on column view.  If the cursor is before the first headline in the file,
5526 column view is turned on for the entire file, using the @code{#+COLUMNS}
5527 definition.  If the cursor is somewhere inside the outline, this command
5528 searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
5529 defines a format.  When one is found, the column view table is established
5530 for the tree starting at the entry that contains the @code{:COLUMNS:}
5531 property.  If no such property is found, the format is taken from the
5532 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
5533 and column view is established for the current entry and its subtree.
5534 @orgcmd{r,org-columns-redo}
5535 Recreate the column view, to include recent changes made in the buffer.
5536 @orgcmd{g,org-columns-redo}
5537 Same as @kbd{r}.
5538 @orgcmd{q,org-columns-quit}
5539 Exit column view.
5540 @tsubheading{Editing values}
5541 @item @key{left} @key{right} @key{up} @key{down}
5542 Move through the column view from field to field.
5543 @kindex S-@key{left}
5544 @kindex S-@key{right}
5545 @item  S-@key{left}/@key{right}
5546 Switch to the next/previous allowed value of the field.  For this, you
5547 have to have specified allowed values for a property.
5548 @item 1..9,0
5549 Directly select the Nth allowed value, @kbd{0} selects the 10th value.
5550 @orgcmdkkcc{n,p,org-columns-next-allowed-value,org-columns-previous-allowed-value}
5551 Same as @kbd{S-@key{left}/@key{right}}
5552 @orgcmd{e,org-columns-edit-value}
5553 Edit the property at point.  For the special properties, this will
5554 invoke the same interface that you normally use to change that
5555 property.  For example, when editing a TAGS property, the tag completion
5556 or fast selection interface will pop up.
5557 @orgcmd{C-c C-c,org-columns-set-tags-or-toggle}
5558 When there is a checkbox at point, toggle it.
5559 @orgcmd{v,org-columns-show-value}
5560 View the full value of this property.  This is useful if the width of
5561 the column is smaller than that of the value.
5562 @orgcmd{a,org-columns-edit-allowed}
5563 Edit the list of allowed values for this property.  If the list is found
5564 in the hierarchy, the modified values is stored there.  If no list is
5565 found, the new value is stored in the first entry that is part of the
5566 current column view.
5567 @tsubheading{Modifying the table structure}
5568 @orgcmdkkcc{<,>,org-columns-narrow,org-columns-widen}
5569 Make the column narrower/wider by one character.
5570 @orgcmd{S-M-@key{right},org-columns-new}
5571 Insert a new column, to the left of the current column.
5572 @orgcmd{S-M-@key{left},org-columns-delete}
5573 Delete the current column.
5574 @end table
5576 @node Capturing column view,  , Using column view, Column view
5577 @subsection Capturing column view
5579 Since column view is just an overlay over a buffer, it cannot be
5580 exported or printed directly.  If you want to capture a column view, use
5581 a @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
5582 of this block looks like this:
5584 @cindex #+BEGIN, columnview
5585 @example
5586 * The column view
5587 #+BEGIN: columnview :hlines 1 :id "label"
5589 #+END:
5590 @end example
5592 @noindent This dynamic block has the following parameters:
5594 @table @code
5595 @item :id
5596 This is the most important parameter.  Column view is a feature that is
5597 often localized to a certain (sub)tree, and the capture block might be
5598 at a different location in the file.  To identify the tree whose view to
5599 capture, you can use 4 values:
5600 @cindex property, ID
5601 @example
5602 local     @r{use the tree in which the capture block is located}
5603 global    @r{make a global view, including all headings in the file}
5604 "file:@var{path-to-file}"
5605           @r{run column view at the top of this file}
5606 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
5607           @r{property with the value @i{label}.  You can use}
5608           @r{@kbd{M-x org-id-copy RET} to create a globally unique ID for}
5609           @r{the current entry and copy it to the kill-ring.}
5610 @end example
5611 @item :hlines
5612 When @code{t}, insert an hline after every line.  When a number @var{N}, insert
5613 an hline before each headline with level @code{<= @var{N}}.
5614 @item :vlines
5615 When set to @code{t}, force column groups to get vertical lines.
5616 @item :maxlevel
5617 When set to a number, don't capture entries below this level.
5618 @item :skip-empty-rows
5619 When set to @code{t}, skip rows where the only non-empty specifier of the
5620 column view is @code{ITEM}.
5622 @end table
5624 @noindent
5625 The following commands insert or update the dynamic block:
5627 @table @kbd
5628 @orgcmd{C-c C-x i,org-insert-columns-dblock}
5629 Insert a dynamic block capturing a column view.  You will be prompted
5630 for the scope or ID of the view.
5631 @orgcmdkkc{C-c C-c,C-c C-x C-u,org-dblock-update}
5632 Update dynamic block at point.  The cursor needs to be in the
5633 @code{#+BEGIN} line of the dynamic block.
5634 @orgcmd{C-u C-c C-x C-u,org-update-all-dblocks}
5635 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5636 you have several clock table blocks, column-capturing blocks or other dynamic
5637 blocks in a buffer.
5638 @end table
5640 You can add formulas to the column view table and you may add plotting
5641 instructions in front of the table---these will survive an update of the
5642 block.  If there is a @code{#+TBLFM:} after the table, the table will
5643 actually be recalculated automatically after an update.
5645 An alternative way to capture and process property values into a table is
5646 provided by Eric Schulte's @file{org-collector.el} which is a contributed
5647 package@footnote{Contributed packages are not part of Emacs, but are
5648 distributed with the main distribution of Org (visit
5649 @uref{http://orgmode.org}).}.  It provides a general API to collect
5650 properties from entries in a certain scope, and arbitrary Lisp expressions to
5651 process these values before inserting them into a table or a dynamic block.
5653 @node Property API,  , Column view, Properties and Columns
5654 @section The Property API
5655 @cindex properties, API
5656 @cindex API, for properties
5658 There is a full API for accessing and changing properties.  This API can
5659 be used by Emacs Lisp programs to work with properties and to implement
5660 features based on them.  For more information see @ref{Using the
5661 property API}.
5663 @node Dates and Times, Capture - Refile - Archive, Properties and Columns, Top
5664 @chapter Dates and times
5665 @cindex dates
5666 @cindex times
5667 @cindex timestamp
5668 @cindex date stamp
5670 To assist project planning, TODO items can be labeled with a date and/or
5671 a time.  The specially formatted string carrying the date and time
5672 information is called a @emph{timestamp} in Org mode.  This may be a
5673 little confusing because timestamp is often used as indicating when
5674 something was created or last changed.  However, in Org mode this term
5675 is used in a much wider sense.
5677 @menu
5678 * Timestamps::                  Assigning a time to a tree entry
5679 * Creating timestamps::         Commands which insert timestamps
5680 * Deadlines and scheduling::    Planning your work
5681 * Clocking work time::          Tracking how long you spend on a task
5682 * Effort estimates::            Planning work effort in advance
5683 * Relative timer::              Notes with a running timer
5684 * Countdown timer::             Starting a countdown timer for a task
5685 @end menu
5688 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
5689 @section Timestamps, deadlines, and scheduling
5690 @cindex timestamps
5691 @cindex ranges, time
5692 @cindex date stamps
5693 @cindex deadlines
5694 @cindex scheduling
5696 A timestamp is a specification of a date (possibly with a time or a range of
5697 times) in a special format, either @samp{<2003-09-16 Tue>}@footnote{In this
5698 simplest form, the day name is optional when you type the date yourself.
5699 However, any dates inserted or modified by Org will add that day name, for
5700 reading convenience.} or @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16
5701 Tue 12:00-12:30>}@footnote{This is inspired by the standard ISO 8601
5702 date/time format.  To use an alternative format, see @ref{Custom time
5703 format}.}.  A timestamp can appear anywhere in the headline or body of an Org
5704 tree entry.  Its presence causes entries to be shown on specific dates in the
5705 agenda (@pxref{Weekly/daily agenda}).  We distinguish:
5707 @table @var
5708 @item Plain timestamp; Event; Appointment
5709 @cindex timestamp
5710 @cindex appointment
5711 A simple timestamp just assigns a date/time to an item.  This is just
5712 like writing down an appointment or event in a paper agenda.  In the
5713 timeline and agenda displays, the headline of an entry associated with a
5714 plain timestamp will be shown exactly on that date.
5716 @example
5717 * Meet Peter at the movies
5718   <2006-11-01 Wed 19:15>
5719 * Discussion on climate change
5720   <2006-11-02 Thu 20:00-22:00>
5721 @end example
5723 @item Timestamp with repeater interval
5724 @cindex timestamp, with repeater interval
5725 A timestamp may contain a @emph{repeater interval}, indicating that it
5726 applies not only on the given date, but again and again after a certain
5727 interval of N days (d), weeks (w), months (m), or years (y).  The
5728 following will show up in the agenda every Wednesday:
5730 @example
5731 * Pick up Sam at school
5732   <2007-05-16 Wed 12:30 +1w>
5733 @end example
5735 @item Diary-style sexp entries
5736 For more complex date specifications, Org mode supports using the special
5737 sexp diary entries implemented in the Emacs calendar/diary
5738 package@footnote{When working with the standard diary sexp functions, you
5739 need to be very careful with the order of the arguments.  That order depend
5740 evilly on the variable @code{calendar-date-style} (or, for older Emacs
5741 versions, @code{european-calendar-style}).  For example, to specify a date
5742 December 12, 2005, the call might look like @code{(diary-date 12 1 2005)} or
5743 @code{(diary-date 1 12 2005)} or @code{(diary-date 2005 12 1)}, depending on
5744 the settings.  This has been the source of much confusion.  Org mode users
5745 can resort to special versions of these functions like @code{org-date} or
5746 @code{org-anniversary}.  These work just like the corresponding @code{diary-}
5747 functions, but with stable ISO order of arguments (year, month, day) wherever
5748 applicable, independent of the value of @code{calendar-date-style}.}.  For
5749 example with optional time
5751 @example
5752 * 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
5753   <%%(diary-float t 4 2)>
5754 @end example
5756 @item Time/Date range
5757 @cindex timerange
5758 @cindex date range
5759 Two timestamps connected by @samp{--} denote a range.  The headline
5760 will be shown on the first and last day of the range, and on any dates
5761 that are displayed and fall in the range.  Here is an example:
5763 @example
5764 ** Meeting in Amsterdam
5765    <2004-08-23 Mon>--<2004-08-26 Thu>
5766 @end example
5768 @item Inactive timestamp
5769 @cindex timestamp, inactive
5770 @cindex inactive timestamp
5771 Just like a plain timestamp, but with square brackets instead of
5772 angular ones.  These timestamps are inactive in the sense that they do
5773 @emph{not} trigger an entry to show up in the agenda.
5775 @example
5776 * Gillian comes late for the fifth time
5777   [2006-11-01 Wed]
5778 @end example
5780 @end table
5782 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
5783 @section Creating timestamps
5784 @cindex creating timestamps
5785 @cindex timestamps, creating
5787 For Org mode to recognize timestamps, they need to be in the specific
5788 format.  All commands listed below produce timestamps in the correct
5789 format.
5791 @table @kbd
5792 @orgcmd{C-c .,org-time-stamp}
5793 Prompt for a date and insert a corresponding timestamp.  When the cursor is
5794 at an existing timestamp in the buffer, the command is used to modify this
5795 timestamp instead of inserting a new one.  When this command is used twice in
5796 succession, a time range is inserted.
5798 @orgcmd{C-c !,org-time-stamp-inactive}
5799 Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
5800 an agenda entry.
5802 @kindex C-u C-c .
5803 @kindex C-u C-c !
5804 @item C-u C-c .
5805 @itemx C-u C-c !
5806 @vindex org-time-stamp-rounding-minutes
5807 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
5808 contains date and time.  The default time can be rounded to multiples of 5
5809 minutes, see the option @code{org-time-stamp-rounding-minutes}.
5811 @orgkey{C-c C-c}
5812 Normalize timestamp, insert/fix day name if missing or wrong.
5814 @orgcmd{C-c <,org-date-from-calendar}
5815 Insert a timestamp corresponding to the cursor date in the Calendar.
5817 @orgcmd{C-c >,org-goto-calendar}
5818 Access the Emacs calendar for the current date.  If there is a
5819 timestamp in the current line, go to the corresponding date
5820 instead.
5822 @orgcmd{C-c C-o,org-open-at-point}
5823 Access the agenda for the date given by the timestamp or -range at
5824 point (@pxref{Weekly/daily agenda}).
5826 @orgcmdkkcc{S-@key{left},S-@key{right},org-timestamp-down-day,org-timestamp-up-day}
5827 Change date at cursor by one day.  These key bindings conflict with
5828 shift-selection and related modes (@pxref{Conflicts}).
5830 @orgcmdkkcc{S-@key{up},S-@key{down},org-timestamp-up,org-timestamp-down-down}
5831 Change the item under the cursor in a timestamp.  The cursor can be on a
5832 year, month, day, hour or minute.  When the timestamp contains a time range
5833 like @samp{15:30-16:30}, modifying the first time will also shift the second,
5834 shifting the time block with constant length.  To change the length, modify
5835 the second time.  Note that if the cursor is in a headline and not at a
5836 timestamp, these same keys modify the priority of an item.
5837 (@pxref{Priorities}).  The key bindings also conflict with shift-selection and
5838 related modes (@pxref{Conflicts}).
5840 @orgcmd{C-c C-y,org-evaluate-time-range}
5841 @cindex evaluate time range
5842 Evaluate a time range by computing the difference between start and end.
5843 With a prefix argument, insert result after the time range (in a table: into
5844 the following column).
5845 @end table
5848 @menu
5849 * The date/time prompt::        How Org mode helps you entering date and time
5850 * Custom time format::          Making dates look different
5851 @end menu
5853 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
5854 @subsection The date/time prompt
5855 @cindex date, reading in minibuffer
5856 @cindex time, reading in minibuffer
5858 @vindex org-read-date-prefer-future
5859 When Org mode prompts for a date/time, the default is shown in default
5860 date/time format, and the prompt therefore seems to ask for a specific
5861 format.  But it will in fact accept date/time information in a variety of
5862 formats.  Generally, the information should start at the beginning of the
5863 string.  Org mode will find whatever information is in
5864 there and derive anything you have not specified from the @emph{default date
5865 and time}.  The default is usually the current date and time, but when
5866 modifying an existing timestamp, or when entering the second stamp of a
5867 range, it is taken from the stamp in the buffer.  When filling in
5868 information, Org mode assumes that most of the time you will want to enter a
5869 date in the future: if you omit the month/year and the given day/month is
5870 @i{before} today, it will assume that you mean a future date@footnote{See the
5871 variable @code{org-read-date-prefer-future}.  You may set that variable to
5872 the symbol @code{time} to even make a time before now shift the date to
5873 tomorrow.}.  If the date has been automatically shifted into the future, the
5874 time prompt will show this with @samp{(=>F).}
5876 For example, let's assume that today is @b{June 13, 2006}.  Here is how
5877 various inputs will be interpreted, the items filled in by Org mode are
5878 in @b{bold}.
5880 @example
5881 3-2-5         @result{} 2003-02-05
5882 2/5/3         @result{} 2003-02-05
5883 14            @result{} @b{2006}-@b{06}-14
5884 12            @result{} @b{2006}-@b{07}-12
5885 2/5           @result{} @b{2007}-02-05
5886 Fri           @result{} nearest Friday after the default date
5887 sep 15        @result{} @b{2006}-09-15
5888 feb 15        @result{} @b{2007}-02-15
5889 sep 12 9      @result{} 2009-09-12
5890 12:45         @result{} @b{2006}-@b{06}-@b{13} 12:45
5891 22 sept 0:34  @result{} @b{2006}-09-22 0:34
5892 w4            @result{} ISO week for of the current year @b{2006}
5893 2012 w4 fri   @result{} Friday of ISO week 4 in 2012
5894 2012-w04-5    @result{} Same as above
5895 @end example
5897 Furthermore you can specify a relative date by giving, as the @emph{first}
5898 thing in the input: a plus/minus sign, a number and a letter ([hdwmy]) to
5899 indicate change in hours, days, weeks, months, or years.  With a single plus
5900 or minus, the date is always relative to today.  With a double plus or minus,
5901 it is relative to the default date.  If instead of a single letter, you use
5902 the abbreviation of day name, the date will be the Nth such day, e.g.:
5904 @example
5905 +0            @result{} today
5906 .             @result{} today
5907 +4d           @result{} four days from today
5908 +4            @result{} same as above
5909 +2w           @result{} two weeks from today
5910 ++5           @result{} five days from default date
5911 +2tue         @result{} second Tuesday from now
5912 -wed          @result{} last Wednesday
5913 @end example
5915 @vindex parse-time-months
5916 @vindex parse-time-weekdays
5917 The function understands English month and weekday abbreviations.  If
5918 you want to use unabbreviated names and/or other languages, configure
5919 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
5921 @vindex org-read-date-force-compatible-dates
5922 Not all dates can be represented in a given Emacs implementation.  By default
5923 Org mode forces dates into the compatibility range 1970--2037 which works on
5924 all Emacs implementations.  If you want to use dates outside of this range,
5925 read the docstring of the variable
5926 @code{org-read-date-force-compatible-dates}.
5928 You can specify a time range by giving start and end times or by giving a
5929 start time and a duration (in HH:MM format).  Use one or two dash(es) as the
5930 separator in the former case and use '+' as the separator in the latter
5931 case, e.g.:
5933 @example
5934 11am-1:15pm    @result{} 11:00-13:15
5935 11am--1:15pm   @result{} same as above
5936 11am+2:15      @result{} same as above
5937 @end example
5939 @cindex calendar, for selecting date
5940 @vindex org-popup-calendar-for-date-prompt
5941 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
5942 you don't need/want the calendar, configure the variable
5943 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
5944 prompt, either by clicking on a date in the calendar, or by pressing
5945 @key{RET}, the date selected in the calendar will be combined with the
5946 information entered at the prompt.  You can control the calendar fully
5947 from the minibuffer:
5949 @kindex <
5950 @kindex >
5951 @kindex M-v
5952 @kindex C-v
5953 @kindex mouse-1
5954 @kindex S-@key{right}
5955 @kindex S-@key{left}
5956 @kindex S-@key{down}
5957 @kindex S-@key{up}
5958 @kindex M-S-@key{right}
5959 @kindex M-S-@key{left}
5960 @kindex @key{RET}
5961 @example
5962 @key{RET}           @r{Choose date at cursor in calendar.}
5963 mouse-1        @r{Select date by clicking on it.}
5964 S-@key{right}/@key{left}     @r{One day forward/backward.}
5965 S-@key{down}/@key{up}     @r{One week forward/backward.}
5966 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
5967 > / <          @r{Scroll calendar forward/backward by one month.}
5968 M-v / C-v      @r{Scroll calendar forward/backward by 3 months.}
5969 @end example
5971 @vindex org-read-date-display-live
5972 The actions of the date/time prompt may seem complex, but I assure you they
5973 will grow on you, and you will start getting annoyed by pretty much any other
5974 way of entering a date/time out there.  To help you understand what is going
5975 on, the current interpretation of your input will be displayed live in the
5976 minibuffer@footnote{If you find this distracting, turn the display of with
5977 @code{org-read-date-display-live}.}.
5979 @node Custom time format,  , The date/time prompt, Creating timestamps
5980 @subsection Custom time format
5981 @cindex custom date/time format
5982 @cindex time format, custom
5983 @cindex date format, custom
5985 @vindex org-display-custom-times
5986 @vindex org-time-stamp-custom-formats
5987 Org mode uses the standard ISO notation for dates and times as it is
5988 defined in ISO 8601.  If you cannot get used to this and require another
5989 representation of date and time to keep you happy, you can get it by
5990 customizing the variables @code{org-display-custom-times} and
5991 @code{org-time-stamp-custom-formats}.
5993 @table @kbd
5994 @orgcmd{C-c C-x C-t,org-toggle-time-stamp-overlays}
5995 Toggle the display of custom formats for dates and times.
5996 @end table
5998 @noindent
5999 Org mode needs the default format for scanning, so the custom date/time
6000 format does not @emph{replace} the default format---instead it is put
6001 @emph{over} the default format using text properties.  This has the
6002 following consequences:
6003 @itemize @bullet
6004 @item
6005 You cannot place the cursor onto a timestamp anymore, only before or
6006 after.
6007 @item
6008 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
6009 each component of a timestamp.  If the cursor is at the beginning of
6010 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
6011 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
6012 time will be changed by one minute.
6013 @item
6014 If the timestamp contains a range of clock times or a repeater, these
6015 will not be overlaid, but remain in the buffer as they were.
6016 @item
6017 When you delete a timestamp character-by-character, it will only
6018 disappear from the buffer after @emph{all} (invisible) characters
6019 belonging to the ISO timestamp have been removed.
6020 @item
6021 If the custom timestamp format is longer than the default and you are
6022 using dates in tables, table alignment will be messed up.  If the custom
6023 format is shorter, things do work as expected.
6024 @end itemize
6027 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
6028 @section Deadlines and scheduling
6030 A timestamp may be preceded by special keywords to facilitate planning:
6032 @table @var
6033 @item DEADLINE
6034 @cindex DEADLINE keyword
6036 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
6037 to be finished on that date.
6039 @vindex org-deadline-warning-days
6040 @vindex org-agenda-skip-deadline-prewarning-if-scheduled
6041 On the deadline date, the task will be listed in the agenda.  In
6042 addition, the agenda for @emph{today} will carry a warning about the
6043 approaching or missed deadline, starting
6044 @code{org-deadline-warning-days} before the due date, and continuing
6045 until the entry is marked DONE@.  An example:
6047 @example
6048 *** TODO write article about the Earth for the Guide
6049     DEADLINE: <2004-02-29 Sun>
6050     The editor in charge is [[bbdb:Ford Prefect]]
6051 @end example
6053 You can specify a different lead time for warnings for a specific
6054 deadlines using the following syntax.  Here is an example with a warning
6055 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.  This warning is
6056 deactivated if the task get scheduled and you set
6057 @code{org-agenda-skip-deadline-prewarning-if-scheduled} to @code{t}.
6059 @item SCHEDULED
6060 @cindex SCHEDULED keyword
6062 Meaning: you are planning to start working on that task on the given
6063 date.
6065 @vindex org-agenda-skip-scheduled-if-done
6066 The headline will be listed under the given date@footnote{It will still
6067 be listed on that date after it has been marked DONE@.  If you don't like
6068 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
6069 addition, a reminder that the scheduled date has passed will be present
6070 in the compilation for @emph{today}, until the entry is marked DONE, i.e.,
6071 the task will automatically be forwarded until completed.
6073 @example
6074 *** TODO Call Trillian for a date on New Years Eve.
6075     SCHEDULED: <2004-12-25 Sat>
6076 @end example
6078 @vindex org-scheduled-delay-days
6079 @vindex org-agenda-skip-scheduled-delay-if-deadline
6080 If you want to @emph{delay} the display of this task in the agenda, use
6081 @code{SCHEDULED: <2004-12-25 Sat -2d>}: the task is still scheduled on the
6082 25th but will appear two days later.  In case the task contains a repeater,
6083 the delay is considered to affect all occurrences; if you want the delay to
6084 only affect the first scheduled occurrence of the task, use @code{--2d}
6085 instead.  See @code{org-scheduled-delay-days} and
6086 @code{org-agenda-skip-scheduled-delay-if-deadline} for details on how to
6087 control this globally or per agenda.
6089 @noindent
6090 @b{Important:} Scheduling an item in Org mode should @i{not} be
6091 understood in the same way that we understand @i{scheduling a meeting}.
6092 Setting a date for a meeting is just a simple appointment, you should
6093 mark this entry with a simple plain timestamp, to get this item shown
6094 on the date where it applies.  This is a frequent misunderstanding by
6095 Org users.  In Org mode, @i{scheduling} means setting a date when you
6096 want to start working on an action item.
6097 @end table
6099 You may use timestamps with repeaters in scheduling and deadline
6100 entries.  Org mode will issue early and late warnings based on the
6101 assumption that the timestamp represents the @i{nearest instance} of
6102 the repeater.  However, the use of diary sexp entries like
6104 @code{<%%(diary-float t 42)>}
6106 in scheduling and deadline timestamps is limited.  Org mode does not
6107 know enough about the internals of each sexp function to issue early and
6108 late warnings.  However, it will show the item on each day where the
6109 sexp entry matches.
6111 @menu
6112 * Inserting deadline/schedule::  Planning items
6113 * Repeated tasks::              Items that show up again and again
6114 @end menu
6116 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
6117 @subsection Inserting deadlines or schedules
6119 The following commands allow you to quickly insert@footnote{The @samp{SCHEDULED} and
6120 @samp{DEADLINE} dates are inserted on the line right below the headline.  Don't put
6121 any text between this line and the headline.} a deadline or to schedule
6122 an item:
6124 @table @kbd
6126 @orgcmd{C-c C-d,org-deadline}
6127 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will happen
6128 in the line directly following the headline.  Any CLOSED timestamp will be
6129 removed.  When called with a prefix arg, an existing deadline will be removed
6130 from the entry.  Depending on the variable @code{org-log-redeadline}@footnote{with corresponding
6131 @code{#+STARTUP} keywords @code{logredeadline}, @code{lognoteredeadline},
6132 and @code{nologredeadline}}, a note will be taken when changing an existing
6133 deadline.
6135 @orgcmd{C-c C-s,org-schedule}
6136 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
6137 happen in the line directly following the headline.  Any CLOSED timestamp
6138 will be removed.  When called with a prefix argument, remove the scheduling
6139 date from the entry.  Depending on the variable
6140 @code{org-log-reschedule}@footnote{with corresponding @code{#+STARTUP}
6141 keywords @code{logreschedule}, @code{lognotereschedule}, and
6142 @code{nologreschedule}}, a note will be taken when changing an existing
6143 scheduling time.
6145 @orgcmd{C-c C-x C-k,org-mark-entry-for-agenda-action}
6146 @kindex k a
6147 @kindex k s
6148 Mark the current entry for agenda action.  After you have marked the entry
6149 like this, you can open the agenda or the calendar to find an appropriate
6150 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
6151 schedule the marked item.
6153 @orgcmd{C-c / d,org-check-deadlines}
6154 @cindex sparse tree, for deadlines
6155 @vindex org-deadline-warning-days
6156 Create a sparse tree with all deadlines that are either past-due, or
6157 which will become due within @code{org-deadline-warning-days}.
6158 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
6159 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
6160 all deadlines due tomorrow.
6162 @orgcmd{C-c / b,org-check-before-date}
6163 Sparse tree for deadlines and scheduled items before a given date.
6165 @orgcmd{C-c / a,org-check-after-date}
6166 Sparse tree for deadlines and scheduled items after a given date.
6167 @end table
6169 Note that @code{org-schedule} and @code{org-deadline} supports
6170 setting the date by indicating a relative time: e.g., +1d will set
6171 the date to the next day after today, and --1w will set the date
6172 to the previous week before any current timestamp.
6174 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
6175 @subsection Repeated tasks
6176 @cindex tasks, repeated
6177 @cindex repeated tasks
6179 Some tasks need to be repeated again and again.  Org mode helps to
6180 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
6181 or plain timestamp.  In the following example
6182 @example
6183 ** TODO Pay the rent
6184    DEADLINE: <2005-10-01 Sat +1m>
6185 @end example
6186 @noindent
6187 the @code{+1m} is a repeater; the intended interpretation is that the task
6188 has a deadline on <2005-10-01> and repeats itself every (one) month starting
6189 from that time.  You can use yearly, monthly, weekly, daily and hourly repeat
6190 cookies by using the @code{y/w/m/d/h} letters.  If you need both a repeater
6191 and a special warning period in a deadline entry, the repeater should come
6192 first and the warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
6194 @vindex org-todo-repeat-to-state
6195 Deadlines and scheduled items produce entries in the agenda when they are
6196 over-due, so it is important to be able to mark such an entry as completed
6197 once you have done so.  When you mark a DEADLINE or a SCHEDULE with the TODO
6198 keyword DONE, it will no longer produce entries in the agenda.  The problem
6199 with this is, however, that then also the @emph{next} instance of the
6200 repeated entry will not be active.  Org mode deals with this in the following
6201 way: When you try to mark such an entry DONE (using @kbd{C-c C-t}), it will
6202 shift the base date of the repeating timestamp by the repeater interval, and
6203 immediately set the entry state back to TODO@footnote{In fact, the target
6204 state is taken from, in this sequence, the @code{REPEAT_TO_STATE} property or
6205 the variable @code{org-todo-repeat-to-state}.  If neither of these is
6206 specified, the target state defaults to the first state of the TODO state
6207 sequence.}.  In the example above, setting the state to DONE would actually
6208 switch the date like this:
6210 @example
6211 ** TODO Pay the rent
6212    DEADLINE: <2005-11-01 Tue +1m>
6213 @end example
6215 @vindex org-log-repeat
6216 A timestamp@footnote{You can change this using the option
6217 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
6218 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
6219 will also be prompted for a note.} will be added under the deadline, to keep
6220 a record that you actually acted on the previous instance of this deadline.
6222 As a consequence of shifting the base date, this entry will no longer be
6223 visible in the agenda when checking past dates, but all future instances
6224 will be visible.
6226 With the @samp{+1m} cookie, the date shift will always be exactly one
6227 month.  So if you have not paid the rent for three months, marking this
6228 entry DONE will still keep it as an overdue deadline.  Depending on the
6229 task, this may not be the best way to handle it.  For example, if you
6230 forgot to call your father for 3 weeks, it does not make sense to call
6231 him 3 times in a single day to make up for it.  Finally, there are tasks
6232 like changing batteries which should always repeat a certain time
6233 @i{after} the last time you did it.  For these tasks, Org mode has
6234 special repeaters  @samp{++} and @samp{.+}.  For example:
6236 @example
6237 ** TODO Call Father
6238    DEADLINE: <2008-02-10 Sun ++1w>
6239    Marking this DONE will shift the date by at least one week,
6240    but also by as many weeks as it takes to get this date into
6241    the future.  However, it stays on a Sunday, even if you called
6242    and marked it done on Saturday.
6243 ** TODO Check the batteries in the smoke detectors
6244    DEADLINE: <2005-11-01 Tue .+1m>
6245    Marking this DONE will shift the date to one month after
6246    today.
6247 @end example
6249 @vindex org-agenda-skip-scheduled-if-deadline-is-shown
6250 You may have both scheduling and deadline information for a specific task.
6251 If the repeater is set for the scheduling information only, you probably want
6252 the repeater to be ignored after the deadline.  If so, set the variable
6253 @code{org-agenda-skip-scheduled-if-deadline-is-shown} to
6254 @code{repeated-after-deadline}.  If you want both scheduling and deadline
6255 information to repeat after the same interval, set the same repeater for both
6256 timestamps.
6258 An alternative to using a repeater is to create a number of copies of a task
6259 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
6260 created for this purpose, it is described in @ref{Structure editing}.
6263 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
6264 @section Clocking work time
6265 @cindex clocking time
6266 @cindex time clocking
6268 Org mode allows you to clock the time you spend on specific tasks in a
6269 project.  When you start working on an item, you can start the clock.  When
6270 you stop working on that task, or when you mark the task done, the clock is
6271 stopped and the corresponding time interval is recorded.  It also computes
6272 the total time spent on each subtree@footnote{Clocking only works if all
6273 headings are indented with less than 30 stars.  This is a hardcoded
6274 limitation of `lmax' in `org-clock-sum'.} of a project.  And it remembers a
6275 history or tasks recently clocked, to that you can jump quickly between a
6276 number of tasks absorbing your time.
6278 To save the clock history across Emacs sessions, use
6279 @lisp
6280 (setq org-clock-persist 'history)
6281 (org-clock-persistence-insinuate)
6282 @end lisp
6283 When you clock into a new task after resuming Emacs, the incomplete
6284 clock@footnote{To resume the clock under the assumption that you have worked
6285 on this task while outside Emacs, use @code{(setq org-clock-persist t)}.}
6286 will be found (@pxref{Resolving idle time}) and you will be prompted about
6287 what to do with it.
6289 @menu
6290 * Clocking commands::           Starting and stopping a clock
6291 * The clock table::             Detailed reports
6292 * Resolving idle time::         Resolving time when you've been idle
6293 @end menu
6295 @node Clocking commands, The clock table, Clocking work time, Clocking work time
6296 @subsection Clocking commands
6298 @table @kbd
6299 @orgcmd{C-c C-x C-i,org-clock-in}
6300 @vindex org-clock-into-drawer
6301 @vindex org-clock-continuously
6302 @cindex property, LOG_INTO_DRAWER
6303 Start the clock on the current item (clock-in).  This inserts the CLOCK
6304 keyword together with a timestamp.  If this is not the first clocking of
6305 this item, the multiple CLOCK lines will be wrapped into a
6306 @code{:LOGBOOK:} drawer (see also the variable
6307 @code{org-clock-into-drawer}).  You can also overrule
6308 the setting of this variable for a subtree by setting a
6309 @code{CLOCK_INTO_DRAWER} or @code{LOG_INTO_DRAWER} property.
6310 When called with a @kbd{C-u} prefix argument,
6311 select the task from a list of recently clocked tasks.  With two @kbd{C-u
6312 C-u} prefixes, clock into the task at point and mark it as the default task;
6313 the default task will then always be available with letter @kbd{d} when
6314 selecting a clocking task.  With three @kbd{C-u C-u C-u} prefixes, force
6315 continuous clocking by starting the clock when the last clock stopped.@*
6316 @cindex property: CLOCK_MODELINE_TOTAL
6317 @cindex property: LAST_REPEAT
6318 @vindex org-clock-modeline-total
6319 While the clock is running, the current clocking time is shown in the mode
6320 line, along with the title of the task.  The clock time shown will be all
6321 time ever clocked for this task and its children.  If the task has an effort
6322 estimate (@pxref{Effort estimates}), the mode line displays the current
6323 clocking time against it@footnote{To add an effort estimate ``on the fly'',
6324 hook a function doing this to @code{org-clock-in-prepare-hook}.}  If the task
6325 is a repeating one (@pxref{Repeated tasks}), only the time since the last
6326 reset of the task @footnote{as recorded by the @code{LAST_REPEAT} property}
6327 will be shown.  More control over what time is shown can be exercised with
6328 the @code{CLOCK_MODELINE_TOTAL} property.  It may have the values
6329 @code{current} to show only the current clocking instance, @code{today} to
6330 show all time clocked on this tasks today (see also the variable
6331 @code{org-extend-today-until}), @code{all} to include all time, or
6332 @code{auto} which is the default@footnote{See also the variable
6333 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
6334 mode line entry will pop up a menu with clocking options.
6336 @orgcmd{C-c C-x C-o,org-clock-out}
6337 @vindex org-log-note-clock-out
6338 Stop the clock (clock-out).  This inserts another timestamp at the same
6339 location where the clock was last started.  It also directly computes
6340 the resulting time in inserts it after the time range as @samp{=>
6341 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
6342 possibility to record an additional note together with the clock-out
6343 timestamp@footnote{The corresponding in-buffer setting is:
6344 @code{#+STARTUP: lognoteclock-out}}.
6345 @orgcmd{C-c C-x C-x,org-clock-in-last}
6346 @vindex org-clock-continuously
6347 Reclock the last clocked task.  With one @kbd{C-u} prefix argument,
6348 select the task from the clock history.  With two @kbd{C-u} prefixes,
6349 force continuous clocking by starting the clock when the last clock
6350 stopped.
6351 @orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
6352 Update the effort estimate for the current clock task.
6353 @kindex C-c C-y
6354 @kindex C-c C-c
6355 @orgcmdkkc{C-c C-c,C-c C-y,org-evaluate-time-range}
6356 Recompute the time interval after changing one of the timestamps.  This
6357 is only necessary if you edit the timestamps directly.  If you change
6358 them with @kbd{S-@key{cursor}} keys, the update is automatic.
6359 @orgcmd{C-S-@key{up/down},org-clock-timestamps-up/down}
6360 On @code{CLOCK} log lines, increase/decrease both timestamps so that the
6361 clock duration keeps the same.
6362 @orgcmd{S-M-@key{up/down},org-timestamp-up/down}
6363 On @code{CLOCK} log lines, increase/decrease the timestamp at point and
6364 the one of the previous (or the next clock) timestamp by the same duration.
6365 For example, if you hit @kbd{S-M-@key{up}} to increase a clocked-out timestamp
6366 by five minutes, then the clocked-in timestamp of the next clock will be
6367 increased by five minutes.
6368 @orgcmd{C-c C-t,org-todo}
6369 Changing the TODO state of an item to DONE automatically stops the clock
6370 if it is running in this same item.
6371 @orgcmd{C-c C-x C-q,org-clock-cancel}
6372 Cancel the current clock.  This is useful if a clock was started by
6373 mistake, or if you ended up working on something else.
6374 @orgcmd{C-c C-x C-j,org-clock-goto}
6375 Jump to the headline of the currently clocked in task.  With a @kbd{C-u}
6376 prefix arg, select the target task from a list of recently clocked tasks.
6377 @orgcmd{C-c C-x C-d,org-clock-display}
6378 @vindex org-remove-highlights-with-change
6379 Display time summaries for each subtree in the current buffer.  This puts
6380 overlays at the end of each headline, showing the total time recorded under
6381 that heading, including the time of any subheadings.  You can use visibility
6382 cycling to study the tree, but the overlays disappear when you change the
6383 buffer (see variable @code{org-remove-highlights-with-change}) or press
6384 @kbd{C-c C-c}.
6385 @end table
6387 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
6388 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
6389 worked on or closed during a day.
6391 @strong{Important:} note that both @code{org-clock-out} and
6392 @code{org-clock-in-last} can have a global keybinding and will not
6393 modify the window disposition.
6395 @node The clock table, Resolving idle time, Clocking commands, Clocking work time
6396 @subsection The clock table
6397 @cindex clocktable, dynamic block
6398 @cindex report, of clocked time
6400 Org mode can produce quite complex reports based on the time clocking
6401 information.  Such a report is called a @emph{clock table}, because it is
6402 formatted as one or several Org tables.
6404 @table @kbd
6405 @orgcmd{C-c C-x C-r,org-clock-report}
6406 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
6407 report as an Org mode table into the current file.  When the cursor is
6408 at an existing clock table, just update it.  When called with a prefix
6409 argument, jump to the first clock report in the current document and
6410 update it.  The clock table always includes also trees with
6411 @code{:ARCHIVE:} tag.
6412 @orgcmdkkc{C-c C-c,C-c C-x C-u,org-dblock-update}
6413 Update dynamic block at point.  The cursor needs to be in the
6414 @code{#+BEGIN} line of the dynamic block.
6415 @orgkey{C-u C-c C-x C-u}
6416 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
6417 you have several clock table blocks in a buffer.
6418 @orgcmdkxkc{S-@key{left},S-@key{right},org-clocktable-try-shift}
6419 Shift the current @code{:block} interval and update the table.  The cursor
6420 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
6421 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
6422 @end table
6425 Here is an example of the frame for a clock table as it is inserted into the
6426 buffer with the @kbd{C-c C-x C-r} command:
6428 @cindex #+BEGIN, clocktable
6429 @example
6430 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
6431 #+END: clocktable
6432 @end example
6433 @noindent
6434 @vindex org-clocktable-defaults
6435 The @samp{BEGIN} line and specify a number of options to define the scope,
6436 structure, and formatting of the report.  Defaults for all these options can
6437 be configured in the variable @code{org-clocktable-defaults}.
6439 @noindent First there are options that determine which clock entries are to
6440 be selected:
6441 @example
6442 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
6443              @r{Clocks at deeper levels will be summed into the upper level.}
6444 :scope       @r{The scope to consider.  This can be any of the following:}
6445              nil        @r{the current buffer or narrowed region}
6446              file       @r{the full current buffer}
6447              subtree    @r{the subtree where the clocktable is located}
6448              tree@var{N}      @r{the surrounding level @var{N} tree, for example @code{tree3}}
6449              tree       @r{the surrounding level 1 tree}
6450              agenda     @r{all agenda files}
6451              ("file"..) @r{scan these files}
6452              file-with-archives    @r{current file and its archives}
6453              agenda-with-archives  @r{all agenda files, including archives}
6454 :block       @r{The time block to consider.  This block is specified either}
6455              @r{absolute, or relative to the current time and may be any of}
6456              @r{these formats:}
6457              2007-12-31    @r{New year eve 2007}
6458              2007-12       @r{December 2007}
6459              2007-W50      @r{ISO-week 50 in 2007}
6460              2007-Q2       @r{2nd quarter in 2007}
6461              2007          @r{the year 2007}
6462              today, yesterday, today-@var{N}          @r{a relative day}
6463              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
6464              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
6465              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
6466              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
6467 :tstart      @r{A time string specifying when to start considering times.}
6468              @r{Relative times like @code{"<-2w>"} can also be used.  See}
6469              @r{@ref{Matching tags and properties} for relative time syntax.}
6470 :tend        @r{A time string specifying when to stop considering times.}
6471              @r{Relative times like @code{"<now>"} can also be used.  See}
6472              @r{@ref{Matching tags and properties} for relative time syntax.}
6473 :wstart      @r{The starting day of the week.  The default is 1 for monday.}
6474 :mstart      @r{The starting day of the month.  The default 1 is for the first}
6475              @r{day of the month.}
6476 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
6477              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
6478 :stepskip0   @r{Do not show steps that have zero time.}
6479 :fileskip0   @r{Do not show table sections from files which did not contribute.}
6480 :tags        @r{A tags match to select entries that should contribute.  See}
6481              @r{@ref{Matching tags and properties} for the match syntax.}
6482 @end example
6484 Then there are options which determine the formatting of the table.  There
6485 options are interpreted by the function @code{org-clocktable-write-default},
6486 but you can specify your own function using the @code{:formatter} parameter.
6487 @example
6488 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
6489 :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".}
6490 :link        @r{Link the item headlines in the table to their origins.}
6491 :narrow      @r{An integer to limit the width of the headline column in}
6492              @r{the org table.  If you write it like @samp{50!}, then the}
6493              @r{headline will also be shortened in export.}
6494 :indent      @r{Indent each headline field according to its level.}
6495 :tcolumns    @r{Number of columns to be used for times.  If this is smaller}
6496              @r{than @code{:maxlevel}, lower levels will be lumped into one column.}
6497 :level       @r{Should a level number column be included?}
6498 :compact     @r{Abbreviation for @code{:level nil :indent t :narrow 40! :tcolumns 1}}
6499              @r{All are overwritten except if there is an explicit @code{:narrow}}
6500 :timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
6501              @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
6502 :properties  @r{List of properties that should be shown in the table.  Each}
6503              @r{property will get its own column.}
6504 :inherit-props @r{When this flag is @code{t}, the values for @code{:properties} will be inherited.}
6505 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
6506              @r{As a special case, @samp{:formula %} adds a column with % time.}
6507              @r{If you do not specify a formula here, any existing formula}
6508              @r{below the clock table will survive updates and be evaluated.}
6509 :formatter   @r{A function to format clock data and insert it into the buffer.}
6510 @end example
6511 To get a clock summary of the current level 1 tree, for the current
6512 day, you could write
6513 @example
6514 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
6515 #+END: clocktable
6516 @end example
6517 @noindent
6518 and to use a specific time range you could write@footnote{Note that all
6519 parameters must be specified in a single line---the line is broken here
6520 only to fit it into the manual.}
6521 @example
6522 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
6523                     :tend "<2006-08-10 Thu 12:00>"
6524 #+END: clocktable
6525 @end example
6526 A range starting a week ago and ending right now could be written as
6527 @example
6528 #+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
6529 #+END: clocktable
6530 @end example
6531 A summary of the current subtree with % times would be
6532 @example
6533 #+BEGIN: clocktable :scope subtree :link t :formula %
6534 #+END: clocktable
6535 @end example
6536 A horizontally compact representation of everything clocked during last week
6537 would be
6538 @example
6539 #+BEGIN: clocktable :scope agenda :block lastweek :compact t
6540 #+END: clocktable
6541 @end example
6543 @node Resolving idle time,  , The clock table, Clocking work time
6544 @subsection Resolving idle time and continuous clocking
6546 @subsubheading Resolving idle time
6547 @cindex resolve idle time
6548 @vindex org-clock-x11idle-program-name
6550 @cindex idle, resolve, dangling
6551 If you clock in on a work item, and then walk away from your
6552 computer---perhaps to take a phone call---you often need to ``resolve'' the
6553 time you were away by either subtracting it from the current clock, or
6554 applying it to another one.
6556 @vindex org-clock-idle-time
6557 By customizing the variable @code{org-clock-idle-time} to some integer, such
6558 as 10 or 15, Emacs can alert you when you get back to your computer after
6559 being idle for that many minutes@footnote{On computers using Mac OS X,
6560 idleness is based on actual user idleness, not just Emacs' idle time.  For
6561 X11, you can install a utility program @file{x11idle.c}, available in the
6562 @code{contrib/scripts} directory of the Org git distribution, or install the
6563 @file{xprintidle} package and set it to the variable
6564 @code{org-clock-x11idle-program-name} if you are running Debian, to get the
6565 same general treatment of idleness.  On other systems, idle time refers to
6566 Emacs idle time only.}, and ask what you want to do with the idle time.
6567 There will be a question waiting for you when you get back, indicating how
6568 much idle time has passed (constantly updated with the current amount), as
6569 well as a set of choices to correct the discrepancy:
6571 @table @kbd
6572 @item k
6573 To keep some or all of the minutes and stay clocked in, press @kbd{k}.  Org
6574 will ask how many of the minutes to keep.  Press @key{RET} to keep them all,
6575 effectively changing nothing, or enter a number to keep that many minutes.
6576 @item K
6577 If you use the shift key and press @kbd{K}, it will keep however many minutes
6578 you request and then immediately clock out of that task.  If you keep all of
6579 the minutes, this is the same as just clocking out of the current task.
6580 @item s
6581 To keep none of the minutes, use @kbd{s} to subtract all the away time from
6582 the clock, and then check back in from the moment you returned.
6583 @item S
6584 To keep none of the minutes and just clock out at the start of the away time,
6585 use the shift key and press @kbd{S}.  Remember that using shift will always
6586 leave you clocked out, no matter which option you choose.
6587 @item C
6588 To cancel the clock altogether, use @kbd{C}.  Note that if instead of
6589 canceling you subtract the away time, and the resulting clock amount is less
6590 than a minute, the clock will still be canceled rather than clutter up the
6591 log with an empty entry.
6592 @end table
6594 What if you subtracted those away minutes from the current clock, and now
6595 want to apply them to a new clock?  Simply clock in to any task immediately
6596 after the subtraction.  Org will notice that you have subtracted time ``on
6597 the books'', so to speak, and will ask if you want to apply those minutes to
6598 the next task you clock in on.
6600 There is one other instance when this clock resolution magic occurs.  Say you
6601 were clocked in and hacking away, and suddenly your cat chased a mouse who
6602 scared a hamster that crashed into your UPS's power button!  You suddenly
6603 lose all your buffers, but thanks to auto-save you still have your recent Org
6604 mode changes, including your last clock in.
6606 If you restart Emacs and clock into any task, Org will notice that you have a
6607 dangling clock which was never clocked out from your last session.  Using
6608 that clock's starting time as the beginning of the unaccounted-for period,
6609 Org will ask how you want to resolve that time.  The logic and behavior is
6610 identical to dealing with away time due to idleness; it is just happening due
6611 to a recovery event rather than a set amount of idle time.
6613 You can also check all the files visited by your Org agenda for dangling
6614 clocks at any time using @kbd{M-x org-resolve-clocks RET} (or @kbd{C-c C-x C-z}).
6616 @subsubheading Continuous clocking
6617 @cindex continuous clocking
6618 @vindex org-clock-continuously
6620 You may want to start clocking from the time when you clocked out the
6621 previous task.  To enable this systematically, set @code{org-clock-continuously}
6622 to @code{t}.  Each time you clock in, Org retrieves the clock-out time of the
6623 last clocked entry for this session, and start the new clock from there.
6625 If you only want this from time to time, use three universal prefix arguments
6626 with @code{org-clock-in} and two @kbd{C-u C-u} with @code{org-clock-in-last}.
6628 @node Effort estimates, Relative timer, Clocking work time, Dates and Times
6629 @section Effort estimates
6630 @cindex effort estimates
6632 @cindex property, Effort
6633 @vindex org-effort-property
6634 If you want to plan your work in a very detailed way, or if you need to
6635 produce offers with quotations of the estimated work effort, you may want to
6636 assign effort estimates to entries.  If you are also clocking your work, you
6637 may later want to compare the planned effort with the actual working time, a
6638 great way to improve planning estimates.  Effort estimates are stored in a
6639 special property @samp{Effort}@footnote{You may change the property being
6640 used with the variable @code{org-effort-property}.}.  You can set the effort
6641 for an entry with the following commands:
6643 @table @kbd
6644 @orgcmd{C-c C-x e,org-set-effort}
6645 Set the effort estimate for the current entry.  With a numeric prefix
6646 argument, set it to the Nth allowed value (see below).  This command is also
6647 accessible from the agenda with the @kbd{e} key.
6648 @orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
6649 Modify the effort estimate of the item currently being clocked.
6650 @end table
6652 Clearly the best way to work with effort estimates is through column view
6653 (@pxref{Column view}).  You should start by setting up discrete values for
6654 effort estimates, and a @code{COLUMNS} format that displays these values
6655 together with clock sums (if you want to clock your time).  For a specific
6656 buffer you can use
6658 @example
6659 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
6660 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
6661 @end example
6663 @noindent
6664 @vindex org-global-properties
6665 @vindex org-columns-default-format
6666 or, even better, you can set up these values globally by customizing the
6667 variables @code{org-global-properties} and @code{org-columns-default-format}.
6668 In particular if you want to use this setup also in the agenda, a global
6669 setup may be advised.
6671 The way to assign estimates to individual items is then to switch to column
6672 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
6673 value.  The values you enter will immediately be summed up in the hierarchy.
6674 In the column next to it, any clocked time will be displayed.
6676 @vindex org-agenda-columns-add-appointments-to-effort-sum
6677 If you switch to column view in the daily/weekly agenda, the effort column
6678 will summarize the estimated work effort for each day@footnote{Please note
6679 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
6680 column view}).}, and you can use this to find space in your schedule.  To get
6681 an overview of the entire part of the day that is committed, you can set the
6682 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
6683 appointments on a day that take place over a specified time interval will
6684 then also be added to the load estimate of the day.
6686 Effort estimates can be used in secondary agenda filtering that is triggered
6687 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
6688 these estimates defined consistently, two or three key presses will narrow
6689 down the list to stuff that fits into an available time slot.
6691 @node Relative timer, Countdown timer, Effort estimates, Dates and Times
6692 @section Taking notes with a relative timer
6693 @cindex relative timer
6695 When taking notes during, for example, a meeting or a video viewing, it can
6696 be useful to have access to times relative to a starting time.  Org provides
6697 such a relative timer and make it easy to create timed notes.
6699 @table @kbd
6700 @orgcmd{C-c C-x .,org-timer}
6701 Insert a relative time into the buffer.  The first time you use this, the
6702 timer will be started.  When called with a prefix argument, the timer is
6703 restarted.
6704 @orgcmd{C-c C-x -,org-timer-item}
6705 Insert a description list item with the current relative time.  With a prefix
6706 argument, first reset the timer to 0.
6707 @orgcmd{M-@key{RET},org-insert-heading}
6708 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
6709 new timer items.
6710 @c for key sequences with a comma, command name macros fail :(
6711 @kindex C-c C-x ,
6712 @item C-c C-x ,
6713 Pause the timer, or continue it if it is already paused
6714 (@command{org-timer-pause-or-continue}).
6715 @c removed the sentence because it is redundant to the following item
6716 @kindex C-u C-c C-x ,
6717 @item C-u C-c C-x ,
6718 Stop the timer.  After this, you can only start a new timer, not continue the
6719 old one.  This command also removes the timer from the mode line.
6720 @orgcmd{C-c C-x 0,org-timer-start}
6721 Reset the timer without inserting anything into the buffer.  By default, the
6722 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
6723 specific starting offset.  The user is prompted for the offset, with a
6724 default taken from a timer string at point, if any, So this can be used to
6725 restart taking notes after a break in the process.  When called with a double
6726 prefix argument @kbd{C-u C-u}, change all timer strings in the active region
6727 by a certain amount.  This can be used to fix timer strings if the timer was
6728 not started at exactly the right moment.
6729 @end table
6731 @node Countdown timer,  , Relative timer, Dates and Times
6732 @section Countdown timer
6733 @cindex Countdown timer
6734 @kindex C-c C-x ;
6735 @kindex ;
6737 Calling @code{org-timer-set-timer} from an Org mode buffer runs a countdown
6738 timer.  Use @kbd{;} from agenda buffers, @key{C-c C-x ;} everywhere else.
6740 @code{org-timer-set-timer} prompts the user for a duration and displays a
6741 countdown timer in the modeline.  @code{org-timer-default-timer} sets the
6742 default countdown value.  Giving a prefix numeric argument overrides this
6743 default value.
6745 @node Capture - Refile - Archive, Agenda Views, Dates and Times, Top
6746 @chapter Capture - Refile - Archive
6747 @cindex capture
6749 An important part of any organization system is the ability to quickly
6750 capture new ideas and tasks, and to associate reference material with them.
6751 Org does this using a process called @i{capture}.  It also can store files
6752 related to a task (@i{attachments}) in a special directory.  Once in the
6753 system, tasks and projects need to be moved around.  Moving completed project
6754 trees to an archive file keeps the system compact and fast.
6756 @menu
6757 * Capture::                     Capturing new stuff
6758 * Attachments::                 Add files to tasks
6759 * RSS Feeds::                   Getting input from RSS feeds
6760 * Protocols::                   External (e.g., Browser) access to Emacs and Org
6761 * Refile and copy::             Moving/copying a tree from one place to another
6762 * Archiving::                   What to do with finished projects
6763 @end menu
6765 @node Capture, Attachments, Capture - Refile - Archive, Capture - Refile - Archive
6766 @section Capture
6767 @cindex capture
6769 Capture lets you quickly store notes with little interruption of your work
6770 flow.  Org's method for capturing new items is heavily inspired by John
6771 Wiegley excellent @code{remember.el} package.  Up to version 6.36, Org
6772 used a special setup for @file{remember.el}, then replaced it with
6773 @file{org-remember.el}.  As of version 8.0, @file{org-remember.el} has
6774 been completely replaced by @file{org-capture.el}.
6776 If your configuration depends on @file{org-remember.el}, you need to update
6777 it and use the setup described below.  To convert your
6778 @code{org-remember-templates}, run the command
6779 @example
6780 @kbd{M-x org-capture-import-remember-templates RET}
6781 @end example
6782 @noindent and then customize the new variable with @kbd{M-x
6783 customize-variable org-capture-templates}, check the result, and save the
6784 customization.
6786 @menu
6787 * Setting up capture::          Where notes will be stored
6788 * Using capture::               Commands to invoke and terminate capture
6789 * Capture templates::           Define the outline of different note types
6790 @end menu
6792 @node Setting up capture, Using capture, Capture, Capture
6793 @subsection Setting up capture
6795 The following customization sets a default target file for notes, and defines
6796 a global key@footnote{Please select your own key, @kbd{C-c c} is only a
6797 suggestion.}  for capturing new material.
6799 @vindex org-default-notes-file
6800 @smalllisp
6801 @group
6802 (setq org-default-notes-file (concat org-directory "/notes.org"))
6803 (define-key global-map "\C-cc" 'org-capture)
6804 @end group
6805 @end smalllisp
6807 @node Using capture, Capture templates, Setting up capture, Capture
6808 @subsection Using capture
6810 @table @kbd
6811 @orgcmd{C-c c,org-capture}
6812 Call the command @code{org-capture}.  Note that this keybinding is global and
6813 not active by default: you need to install it.  If you have templates
6814 @cindex date tree
6815 defined @pxref{Capture templates}, it will offer these templates for
6816 selection or use a new Org outline node as the default template.  It will
6817 insert the template into the target file and switch to an indirect buffer
6818 narrowed to this new node.  You may then insert the information you want.
6820 @orgcmd{C-c C-c,org-capture-finalize}
6821 Once you have finished entering information into the capture buffer, @kbd{C-c
6822 C-c} will return you to the window configuration before the capture process,
6823 so that you can resume your work without further distraction.  When called
6824 with a prefix arg, finalize and then jump to the captured item.
6826 @orgcmd{C-c C-w,org-capture-refile}
6827 Finalize the capture process by refiling (@pxref{Refile and copy}) the note to
6828 a different place.  Please realize that this is a normal refiling command
6829 that will be executed---so the cursor position at the moment you run this
6830 command is important.  If you have inserted a tree with a parent and
6831 children, first move the cursor back to the parent.  Any prefix argument
6832 given to this command will be passed on to the @code{org-refile} command.
6834 @orgcmd{C-c C-k,org-capture-kill}
6835 Abort the capture process and return to the previous state.
6837 @end table
6839 You can also call @code{org-capture} in a special way from the agenda, using
6840 the @kbd{k c} key combination.  With this access, any timestamps inserted by
6841 the selected capture template will default to the cursor date in the agenda,
6842 rather than to the current date.
6844 To find the locations of the last stored capture, use @code{org-capture} with
6845 prefix commands:
6847 @table @kbd
6848 @orgkey{C-u C-c c}
6849 Visit the target location of a capture template.  You get to select the
6850 template in the usual way.
6851 @orgkey{C-u C-u C-c c}
6852 Visit the last stored capture item in its buffer.
6853 @end table
6855 @vindex org-capture-bookmark
6856 @cindex org-capture-last-stored
6857 You can also jump to the bookmark @code{org-capture-last-stored}, which will
6858 automatically be created unless you set @code{org-capture-bookmark} to
6859 @code{nil}.
6861 To insert the capture at point in an Org buffer, call @code{org-capture} with
6862 a @code{C-0} prefix argument.
6864 @node Capture templates,  , Using capture, Capture
6865 @subsection Capture templates
6866 @cindex templates, for Capture
6868 You can use templates for different types of capture items, and
6869 for different target locations.  The easiest way to create such templates is
6870 through the customize interface.
6872 @table @kbd
6873 @orgkey{C-c c C}
6874 Customize the variable @code{org-capture-templates}.
6875 @end table
6877 Before we give the formal description of template definitions, let's look at
6878 an example.  Say you would like to use one template to create general TODO
6879 entries, and you want to put these entries under the heading @samp{Tasks} in
6880 your file @file{~/org/gtd.org}.  Also, a date tree in the file
6881 @file{journal.org} should capture journal entries.  A possible configuration
6882 would look like:
6884 @smalllisp
6885 @group
6886 (setq org-capture-templates
6887  '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
6888         "* TODO %?\n  %i\n  %a")
6889    ("j" "Journal" entry (file+datetree "~/org/journal.org")
6890         "* %?\nEntered on %U\n  %i\n  %a")))
6891 @end group
6892 @end smalllisp
6894 @noindent If you then press @kbd{C-c c t}, Org will prepare the template
6895 for you like this:
6896 @example
6897 * TODO
6898   [[file:@var{link to where you initiated capture}]]
6899 @end example
6901 @noindent
6902 During expansion of the template, @code{%a} has been replaced by a link to
6903 the location from where you called the capture command.  This can be
6904 extremely useful for deriving tasks from emails, for example.  You fill in
6905 the task definition, press @code{C-c C-c} and Org returns you to the same
6906 place where you started the capture process.
6908 To define special keys to capture to a particular template without going
6909 through the interactive template selection, you can create your key binding
6910 like this:
6912 @lisp
6913 (define-key global-map "\C-cx"
6914    (lambda () (interactive) (org-capture nil "x")))
6915 @end lisp
6917 @menu
6918 * Template elements::           What is needed for a complete template entry
6919 * Template expansion::          Filling in information about time and context
6920 * Templates in contexts::       Only show a template in a specific context
6921 @end menu
6923 @node Template elements, Template expansion, Capture templates, Capture templates
6924 @subsubsection Template elements
6926 Now lets look at the elements of a template definition.  Each entry in
6927 @code{org-capture-templates} is a list with the following items:
6929 @table @var
6930 @item keys
6931 The keys that will select the template, as a string, characters
6932 only, for example @code{"a"} for a template to be selected with a
6933 single key, or @code{"bt"} for selection with two keys.  When using
6934 several keys, keys using the same prefix key must be sequential
6935 in the list and preceded by a 2-element entry explaining the
6936 prefix key, for example
6937 @smalllisp
6938          ("b" "Templates for marking stuff to buy")
6939 @end smalllisp
6940 @noindent If you do not define a template for the @kbd{C} key, this key will
6941 be used to open the customize buffer for this complex variable.
6943 @item description
6944 A short string describing the template, which will be shown during
6945 selection.
6947 @item type
6948 The type of entry, a symbol.  Valid values are:
6950 @table @code
6951 @item entry
6952 An Org mode node, with a headline.  Will be filed as the child of the target
6953 entry or as a top-level entry.  The target file should be an Org mode file.
6954 @item item
6955 A plain list item, placed in the first plain  list at the target
6956 location.  Again the target file should be an Org file.
6957 @item checkitem
6958 A checkbox item.  This only differs from the plain list item by the
6959 default template.
6960 @item table-line
6961 a new line in the first table at the target location.  Where exactly the
6962 line will be inserted depends on the properties @code{:prepend} and
6963 @code{:table-line-pos} (see below).
6964 @item plain
6965 Text to be inserted as it is.
6966 @end table
6968 @item target
6969 @vindex org-default-notes-file
6970 Specification of where the captured item should be placed.  In Org mode
6971 files, targets usually define a node.  Entries will become children of this
6972 node.  Other types will be added to the table or list in the body of this
6973 node.  Most target specifications contain a file name.  If that file name is
6974 the empty string, it defaults to @code{org-default-notes-file}.  A file can
6975 also be given as a variable, function, or Emacs Lisp form.
6977 Valid values are:
6979 @table @code
6980 @item (file "path/to/file")
6981 Text will be placed at the beginning or end of that file.
6983 @item (id "id of existing org entry")
6984 Filing as child of this entry, or in the body of the entry.
6986 @item (file+headline "path/to/file" "node headline")
6987 Fast configuration if the target heading is unique in the file.
6989 @item (file+olp "path/to/file" "Level 1 heading" "Level 2" ...)
6990 For non-unique headings, the full path is safer.
6992 @item (file+regexp  "path/to/file" "regexp to find location")
6993 Use a regular expression to position the cursor.
6995 @item (file+datetree "path/to/file")
6996 Will create a heading in a date tree for today's date.
6998 @item (file+datetree+prompt "path/to/file")
6999 Will create a heading in a date tree, but will prompt for the date.
7001 @item (file+function "path/to/file" function-finding-location)
7002 A function to find the right location in the file.
7004 @item (clock)
7005 File to the entry that is currently being clocked.
7007 @item (function function-finding-location)
7008 Most general way, write your own function to find both
7009 file and location.
7010 @end table
7012 @item template
7013 The template for creating the capture item.  If you leave this empty, an
7014 appropriate default template will be used.  Otherwise this is a string with
7015 escape codes, which will be replaced depending on time and context of the
7016 capture call.  The string with escapes may be loaded from a template file,
7017 using the special syntax @code{(file "path/to/template")}.  See below for
7018 more details.
7020 @item properties
7021 The rest of the entry is a property list of additional options.
7022 Recognized properties are:
7024 @table @code
7025 @item :prepend
7026 Normally new captured information will be appended at
7027 the target location (last child, last table line, last list item...).
7028 Setting this property will change that.
7030 @item :immediate-finish
7031 When set, do not offer to edit the information, just
7032 file it away immediately.  This makes sense if the template only needs
7033 information that can be added automatically.
7035 @item :empty-lines
7036 Set this to the number of lines to insert
7037 before and after the new item.  Default 0, only common other value is 1.
7039 @item :clock-in
7040 Start the clock in this item.
7042 @item :clock-keep
7043 Keep the clock running when filing the captured entry.
7045 @item :clock-resume
7046 If starting the capture interrupted a clock, restart that clock when finished
7047 with the capture.  Note that @code{:clock-keep} has precedence over
7048 @code{:clock-resume}.  When setting both to @code{t}, the current clock will
7049 run and the previous one will not be resumed.
7051 @item :unnarrowed
7052 Do not narrow the target buffer, simply show the full buffer.  Default is to
7053 narrow it so that you only see the new material.
7055 @item :table-line-pos
7056 Specification of the location in the table where the new line should be
7057 inserted.  It should be a string like @code{"II-3"} meaning that the new
7058 line should become the third line before the second horizontal separator
7059 line.
7061 @item :kill-buffer
7062 If the target file was not yet visited when capture was invoked, kill the
7063 buffer again after capture is completed.
7064 @end table
7065 @end table
7067 @node Template expansion, Templates in contexts, Template elements, Capture templates
7068 @subsubsection Template expansion
7070 In the template itself, special @kbd{%}-escapes@footnote{If you need one of
7071 these sequences literally, escape the @kbd{%} with a backslash.} allow
7072 dynamic insertion of content.  The templates are expanded in the order given here:
7074 @smallexample
7075 %[@var{file}]     @r{Insert the contents of the file given by @var{file}.}
7076 %(@var{sexp})     @r{Evaluate Elisp @var{sexp} and replace with the result.}
7077                   @r{For convenience, %:keyword (see below) placeholders}
7078                   @r{within the expression will be expanded prior to this.}
7079                   @r{The sexp must return a string.}
7080 %<...>      @r{The result of format-time-string on the ... format specification.}
7081 %t          @r{Timestamp, date only.}
7082 %T          @r{Timestamp, with date and time.}
7083 %u, %U      @r{Like the above, but inactive timestamps.}
7084 %i          @r{Initial content, the region when capture is called while the}
7085             @r{region is active.}
7086             @r{The entire text will be indented like @code{%i} itself.}
7087 %a          @r{Annotation, normally the link created with @code{org-store-link}.}
7088 %A          @r{Like @code{%a}, but prompt for the description part.}
7089 %l          @r{Like %a, but only insert the literal link.}
7090 %c          @r{Current kill ring head.}
7091 %x          @r{Content of the X clipboard.}
7092 %k          @r{Title of the currently clocked task.}
7093 %K          @r{Link to the currently clocked task.}
7094 %n          @r{User name (taken from @code{user-full-name}).}
7095 %f          @r{File visited by current buffer when org-capture was called.}
7096 %F          @r{Full path of the file or directory visited by current buffer.}
7097 %:keyword   @r{Specific information for certain link types, see below.}
7098 %^g         @r{Prompt for tags, with completion on tags in target file.}
7099 %^G         @r{Prompt for tags, with completion all tags in all agenda files.}
7100 %^t         @r{Like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}.}
7101             @r{You may define a prompt like @code{%^@{Birthday@}t}.}
7102 %^C         @r{Interactive selection of which kill or clip to use.}
7103 %^L         @r{Like @code{%^C}, but insert as link.}
7104 %^@{@var{prop}@}p   @r{Prompt the user for a value for property @var{prop}.}
7105 %^@{@var{prompt}@}  @r{prompt the user for a string and replace this sequence with it.}
7106             @r{You may specify a default value and a completion table with}
7107             @r{%^@{prompt|default|completion2|completion3...@}.}
7108             @r{The arrow keys access a prompt-specific history.}
7109 %\n         @r{Insert the text entered at the nth %^@{@var{prompt}@}, where @code{n} is}
7110             @r{a number, starting from 1.}
7111 %?          @r{After completing the template, position cursor here.}
7112 @end smallexample
7114 @noindent
7115 For specific link types, the following keywords will be
7116 defined@footnote{If you define your own link types (@pxref{Adding
7117 hyperlink types}), any property you store with
7118 @code{org-store-link-props} can be accessed in capture templates in a
7119 similar way.}:
7121 @vindex org-from-is-user-regexp
7122 @smallexample
7123 Link type                        |  Available keywords
7124 ---------------------------------+----------------------------------------------
7125 bbdb                             |  %:name %:company
7126 irc                              |  %:server %:port %:nick
7127 vm, vm-imap, wl, mh, mew, rmail  |  %:type %:subject %:message-id
7128                                  |  %:from %:fromname %:fromaddress
7129                                  |  %:to   %:toname   %:toaddress
7130                                  |  %:date @r{(message date header field)}
7131                                  |  %:date-timestamp @r{(date as active timestamp)}
7132                                  |  %:date-timestamp-inactive @r{(date as inactive timestamp)}
7133                                  |  %: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}.}}
7134 gnus                             |  %:group, @r{for messages also all email fields}
7135 w3, w3m                          |  %:url
7136 info                             |  %:file %:node
7137 calendar                         |  %:date
7138 @end smallexample
7140 @noindent
7141 To place the cursor after template expansion use:
7143 @smallexample
7144 %?          @r{After completing the template, position cursor here.}
7145 @end smallexample
7147 @node Templates in contexts,  , Template expansion, Capture templates
7148 @subsubsection Templates in contexts
7150 @vindex org-capture-templates-contexts
7151 To control whether a capture template should be accessible from a specific
7152 context, you can customize @var{org-capture-templates-contexts}.  Let's say
7153 for example that you have a capture template @code{"p"} for storing Gnus
7154 emails containing patches.  Then you would configure this option like this:
7156 @smalllisp
7157 (setq org-capture-templates-contexts
7158       '(("p" (in-mode . "message-mode"))))
7159 @end smalllisp
7161 You can also tell that the command key @code{"p"} should refer to another
7162 template.  In that case, add this command key like this:
7164 @smalllisp
7165 (setq org-capture-templates-contexts
7166       '(("p" "q" (in-mode . "message-mode"))))
7167 @end smalllisp
7169 See the docstring of the variable for more information.
7171 @node Attachments, RSS Feeds, Capture, Capture - Refile - Archive
7172 @section Attachments
7173 @cindex attachments
7175 @vindex org-attach-directory
7176 It is often useful to associate reference material with an outline node/task.
7177 Small chunks of plain text can simply be stored in the subtree of a project.
7178 Hyperlinks (@pxref{Hyperlinks}) can establish associations with
7179 files that live elsewhere on your computer or in the cloud, like emails or
7180 source code files belonging to a project.  Another method is @i{attachments},
7181 which are files located in a directory belonging to an outline node.  Org
7182 uses directories named by the unique ID of each entry.  These directories are
7183 located in the @file{data} directory which lives in the same directory where
7184 your Org file lives@footnote{If you move entries or Org files from one
7185 directory to another, you may want to configure @code{org-attach-directory}
7186 to contain an absolute path.}.  If you initialize this directory with
7187 @code{git init}, Org will automatically commit changes when it sees them.
7188 The attachment system has been contributed to Org by John Wiegley.
7190 In cases where it seems better to do so, you can also attach a directory of your
7191 choice to an entry.  You can also make children inherit the attachment
7192 directory from a parent, so that an entire subtree uses the same attached
7193 directory.
7195 @noindent The following commands deal with attachments:
7197 @table @kbd
7198 @orgcmd{C-c C-a,org-attach}
7199 The dispatcher for commands related to the attachment system.  After these
7200 keys, a list of commands is displayed and you must press an additional key
7201 to select a command:
7203 @table @kbd
7204 @orgcmdtkc{a,C-c C-a a,org-attach-attach}
7205 @vindex org-attach-method
7206 Select a file and move it into the task's attachment directory.  The file
7207 will be copied, moved, or linked, depending on @code{org-attach-method}.
7208 Note that hard links are not supported on all systems.
7210 @kindex C-c C-a c
7211 @kindex C-c C-a m
7212 @kindex C-c C-a l
7213 @item c/m/l
7214 Attach a file using the copy/move/link method.
7215 Note that hard links are not supported on all systems.
7217 @orgcmdtkc{n,C-c C-a n,org-attach-new}
7218 Create a new attachment as an Emacs buffer.
7220 @orgcmdtkc{z,C-c C-a z,org-attach-sync}
7221 Synchronize the current task with its attachment directory, in case you added
7222 attachments yourself.
7224 @orgcmdtkc{o,C-c C-a o,org-attach-open}
7225 @vindex org-file-apps
7226 Open current task's attachment.  If there is more than one, prompt for a
7227 file name first.  Opening will follow the rules set by @code{org-file-apps}.
7228 For more details, see the information on following hyperlinks
7229 (@pxref{Handling links}).
7231 @orgcmdtkc{O,C-c C-a O,org-attach-open-in-emacs}
7232 Also open the attachment, but force opening the file in Emacs.
7234 @orgcmdtkc{f,C-c C-a f,org-attach-reveal}
7235 Open the current task's attachment directory.
7237 @orgcmdtkc{F,C-c C-a F,org-attach-reveal-in-emacs}
7238 Also open the directory, but force using @command{dired} in Emacs.
7240 @orgcmdtkc{d,C-c C-a d,org-attach-delete-one}
7241 Select and delete a single attachment.
7243 @orgcmdtkc{D,C-c C-a D,org-attach-delete-all}
7244 Delete all of a task's attachments.  A safer way is to open the directory in
7245 @command{dired} and delete from there.
7247 @orgcmdtkc{s,C-c C-a s,org-attach-set-directory}
7248 @cindex property, ATTACH_DIR
7249 Set a specific directory as the entry's attachment directory.  This works by
7250 putting the directory path into the @code{ATTACH_DIR} property.
7252 @orgcmdtkc{i,C-c C-a i,org-attach-set-inherit}
7253 @cindex property, ATTACH_DIR_INHERIT
7254 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
7255 same directory for attachments as the parent does.
7256 @end table
7257 @end table
7259 @node RSS Feeds, Protocols, Attachments, Capture - Refile - Archive
7260 @section RSS feeds
7261 @cindex RSS feeds
7262 @cindex Atom feeds
7264 Org can add and change entries based on information found in RSS feeds and
7265 Atom feeds.  You could use this to make a task out of each new podcast in a
7266 podcast feed.  Or you could use a phone-based note-creating service on the
7267 web to import tasks into Org.  To access feeds, configure the variable
7268 @code{org-feed-alist}.  The docstring of this variable has detailed
7269 information.  Here is just an example:
7271 @smalllisp
7272 @group
7273 (setq org-feed-alist
7274      '(("Slashdot"
7275          "http://rss.slashdot.org/Slashdot/slashdot"
7276          "~/txt/org/feeds.org" "Slashdot Entries")))
7277 @end group
7278 @end smalllisp
7280 @noindent
7281 will configure that new items from the feed provided by
7282 @code{rss.slashdot.org} will result in new entries in the file
7283 @file{~/org/feeds.org} under the heading @samp{Slashdot Entries}, whenever
7284 the following command is used:
7286 @table @kbd
7287 @orgcmd{C-c C-x g,org-feed-update-all}
7288 @item C-c C-x g
7289 Collect items from the feeds configured in @code{org-feed-alist} and act upon
7290 them.
7291 @orgcmd{C-c C-x G,org-feed-goto-inbox}
7292 Prompt for a feed name and go to the inbox configured for this feed.
7293 @end table
7295 Under the same headline, Org will create a drawer @samp{FEEDSTATUS} in which
7296 it will store information about the status of items in the feed, to avoid
7297 adding the same item several times.  You should add @samp{FEEDSTATUS} to the
7298 list of drawers in that file:
7300 @example
7301 #+DRAWERS: LOGBOOK PROPERTIES FEEDSTATUS
7302 @end example
7304 For more information, including how to read atom feeds, see
7305 @file{org-feed.el} and the docstring of @code{org-feed-alist}.
7307 @node Protocols, Refile and copy, RSS Feeds, Capture - Refile - Archive
7308 @section Protocols for external access
7309 @cindex protocols, for external access
7310 @cindex emacsserver
7312 You can set up Org for handling protocol calls from outside applications that
7313 are passed to Emacs through the @file{emacsserver}.  For example, you can
7314 configure bookmarks in your web browser to send a link to the current page to
7315 Org and create a note from it using capture (@pxref{Capture}).  Or you
7316 could create a bookmark that will tell Emacs to open the local source file of
7317 a remote website you are looking at with the browser.  See
7318 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
7319 documentation and setup instructions.
7321 @node Refile and copy, Archiving, Protocols, Capture - Refile - Archive
7322 @section Refile and copy
7323 @cindex refiling notes
7324 @cindex copying notes
7326 When reviewing the captured data, you may want to refile or to copy some of
7327 the entries into a different list, for example into a project.  Cutting,
7328 finding the right location, and then pasting the note is cumbersome.  To
7329 simplify this process, you can use the following special command:
7331 @table @kbd
7332 @orgcmd{C-c M-w,org-copy}
7333 @findex org-copy
7334 Copying works like refiling, except that the original note is not deleted.
7335 @orgcmd{C-c C-w,org-refile}
7336 @findex org-refile
7337 @vindex org-reverse-note-order
7338 @vindex org-refile-targets
7339 @vindex org-refile-use-outline-path
7340 @vindex org-outline-path-complete-in-steps
7341 @vindex org-refile-allow-creating-parent-nodes
7342 @vindex org-log-refile
7343 @vindex org-refile-use-cache
7344 Refile the entry or region at point.  This command offers possible locations
7345 for refiling the entry and lets you select one with completion.  The item (or
7346 all items in the region) is filed below the target heading as a subitem.
7347 Depending on @code{org-reverse-note-order}, it will be either the first or
7348 last subitem.@*
7349 By default, all level 1 headlines in the current buffer are considered to be
7350 targets, but you can have more complex definitions across a number of files.
7351 See the variable @code{org-refile-targets} for details.  If you would like to
7352 select a location via a file-path-like completion along the outline path, see
7353 the variables @code{org-refile-use-outline-path} and
7354 @code{org-outline-path-complete-in-steps}.  If you would like to be able to
7355 create new nodes as new parents for refiling on the fly, check the
7356 variable @code{org-refile-allow-creating-parent-nodes}.
7357 When the variable @code{org-log-refile}@footnote{with corresponding
7358 @code{#+STARTUP} keywords @code{logrefile}, @code{lognoterefile},
7359 and @code{nologrefile}} is set, a timestamp or a note will be
7360 recorded when an entry has been refiled.
7361 @orgkey{C-u C-c C-w}
7362 Use the refile interface to jump to a heading.
7363 @orgcmd{C-u C-u C-c C-w,org-refile-goto-last-stored}
7364 Jump to the location where @code{org-refile} last moved a tree to.
7365 @item C-2 C-c C-w
7366 Refile as the child of the item currently being clocked.
7367 @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}
7368 Clear the target cache.  Caching of refile targets can be turned on by
7369 setting @code{org-refile-use-cache}.  To make the command see new possible
7370 targets, you have to clear the cache with this command.
7371 @end table
7373 @node Archiving,  , Refile and copy, Capture - Refile - Archive
7374 @section Archiving
7375 @cindex archiving
7377 When a project represented by a (sub)tree is finished, you may want
7378 to move the tree out of the way and to stop it from contributing to the
7379 agenda.  Archiving is important to keep your working files compact and global
7380 searches like the construction of agenda views fast.
7382 @table @kbd
7383 @orgcmd{C-c C-x C-a,org-archive-subtree-default}
7384 @vindex org-archive-default-command
7385 Archive the current entry using the command specified in the variable
7386 @code{org-archive-default-command}.
7387 @end table
7389 @menu
7390 * Moving subtrees::             Moving a tree to an archive file
7391 * Internal archiving::          Switch off a tree but keep it in the file
7392 @end menu
7394 @node Moving subtrees, Internal archiving, Archiving, Archiving
7395 @subsection Moving a tree to the archive file
7396 @cindex external archiving
7398 The most common archiving action is to move a project tree to another file,
7399 the archive file.
7401 @table @kbd
7402 @orgcmdkskc{C-c C-x C-s,C-c $,org-archive-subtree}
7403 @vindex org-archive-location
7404 Archive the subtree starting at the cursor position to the location
7405 given by @code{org-archive-location}.
7406 @orgkey{C-u C-c C-x C-s}
7407 Check if any direct children of the current headline could be moved to
7408 the archive.  To do this, each subtree is checked for open TODO entries.
7409 If none are found, the command offers to move it to the archive
7410 location.  If the cursor is @emph{not} on a headline when this command
7411 is invoked, the level 1 trees will be checked.
7412 @end table
7414 @cindex archive locations
7415 The default archive location is a file in the same directory as the
7416 current file, with the name derived by appending @file{_archive} to the
7417 current file name.  You can also choose what heading to file archived
7418 items under, with the possibility to add them to a datetree in a file.
7419 For information and examples on how to specify the file and the heading,
7420 see the documentation string of the variable
7421 @code{org-archive-location}.
7423 There is also an in-buffer option for setting this variable, for
7424 example@footnote{For backward compatibility, the following also works:
7425 If there are several such lines in a file, each specifies the archive
7426 location for the text below it.  The first such line also applies to any
7427 text before its definition.  However, using this method is
7428 @emph{strongly} deprecated as it is incompatible with the outline
7429 structure of the document.  The correct method for setting multiple
7430 archive locations in a buffer is using properties.}:
7432 @cindex #+ARCHIVE
7433 @example
7434 #+ARCHIVE: %s_done::
7435 @end example
7437 @cindex property, ARCHIVE
7438 @noindent
7439 If you would like to have a special ARCHIVE location for a single entry
7440 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
7441 location as the value (@pxref{Properties and Columns}).
7443 @vindex org-archive-save-context-info
7444 When a subtree is moved, it receives a number of special properties that
7445 record context information like the file from where the entry came, its
7446 outline path the archiving time etc.  Configure the variable
7447 @code{org-archive-save-context-info} to adjust the amount of information
7448 added.
7451 @node Internal archiving,  , Moving subtrees, Archiving
7452 @subsection Internal archiving
7454 If you want to just switch off (for agenda views) certain subtrees without
7455 moving them to a different file, you can use the @code{ARCHIVE tag}.
7457 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
7458 its location in the outline tree, but behaves in the following way:
7459 @itemize @minus
7460 @item
7461 @vindex org-cycle-open-archived-trees
7462 It does not open when you attempt to do so with a visibility cycling
7463 command (@pxref{Visibility cycling}).  You can force cycling archived
7464 subtrees with @kbd{C-@key{TAB}}, or by setting the option
7465 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
7466 @code{show-all} will open archived subtrees.
7467 @item
7468 @vindex org-sparse-tree-open-archived-trees
7469 During sparse tree construction (@pxref{Sparse trees}), matches in
7470 archived subtrees are not exposed, unless you configure the option
7471 @code{org-sparse-tree-open-archived-trees}.
7472 @item
7473 @vindex org-agenda-skip-archived-trees
7474 During agenda view construction (@pxref{Agenda Views}), the content of
7475 archived trees is ignored unless you configure the option
7476 @code{org-agenda-skip-archived-trees}, in which case these trees will always
7477 be included.  In the agenda you can press @kbd{v a} to get archives
7478 temporarily included.
7479 @item
7480 @vindex org-export-with-archived-trees
7481 Archived trees are not exported (@pxref{Exporting}), only the headline
7482 is.  Configure the details using the variable
7483 @code{org-export-with-archived-trees}.
7484 @item
7485 @vindex org-columns-skip-archived-trees
7486 Archived trees are excluded from column view unless the variable
7487 @code{org-columns-skip-archived-trees} is configured to @code{nil}.
7488 @end itemize
7490 The following commands help manage the ARCHIVE tag:
7492 @table @kbd
7493 @orgcmd{C-c C-x a,org-toggle-archive-tag}
7494 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
7495 the headline changes to a shadowed face, and the subtree below it is
7496 hidden.
7497 @orgkey{C-u C-c C-x a}
7498 Check if any direct children of the current headline should be archived.
7499 To do this, each subtree is checked for open TODO entries.  If none are
7500 found, the command offers to set the ARCHIVE tag for the child.  If the
7501 cursor is @emph{not} on a headline when this command is invoked, the
7502 level 1 trees will be checked.
7503 @orgcmd{C-@kbd{TAB},org-force-cycle-archived}
7504 Cycle a tree even if it is tagged with ARCHIVE.
7505 @orgcmd{C-c C-x A,org-archive-to-archive-sibling}
7506 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
7507 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}.  The
7508 entry becomes a child of that sibling and in this way retains a lot of its
7509 original context, including inherited tags and approximate position in the
7510 outline.
7511 @end table
7514 @node Agenda Views, Markup, Capture - Refile - Archive, Top
7515 @chapter Agenda views
7516 @cindex agenda views
7518 Due to the way Org works, TODO items, time-stamped items, and
7519 tagged headlines can be scattered throughout a file or even a number of
7520 files.  To get an overview of open action items, or of events that are
7521 important for a particular date, this information must be collected,
7522 sorted and displayed in an organized way.
7524 Org can select items based on various criteria and display them
7525 in a separate buffer.  Seven different view types are provided:
7527 @itemize @bullet
7528 @item
7529 an @emph{agenda} that is like a calendar and shows information
7530 for specific dates,
7531 @item
7532 a @emph{TODO list} that covers all unfinished
7533 action items,
7534 @item
7535 a @emph{match view}, showings headlines based on the tags, properties, and
7536 TODO state associated with them,
7537 @item
7538 a @emph{timeline view} that shows all events in a single Org file,
7539 in time-sorted view,
7540 @item
7541 a @emph{text search view} that shows all entries from multiple files
7542 that contain specified keywords,
7543 @item
7544 a @emph{stuck projects view} showing projects that currently don't move
7545 along, and
7546 @item
7547 @emph{custom views} that are special searches and combinations of different
7548 views.
7549 @end itemize
7551 @noindent
7552 The extracted information is displayed in a special @emph{agenda
7553 buffer}.  This buffer is read-only, but provides commands to visit the
7554 corresponding locations in the original Org files, and even to
7555 edit these files remotely.
7557 @vindex org-agenda-window-setup
7558 @vindex org-agenda-restore-windows-after-quit
7559 Two variables control how the agenda buffer is displayed and whether the
7560 window configuration is restored when the agenda exits:
7561 @code{org-agenda-window-setup} and
7562 @code{org-agenda-restore-windows-after-quit}.
7564 @menu
7565 * Agenda files::                Files being searched for agenda information
7566 * Agenda dispatcher::           Keyboard access to agenda views
7567 * Built-in agenda views::       What is available out of the box?
7568 * Presentation and sorting::    How agenda items are prepared for display
7569 * Agenda commands::             Remote editing of Org trees
7570 * Custom agenda views::         Defining special searches and views
7571 * Exporting Agenda Views::      Writing a view to a file
7572 * Agenda column view::          Using column view for collected entries
7573 @end menu
7575 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
7576 @section Agenda files
7577 @cindex agenda files
7578 @cindex files for agenda
7580 @vindex org-agenda-files
7581 The information to be shown is normally collected from all @emph{agenda
7582 files}, the files listed in the variable
7583 @code{org-agenda-files}@footnote{If the value of that variable is not a
7584 list, but a single file name, then the list of agenda files will be
7585 maintained in that external file.}.  If a directory is part of this list,
7586 all files with the extension @file{.org} in this directory will be part
7587 of the list.
7589 Thus, even if you only work with a single Org file, that file should
7590 be put into the list@footnote{When using the dispatcher, pressing
7591 @kbd{<} before selecting a command will actually limit the command to
7592 the current file, and ignore @code{org-agenda-files} until the next
7593 dispatcher command.}.  You can customize @code{org-agenda-files}, but
7594 the easiest way to maintain it is through the following commands
7596 @cindex files, adding to agenda list
7597 @table @kbd
7598 @orgcmd{C-c [,org-agenda-file-to-front}
7599 Add current file to the list of agenda files.  The file is added to
7600 the front of the list.  If it was already in the list, it is moved to
7601 the front.  With a prefix argument, file is added/moved to the end.
7602 @orgcmd{C-c ],org-remove-file}
7603 Remove current file from the list of agenda files.
7604 @kindex C-,
7605 @cindex cycling, of agenda files
7606 @orgcmd{C-',org-cycle-agenda-files}
7607 @itemx C-,
7608 Cycle through agenda file list, visiting one file after the other.
7609 @kindex M-x org-iswitchb
7610 @item M-x org-iswitchb RET
7611 Command to use an @code{iswitchb}-like interface to switch to and between Org
7612 buffers.
7613 @end table
7615 @noindent
7616 The Org menu contains the current list of files and can be used
7617 to visit any of them.
7619 If you would like to focus the agenda temporarily on a file not in
7620 this list, or on just one file in the list, or even on only a subtree in a
7621 file, then this can be done in different ways.  For a single agenda command,
7622 you may press @kbd{<} once or several times in the dispatcher
7623 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
7624 extended period, use the following commands:
7626 @table @kbd
7627 @orgcmd{C-c C-x <,org-agenda-set-restriction-lock}
7628 Permanently restrict the agenda to the current subtree.  When with a
7629 prefix argument, or with the cursor before the first headline in a file,
7630 the agenda scope is set to the entire file.  This restriction remains in
7631 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
7632 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
7633 agenda view, the new restriction takes effect immediately.
7634 @orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
7635 Remove the permanent restriction created by @kbd{C-c C-x <}.
7636 @end table
7638 @noindent
7639 When working with @file{speedbar.el}, you can use the following commands in
7640 the Speedbar frame:
7642 @table @kbd
7643 @orgcmdtkc{< @r{in the speedbar frame},<,org-speedbar-set-agenda-restriction}
7644 Permanently restrict the agenda to the item---either an Org file or a subtree
7645 in such a file---at the cursor in the Speedbar frame.
7646 If there is a window displaying an agenda view, the new restriction takes
7647 effect immediately.
7648 @orgcmdtkc{> @r{in the speedbar frame},>,org-agenda-remove-restriction-lock}
7649 Lift the restriction.
7650 @end table
7652 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
7653 @section The agenda dispatcher
7654 @cindex agenda dispatcher
7655 @cindex dispatching agenda commands
7656 The views are created through a dispatcher, which should be bound to a
7657 global key---for example @kbd{C-c a} (@pxref{Activation}).  In the
7658 following we will assume that @kbd{C-c a} is indeed how the dispatcher
7659 is accessed and list keyboard access to commands accordingly.  After
7660 pressing @kbd{C-c a}, an additional letter is required to execute a
7661 command.  The dispatcher offers the following default commands:
7663 @table @kbd
7664 @item a
7665 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
7666 @item t @r{/} T
7667 Create a list of all TODO items (@pxref{Global TODO list}).
7668 @item m @r{/} M
7669 Create a list of headlines matching a TAGS expression (@pxref{Matching
7670 tags and properties}).
7671 @item L
7672 Create the timeline view for the current buffer (@pxref{Timeline}).
7673 @item s
7674 Create a list of entries selected by a boolean expression of keywords
7675 and/or regular expressions that must or must not occur in the entry.
7676 @item /
7677 @vindex org-agenda-text-search-extra-files
7678 Search for a regular expression in all agenda files and additionally in
7679 the files listed in @code{org-agenda-text-search-extra-files}.  This
7680 uses the Emacs command @code{multi-occur}.  A prefix argument can be
7681 used to specify the number of context lines for each match, default is
7683 @item # @r{/} !
7684 Create a list of stuck projects (@pxref{Stuck projects}).
7685 @item <
7686 Restrict an agenda command to the current buffer@footnote{For backward
7687 compatibility, you can also press @kbd{1} to restrict to the current
7688 buffer.}.  After pressing @kbd{<}, you still need to press the character
7689 selecting the command.
7690 @item < <
7691 If there is an active region, restrict the following agenda command to
7692 the region.  Otherwise, restrict it to the current subtree@footnote{For
7693 backward compatibility, you can also press @kbd{0} to restrict to the
7694 current region/subtree.}.  After pressing @kbd{< <}, you still need to press the
7695 character selecting the command.
7697 @item *
7698 @vindex org-agenda-sticky
7699 Toggle sticky agenda views.  By default, Org maintains only a single agenda
7700 buffer and rebuilds it each time you change the view, to make sure everything
7701 is always up to date.  If you switch between views often and the build time
7702 bothers you, you can turn on sticky agenda buffers (make this the default by
7703 customizing the variable @code{org-agenda-sticky}).  With sticky agendas, the
7704 dispatcher only switches to the selected view, you need to update it by hand
7705 with @kbd{r} or @kbd{g}.  You can toggle sticky agenda view any time with
7706 @code{org-toggle-sticky-agenda}.
7707 @end table
7709 You can also define custom commands that will be accessible through the
7710 dispatcher, just like the default commands.  This includes the
7711 possibility to create extended agenda buffers that contain several
7712 blocks together, for example the weekly agenda, the global TODO list and
7713 a number of special tags matches.  @xref{Custom agenda views}.
7715 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
7716 @section The built-in agenda views
7718 In this section we describe the built-in views.
7720 @menu
7721 * Weekly/daily agenda::         The calendar page with current tasks
7722 * Global TODO list::            All unfinished action items
7723 * Matching tags and properties::  Structured information with fine-tuned search
7724 * Timeline::                    Time-sorted view for single file
7725 * Search view::                 Find entries by searching for text
7726 * Stuck projects::              Find projects you need to review
7727 @end menu
7729 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
7730 @subsection The weekly/daily agenda
7731 @cindex agenda
7732 @cindex weekly agenda
7733 @cindex daily agenda
7735 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
7736 paper agenda, showing all the tasks for the current week or day.
7738 @table @kbd
7739 @cindex org-agenda, command
7740 @orgcmd{C-c a a,org-agenda-list}
7741 Compile an agenda for the current week from a list of Org files.  The agenda
7742 shows the entries for each day.  With a numeric prefix@footnote{For backward
7743 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
7744 listed before the agenda.  This feature is deprecated, use the dedicated TODO
7745 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
7746 C-c a a}) you may set the number of days to be displayed.
7747 @end table
7749 @vindex org-agenda-span
7750 @vindex org-agenda-ndays
7751 @vindex org-agenda-start-day
7752 @vindex org-agenda-start-on-weekday
7753 The default number of days displayed in the agenda is set by the variable
7754 @var{org-agenda-span} (or the obsolete @var{org-agenda-ndays}).  This
7755 variable can be set to any number of days you want to see by default in the
7756 agenda, or to a span name, such as @code{day}, @code{week}, @code{month} or
7757 @code{year}.  For weekly agendas, the default is to start on the previous
7758 monday (see @var{org-agenda-start-on-weekday}).  You can also set the start
7759 date using a date shift: @code{(setq org-agenda-start-day "+10d")} will
7760 start the agenda ten days from today in the future.
7762 Remote editing from the agenda buffer means, for example, that you can
7763 change the dates of deadlines and appointments from the agenda buffer.
7764 The commands available in the Agenda buffer are listed in @ref{Agenda
7765 commands}.
7767 @subsubheading Calendar/Diary integration
7768 @cindex calendar integration
7769 @cindex diary integration
7771 Emacs contains the calendar and diary by Edward M. Reingold.  The
7772 calendar displays a three-month calendar with holidays from different
7773 countries and cultures.  The diary allows you to keep track of
7774 anniversaries, lunar phases, sunrise/set, recurrent appointments
7775 (weekly, monthly) and more.  In this way, it is quite complementary to
7776 Org.  It can be very useful to combine output from Org with
7777 the diary.
7779 In order to include entries from the Emacs diary into Org mode's
7780 agenda, you only need to customize the variable
7782 @lisp
7783 (setq org-agenda-include-diary t)
7784 @end lisp
7786 @noindent After that, everything will happen automatically.  All diary
7787 entries including holidays, anniversaries, etc., will be included in the
7788 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
7789 @key{RET} can be used from the agenda buffer to jump to the diary
7790 file in order to edit existing diary entries.  The @kbd{i} command to
7791 insert new entries for the current date works in the agenda buffer, as
7792 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
7793 Sunrise/Sunset times, show lunar phases and to convert to other
7794 calendars, respectively.  @kbd{c} can be used to switch back and forth
7795 between calendar and agenda.
7797 If you are using the diary only for sexp entries and holidays, it is
7798 faster to not use the above setting, but instead to copy or even move
7799 the entries into an Org file.  Org mode evaluates diary-style sexp
7800 entries, and does it faster because there is no overhead for first
7801 creating the diary display.  Note that the sexp entries must start at
7802 the left margin, no whitespace is allowed before them.  For example,
7803 the following segment of an Org file will be processed and entries
7804 will be made in the agenda:
7806 @example
7807 * Birthdays and similar stuff
7808 #+CATEGORY: Holiday
7809 %%(org-calendar-holiday)   ; special function for holiday names
7810 #+CATEGORY: Ann
7811 %%(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
7812 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
7813 @end example
7815 @subsubheading Anniversaries from BBDB
7816 @cindex BBDB, anniversaries
7817 @cindex anniversaries, from BBDB
7819 If you are using the Big Brothers Database to store your contacts, you will
7820 very likely prefer to store anniversaries in BBDB rather than in a
7821 separate Org or diary file.  Org supports this and will show BBDB
7822 anniversaries as part of the agenda.  All you need to do is to add the
7823 following to one of your agenda files:
7825 @example
7826 * Anniversaries
7827   :PROPERTIES:
7828   :CATEGORY: Anniv
7829   :END:
7830 %%(org-bbdb-anniversaries)
7831 @end example
7833 You can then go ahead and define anniversaries for a BBDB record.  Basically,
7834 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
7835 record and then add the date in the format @code{YYYY-MM-DD} or @code{MM-DD},
7836 followed by a space and the class of the anniversary (@samp{birthday} or
7837 @samp{wedding}, or a format string).  If you omit the class, it will default to
7838 @samp{birthday}.  Here are a few examples, the header for the file
7839 @file{org-bbdb.el} contains more detailed information.
7841 @example
7842 1973-06-22
7843 06-22
7844 1955-08-02 wedding
7845 2008-04-14 %s released version 6.01 of org mode, %d years ago
7846 @end example
7848 After a change to BBDB, or for the first agenda display during an Emacs
7849 session, the agenda display will suffer a short delay as Org updates its
7850 hash with anniversaries.  However, from then on things will be very fast---much
7851 faster in fact than a long list of @samp{%%(diary-anniversary)} entries
7852 in an Org or Diary file.
7854 @subsubheading Appointment reminders
7855 @cindex @file{appt.el}
7856 @cindex appointment reminders
7857 @cindex appointment
7858 @cindex reminders
7860 Org can interact with Emacs appointments notification facility.  To add the
7861 appointments of your agenda files, use the command @code{org-agenda-to-appt}.
7862 This command lets you filter through the list of your appointments and add
7863 only those belonging to a specific category or matching a regular expression.
7864 It also reads a @code{APPT_WARNTIME} property which will then override the
7865 value of @code{appt-message-warning-time} for this appointment.  See the
7866 docstring for details.
7868 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
7869 @subsection The global TODO list
7870 @cindex global TODO list
7871 @cindex TODO list, global
7873 The global TODO list contains all unfinished TODO items formatted and
7874 collected into a single place.
7876 @table @kbd
7877 @orgcmd{C-c a t,org-todo-list}
7878 Show the global TODO list.  This collects the TODO items from all agenda
7879 files (@pxref{Agenda Views}) into a single buffer.  By default, this lists
7880 items with a state the is not a DONE state.  The buffer is in
7881 @code{agenda-mode}, so there are commands to examine and manipulate the TODO
7882 entries directly from that buffer (@pxref{Agenda commands}).
7883 @orgcmd{C-c a T,org-todo-list}
7884 @cindex TODO keyword matching
7885 @vindex org-todo-keywords
7886 Like the above, but allows selection of a specific TODO keyword.  You can
7887 also do this by specifying a prefix argument to @kbd{C-c a t}.  You are
7888 prompted for a keyword, and you may also specify several keywords by
7889 separating them with @samp{|} as the boolean OR operator.  With a numeric
7890 prefix, the Nth keyword in @code{org-todo-keywords} is selected.
7891 @kindex r
7892 The @kbd{r} key in the agenda buffer regenerates it, and you can give
7893 a prefix argument to this command to change the selected TODO keyword,
7894 for example @kbd{3 r}.  If you often need a search for a specific
7895 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
7896 Matching specific TODO keywords can also be done as part of a tags
7897 search (@pxref{Tag searches}).
7898 @end table
7900 Remote editing of TODO items means that you can change the state of a
7901 TODO entry with a single key press.  The commands available in the
7902 TODO list are described in @ref{Agenda commands}.
7904 @cindex sublevels, inclusion into TODO list
7905 Normally the global TODO list simply shows all headlines with TODO
7906 keywords.  This list can become very long.  There are two ways to keep
7907 it more compact:
7908 @itemize @minus
7909 @item
7910 @vindex org-agenda-todo-ignore-scheduled
7911 @vindex org-agenda-todo-ignore-deadlines
7912 @vindex org-agenda-todo-ignore-timestamp
7913 @vindex org-agenda-todo-ignore-with-date
7914 Some people view a TODO item that has been @emph{scheduled} for execution or
7915 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
7916 Configure the variables @code{org-agenda-todo-ignore-scheduled},
7917 @code{org-agenda-todo-ignore-deadlines},
7918 @code{org-agenda-todo-ignore-timestamp} and/or
7919 @code{org-agenda-todo-ignore-with-date} to exclude such items from the global
7920 TODO list.
7921 @item
7922 @vindex org-agenda-todo-list-sublevels
7923 TODO items may have sublevels to break up the task into subtasks.  In
7924 such cases it may be enough to list only the highest level TODO headline
7925 and omit the sublevels from the global list.  Configure the variable
7926 @code{org-agenda-todo-list-sublevels} to get this behavior.
7927 @end itemize
7929 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
7930 @subsection Matching tags and properties
7931 @cindex matching, of tags
7932 @cindex matching, of properties
7933 @cindex tags view
7934 @cindex match view
7936 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
7937 or have properties (@pxref{Properties and Columns}), you can select headlines
7938 based on this metadata and collect them into an agenda buffer.  The match
7939 syntax described here also applies when creating sparse trees with @kbd{C-c /
7942 @table @kbd
7943 @orgcmd{C-c a m,org-tags-view}
7944 Produce a list of all headlines that match a given set of tags.  The
7945 command prompts for a selection criterion, which is a boolean logic
7946 expression with tags, like @samp{+work+urgent-withboss} or
7947 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
7948 define a custom command for it (@pxref{Agenda dispatcher}).
7949 @orgcmd{C-c a M,org-tags-view}
7950 @vindex org-tags-match-list-sublevels
7951 @vindex org-agenda-tags-todo-honor-ignore-options
7952 Like @kbd{C-c a m}, but only select headlines that are also TODO items in a
7953 not-DONE state and force checking subitems (see variable
7954 @code{org-tags-match-list-sublevels}).  To exclude scheduled/deadline items,
7955 see the variable @code{org-agenda-tags-todo-honor-ignore-options}.  Matching
7956 specific TODO keywords together with a tags match is also possible, see
7957 @ref{Tag searches}.
7958 @end table
7960 The commands available in the tags list are described in @ref{Agenda
7961 commands}.
7963 @subsubheading Match syntax
7965 @cindex Boolean logic, for tag/property searches
7966 A search string can use Boolean operators @samp{&} for @code{AND} and
7967 @samp{|} for @code{OR}@.  @samp{&} binds more strongly than @samp{|}.
7968 Parentheses are not implemented.  Each element in the search is either a
7969 tag, a regular expression matching tags, or an expression like
7970 @code{PROPERTY OPERATOR VALUE} with a comparison operator, accessing a
7971 property value.  Each element may be preceded by @samp{-}, to select
7972 against it, and @samp{+} is syntactic sugar for positive selection.  The
7973 @code{AND} operator @samp{&} is optional when @samp{+} or @samp{-} is
7974 present.  Here are some examples, using only tags.
7976 @table @samp
7977 @item work
7978 Select headlines tagged @samp{:work:}.
7979 @item work&boss
7980 Select headlines tagged @samp{:work:} and @samp{:boss:}.
7981 @item +work-boss
7982 Select headlines tagged @samp{:work:}, but discard those also tagged
7983 @samp{:boss:}.
7984 @item work|laptop
7985 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
7986 @item work|laptop+night
7987 Like before, but require the @samp{:laptop:} lines to be tagged also
7988 @samp{:night:}.
7989 @end table
7991 @cindex regular expressions, with tags search
7992 Instead of a tag, you may also specify a regular expression enclosed in curly
7993 braces.  For example,
7994 @samp{work+@{^boss.*@}} matches headlines that contain the tag
7995 @samp{:work:} and any tag @i{starting} with @samp{boss}.
7997 @cindex group tags, as regular expressions
7998 Group tags (@pxref{Tag groups}) are expanded as regular expressions.  E.g.,
7999 if @samp{:work:} is a group tag for the group @samp{:work:lab:conf:}, then
8000 searching for @samp{work} will search for @samp{@{\(?:work\|lab\|conf\)@}}
8001 and searching for @samp{-work} will search for all headlines but those with
8002 one of the tag in the group (i.e., @samp{-@{\(?:work\|lab\|conf\)@}}).
8004 @cindex TODO keyword matching, with tags search
8005 @cindex level, require for tags/property match
8006 @cindex category, require for tags/property match
8007 @vindex org-odd-levels-only
8008 You may also test for properties (@pxref{Properties and Columns}) at the same
8009 time as matching tags.  The properties may be real properties, or special
8010 properties that represent other metadata (@pxref{Special properties}).  For
8011 example, the ``property'' @code{TODO} represents the TODO keyword of the
8012 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
8013 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
8014 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
8015 DONE@.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
8016 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
8017 The ITEM special property cannot currently be used in tags/property
8018 searches@footnote{But @pxref{x-agenda-skip-entry-regexp,
8019 ,skipping entries based on regexp}.}.
8021 Here are more examples:
8023 @table @samp
8024 @item work+TODO="WAITING"
8025 Select @samp{:work:}-tagged TODO lines with the specific TODO
8026 keyword @samp{WAITING}.
8027 @item work+TODO="WAITING"|home+TODO="WAITING"
8028 Waiting tasks both at work and at home.
8029 @end table
8031 When matching properties, a number of different operators can be used to test
8032 the value of a property.  Here is a complex example:
8034 @example
8035 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
8036          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
8037 @end example
8039 @noindent
8040 The type of comparison will depend on how the comparison value is written:
8041 @itemize @minus
8042 @item
8043 If the comparison value is a plain number, a numerical comparison is done,
8044 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
8045 @samp{>=}, and @samp{<>}.
8046 @item
8047 If the comparison value is enclosed in double-quotes,
8048 a string comparison is done, and the same operators are allowed.
8049 @item
8050 If the comparison value is enclosed in double-quotes @emph{and} angular
8051 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
8052 assumed to be date/time specifications in the standard Org way, and the
8053 comparison will be done accordingly.  Special values that will be recognized
8054 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
8055 @code{"<tomorrow>"} for these days at 0:00 hours, i.e., without a time
8056 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
8057 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
8058 respectively, can be used.
8059 @item
8060 If the comparison value is enclosed
8061 in curly braces, a regexp match is performed, with @samp{=} meaning that the
8062 regexp matches the property value, and @samp{<>} meaning that it does not
8063 match.
8064 @end itemize
8066 So the search string in the example finds entries tagged @samp{:work:} but
8067 not @samp{:boss:}, which also have a priority value @samp{A}, a
8068 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
8069 property that is numerically smaller than 2, a @samp{:With:} property that is
8070 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
8071 on or after October 11, 2008.
8073 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
8074 other properties will slow down the search.  However, once you have paid the
8075 price by accessing one property, testing additional properties is cheap
8076 again.
8078 You can configure Org mode to use property inheritance during a search, but
8079 beware that this can slow down searches considerably.  See @ref{Property
8080 inheritance}, for details.
8082 For backward compatibility, and also for typing speed, there is also a
8083 different way to test TODO states in a search.  For this, terminate the
8084 tags/property part of the search string (which may include several terms
8085 connected with @samp{|}) with a @samp{/} and then specify a Boolean
8086 expression just for TODO keywords.  The syntax is then similar to that for
8087 tags, but should be applied with care: for example, a positive selection on
8088 several TODO keywords cannot meaningfully be combined with boolean AND@.
8089 However, @emph{negative selection} combined with AND can be meaningful.  To
8090 make sure that only lines are checked that actually have any TODO keyword
8091 (resulting in a speed-up), use @kbd{C-c a M}, or equivalently start the TODO
8092 part after the slash with @samp{!}.  Using @kbd{C-c a M} or @samp{/!} will
8093 not match TODO keywords in a DONE state.  Examples:
8095 @table @samp
8096 @item work/WAITING
8097 Same as @samp{work+TODO="WAITING"}
8098 @item work/!-WAITING-NEXT
8099 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
8100 nor @samp{NEXT}
8101 @item work/!+WAITING|+NEXT
8102 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
8103 @samp{NEXT}.
8104 @end table
8106 @node Timeline, Search view, Matching tags and properties, Built-in agenda views
8107 @subsection Timeline for a single file
8108 @cindex timeline, single file
8109 @cindex time-sorted view
8111 The timeline summarizes all time-stamped items from a single Org mode
8112 file in a @emph{time-sorted view}.  The main purpose of this command is
8113 to give an overview over events in a project.
8115 @table @kbd
8116 @orgcmd{C-c a L,org-timeline}
8117 Show a time-sorted view of the Org file, with all time-stamped items.
8118 When called with a @kbd{C-u} prefix, all unfinished TODO entries
8119 (scheduled or not) are also listed under the current date.
8120 @end table
8122 @noindent
8123 The commands available in the timeline buffer are listed in
8124 @ref{Agenda commands}.
8126 @node Search view, Stuck projects, Timeline, Built-in agenda views
8127 @subsection Search view
8128 @cindex search view
8129 @cindex text search
8130 @cindex searching, for text
8132 This agenda view is a general text search facility for Org mode entries.
8133 It is particularly useful to find notes.
8135 @table @kbd
8136 @orgcmd{C-c a s,org-search-view}
8137 This is a special search that lets you select entries by matching a substring
8138 or specific words using a boolean logic.
8139 @end table
8140 For example, the search string @samp{computer equipment} will find entries
8141 that contain @samp{computer equipment} as a substring.  If the two words are
8142 separated by more space or a line break, the search will still match.
8143 Search view can also search for specific keywords in the entry, using Boolean
8144 logic.  The search string @samp{+computer +wifi -ethernet -@{8\.11[bg]@}}
8145 will search for note entries that contain the keywords @code{computer}
8146 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
8147 not matched by the regular expression @code{8\.11[bg]}, meaning to
8148 exclude both 8.11b and 8.11g.  The first @samp{+} is necessary to turn on
8149 word search, other @samp{+} characters are optional.  For more details, see
8150 the docstring of the command @code{org-search-view}.
8152 @vindex org-agenda-text-search-extra-files
8153 Note that in addition to the agenda files, this command will also search
8154 the files listed in @code{org-agenda-text-search-extra-files}.
8156 @node Stuck projects,  , Search view, Built-in agenda views
8157 @subsection Stuck projects
8158 @pindex GTD, Getting Things Done
8160 If you are following a system like David Allen's GTD to organize your
8161 work, one of the ``duties'' you have is a regular review to make sure
8162 that all projects move along.  A @emph{stuck} project is a project that
8163 has no defined next actions, so it will never show up in the TODO lists
8164 Org mode produces.  During the review, you need to identify such
8165 projects and define next actions for them.
8167 @table @kbd
8168 @orgcmd{C-c a #,org-agenda-list-stuck-projects}
8169 List projects that are stuck.
8170 @kindex C-c a !
8171 @item C-c a !
8172 @vindex org-stuck-projects
8173 Customize the variable @code{org-stuck-projects} to define what a stuck
8174 project is and how to find it.
8175 @end table
8177 You almost certainly will have to configure this view before it will
8178 work for you.  The built-in default assumes that all your projects are
8179 level-2 headlines, and that a project is not stuck if it has at least
8180 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
8182 Let's assume that you, in your own way of using Org mode, identify
8183 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
8184 indicate a project that should not be considered yet.  Let's further
8185 assume that the TODO keyword DONE marks finished projects, and that NEXT
8186 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
8187 is a next action even without the NEXT tag.  Finally, if the project
8188 contains the special word IGNORE anywhere, it should not be listed
8189 either.  In this case you would start by identifying eligible projects
8190 with a tags/todo match@footnote{@xref{Tag searches}.}
8191 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
8192 IGNORE in the subtree to identify projects that are not stuck.  The
8193 correct customization for this is
8195 @lisp
8196 (setq org-stuck-projects
8197       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
8198                                "\\<IGNORE\\>"))
8199 @end lisp
8201 Note that if a project is identified as non-stuck, the subtree of this entry
8202 will still be searched for stuck projects.
8204 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
8205 @section Presentation and sorting
8206 @cindex presentation, of agenda items
8208 @vindex org-agenda-prefix-format
8209 @vindex org-agenda-tags-column
8210 Before displaying items in an agenda view, Org mode visually prepares the
8211 items and sorts them.  Each item occupies a single line.  The line starts
8212 with a @emph{prefix} that contains the @emph{category} (@pxref{Categories})
8213 of the item and other important information.  You can customize in which
8214 column tags will be displayed through @code{org-agenda-tags-column}.  You can
8215 also customize the prefix using the option @code{org-agenda-prefix-format}.
8216 This prefix is followed by a cleaned-up version of the outline headline
8217 associated with the item.
8219 @menu
8220 * Categories::                  Not all tasks are equal
8221 * Time-of-day specifications::  How the agenda knows the time
8222 * Sorting agenda items::        The order of things
8223 * Filtering/limiting agenda items:: Dynamically narrow the agenda
8224 @end menu
8226 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
8227 @subsection Categories
8229 @cindex category
8230 @cindex #+CATEGORY
8231 The category is a broad label assigned to each agenda item.  By default,
8232 the category is simply derived from the file name, but you can also
8233 specify it with a special line in the buffer, like this@footnote{For
8234 backward compatibility, the following also works: if there are several
8235 such lines in a file, each specifies the category for the text below it.
8236 The first category also applies to any text before the first CATEGORY
8237 line.  However, using this method is @emph{strongly} deprecated as it is
8238 incompatible with the outline structure of the document.  The correct
8239 method for setting multiple categories in a buffer is using a
8240 property.}:
8242 @example
8243 #+CATEGORY: Thesis
8244 @end example
8246 @noindent
8247 @cindex property, CATEGORY
8248 If you would like to have a special CATEGORY for a single entry or a
8249 (sub)tree, give the entry a @code{:CATEGORY:} property with the
8250 special category you want to apply as the value.
8252 @noindent
8253 The display in the agenda buffer looks best if the category is not
8254 longer than 10 characters.
8256 @noindent
8257 You can set up icons for category by customizing the
8258 @code{org-agenda-category-icon-alist} variable.
8260 @node Time-of-day specifications, Sorting agenda items, Categories, Presentation and sorting
8261 @subsection Time-of-day specifications
8262 @cindex time-of-day specification
8264 Org mode checks each agenda item for a time-of-day specification.  The
8265 time can be part of the timestamp that triggered inclusion into the
8266 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
8267 ranges can be specified with two timestamps, like
8269 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
8271 In the headline of the entry itself, a time(range) may also appear as
8272 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
8273 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
8274 specifications in diary entries are recognized as well.
8276 For agenda display, Org mode extracts the time and displays it in a
8277 standard 24 hour format as part of the prefix.  The example times in
8278 the previous paragraphs would end up in the agenda like this:
8280 @example
8281     8:30-13:00 Arthur Dent lies in front of the bulldozer
8282    12:45...... Ford Prefect arrives and takes Arthur to the pub
8283    19:00...... The Vogon reads his poem
8284    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8285 @end example
8287 @cindex time grid
8288 If the agenda is in single-day mode, or for the display of today, the
8289 timed entries are embedded in a time grid, like
8291 @example
8292     8:00...... ------------------
8293     8:30-13:00 Arthur Dent lies in front of the bulldozer
8294    10:00...... ------------------
8295    12:00...... ------------------
8296    12:45...... Ford Prefect arrives and takes Arthur to the pub
8297    14:00...... ------------------
8298    16:00...... ------------------
8299    18:00...... ------------------
8300    19:00...... The Vogon reads his poem
8301    20:00...... ------------------
8302    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8303 @end example
8305 @vindex org-agenda-use-time-grid
8306 @vindex org-agenda-time-grid
8307 The time grid can be turned on and off with the variable
8308 @code{org-agenda-use-time-grid}, and can be configured with
8309 @code{org-agenda-time-grid}.
8311 @node Sorting agenda items, Filtering/limiting agenda items, Time-of-day specifications, Presentation and sorting
8312 @subsection Sorting agenda items
8313 @cindex sorting, of agenda items
8314 @cindex priorities, of agenda items
8315 Before being inserted into a view, the items are sorted.  How this is
8316 done depends on the type of view.
8317 @itemize @bullet
8318 @item
8319 @vindex org-agenda-files
8320 For the daily/weekly agenda, the items for each day are sorted.  The
8321 default order is to first collect all items containing an explicit
8322 time-of-day specification.  These entries will be shown at the beginning
8323 of the list, as a @emph{schedule} for the day.  After that, items remain
8324 grouped in categories, in the sequence given by @code{org-agenda-files}.
8325 Within each category, items are sorted by priority (@pxref{Priorities}),
8326 which is composed of the base priority (2000 for priority @samp{A}, 1000
8327 for @samp{B}, and 0 for @samp{C}), plus additional increments for
8328 overdue scheduled or deadline items.
8329 @item
8330 For the TODO list, items remain in the order of categories, but within
8331 each category, sorting takes place according to priority
8332 (@pxref{Priorities}).  The priority used for sorting derives from the
8333 priority cookie, with additions depending on how close an item is to its due
8334 or scheduled date.
8335 @item
8336 For tags matches, items are not sorted at all, but just appear in the
8337 sequence in which they are found in the agenda files.
8338 @end itemize
8340 @vindex org-agenda-sorting-strategy
8341 Sorting can be customized using the variable
8342 @code{org-agenda-sorting-strategy}, and may also include criteria based on
8343 the estimated effort of an entry (@pxref{Effort estimates}).
8345 @node Filtering/limiting agenda items,  , Sorting agenda items, Presentation and sorting
8346 @subsection Filtering/limiting agenda items
8348 Agenda built-in or customized commands are statically defined.  Agenda
8349 filters and limits provide two ways of dynamically narrowing down the list of
8350 agenda entries: @emph{fitlers} and @emph{limits}.  Filters only act on the
8351 display of the items, while limits take effect before the list of agenda
8352 entries is built.  Filter are more often used interactively, while limits are
8353 mostly useful when defined as local variables within custom agenda commands.
8355 @subsubheading Filtering in the agenda
8356 @cindex filtering, by tag, category, top headline and effort, in agenda
8357 @cindex tag filtering, in agenda
8358 @cindex category filtering, in agenda
8359 @cindex top headline filtering, in agenda
8360 @cindex effort filtering, in agenda
8361 @cindex query editing, in agenda
8363 @table @kbd
8364 @orgcmd{/,org-agenda-filter-by-tag}
8365 @vindex org-agenda-tag-filter-preset
8366 Filter the agenda view with respect to a tag and/or effort estimates.  The
8367 difference between this and a custom agenda command is that filtering is very
8368 fast, so that you can switch quickly between different filters without having
8369 to recreate the agenda.@footnote{Custom commands can preset a filter by
8370 binding the variable @code{org-agenda-tag-filter-preset} as an option.  This
8371 filter will then be applied to the view and persist as a basic filter through
8372 refreshes and more secondary filtering.  The filter is a global property of
8373 the entire agenda view---in a block agenda, you should only set this in the
8374 global options section, not in the section of an individual block.}
8376 You will be prompted for a tag selection letter; @key{SPC} will mean any tag at
8377 all.  Pressing @key{TAB} at that prompt will offer use completion to select a
8378 tag (including any tags that do not have a selection character).  The command
8379 then hides all entries that do not contain or inherit this tag.  When called
8380 with prefix arg, remove the entries that @emph{do} have the tag.  A second
8381 @kbd{/} at the prompt will turn off the filter and unhide any hidden entries.
8382 If the first key you press is either @kbd{+} or @kbd{-}, the previous filter
8383 will be narrowed by requiring or forbidding the selected additional tag.
8384 Instead of pressing @kbd{+} or @kbd{-} after @kbd{/}, you can also
8385 immediately use the @kbd{\} command.
8387 @vindex org-sort-agenda-noeffort-is-high
8388 In order to filter for effort estimates, you should set up allowed
8389 efforts globally, for example
8390 @lisp
8391 (setq org-global-properties
8392     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
8393 @end lisp
8394 You can then filter for an effort by first typing an operator, one of
8395 @kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
8396 estimate in your array of allowed values, where @kbd{0} means the 10th value.
8397 The filter will then restrict to entries with effort smaller-or-equal, equal,
8398 or larger-or-equal than the selected value.  If the digits 0--9 are not used
8399 as fast access keys to tags, you can also simply press the index digit
8400 directly without an operator.  In this case, @kbd{<} will be assumed.  For
8401 application of the operator, entries without a defined effort will be treated
8402 according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
8403 for tasks without effort definition, press @kbd{?} as the operator.
8405 Org also supports automatic, context-aware tag filtering.  If the variable
8406 @code{org-agenda-auto-exclude-function} is set to a user-defined function,
8407 that function can decide which tags should be excluded from the agenda
8408 automatically.  Once this is set, the @kbd{/} command then accepts @kbd{RET}
8409 as a sub-option key and runs the auto exclusion logic.  For example, let's
8410 say you use a @code{Net} tag to identify tasks which need network access, an
8411 @code{Errand} tag for errands in town, and a @code{Call} tag for making phone
8412 calls.  You could auto-exclude these tags based on the availability of the
8413 Internet, and outside of business hours, with something like this:
8415 @smalllisp
8416 @group
8417 (defun org-my-auto-exclude-function (tag)
8418   (and (cond
8419         ((string= tag "Net")
8420          (/= 0 (call-process "/sbin/ping" nil nil nil
8421                              "-c1" "-q" "-t1" "mail.gnu.org")))
8422         ((or (string= tag "Errand") (string= tag "Call"))
8423          (let ((hour (nth 2 (decode-time))))
8424            (or (< hour 8) (> hour 21)))))
8425        (concat "-" tag)))
8427 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
8428 @end group
8429 @end smalllisp
8431 @orgcmd{\\,org-agenda-filter-by-tag-refine}
8432 Narrow the current agenda filter by an additional condition.  When called with
8433 prefix arg, remove the entries that @emph{do} have the tag, or that do match
8434 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
8435 @kbd{-} as the first key after the @kbd{/} command.
8438 @kindex [
8439 @kindex ]
8440 @kindex @{
8441 @kindex @}
8442 @item [ ] @{ @}
8443 @table @i
8444 @item @r{in} search view
8445 add new search words (@kbd{[} and @kbd{]}) or new regular expressions
8446 (@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
8447 add a positive search term prefixed by @samp{+}, indicating that this search
8448 term @i{must} occur/match in the entry.  The closing bracket/brace will add a
8449 negative search term which @i{must not} occur/match in the entry for it to be
8450 selected.
8451 @end table
8453 @orgcmd{<,org-agenda-filter-by-category}
8454 @vindex org-agenda-category-filter-preset
8456 Filter the current agenda view with respect to the category of the item at
8457 point.  Pressing @code{<} another time will remove this filter.  You can add
8458 a filter preset through the option @code{org-agenda-category-filter-preset}
8459 (see below.)
8461 @orgcmd{^,org-agenda-filter-by-top-headline}
8462 Filter the current agenda view and only display the siblings and the parent
8463 headline of the one at point.
8465 @orgcmd{=,org-agenda-filter-by-regexp}
8466 @vindex org-agenda-regexp-filter-preset
8468 Filter the agenda view by a regular expression: only show agenda entries
8469 matching the regular expression the user entered.  When called with a prefix
8470 argument, it will filter @emph{out} entries matching the regexp.  With two
8471 universal prefix arguments, it will remove all the regexp filters, which can
8472 be accumulated.  You can add a filter preset through the option
8473 @code{org-agenda-category-filter-preset} (see below.)
8475 @orgcmd{|,org-agenda-filter-remove-all}
8476 Remove all filters in the current agenda view.
8477 @end table
8479 @subsubheading Setting limits for the agenda
8480 @cindex limits, in agenda
8481 @vindex org-agenda-max-entries
8482 @vindex org-agenda-max-effort
8483 @vindex org-agenda-max-todos
8484 @vindex org-agenda-max-tags
8486 Here is a list of options that you can set, either globally, or locally in
8487 your custom agenda views@pxref{Custom agenda views}.
8489 @table @var
8490 @item org-agenda-max-entries
8491 Limit the number of entries.
8492 @item org-agenda-max-effort
8493 Limit the duration of accumulated efforts (as minutes).
8494 @item org-agenda-max-todos
8495 Limit the number of entries with TODO keywords.
8496 @item org-agenda-max-tags
8497 Limit the number of tagged entries.
8498 @end table
8500 When set to a positive integer, each option will exclude entries from other
8501 catogories: for example, @code{(setq org-agenda-max-effort 100)} will limit
8502 the agenda to 100 minutes of effort and exclude any entry that as no effort
8503 property.  If you want to include entries with no effort property, use a
8504 negative value for @var{org-agenda-max-effort}.
8506 One useful setup is to use @var{org-agenda-max-entries} locally in a custom
8507 command.  For example, this custom command will display the next five entries
8508 with a @code{NEXT} TODO keyword.
8510 @smalllisp
8511 (setq org-agenda-custom-commands
8512       '(("n" todo "NEXT"
8513          ((org-agenda-max-entries 5)))))
8514 @end smalllisp
8516 Once you mark one of these five entry as @code{DONE}, rebuilding the agenda
8517 will again the next five entries again, including the first entry that was
8518 excluded so far.
8520 You can also dynamically set temporary limits@footnote{Those temporary limits
8521 are lost when rebuilding the agenda.}:
8523 @table @kbd
8524 @orgcmd{~,org-agenda-limit-interactively}
8525 This prompts for the type of limit to apply and its value.
8526 @end table
8528 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
8529 @section Commands in the agenda buffer
8530 @cindex commands, in agenda buffer
8532 Entries in the agenda buffer are linked back to the Org file or diary
8533 file where they originate.  You are not allowed to edit the agenda
8534 buffer itself, but commands are provided to show and jump to the
8535 original entry location, and to edit the Org files ``remotely'' from
8536 the agenda buffer.  In this way, all information is stored only once,
8537 removing the risk that your agenda and note files may diverge.
8539 Some commands can be executed with mouse clicks on agenda lines.  For
8540 the other commands, the cursor needs to be in the desired line.
8542 @table @kbd
8543 @tsubheading{Motion}
8544 @cindex motion commands in agenda
8545 @orgcmd{n,org-agenda-next-line}
8546 Next line (same as @key{down} and @kbd{C-n}).
8547 @orgcmd{p,org-agenda-previous-line}
8548 Previous line (same as @key{up} and @kbd{C-p}).
8549 @tsubheading{View/Go to Org file}
8550 @orgcmdkkc{@key{SPC},mouse-3,org-agenda-show-and-scroll-up}
8551 Display the original location of the item in another window.
8552 With prefix arg, make sure that the entire entry is made visible in the
8553 outline, not only the heading.
8555 @orgcmd{L,org-agenda-recenter}
8556 Display original location and recenter that window.
8558 @orgcmdkkc{@key{TAB},mouse-2,org-agenda-goto}
8559 Go to the original location of the item in another window.
8561 @orgcmd{@key{RET},org-agenda-switch-to}
8562 Go to the original location of the item and delete other windows.
8564 @orgcmd{F,org-agenda-follow-mode}
8565 @vindex org-agenda-start-with-follow-mode
8566 Toggle Follow mode.  In Follow mode, as you move the cursor through
8567 the agenda buffer, the other window always shows the corresponding
8568 location in the Org file.  The initial setting for this mode in new
8569 agenda buffers can be set with the variable
8570 @code{org-agenda-start-with-follow-mode}.
8572 @orgcmd{C-c C-x b,org-agenda-tree-to-indirect-buffer}
8573 Display the entire subtree of the current item in an indirect buffer.  With a
8574 numeric prefix argument N, go up to level N and then take that tree.  If N is
8575 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
8576 previously used indirect buffer.
8578 @orgcmd{C-c C-o,org-agenda-open-link}
8579 Follow a link in the entry.  This will offer a selection of any links in the
8580 text belonging to the referenced Org node.  If there is only one link, it
8581 will be followed without a selection prompt.
8583 @tsubheading{Change display}
8584 @cindex display changing, in agenda
8585 @kindex A
8586 @item A
8587 Interactively select another agenda view and append it to the current view.
8589 @kindex o
8590 @item o
8591 Delete other windows.
8593 @orgcmdkskc{v d,d,org-agenda-day-view}
8594 @xorgcmdkskc{v w,w,org-agenda-week-view}
8595 @xorgcmd{v m,org-agenda-month-view}
8596 @xorgcmd{v y,org-agenda-year-view}
8597 @xorgcmd{v SPC,org-agenda-reset-view}
8598 @vindex org-agenda-span
8599 Switch to day/week/month/year view.  When switching to day or week view, this
8600 setting becomes the default for subsequent agenda refreshes.  Since month and
8601 year views are slow to create, they do not become the default.  A numeric
8602 prefix argument may be used to jump directly to a specific day of the year,
8603 ISO week, month, or year, respectively.  For example, @kbd{32 d} jumps to
8604 February 1st, @kbd{9 w} to ISO week number 9.  When setting day, week, or
8605 month view, a year may be encoded in the prefix argument as well.  For
8606 example, @kbd{200712 w} will jump to week 12 in 2007.  If such a year
8607 specification has only one or two digits, it will be mapped to the interval
8608 1938--2037.  @kbd{v @key{SPC}} will reset to what is set in
8609 @code{org-agenda-span}.
8611 @orgcmd{f,org-agenda-later}
8612 Go forward in time to display the following @code{org-agenda-current-span} days.
8613 For example, if the display covers a week, switch to the following week.
8614 With prefix arg, go forward that many times @code{org-agenda-current-span} days.
8616 @orgcmd{b,org-agenda-earlier}
8617 Go backward in time to display earlier dates.
8619 @orgcmd{.,org-agenda-goto-today}
8620 Go to today.
8622 @orgcmd{j,org-agenda-goto-date}
8623 Prompt for a date and go there.
8625 @orgcmd{J,org-agenda-clock-goto}
8626 Go to the currently clocked-in task @i{in the agenda buffer}.
8628 @orgcmd{D,org-agenda-toggle-diary}
8629 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
8631 @orgcmdkskc{v l,l,org-agenda-log-mode}
8632 @kindex v L
8633 @vindex org-log-done
8634 @vindex org-agenda-log-mode-items
8635 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
8636 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
8637 entries that have been clocked on that day.  You can configure the entry
8638 types that should be included in log mode using the variable
8639 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
8640 all possible logbook entries, including state changes.  When called with two
8641 prefix arguments @kbd{C-u C-u}, show only logging information, nothing else.
8642 @kbd{v L} is equivalent to @kbd{C-u v l}.
8644 @orgcmdkskc{v [,[,org-agenda-manipulate-query-add}
8645 Include inactive timestamps into the current view.  Only for weekly/daily
8646 agenda and timeline views.
8648 @orgcmd{v a,org-agenda-archives-mode}
8649 @xorgcmd{v A,org-agenda-archives-mode 'files}
8650 Toggle Archives mode.  In Archives mode, trees that are marked
8651 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
8652 capital @kbd{A}, even all archive files are included.  To exit archives mode,
8653 press @kbd{v a} again.
8655 @orgcmdkskc{v R,R,org-agenda-clockreport-mode}
8656 @vindex org-agenda-start-with-clockreport-mode
8657 @vindex org-clock-report-include-clocking-task
8658 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
8659 always show a table with the clocked times for the time span and file scope
8660 covered by the current agenda view.  The initial setting for this mode in new
8661 agenda buffers can be set with the variable
8662 @code{org-agenda-start-with-clockreport-mode}.  By using a prefix argument
8663 when toggling this mode (i.e., @kbd{C-u R}), the clock table will not show
8664 contributions from entries that are hidden by agenda filtering@footnote{Only
8665 tags filtering will be respected here, effort filtering is ignored.}.  See
8666 also the variable @code{org-clock-report-include-clocking-task}.
8668 @orgkey{v c}
8669 @vindex org-agenda-clock-consistency-checks
8670 Show overlapping clock entries, clocking gaps, and other clocking problems in
8671 the current agenda range.  You can then visit clocking lines and fix them
8672 manually.  See the variable @code{org-agenda-clock-consistency-checks} for
8673 information on how to customize the definition of what constituted a clocking
8674 problem.  To return to normal agenda display, press @kbd{l} to exit Logbook
8675 mode.
8677 @orgcmdkskc{v E,E,org-agenda-entry-text-mode}
8678 @vindex org-agenda-start-with-entry-text-mode
8679 @vindex org-agenda-entry-text-maxlines
8680 Toggle entry text mode.  In entry text mode, a number of lines from the Org
8681 outline node referenced by an agenda line will be displayed below the line.
8682 The maximum number of lines is given by the variable
8683 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
8684 prefix argument will temporarily modify that number to the prefix value.
8686 @orgcmd{G,org-agenda-toggle-time-grid}
8687 @vindex org-agenda-use-time-grid
8688 @vindex org-agenda-time-grid
8689 Toggle the time grid on and off.  See also the variables
8690 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
8692 @orgcmd{r,org-agenda-redo}
8693 Recreate the agenda buffer, for example to reflect the changes after
8694 modification of the timestamps of items with @kbd{S-@key{left}} and
8695 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
8696 argument is interpreted to create a selective list for a specific TODO
8697 keyword.
8698 @orgcmd{g,org-agenda-redo}
8699 Same as @kbd{r}.
8701 @orgcmdkskc{C-x C-s,s,org-save-all-org-buffers}
8702 Save all Org buffers in the current Emacs session, and also the locations of
8703 IDs.
8705 @orgcmd{C-c C-x C-c,org-agenda-columns}
8706 @vindex org-columns-default-format
8707 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
8708 view format is taken from the entry at point, or (if there is no entry at
8709 point), from the first entry in the agenda view.  So whatever the format for
8710 that entry would be in the original buffer (taken from a property, from a
8711 @code{#+COLUMNS} line, or from the default variable
8712 @code{org-columns-default-format}), will be used in the agenda.
8714 @orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
8715 Remove the restriction lock on the agenda, if it is currently restricted to a
8716 file or subtree (@pxref{Agenda files}).
8718 @tsubheading{Secondary filtering and query editing}
8720 For a detailed description of these commands, see @pxref{Filtering/limiting
8721 agenda items}.
8723 @orgcmd{/,org-agenda-filter-by-tag}
8724 @vindex org-agenda-tag-filter-preset
8725 Filter the agenda view with respect to a tag and/or effort estimates.
8727 @orgcmd{\\,org-agenda-filter-by-tag-refine}
8728 Narrow the current agenda filter by an additional condition.
8730 @orgcmd{<,org-agenda-filter-by-category}
8731 @vindex org-agenda-category-filter-preset
8733 Filter the current agenda view with respect to the category of the item at
8734 point.  Pressing @code{<} another time will remove this filter.
8736 @orgcmd{^,org-agenda-filter-by-top-headline}
8737 Filter the current agenda view and only display the siblings and the parent
8738 headline of the one at point.
8740 @orgcmd{=,org-agenda-filter-by-regexp}
8741 @vindex org-agenda-regexp-filter-preset
8743 Filter the agenda view by a regular expression: only show agenda entries
8744 matching the regular expression the user entered.  When called with a prefix
8745 argument, it will filter @emph{out} entries matching the regexp.  With two
8746 universal prefix arguments, it will remove all the regexp filters, which can
8747 be accumulated.  You can add a filter preset through the option
8748 @code{org-agenda-category-filter-preset} (see below.)
8750 @orgcmd{|,org-agenda-filter-remove-all}
8751 Remove all filters in the current agenda view.
8753 @tsubheading{Remote editing}
8754 @cindex remote editing, from agenda
8756 @item 0--9
8757 Digit argument.
8759 @cindex undoing remote-editing events
8760 @cindex remote editing, undo
8761 @orgcmd{C-_,org-agenda-undo}
8762 Undo a change due to a remote editing command.  The change is undone
8763 both in the agenda buffer and in the remote buffer.
8765 @orgcmd{t,org-agenda-todo}
8766 Change the TODO state of the item, both in the agenda and in the
8767 original org file.
8769 @orgcmd{C-S-@key{right},org-agenda-todo-nextset}
8770 @orgcmd{C-S-@key{left},org-agenda-todo-previousset}
8771 Switch to the next/previous set of TODO keywords.
8773 @orgcmd{C-k,org-agenda-kill}
8774 @vindex org-agenda-confirm-kill
8775 Delete the current agenda item along with the entire subtree belonging
8776 to it in the original Org file.  If the text to be deleted remotely
8777 is longer than one line, the kill needs to be confirmed by the user.  See
8778 variable @code{org-agenda-confirm-kill}.
8780 @orgcmd{C-c C-w,org-agenda-refile}
8781 Refile the entry at point.
8783 @orgcmdkskc{C-c C-x C-a,a,org-agenda-archive-default-with-confirmation}
8784 @vindex org-archive-default-command
8785 Archive the subtree corresponding to the entry at point using the default
8786 archiving command set in @code{org-archive-default-command}.  When using the
8787 @code{a} key, confirmation will be required.
8789 @orgcmd{C-c C-x a,org-agenda-toggle-archive-tag}
8790 Toggle the ARCHIVE tag for the current headline.
8792 @orgcmd{C-c C-x A,org-agenda-archive-to-archive-sibling}
8793 Move the subtree corresponding to the current entry to its @emph{archive
8794 sibling}.
8796 @orgcmdkskc{C-c C-x C-s,$,org-agenda-archive}
8797 Archive the subtree corresponding to the current headline.  This means the
8798 entry will be moved to the configured archive location, most likely a
8799 different file.
8801 @orgcmd{T,org-agenda-show-tags}
8802 @vindex org-agenda-show-inherited-tags
8803 Show all tags associated with the current item.  This is useful if you have
8804 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
8805 tags of a headline occasionally.
8807 @orgcmd{:,org-agenda-set-tags}
8808 Set tags for the current headline.  If there is an active region in the
8809 agenda, change a tag for all headings in the region.
8811 @kindex ,
8812 @item ,
8813 Set the priority for the current item (@command{org-agenda-priority}).
8814 Org mode prompts for the priority character.  If you reply with @key{SPC},
8815 the priority cookie is removed from the entry.
8817 @orgcmd{P,org-agenda-show-priority}
8818 Display weighted priority of current item.
8820 @orgcmdkkc{+,S-@key{up},org-agenda-priority-up}
8821 Increase the priority of the current item.  The priority is changed in
8822 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
8823 key for this.
8825 @orgcmdkkc{-,S-@key{down},org-agenda-priority-down}
8826 Decrease the priority of the current item.
8828 @orgcmdkkc{z,C-c C-z,org-agenda-add-note}
8829 @vindex org-log-into-drawer
8830 Add a note to the entry.  This note will be recorded, and then filed to the
8831 same location where state change notes are put.  Depending on
8832 @code{org-log-into-drawer}, this may be inside a drawer.
8834 @orgcmd{C-c C-a,org-attach}
8835 Dispatcher for all command related to attachments.
8837 @orgcmd{C-c C-s,org-agenda-schedule}
8838 Schedule this item.  With prefix arg remove the scheduling timestamp
8840 @orgcmd{C-c C-d,org-agenda-deadline}
8841 Set a deadline for this item.  With prefix arg remove the deadline.
8843 @orgcmd{S-@key{right},org-agenda-do-date-later}
8844 Change the timestamp associated with the current line by one day into the
8845 future.  If the date is in the past, the first call to this command will move
8846 it to today.@*
8847 With a numeric prefix argument, change it by that many days.  For example,
8848 @kbd{3 6 5 S-@key{right}} will change it by a year.  With a @kbd{C-u} prefix,
8849 change the time by one hour.  If you immediately repeat the command, it will
8850 continue to change hours even without the prefix arg.  With a double @kbd{C-u
8851 C-u} prefix, do the same for changing minutes.@*
8852 The stamp is changed in the original Org file, but the change is not directly
8853 reflected in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
8855 @orgcmd{S-@key{left},org-agenda-do-date-earlier}
8856 Change the timestamp associated with the current line by one day
8857 into the past.
8859 @orgcmd{>,org-agenda-date-prompt}
8860 Change the timestamp associated with the current line.  The key @kbd{>} has
8861 been chosen, because it is the same as @kbd{S-.}  on my keyboard.
8863 @orgcmd{I,org-agenda-clock-in}
8864 Start the clock on the current item.  If a clock is running already, it
8865 is stopped first.
8867 @orgcmd{O,org-agenda-clock-out}
8868 Stop the previously started clock.
8870 @orgcmd{X,org-agenda-clock-cancel}
8871 Cancel the currently running clock.
8873 @orgcmd{J,org-agenda-clock-goto}
8874 Jump to the running clock in another window.
8876 @orgcmd{k,org-agenda-capture}
8877 Like @code{org-capture}, but use the date at point as the default date for
8878 the capture template.  See @var{org-capture-use-agenda-date} to make this
8879 the default behavior of @code{org-capture}.
8880 @cindex capturing, from agenda
8881 @vindex org-capture-use-agenda-date
8883 @tsubheading{Bulk remote editing selected entries}
8884 @cindex remote editing, bulk, from agenda
8885 @vindex org-agenda-bulk-persistent-marks
8886 @vindex org-agenda-bulk-custom-functions
8888 @orgcmd{m,org-agenda-bulk-mark}
8889 Mark the entry at point for bulk action.  With prefix arg, mark that many
8890 successive entries.
8892 @orgcmd{%,org-agenda-bulk-mark-regexp}
8893 Mark entries matching a regular expression for bulk action.
8895 @orgcmd{u,org-agenda-bulk-unmark}
8896 Unmark entry for bulk action.
8898 @orgcmd{U,org-agenda-bulk-remove-all-marks}
8899 Unmark all marked entries for bulk action.
8901 @orgcmd{B,org-agenda-bulk-action}
8902 Bulk action: act on all marked entries in the agenda.  This will prompt for
8903 another key to select the action to be applied.  The prefix arg to @kbd{B}
8904 will be passed through to the @kbd{s} and @kbd{d} commands, to bulk-remove
8905 these special timestamps.  By default, marks are removed after the bulk.  If
8906 you want them to persist, set @code{org-agenda-bulk-persistent-marks} to
8907 @code{t} or hit @kbd{p} at the prompt.
8909 @table @kbd
8910 @item *
8911 Toggle persistent marks.
8912 @item $
8913 Archive all selected entries.
8914 @item A
8915 Archive entries by moving them to their respective archive siblings.
8916 @item t
8917 Change TODO state.  This prompts for a single TODO keyword and changes the
8918 state of all selected entries, bypassing blocking and suppressing logging
8919 notes (but not timestamps).
8920 @item +
8921 Add a tag to all selected entries.
8922 @item -
8923 Remove a tag from all selected entries.
8924 @item s
8925 Schedule all items to a new date.  To shift existing schedule dates by a
8926 fixed number of days, use something starting with double plus at the prompt,
8927 for example @samp{++8d} or @samp{++2w}.
8928 @item d
8929 Set deadline to a specific date.
8930 @item r
8931 Prompt for a single refile target and move all entries.  The entries will no
8932 longer be in the agenda; refresh (@kbd{g}) to bring them back.
8933 @item S
8934 Reschedule randomly into the coming N days.  N will be prompted for.  With
8935 prefix arg (@kbd{C-u B S}), scatter only across weekdays.
8936 @item f
8937 Apply a function@footnote{You can also create persistent custom functions
8938 through@code{org-agenda-bulk-custom-functions}.} to marked entries.  For
8939 example, the function below sets the CATEGORY property of the entries to web.
8941 @lisp
8942 @group
8943 (defun set-category ()
8944   (interactive "P")
8945   (let* ((marker (or (org-get-at-bol 'org-hd-marker)
8946                      (org-agenda-error)))
8947          (buffer (marker-buffer marker)))
8948     (with-current-buffer buffer
8949       (save-excursion
8950         (save-restriction
8951           (widen)
8952           (goto-char marker)
8953           (org-back-to-heading t)
8954           (org-set-property "CATEGORY" "web"))))))
8955 @end group
8956 @end lisp
8957 @end table
8959 @tsubheading{Calendar commands}
8960 @cindex calendar commands, from agenda
8962 @orgcmd{c,org-agenda-goto-calendar}
8963 Open the Emacs calendar and move to the date at the agenda cursor.
8965 @orgcmd{c,org-calendar-goto-agenda}
8966 When in the calendar, compute and show the Org mode agenda for the
8967 date at the cursor.
8969 @cindex diary entries, creating from agenda
8970 @orgcmd{i,org-agenda-diary-entry}
8971 @vindex org-agenda-diary-file
8972 Insert a new entry into the diary, using the date at the cursor and (for
8973 block entries) the date at the mark.  This will add to the Emacs diary
8974 file@footnote{This file is parsed for the agenda when
8975 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
8976 command in the calendar.  The diary file will pop up in another window, where
8977 you can add the entry.
8979 If you configure @code{org-agenda-diary-file} to point to an Org mode file,
8980 Org will create entries (in Org mode syntax) in that file instead.  Most
8981 entries will be stored in a date-based outline tree that will later make it
8982 easy to archive appointments from previous months/years.  The tree will be
8983 built under an entry with a @code{DATE_TREE} property, or else with years as
8984 top-level entries.  Emacs will prompt you for the entry text---if you specify
8985 it, the entry will be created in @code{org-agenda-diary-file} without further
8986 interaction.  If you directly press @key{RET} at the prompt without typing
8987 text, the target file will be shown in another window for you to finish the
8988 entry there.  See also the @kbd{k r} command.
8990 @orgcmd{M,org-agenda-phases-of-moon}
8991 Show the phases of the moon for the three months around current date.
8993 @orgcmd{S,org-agenda-sunrise-sunset}
8994 Show sunrise and sunset times.  The geographical location must be set
8995 with calendar variables, see the documentation for the Emacs calendar.
8997 @orgcmd{C,org-agenda-convert-date}
8998 Convert the date at cursor into many other cultural and historic
8999 calendars.
9001 @orgcmd{H,org-agenda-holidays}
9002 Show holidays for three months around the cursor date.
9004 @item M-x org-icalendar-combine-agenda-files RET
9005 Export a single iCalendar file containing entries from all agenda files.
9006 This is a globally available command, and also available in the agenda menu.
9008 @tsubheading{Exporting to a file}
9009 @orgcmd{C-x C-w,org-agenda-write}
9010 @cindex exporting agenda views
9011 @cindex agenda views, exporting
9012 @vindex org-agenda-exporter-settings
9013 Write the agenda view to a file.  Depending on the extension of the selected
9014 file name, the view will be exported as HTML (@file{.html} or @file{.htm}),
9015 Postscript (@file{.ps}), PDF (@file{.pdf}), Org (@file{.org}) and plain text
9016 (any other extension).  When exporting to Org, only the body of original
9017 headlines are exported, not subtrees or inherited tags.  When called with a
9018 @kbd{C-u} prefix argument, immediately open the newly created file.  Use the
9019 variable @code{org-agenda-exporter-settings} to set options for
9020 @file{ps-print} and for @file{htmlize} to be used during export.
9022 @tsubheading{Quit and Exit}
9023 @orgcmd{q,org-agenda-quit}
9024 Quit agenda, remove the agenda buffer.
9026 @cindex agenda files, removing buffers
9027 @orgcmd{x,org-agenda-exit}
9028 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
9029 for the compilation of the agenda.  Buffers created by the user to
9030 visit Org files will not be removed.
9031 @end table
9034 @node Custom agenda views, Exporting Agenda Views, Agenda commands, Agenda Views
9035 @section Custom agenda views
9036 @cindex custom agenda views
9037 @cindex agenda views, custom
9039 Custom agenda commands serve two purposes: to store and quickly access
9040 frequently used TODO and tags searches, and to create special composite
9041 agenda buffers.  Custom agenda commands will be accessible through the
9042 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
9044 @menu
9045 * Storing searches::            Type once, use often
9046 * Block agenda::                All the stuff you need in a single buffer
9047 * Setting Options::             Changing the rules
9048 @end menu
9050 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
9051 @subsection Storing searches
9053 The first application of custom searches is the definition of keyboard
9054 shortcuts for frequently used searches, either creating an agenda
9055 buffer, or a sparse tree (the latter covering of course only the current
9056 buffer).
9057 @kindex C-c a C
9058 @vindex org-agenda-custom-commands
9059 @cindex agenda views, main example
9060 @cindex agenda, as an agenda views
9061 @cindex agenda*, as an agenda views
9062 @cindex tags, as an agenda view
9063 @cindex todo, as an agenda view
9064 @cindex tags-todo
9065 @cindex todo-tree
9066 @cindex occur-tree
9067 @cindex tags-tree
9069 Custom commands are configured in the variable
9070 @code{org-agenda-custom-commands}.  You can customize this variable, for
9071 example by pressing @kbd{C-c a C}.  You can also directly set it with Emacs
9072 Lisp in @file{.emacs}.  The following example contains all valid agenda
9073 views:
9075 @lisp
9076 @group
9077 (setq org-agenda-custom-commands
9078       '(("x" agenda)
9079         ("y" agenda*)
9080         ("w" todo "WAITING")
9081         ("W" todo-tree "WAITING")
9082         ("u" tags "+boss-urgent")
9083         ("v" tags-todo "+boss-urgent")
9084         ("U" tags-tree "+boss-urgent")
9085         ("f" occur-tree "\\<FIXME\\>")
9086         ("h" . "HOME+Name tags searches") ; description for "h" prefix
9087         ("hl" tags "+home+Lisa")
9088         ("hp" tags "+home+Peter")
9089         ("hk" tags "+home+Kim")))
9090 @end group
9091 @end lisp
9093 @noindent
9094 The initial string in each entry defines the keys you have to press
9095 after the dispatcher command @kbd{C-c a} in order to access the command.
9096 Usually this will be just a single character, but if you have many
9097 similar commands, you can also define two-letter combinations where the
9098 first character is the same in several combinations and serves as a
9099 prefix key@footnote{You can provide a description for a prefix key by
9100 inserting a cons cell with the prefix and the description.}.  The second
9101 parameter is the search type, followed by the string or regular
9102 expression to be used for the matching.  The example above will
9103 therefore define:
9105 @table @kbd
9106 @item C-c a x
9107 as a global search for agenda entries planned@footnote{@emph{Planned} means
9108 here that these entries have some planning information attached to them, like
9109 a time-stamp, a scheduled or a deadline string.  See
9110 @var{org-agenda-entry-types} on how to set what planning information will be
9111 taken into account.} this week/day.
9112 @item C-c a y
9113 as a global search for agenda entries planned this week/day, but only those
9114 with an hour specification like @code{[h]h:mm}---think of them as appointments.
9115 @item C-c a w
9116 as a global search for TODO entries with @samp{WAITING} as the TODO
9117 keyword
9118 @item C-c a W
9119 as the same search, but only in the current buffer and displaying the
9120 results as a sparse tree
9121 @item C-c a u
9122 as a global tags search for headlines marked @samp{:boss:} but not
9123 @samp{:urgent:}
9124 @item C-c a v
9125 as the same search as @kbd{C-c a u}, but limiting the search to
9126 headlines that are also TODO items
9127 @item C-c a U
9128 as the same search as @kbd{C-c a u}, but only in the current buffer and
9129 displaying the result as a sparse tree
9130 @item C-c a f
9131 to create a sparse tree (again: current buffer only) with all entries
9132 containing the word @samp{FIXME}
9133 @item C-c a h
9134 as a prefix command for a HOME tags search where you have to press an
9135 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
9136 Peter, or Kim) as additional tag to match.
9137 @end table
9139 Note that the @code{*-tree} agenda views need to be called from an
9140 Org buffer as they operate on the current buffer only.
9142 @node Block agenda, Setting Options, Storing searches, Custom agenda views
9143 @subsection Block agenda
9144 @cindex block agenda
9145 @cindex agenda, with block views
9147 Another possibility is the construction of agenda views that comprise
9148 the results of @emph{several} commands, each of which creates a block in
9149 the agenda buffer.  The available commands include @code{agenda} for the
9150 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
9151 for the global TODO list (as constructed with @kbd{C-c a t}), and the
9152 matching commands discussed above: @code{todo}, @code{tags}, and
9153 @code{tags-todo}.  Here are two examples:
9155 @lisp
9156 @group
9157 (setq org-agenda-custom-commands
9158       '(("h" "Agenda and Home-related tasks"
9159          ((agenda "")
9160           (tags-todo "home")
9161           (tags "garden")))
9162         ("o" "Agenda and Office-related tasks"
9163          ((agenda "")
9164           (tags-todo "work")
9165           (tags "office")))))
9166 @end group
9167 @end lisp
9169 @noindent
9170 This will define @kbd{C-c a h} to create a multi-block view for stuff
9171 you need to attend to at home.  The resulting agenda buffer will contain
9172 your agenda for the current week, all TODO items that carry the tag
9173 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
9174 command @kbd{C-c a o} provides a similar view for office tasks.
9176 @node Setting Options,  , Block agenda, Custom agenda views
9177 @subsection Setting options for custom commands
9178 @cindex options, for custom agenda views
9180 @vindex org-agenda-custom-commands
9181 Org mode contains a number of variables regulating agenda construction
9182 and display.  The global variables define the behavior for all agenda
9183 commands, including the custom commands.  However, if you want to change
9184 some settings just for a single custom view, you can do so.  Setting
9185 options requires inserting a list of variable names and values at the
9186 right spot in @code{org-agenda-custom-commands}.  For example:
9188 @lisp
9189 @group
9190 (setq org-agenda-custom-commands
9191       '(("w" todo "WAITING"
9192          ((org-agenda-sorting-strategy '(priority-down))
9193           (org-agenda-prefix-format "  Mixed: ")))
9194         ("U" tags-tree "+boss-urgent"
9195          ((org-show-following-heading nil)
9196           (org-show-hierarchy-above nil)))
9197         ("N" search ""
9198          ((org-agenda-files '("~org/notes.org"))
9199           (org-agenda-text-search-extra-files nil)))))
9200 @end group
9201 @end lisp
9203 @noindent
9204 Now the @kbd{C-c a w} command will sort the collected entries only by
9205 priority, and the prefix format is modified to just say @samp{  Mixed: }
9206 instead of giving the category of the entry.  The sparse tags tree of
9207 @kbd{C-c a U} will now turn out ultra-compact, because neither the
9208 headline hierarchy above the match, nor the headline following the match
9209 will be shown.  The command @kbd{C-c a N} will do a text search limited
9210 to only a single file.
9212 @vindex org-agenda-custom-commands
9213 For command sets creating a block agenda,
9214 @code{org-agenda-custom-commands} has two separate spots for setting
9215 options.  You can add options that should be valid for just a single
9216 command in the set, and options that should be valid for all commands in
9217 the set.  The former are just added to the command entry; the latter
9218 must come after the list of command entries.  Going back to the block
9219 agenda example (@pxref{Block agenda}), let's change the sorting strategy
9220 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
9221 the results for GARDEN tags query in the opposite order,
9222 @code{priority-up}.  This would look like this:
9224 @lisp
9225 @group
9226 (setq org-agenda-custom-commands
9227       '(("h" "Agenda and Home-related tasks"
9228          ((agenda)
9229           (tags-todo "home")
9230           (tags "garden"
9231                 ((org-agenda-sorting-strategy '(priority-up)))))
9232          ((org-agenda-sorting-strategy '(priority-down))))
9233         ("o" "Agenda and Office-related tasks"
9234          ((agenda)
9235           (tags-todo "work")
9236           (tags "office")))))
9237 @end group
9238 @end lisp
9240 As you see, the values and parentheses setting is a little complex.
9241 When in doubt, use the customize interface to set this variable---it
9242 fully supports its structure.  Just one caveat: when setting options in
9243 this interface, the @emph{values} are just Lisp expressions.  So if the
9244 value is a string, you need to add the double-quotes around the value
9245 yourself.
9247 @vindex org-agenda-custom-commands-contexts
9248 To control whether an agenda command should be accessible from a specific
9249 context, you can customize @var{org-agenda-custom-commands-contexts}.  Let's
9250 say for example that you have an agenda commands @code{"o"} displaying a view
9251 that you only need when reading emails.  Then you would configure this option
9252 like this:
9254 @lisp
9255 (setq org-agenda-custom-commands-contexts
9256       '(("o" (in-mode . "message-mode"))))
9257 @end lisp
9259 You can also tell that the command key @code{"o"} should refer to another
9260 command key @code{"r"}.  In that case, add this command key like this:
9262 @lisp
9263 (setq org-agenda-custom-commands-contexts
9264       '(("o" "r" (in-mode . "message-mode"))))
9265 @end lisp
9267 See the docstring of the variable for more information.
9269 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
9270 @section Exporting Agenda Views
9271 @cindex agenda views, exporting
9273 If you are away from your computer, it can be very useful to have a printed
9274 version of some agenda views to carry around.  Org mode can export custom
9275 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
9276 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
9277 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
9278 a PDF file will also create the postscript file.}, and iCalendar files.  If
9279 you want to do this only occasionally, use the command
9281 @table @kbd
9282 @orgcmd{C-x C-w,org-agenda-write}
9283 @cindex exporting agenda views
9284 @cindex agenda views, exporting
9285 @vindex org-agenda-exporter-settings
9286 Write the agenda view to a file.  Depending on the extension of the selected
9287 file name, the view will be exported as HTML (extension @file{.html} or
9288 @file{.htm}), Postscript (extension @file{.ps}), iCalendar (extension
9289 @file{.ics}), or plain text (any other extension).  Use the variable
9290 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
9291 for @file{htmlize} to be used during export, for example
9293 @vindex org-agenda-add-entry-text-maxlines
9294 @vindex htmlize-output-type
9295 @vindex ps-number-of-columns
9296 @vindex ps-landscape-mode
9297 @lisp
9298 (setq org-agenda-exporter-settings
9299       '((ps-number-of-columns 2)
9300         (ps-landscape-mode t)
9301         (org-agenda-add-entry-text-maxlines 5)
9302         (htmlize-output-type 'css)))
9303 @end lisp
9304 @end table
9306 If you need to export certain agenda views frequently, you can associate
9307 any custom agenda command with a list of output file names
9308 @footnote{If you want to store standard views like the weekly agenda
9309 or the global TODO list as well, you need to define custom commands for
9310 them in order to be able to specify file names.}.  Here is an example
9311 that first defines custom commands for the agenda and the global
9312 TODO list, together with a number of files to which to export them.
9313 Then we define two block agenda commands and specify file names for them
9314 as well.  File names can be relative to the current working directory,
9315 or absolute.
9317 @lisp
9318 @group
9319 (setq org-agenda-custom-commands
9320       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
9321         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
9322         ("h" "Agenda and Home-related tasks"
9323          ((agenda "")
9324           (tags-todo "home")
9325           (tags "garden"))
9326          nil
9327          ("~/views/home.html"))
9328         ("o" "Agenda and Office-related tasks"
9329          ((agenda)
9330           (tags-todo "work")
9331           (tags "office"))
9332          nil
9333          ("~/views/office.ps" "~/calendars/office.ics"))))
9334 @end group
9335 @end lisp
9337 The extension of the file name determines the type of export.  If it is
9338 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
9339 the buffer to HTML and save it to this file name.  If the extension is
9340 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
9341 Postscript output.  If the extension is @file{.ics}, iCalendar export is
9342 run export over all files that were used to construct the agenda, and
9343 limit the export to entries listed in the agenda.  Any other
9344 extension produces a plain ASCII file.
9346 The export files are @emph{not} created when you use one of those
9347 commands interactively because this might use too much overhead.
9348 Instead, there is a special command to produce @emph{all} specified
9349 files in one step:
9351 @table @kbd
9352 @orgcmd{C-c a e,org-store-agenda-views}
9353 Export all agenda views that have export file names associated with
9354 them.
9355 @end table
9357 You can use the options section of the custom agenda commands to also
9358 set options for the export commands.  For example:
9360 @lisp
9361 (setq org-agenda-custom-commands
9362       '(("X" agenda ""
9363          ((ps-number-of-columns 2)
9364           (ps-landscape-mode t)
9365           (org-agenda-prefix-format " [ ] ")
9366           (org-agenda-with-colors nil)
9367           (org-agenda-remove-tags t))
9368          ("theagenda.ps"))))
9369 @end lisp
9371 @noindent
9372 This command sets two options for the Postscript exporter, to make it
9373 print in two columns in landscape format---the resulting page can be cut
9374 in two and then used in a paper agenda.  The remaining settings modify
9375 the agenda prefix to omit category and scheduling information, and
9376 instead include a checkbox to check off items.  We also remove the tags
9377 to make the lines compact, and we don't want to use colors for the
9378 black-and-white printer.  Settings specified in
9379 @code{org-agenda-exporter-settings} will also apply, but the settings
9380 in @code{org-agenda-custom-commands} take precedence.
9382 @noindent
9383 From the command line you may also use
9384 @example
9385 emacs -eval (org-batch-store-agenda-views) -kill
9386 @end example
9387 @noindent
9388 or, if you need to modify some parameters@footnote{Quoting depends on the
9389 system you use, please check the FAQ for examples.}
9390 @example
9391 emacs -eval '(org-batch-store-agenda-views                      \
9392               org-agenda-span (quote month)                     \
9393               org-agenda-start-day "2007-11-01"                 \
9394               org-agenda-include-diary nil                      \
9395               org-agenda-files (quote ("~/org/project.org")))'  \
9396       -kill
9397 @end example
9398 @noindent
9399 which will create the agenda views restricted to the file
9400 @file{~/org/project.org}, without diary entries and with a 30-day
9401 extent.
9403 You can also extract agenda information in a way that allows further
9404 processing by other programs.  See @ref{Extracting agenda information}, for
9405 more information.
9408 @node Agenda column view,  , Exporting Agenda Views, Agenda Views
9409 @section Using column view in the agenda
9410 @cindex column view, in agenda
9411 @cindex agenda, column view
9413 Column view (@pxref{Column view}) is normally used to view and edit
9414 properties embedded in the hierarchical structure of an Org file.  It can be
9415 quite useful to use column view also from the agenda, where entries are
9416 collected by certain criteria.
9418 @table @kbd
9419 @orgcmd{C-c C-x C-c,org-agenda-columns}
9420 Turn on column view in the agenda.
9421 @end table
9423 To understand how to use this properly, it is important to realize that the
9424 entries in the agenda are no longer in their proper outline environment.
9425 This causes the following issues:
9427 @enumerate
9428 @item
9429 @vindex org-columns-default-format
9430 @vindex org-overriding-columns-format
9431 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
9432 entries in the agenda are collected from different files, and different files
9433 may have different @code{COLUMNS} formats, this is a non-trivial problem.
9434 Org first checks if the variable @code{org-agenda-overriding-columns-format} is
9435 currently set, and if so, takes the format from there.  Otherwise it takes
9436 the format associated with the first item in the agenda, or, if that item
9437 does not have a specific format (defined in a property, or in its file), it
9438 uses @code{org-columns-default-format}.
9439 @item
9440 @cindex property, special, CLOCKSUM
9441 If any of the columns has a summary type defined (@pxref{Column attributes}),
9442 turning on column view in the agenda will visit all relevant agenda files and
9443 make sure that the computations of this property are up to date.  This is
9444 also true for the special @code{CLOCKSUM} property.  Org will then sum the
9445 values displayed in the agenda.  In the daily/weekly agenda, the sums will
9446 cover a single day; in all other views they cover the entire block.  It is
9447 vital to realize that the agenda may show the same entry @emph{twice} (for
9448 example as scheduled and as a deadline), and it may show two entries from the
9449 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
9450 cases, the summation in the agenda will lead to incorrect results because
9451 some values will count double.
9452 @item
9453 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
9454 the entire clocked time for this item.  So even in the daily/weekly agenda,
9455 the clocksum listed in column view may originate from times outside the
9456 current view.  This has the advantage that you can compare these values with
9457 a column listing the planned total effort for a task---one of the major
9458 applications for column view in the agenda.  If you want information about
9459 clocked time in the displayed period use clock table mode (press @kbd{R} in
9460 the agenda).
9462 @item
9463 @cindex property, special, CLOCKSUM_T
9464 When the column view in the agenda shows the @code{CLOCKSUM_T}, that is
9465 always today's clocked time for this item.  So even in the weekly agenda,
9466 the clocksum listed in column view only originates from today.  This lets
9467 you compare the time you spent on a task for today, with the time already
9468 spent (via @code{CLOCKSUM}) and with the planned total effort for it.
9469 @end enumerate
9472 @node Markup, Exporting, Agenda Views, Top
9473 @chapter Markup for rich export
9475 When exporting Org mode documents, the exporter tries to reflect the
9476 structure of the document as accurately as possible in the back-end.  Since
9477 export targets like HTML, @LaTeX{} allow much richer formatting, Org mode has
9478 rules on how to prepare text for rich export.  This section summarizes the
9479 markup rules used in an Org mode buffer.
9481 @menu
9482 * Structural markup elements::  The basic structure as seen by the exporter
9483 * Images and tables::           Images, tables and caption mechanism
9484 * Literal examples::            Source code examples with special formatting
9485 * Include files::               Include additional files into a document
9486 * Index entries::               Making an index
9487 * Macro replacement::           Use macros to create templates
9488 * Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
9489 * Special blocks::              Containers targeted at export back-ends
9490 @end menu
9492 @node Structural markup elements, Images and tables, Markup, Markup
9493 @section Structural markup elements
9495 @menu
9496 * Document title::              Where the title is taken from
9497 * Headings and sections::       The document structure as seen by the exporter
9498 * Table of contents::           The if and where of the table of contents
9499 * Lists::                       Lists
9500 * Paragraphs::                  Paragraphs
9501 * Footnote markup::             Footnotes
9502 * Emphasis and monospace::      Bold, italic, etc.
9503 * Horizontal rules::            Make a line
9504 * Comment lines::               What will *not* be exported
9505 @end menu
9507 @node Document title, Headings and sections, Structural markup elements, Structural markup elements
9508 @subheading Document title
9509 @cindex document title, markup rules
9511 @noindent
9512 The title of the exported document is taken from the special line
9514 @cindex #+TITLE
9515 @example
9516 #+TITLE: This is the title of the document
9517 @end example
9519 @noindent
9520 If this line does not exist, the title will be the name of the file
9521 associated to buffer, without extension, or the buffer name.
9523 @cindex property, EXPORT_TITLE
9524 If you are exporting only a subtree by marking is as the region, the heading
9525 of the subtree will become the title of the document.  If the subtree has a
9526 property @code{EXPORT_TITLE}, that will take precedence.
9528 @node Headings and sections, Table of contents, Document title, Structural markup elements
9529 @subheading Headings and sections
9530 @cindex headings and sections, markup rules
9532 @vindex org-export-headline-levels
9533 The outline structure of the document as described in @ref{Document
9534 Structure}, forms the basis for defining sections of the exported document.
9535 However, since the outline structure is also used for (for example) lists of
9536 tasks, only the first three outline levels will be used as headings.  Deeper
9537 levels will become itemized lists.  You can change the location of this
9538 switch globally by setting the variable @code{org-export-headline-levels}, or on a
9539 per-file basis with a line
9541 @cindex #+OPTIONS
9542 @example
9543 #+OPTIONS: H:4
9544 @end example
9546 @node Table of contents, Lists, Headings and sections, Structural markup elements
9547 @subheading Table of contents
9548 @cindex table of contents, markup rules
9550 @cindex #+TOC
9551 @vindex org-export-with-toc
9552 The table of contents is normally inserted directly before the first headline
9553 of the file.  If you would like to get it to a different location, insert
9554 @code{#+TOC: headlines} at the desired location.  The depth of the table of
9555 contents is by default the same as the number of headline levels, but you can
9556 choose a smaller number, or turn off the table of contents entirely, by
9557 configuring the variable @code{org-export-with-toc}, or on a per-file basis
9558 with a line like
9560 @example
9561 #+OPTIONS: toc:2          (only to two levels in TOC)
9562 #+TOC: headlines 2        (the same, at a specific location)
9563 #+OPTIONS: toc:nil        (no TOC at all)
9564 @end example
9566 The same @code{TOC} keyword can also generate a list of all tables (resp.@:
9567 all listings) with a caption in the buffer.
9569 @example
9570 #+TOC: listings           (build a list of listings)
9571 #+TOC: tables             (build a list of tables)
9572 @end example
9574 @cindex property, ALT_TITLE
9575 The headline's title usually determines its corresponding entry in a table of
9576 contents.  However, it is possible to specify an alternative title by
9577 setting @code{ALT_TITLE} property accordingly.  It will then be used when
9578 building the table.
9580 @node Lists, Paragraphs, Table of contents, Structural markup elements
9581 @subheading Lists
9582 @cindex lists, markup rules
9584 Plain lists as described in @ref{Plain lists}, are translated to the back-end's
9585 syntax for such lists.  Most back-ends support unordered, ordered, and
9586 description lists.
9588 @node Paragraphs, Footnote markup, Lists, Structural markup elements
9589 @subheading Paragraphs, line breaks, and quoting
9590 @cindex paragraphs, markup rules
9592 Paragraphs are separated by at least one empty line.  If you need to enforce
9593 a line break within a paragraph, use @samp{\\} at the end of a line.
9595 To keep the line breaks in a region, but otherwise use normal formatting, you
9596 can use this construct, which can also be used to format poetry.
9598 @cindex #+BEGIN_VERSE
9599 @example
9600 #+BEGIN_VERSE
9601  Great clouds overhead
9602  Tiny black birds rise and fall
9603  Snow covers Emacs
9605      -- AlexSchroeder
9606 #+END_VERSE
9607 @end example
9609 When quoting a passage from another document, it is customary to format this
9610 as a paragraph that is indented on both the left and the right margin.  You
9611 can include quotations in Org mode documents like this:
9613 @cindex #+BEGIN_QUOTE
9614 @example
9615 #+BEGIN_QUOTE
9616 Everything should be made as simple as possible,
9617 but not any simpler -- Albert Einstein
9618 #+END_QUOTE
9619 @end example
9621 If you would like to center some text, do it like this:
9622 @cindex #+BEGIN_CENTER
9623 @example
9624 #+BEGIN_CENTER
9625 Everything should be made as simple as possible, \\
9626 but not any simpler
9627 #+END_CENTER
9628 @end example
9631 @node Footnote markup, Emphasis and monospace, Paragraphs, Structural markup elements
9632 @subheading Footnote markup
9633 @cindex footnotes, markup rules
9634 @cindex @file{footnote.el}
9636 Footnotes defined in the way described in @ref{Footnotes}, will be exported
9637 by all back-ends.  Org allows multiple references to the same note, and
9638 multiple footnotes side by side.
9640 @node Emphasis and monospace, Horizontal rules, Footnote markup, Structural markup elements
9641 @subheading Emphasis and monospace
9643 @cindex underlined text, markup rules
9644 @cindex bold text, markup rules
9645 @cindex italic text, markup rules
9646 @cindex verbatim text, markup rules
9647 @cindex code text, markup rules
9648 @cindex strike-through text, markup rules
9649 @vindex org-fontify-emphasized-text
9650 @vindex org-emphasis-regexp-components
9651 @vindex org-emphasis-alist
9652 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
9653 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
9654 in the code and verbatim string is not processed for Org mode specific
9655 syntax, it is exported verbatim.
9657 To turn off fontification for marked up text, you can set
9658 @code{org-fontify-emphasized-text} to @code{nil}.  To narrow down the list of
9659 available markup syntax, you can customize @var{org-emphasis-alist}.  To fine
9660 tune what characters are allowed before and after the markup characters, you
9661 can tweak @code{org-emphasis-regexp-components}.  Beware that changing one of
9662 the above variables will no take effect until you reload Org, for which you
9663 may need to restart Emacs.
9665 @node Horizontal rules, Comment lines, Emphasis and monospace, Structural markup elements
9666 @subheading  Horizontal rules
9667 @cindex horizontal rules, markup rules
9668 A line consisting of only dashes, and at least 5 of them, will be exported as
9669 a horizontal line (@samp{<hr/>} in HTML and @code{\hrule} in @LaTeX{}).
9671 @node Comment lines,  , Horizontal rules, Structural markup elements
9672 @subheading Comment lines
9673 @cindex comment lines
9674 @cindex exporting, not
9675 @cindex #+BEGIN_COMMENT
9677 Lines starting with zero or more whitespace characters followed by one
9678 @samp{#} and a whitespace are treated as comments and will never be exported.
9679 Also entire subtrees starting with the word @samp{COMMENT} will never be
9680 exported.  Finally, regions surrounded by @samp{#+BEGIN_COMMENT}
9681 ... @samp{#+END_COMMENT} will not be exported.
9683 @table @kbd
9684 @kindex C-c ;
9685 @item C-c ;
9686 Toggle the COMMENT keyword at the beginning of an entry.
9687 @end table
9690 @node Images and tables, Literal examples, Structural markup elements, Markup
9691 @section Images and Tables
9693 @cindex tables, markup rules
9694 @cindex #+CAPTION
9695 @cindex #+NAME
9696 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
9697 the @file{table.el} package will be exported properly.  For Org mode tables,
9698 the lines before the first horizontal separator line will become table header
9699 lines.  You can use the following lines somewhere before the table to assign
9700 a caption and a label for cross references, and in the text you can refer to
9701 the object with @code{[[tab:basic-data]]} (@pxref{Internal links}):
9703 @example
9704 #+CAPTION: This is the caption for the next table (or link)
9705 #+NAME:   tab:basic-data
9706    | ... | ...|
9707    |-----|----|
9708 @end example
9710 Optionally, the caption can take the form:
9711 @example
9712 #+CAPTION[Caption for list of tables]: Caption for table.
9713 @end example
9715 @cindex inlined images, markup rules
9716 Some back-ends allow you to directly include images into the exported
9717 document.  Org does this, if a link to an image files does not have
9718 a description part, for example @code{[[./img/a.jpg]]}.  If you wish to
9719 define a caption for the image and maybe a label for internal cross
9720 references, make sure that the link is on a line by itself and precede it
9721 with @code{#+CAPTION} and @code{#+NAME} as follows:
9723 @example
9724 #+CAPTION: This is the caption for the next figure link (or table)
9725 #+NAME:   fig:SED-HR4049
9726 [[./img/a.jpg]]
9727 @end example
9729 @noindent
9730 Such images can be displayed within the buffer.  @xref{Handling links,the
9731 discussion of image links}.
9733 Even though images and tables are prominent examples of captioned structures,
9734 the same caption mechanism can apply to many others (e.g., @LaTeX{}
9735 equations, source code blocks).  Depending on the export back-end, those may
9736 or may not be handled.
9738 @node Literal examples, Include files, Images and tables, Markup
9739 @section Literal examples
9740 @cindex literal examples, markup rules
9741 @cindex code line references, markup rules
9743 You can include literal examples that should not be subjected to
9744 markup.  Such examples will be typeset in monospace, so this is well suited
9745 for source code and similar examples.
9746 @cindex #+BEGIN_EXAMPLE
9748 @example
9749 #+BEGIN_EXAMPLE
9750 Some example from a text file.
9751 #+END_EXAMPLE
9752 @end example
9754 Note that such blocks may be @i{indented} in order to align nicely with
9755 indented text and in particular with plain list structure (@pxref{Plain
9756 lists}).  For simplicity when using small examples, you can also start the
9757 example lines with a colon followed by a space.  There may also be additional
9758 whitespace before the colon:
9760 @example
9761 Here is an example
9762    : Some example from a text file.
9763 @end example
9765 @cindex formatting source code, markup rules
9766 If the example is source code from a programming language, or any other text
9767 that can be marked up by font-lock in Emacs, you can ask for the example to
9768 look like the fontified Emacs buffer@footnote{This works automatically for
9769 the HTML back-end (it requires version 1.34 of the @file{htmlize.el} package,
9770 which is distributed with Org).  Fontified code chunks in @LaTeX{} can be
9771 achieved using either the listings or the
9772 @url{http://code.google.com/p/minted, minted,} package.  Refer to
9773 @code{org-latex-listings} documentation for details.}.  This is done
9774 with the @samp{src} block, where you also need to specify the name of the
9775 major mode that should be used to fontify the example@footnote{Code in
9776 @samp{src} blocks may also be evaluated either interactively or on export.
9777 See @pxref{Working With Source Code} for more information on evaluating code
9778 blocks.}, see @ref{Easy Templates} for shortcuts to easily insert code
9779 blocks.
9780 @cindex #+BEGIN_SRC
9782 @example
9783 #+BEGIN_SRC emacs-lisp
9784   (defun org-xor (a b)
9785      "Exclusive or."
9786      (if a (not b) b))
9787 #+END_SRC
9788 @end example
9790 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
9791 switch to the end of the @code{BEGIN} line, to get the lines of the example
9792 numbered.  If you use a @code{+n} switch, the numbering from the previous
9793 numbered snippet will be continued in the current one.  In literal examples,
9794 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
9795 targets for special hyperlinks like @code{[[(name)]]} (i.e., the reference name
9796 enclosed in single parenthesis).  In HTML, hovering the mouse over such a
9797 link will remote-highlight the corresponding code line, which is kind of
9798 cool.
9800 You can also add a @code{-r} switch which @i{removes} the labels from the
9801 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
9802 labels in the source code while using line numbers for the links, which might
9803 be useful to explain those in an Org mode example code.}.  With the @code{-n}
9804 switch, links to these references will be labeled by the line numbers from
9805 the code listing, otherwise links will use the labels with no parentheses.
9806 Here is an example:
9808 @example
9809 #+BEGIN_SRC emacs-lisp -n -r
9810 (save-excursion                  (ref:sc)
9811    (goto-char (point-min))       (ref:jump)
9812 #+END_SRC
9813 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
9814 jumps to point-min.
9815 @end example
9817 @vindex org-coderef-label-format
9818 If the syntax for the label format conflicts with the language syntax, use a
9819 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
9820 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
9822 HTML export also allows examples to be published as text areas (@pxref{Text
9823 areas in HTML export}).
9825 Because the @code{#+BEGIN_...} and @code{#+END_...} patterns need to be added
9826 so often, shortcuts are provided using the Easy Templates facility
9827 (@pxref{Easy Templates}).
9829 @table @kbd
9830 @kindex C-c '
9831 @item C-c '
9832 Edit the source code example at point in its native mode.  This works by
9833 switching to a temporary buffer with the source code.  You need to exit by
9834 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*},
9835 @samp{,*}, @samp{#+} and @samp{,#+} will get a comma prepended, to keep them
9836 from being interpreted by Org as outline nodes or special syntax.  These
9837 commas will be stripped for editing with @kbd{C-c '}, and also for export.}.
9838 The edited version will then replace the old version in the Org buffer.
9839 Fixed-width regions (where each line starts with a colon followed by a space)
9840 will be edited using @code{artist-mode}@footnote{You may select
9841 a different-mode with the variable @code{org-edit-fixed-width-region-mode}.}
9842 to allow creating ASCII drawings easily.  Using this command in an empty line
9843 will create a new fixed-width region.
9844 @kindex C-c l
9845 @item C-c l
9846 Calling @code{org-store-link} while editing a source code example in a
9847 temporary buffer created with @kbd{C-c '} will prompt for a label.  Make sure
9848 that it is unique in the current buffer, and insert it with the proper
9849 formatting like @samp{(ref:label)} at the end of the current line.  Then the
9850 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
9851 @end table
9854 @node Include files, Index entries, Literal examples, Markup
9855 @section Include files
9856 @cindex include files, markup rules
9858 During export, you can include the content of another file.  For example, to
9859 include your @file{.emacs} file, you could use:
9860 @cindex #+INCLUDE
9862 @example
9863 #+INCLUDE: "~/.emacs" src emacs-lisp
9864 @end example
9866 @noindent
9867 The optional second and third parameter are the markup (e.g., @samp{quote},
9868 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
9869 language for formatting the contents.  The markup is optional; if it is not
9870 given, the text will be assumed to be in Org mode format and will be
9871 processed normally.
9873 Contents of the included file will belong to the same structure (headline,
9874 item) containing the INCLUDE keyword.  In particular, headlines within the
9875 file will become children of the current section.  That behaviour can be
9876 changed by providing an additional keyword parameter, @code{:minlevel}.  In
9877 that case, all headlines in the included file will be shifted so the one with
9878 the lowest level reaches that specified level.  For example, to make a file
9879 become a sibling of the current top-level headline, use
9881 @example
9882 #+INCLUDE: "~/my-book/chapter2.org" :minlevel 1
9883 @end example
9885 You can also include a portion of a file by specifying a lines range using
9886 the @code{:lines} parameter.  The line at the upper end of the range will not
9887 be included.  The start and/or the end of the range may be omitted to use the
9888 obvious defaults.
9890 @example
9891 #+INCLUDE: "~/.emacs" :lines "5-10"   @r{Include lines 5 to 10, 10 excluded}
9892 #+INCLUDE: "~/.emacs" :lines "-10"    @r{Include lines 1 to 10, 10 excluded}
9893 #+INCLUDE: "~/.emacs" :lines "10-"    @r{Include lines from 10 to EOF}
9894 @end example
9896 @table @kbd
9897 @kindex C-c '
9898 @item C-c '
9899 Visit the include file at point.
9900 @end table
9902 @node Index entries, Macro replacement, Include files, Markup
9903 @section Index entries
9904 @cindex index entries, for publishing
9906 You can specify entries that will be used for generating an index during
9907 publishing.  This is done by lines starting with @code{#+INDEX}.  An entry
9908 the contains an exclamation mark will create a sub item.  See @ref{Generating
9909 an index} for more information.
9911 @example
9912 * Curriculum Vitae
9913 #+INDEX: CV
9914 #+INDEX: Application!CV
9915 @end example
9920 @node Macro replacement, Embedded @LaTeX{}, Index entries, Markup
9921 @section Macro replacement
9922 @cindex macro replacement, during export
9923 @cindex #+MACRO
9925 You can define text snippets with
9927 @example
9928 #+MACRO: name   replacement text $1, $2 are arguments
9929 @end example
9931 @noindent which can be referenced in
9932 paragraphs, verse blocks, table cells and some keywords with
9933 @code{@{@{@{name(arg1,arg2)@}@}@}}@footnote{Since commas separate arguments,
9934 commas within arguments have to be escaped with a backslash character.
9935 Conversely, backslash characters before a comma, and only them, need to be
9936 escaped with another backslash character.}.  In addition to defined macros,
9937 @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc., will reference
9938 information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and similar lines.
9939 Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
9940 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
9941 and to the modification time of the file being exported, respectively.
9942 @var{FORMAT} should be a format string understood by
9943 @code{format-time-string}.
9945 Macro expansion takes place during export.
9948 @node Embedded @LaTeX{}, Special blocks , Macro replacement, Markup
9949 @section Embedded @LaTeX{}
9950 @cindex @TeX{} interpretation
9951 @cindex @LaTeX{} interpretation
9953 Plain ASCII is normally sufficient for almost all note taking.  Exceptions
9954 include scientific notes, which often require mathematical symbols and the
9955 occasional formula.  @LaTeX{}@footnote{@LaTeX{} is a macro system based on
9956 Donald E. Knuth's @TeX{} system.  Many of the features described here as
9957 ``@LaTeX{}'' are really from @TeX{}, but for simplicity I am blurring this
9958 distinction.}  is widely used to typeset scientific documents.  Org mode
9959 supports embedding @LaTeX{} code into its files, because many academics are
9960 used to writing and reading @LaTeX{} source code, and because it can be
9961 readily processed to produce pretty output for a number of export back-ends.
9963 @menu
9964 * Special symbols::             Greek letters and other symbols
9965 * Subscripts and superscripts::  Simple syntax for raising/lowering text
9966 * @LaTeX{} fragments::          Complex formulas made easy
9967 * Previewing @LaTeX{} fragments::  What will this snippet look like?
9968 * CDLaTeX mode::                Speed up entering of formulas
9969 @end menu
9971 @node Special symbols, Subscripts and superscripts, Embedded @LaTeX{}, Embedded @LaTeX{}
9972 @subsection Special symbols
9973 @cindex math symbols
9974 @cindex special symbols
9975 @cindex @TeX{} macros
9976 @cindex @LaTeX{} fragments, markup rules
9977 @cindex HTML entities
9978 @cindex @LaTeX{} entities
9980 You can use @LaTeX{}-like syntax to insert special symbols like @samp{\alpha}
9981 to indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
9982 for these symbols is available, just type @samp{\} and maybe a few letters,
9983 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike @LaTeX{}
9984 code, Org mode allows these symbols to be present without surrounding math
9985 delimiters, for example:
9987 @example
9988 Angles are written as Greek letters \alpha, \beta and \gamma.
9989 @end example
9991 @vindex org-entities
9992 During export, these symbols will be transformed into the native format of
9993 the exporter back-end.  Strings like @code{\alpha} will be exported as
9994 @code{&alpha;} in the HTML output, and as @code{$\alpha$} in the @LaTeX{}
9995 output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in HTML and
9996 @code{~} in @LaTeX{}.  If you need such a symbol inside a word, terminate it
9997 like this: @samp{\Aacute@{@}stor}.
9999 A large number of entities is provided, with names taken from both HTML and
10000 @LaTeX{}; see the variable @code{org-entities} for the complete list.
10001 @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
10002 @samp{...} are all converted into special commands creating hyphens of
10003 different lengths or a compact set of dots.
10005 If you would like to see entities displayed as UTF-8 characters, use the
10006 following command@footnote{You can turn this on by default by setting the
10007 variable @code{org-pretty-entities}, or on a per-file base with the
10008 @code{#+STARTUP} option @code{entitiespretty}.}:
10010 @table @kbd
10011 @cindex @code{entitiespretty}, STARTUP keyword
10012 @kindex C-c C-x \
10013 @item C-c C-x \
10014 Toggle display of entities as UTF-8 characters.  This does not change the
10015 buffer content which remains plain ASCII, but it overlays the UTF-8 character
10016 for display purposes only.
10017 @end table
10019 @node Subscripts and superscripts, @LaTeX{} fragments, Special symbols, Embedded @LaTeX{}
10020 @subsection Subscripts and superscripts
10021 @cindex subscript
10022 @cindex superscript
10024 Just like in @LaTeX{}, @samp{^} and @samp{_} are used to indicate super- and
10025 subscripts.  Again, these can be used without embedding them in math-mode
10026 delimiters.  To increase the readability of ASCII text, it is not necessary
10027 (but OK) to surround multi-character sub- and superscripts with curly braces.
10028 For example
10030 @example
10031 The mass of the sun is M_sun = 1.989 x 10^30 kg.  The radius of
10032 the sun is R_@{sun@} = 6.96 x 10^8 m.
10033 @end example
10035 @vindex org-use-sub-superscripts
10036 To avoid interpretation as raised or lowered text, you can quote @samp{^} and
10037 @samp{_} with a backslash: @samp{\^} and @samp{\_}.  If you write a text
10038 where the underscore is often used in a different context, Org's convention
10039 to always interpret these as subscripts can get in your way.  Configure the
10040 variable @code{org-use-sub-superscripts} to change this convention.  For
10041 example, when setting this variable to @code{@{@}}, @samp{a_b} will not be
10042 interpreted as a subscript, but @samp{a_@{b@}} will.
10044 @table @kbd
10045 @kindex C-c C-x \
10046 @item C-c C-x \
10047 In addition to showing entities as UTF-8 characters, this command will also
10048 format sub- and superscripts in a WYSIWYM way.
10049 @end table
10051 @node @LaTeX{} fragments, Previewing @LaTeX{} fragments, Subscripts and superscripts, Embedded @LaTeX{}
10052 @subsection @LaTeX{} fragments
10053 @cindex @LaTeX{} fragments
10055 @vindex org-format-latex-header
10056 Going beyond symbols and sub- and superscripts, a full formula language is
10057 needed.  Org mode can contain @LaTeX{} math fragments, and it supports ways
10058 to process these for several export back-ends.  When exporting to @LaTeX{},
10059 the code is obviously left as it is.  When exporting to HTML, Org invokes the
10060 @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in
10061 HTML export}) to process and display the math@footnote{If you plan to use
10062 this regularly or on pages with significant page views, you should install
10063 @file{MathJax} on your own server in order to limit the load of our server.}.
10064 Finally, it can also process the mathematical expressions into
10065 images@footnote{For this to work you need to be on a system with a working
10066 @LaTeX{} installation.  You also need the @file{dvipng} program or the
10067 @file{convert}, respectively available at
10068 @url{http://sourceforge.net/projects/dvipng/} and from the @file{imagemagick}
10069 suite.  The @LaTeX{} header that will be used when processing a fragment can
10070 be configured with the variable @code{org-format-latex-header}.} that can be
10071 displayed in a browser.
10073 @LaTeX{} fragments don't need any special marking at all.  The following
10074 snippets will be identified as @LaTeX{} source code:
10075 @itemize @bullet
10076 @item
10077 Environments of any kind@footnote{When @file{MathJax} is used, only the
10078 environments recognized by @file{MathJax} will be processed.  When
10079 @file{dvipng} is used to create images, any @LaTeX{} environment will be
10080 handled.}.  The only requirement is that the @code{\begin} and @code{\end}
10081 statements appear on a new line, at the beginning of the line or after
10082 whitespaces only.
10083 @item
10084 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
10085 currency specifications, single @samp{$} characters are only recognized as
10086 math delimiters if the enclosed text contains at most two line breaks, is
10087 directly attached to the @samp{$} characters with no whitespace in between,
10088 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
10089 For the other delimiters, there is no such restriction, so when in doubt, use
10090 @samp{\(...\)} as inline math delimiters.
10091 @end itemize
10093 @noindent For example:
10095 @example
10096 \begin@{equation@}
10097 x=\sqrt@{b@}
10098 \end@{equation@}
10100 If $a^2=b$ and \( b=2 \), then the solution must be
10101 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
10102 @end example
10104 @c FIXME
10105 @c @noindent
10106 @c @vindex org-format-latex-options
10107 @c If you need any of the delimiter ASCII sequences for other purposes, you
10108 @c can configure the option @code{org-format-latex-options} to deselect the
10109 @c ones you do not wish to have interpreted by the @LaTeX{} converter.
10111 @vindex org-export-with-latex
10112 @LaTeX{} processing can be configured with the variable
10113 @code{org-export-with-latex}.  The default setting is @code{t} which means
10114 @file{MathJax} for HTML, and no processing for ASCII and @LaTeX{} back-ends.
10115 You can also set this variable on a per-file basis using one of these
10116 lines:
10118 @example
10119 #+OPTIONS: tex:t          @r{Do the right thing automatically (MathJax)}
10120 #+OPTIONS: tex:dvipng     @r{Force using dvipng images}
10121 #+OPTIONS: tex:nil        @r{Do not process @LaTeX{} fragments at all}
10122 #+OPTIONS: tex:verbatim   @r{Verbatim export, for jsMath or so}
10123 @end example
10125 @node Previewing @LaTeX{} fragments, CDLaTeX mode, @LaTeX{} fragments, Embedded @LaTeX{}
10126 @subsection Previewing @LaTeX{} fragments
10127 @cindex @LaTeX{} fragments, preview
10129 @vindex org-latex-create-formula-image-program
10130 If you have @file{dvipng} or @file{imagemagick} installed@footnote{Choose the
10131 converter by setting the variable
10132 @code{org-latex-create-formula-image-program} accordingly.}, @LaTeX{}
10133 fragments can be processed to produce preview images of the typeset
10134 expressions:
10136 @table @kbd
10137 @kindex C-c C-x C-l
10138 @item C-c C-x C-l
10139 Produce a preview image of the @LaTeX{} fragment at point and overlay it
10140 over the source code.  If there is no fragment at point, process all
10141 fragments in the current entry (between two headlines).  When called
10142 with a prefix argument, process the entire subtree.  When called with
10143 two prefix arguments, or when the cursor is before the first headline,
10144 process the entire buffer.
10145 @kindex C-c C-c
10146 @item C-c C-c
10147 Remove the overlay preview images.
10148 @end table
10150 @vindex org-format-latex-options
10151 You can customize the variable @code{org-format-latex-options} to influence
10152 some aspects of the preview.  In particular, the @code{:scale} (and for HTML
10153 export, @code{:html-scale}) property can be used to adjust the size of the
10154 preview images.
10156 @vindex org-startup-with-latex-preview
10157 You can turn on the previewing of all @LaTeX{} fragments in a file with
10159 @example
10160 #+STARTUP: latexpreview
10161 @end example
10163 To disable it, simply use
10165 @example
10166 #+STARTUP: nolatexpreview
10167 @end example
10169 @node CDLaTeX mode,  , Previewing @LaTeX{} fragments, Embedded @LaTeX{}
10170 @subsection Using CD@LaTeX{} to enter math
10171 @cindex CD@LaTeX{}
10173 CD@LaTeX{} mode is a minor mode that is normally used in combination with a
10174 major @LaTeX{} mode like AUC@TeX{} in order to speed-up insertion of
10175 environments and math templates.  Inside Org mode, you can make use of
10176 some of the features of CD@LaTeX{} mode.  You need to install
10177 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
10178 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
10179 Don't use CD@LaTeX{} mode itself under Org mode, but use the light
10180 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
10181 on for the current buffer with @kbd{M-x org-cdlatex-mode RET}, or for all
10182 Org files with
10184 @lisp
10185 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
10186 @end lisp
10188 When this mode is enabled, the following features are present (for more
10189 details see the documentation of CD@LaTeX{} mode):
10190 @itemize @bullet
10191 @kindex C-c @{
10192 @item
10193 Environment templates can be inserted with @kbd{C-c @{}.
10194 @item
10195 @kindex @key{TAB}
10196 The @key{TAB} key will do template expansion if the cursor is inside a
10197 @LaTeX{} fragment@footnote{Org mode has a method to test if the cursor is
10198 inside such a fragment, see the documentation of the function
10199 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
10200 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
10201 correctly inside the first brace.  Another @key{TAB} will get you into
10202 the second brace.  Even outside fragments, @key{TAB} will expand
10203 environment abbreviations at the beginning of a line.  For example, if
10204 you write @samp{equ} at the beginning of a line and press @key{TAB},
10205 this abbreviation will be expanded to an @code{equation} environment.
10206 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help RET}.
10207 @item
10208 @kindex _
10209 @kindex ^
10210 @vindex cdlatex-simplify-sub-super-scripts
10211 Pressing @kbd{_} and @kbd{^} inside a @LaTeX{} fragment will insert these
10212 characters together with a pair of braces.  If you use @key{TAB} to move
10213 out of the braces, and if the braces surround only a single character or
10214 macro, they are removed again (depending on the variable
10215 @code{cdlatex-simplify-sub-super-scripts}).
10216 @item
10217 @kindex `
10218 Pressing the backquote @kbd{`} followed by a character inserts math
10219 macros, also outside @LaTeX{} fragments.  If you wait more than 1.5 seconds
10220 after the backquote, a help window will pop up.
10221 @item
10222 @kindex '
10223 Pressing the single-quote @kbd{'} followed by another character modifies
10224 the symbol before point with an accent or a font.  If you wait more than
10225 1.5 seconds after the single-quote, a help window will pop up.  Character
10226 modification will work only inside @LaTeX{} fragments; outside the quote
10227 is normal.
10228 @end itemize
10230 @node Special blocks, , Embedded @LaTeX{}, Markup
10231 @section Special blocks
10232 @cindex Special blocks
10234 Org syntax includes pre-defined blocks (@pxref{Paragraphs} and @ref{Literal
10235 examples}).  It is also possible to create blocks containing raw code
10236 targeted at a specific back-ends (e.g., @samp{#+BEGIN_LATEX}).
10238 Any other block is a @emph{special block}.  Each export back-end decides if
10239 they should be exported, and how.  When the block is ignored, its contents
10240 are still exported, as if the block were not there.  For example, when
10241 exporting a @samp{#+BEGIN_TEST} block, HTML back-end wraps its contents
10242 within @samp{<div name="test">} tag.  Refer to back-end specific
10243 documentation for more information.
10245 @node Exporting, Publishing, Markup, Top
10246 @chapter Exporting
10247 @cindex exporting
10249 Org mode documents can be exported to a variety of other formats.
10251 ASCII export produces a readable and simple version of an Org file for
10252 printing and sharing notes.  HTML export allows you to easily publish notes
10253 on the web, or to build full-fledged websites.  @LaTeX{} export lets you use
10254 Org mode and its structured editing functions to create arbitrarily complex
10255 @LaTeX{} files for any kind of document.  OpenDocument Text (ODT) export
10256 allows seamless collaboration across organizational boundaries.  Markdown
10257 export lets you seamlessly collaborate with other developers.  Finally, iCal
10258 export can extract entries with deadlines or appointments to produce a file
10259 in the iCalendar format.
10261 Note that the built-in back-ends come with commands to convert the selected
10262 region: e.g., in a HTML buffer, @kbd{M-x org-html-convert-region-to-html
10263 RET} will replace the selected region with its HTML export.  Used in
10264 combination with @code{orgtbl-mode} and/or @code{orgstruc-mode}, this is a
10265 powerful way of quickly editing tables and lists in HTML, @LaTeX{},
10266 @code{Texinfo}, etc.
10269 @menu
10270 * The Export Dispatcher::       The main exporter interface
10271 * Export formats::              Available export formats
10272 * Export settings::             Generic export settings
10273 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
10274 * Beamer export::               Exporting as a Beamer presentation
10275 * HTML export::                 Exporting to HTML
10276 * @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
10277 * Markdown export::             Exporting to Markdown
10278 * OpenDocument Text export::    Exporting to OpenDocument Text
10279 * iCalendar export::            Exporting to iCalendar
10280 @end menu
10282 @node The Export Dispatcher, Export formats, Exporting, Exporting
10283 @section The Export Dispatcher
10284 @vindex org-export-dispatch-use-expert-ui
10285 @cindex Export, dispatcher
10287 The main entry point for any export related task is the dispatcher, a
10288 hierarchical menu@footnote{It is also possible to use a less intrusive
10289 interface by setting @var{org-export-dispatch-use-expert-ui} to a non-nil
10290 value.  In that case, only a prompt is visible from the minibuffer.  From
10291 there one can still switch back to regular menu with @kbd{?} key.} from
10292 which it is possible to select an export format and to toggle export
10293 options.
10295 @c @quotation
10296 @table @asis
10297 @orgcmd{C-c C-e,org-export-dispatch}
10299 Dispatch for export and publishing commands.  When called with @kbd{C-u}
10300 prefix argument, repeat last command, preserving toggled options, on
10301 current buffer.  If the active buffer hasn't changed and subtree export was
10302 activated, the command will affect that same subtree.
10303 @end table
10304 @c @end quotation
10306 Normally the entire buffer is exported, but if there is an active region
10307 only that part of the buffer will be exported.
10309 Export options can also, among other things, affect the scope of export
10310 process.  They are toggled from the dispatcher with appropriate key
10311 combinations:
10313 @table @kbd
10314 @item C-a
10315 @vindex org-export-async-init-file
10316 Toggles asynchronous export.  The export happens in an external Emacs
10317 process@footnote{Configure @var{org-export-async-init-file} to properly set
10318 it up.}.
10320 In this case, no output is displayed automatically.  It is stored in a list
10321 called the export stack, and can be viewed from there.  The stack can be
10322 reached by calling the dispatcher with a double @kbd{C-u} prefix argument,
10323 or with @kbd{&} key from the dispatcher.
10325 @vindex org-export-in-background
10326 To make this behaviour the default, customize the variable
10327 @var{org-export-in-background}.
10329 @item C-b
10330 Toggles body-only export.  Its effect, if any, depends on the back-end
10331 used.  Its purpose is to remove all meta-data from output and focus on the
10332 real contents.
10334 @item C-s
10335 @vindex org-export-initial-scope
10336 Toggles subtree export.  The top heading becomes the document title and is
10337 removed from the contents.
10339 You can change the default state of this option by setting
10340 @var{org-export-initial-scope}.
10342 @item C-v
10343 Toggles visible-only export.  Only export the text that is currently
10344 visible, i.e. not hidden by outline visibility in the buffer.
10346 @end table
10348 @vindex org-export-copy-to-kill-ring
10349 Unless it happened asynchronously, a successful export process usually
10350 stores its output into the kill-ring.  You can configure
10351 @var{org-export-copy-to-kill-ring} in order to change this behaviour.
10353 @node Export formats, Export settings, The Export Dispatcher, Exporting
10354 @section Export formats
10355 @cindex Export, formats
10357 Libraries translating an Org buffer into a foreign format are called export
10358 back-ends.  An export format is not available until the proper back-end has
10359 been loaded.
10361 @vindex org-export-backends
10362 By default, the following four back-ends are ready to use: @code{ascii},
10363 @code{html}, @code{icalendar} and @code{latex}.  It is possible to add more
10364 (or remove some) by customizing @var{org-export-backends}.
10366 Core back-ends include:
10368 @itemize
10369 @item ascii (ASCII format)
10370 @item beamer (@LaTeX{} Beamer format)
10371 @item html (HTML format)
10372 @item icalendar (iCalendar format)
10373 @item latex (@LaTeX{} format)
10374 @item man (Man page format)
10375 @item md (Markdown format)
10376 @item odt (OpenDocument Text format)
10377 @item texinfo (Texinfo format)
10378 @end itemize
10380 More are available from the @code{contrib/} directory available from the
10381 distribution archives or from GNU/Org ELPA.
10383 @node Export settings, ASCII/Latin-1/UTF-8 export, Export formats, Exporting
10384 @section Export settings
10385 @cindex Export, settings
10387 Export output can be controlled through a number of export options.  These
10388 can be set globally with variables, and overridden on a per-buffer basis with
10389 keywords.  Such keywords may be put anywhere in the file.  For individual
10390 lines, a good way to make sure the keyword is correct is to type @code{#+}
10391 and then use @kbd{M-<TAB>} completion.
10393 Here is an exhaustive list of such keywords along with the equivalent global
10394 variable.  Only options available for every back-end are discussed in this
10395 section.
10397 @table @samp
10398 @item AUTHOR
10399 @vindex user-full-name
10400 the author (@var{user-full-name}).
10402 @item CREATOR
10403 @vindex org-export-creator-string
10404 entity responsible for output generation (@var{org-export-creator-string}).
10406 @item DATE
10407 @vindex org-export-date-timestamp-format
10408 A date or a time-stamp@footnote{The variable
10409 @var{org-export-date-timestamp-format} defines how this time-stamp will be
10410 exported.}.
10412 @item DESCRIPTION
10413 the page description, e.g., for the XHTML meta tag.
10415 @item EMAIL
10416 @vindex user-mail-address
10417 email address (@var{user-mail-address}).
10419 @item KEYWORDS
10420 keywords defining the contents, e.g., for the XHTML meta tag.
10422 @item LANGUAGE
10423 @vindex org-export-default-language
10424 language used for translation of some strings
10425 (@var{org-export-default-language}).
10427 @item SELECT_TAGS
10428 @vindex org-export-select-tags
10429 Tags that select a tree for export (@var{org-export-select-tags}).  The
10430 default value is @code{:export:}.  Within a subtree tagged with
10431 @code{:export:}, you can still exclude entries with @code{:noexport:} (see
10432 below).
10434 @item EXCLUDE_TAGS
10435 Tags that exclude a tree from export (@var{org-export-exclude-tags}).  The
10436 default value is @code{:noexport:}.  Entries with the @code{:noexport:} tag
10437 will be unconditionally excluded from the export, even if they have an
10438 @code{:export:} tag.
10440 @item TITLE
10441 the title to be shown (otherwise derived from buffer's name).
10442 @end table
10444 Additionally, the @code{OPTIONS} keyword is a compact@footnote{If you want
10445 to configure many options this way, you can use several @code{#+OPTIONS}
10446 lines.} form to specify export settings.  Here you can:
10448 @table @code
10449 @item ':
10450 @vindex org-export-with-smart-quotes
10451 toggle smart quotes (@var{org-export-with-smart-quotes}).
10453 @item *:
10454 toggle emphasized text (@var{org-export-with-emphasize}).
10456 @item -:
10457 @vindex org-export-with-special-strings
10458 toggle conversion of special strings
10459 (@var{org-export-with-special-strings}).
10461 @item ::
10462 @vindex org-export-with-fixed-width
10463 toggle fixed-width sections
10464 (@var{org-export-with-fixed-width}).
10466 @item <:
10467 @vindex org-export-with-timestamps
10468 toggle inclusion of any time/date active/inactive stamps
10469 (@var{org-export-with-timestamps}).
10471 @item :
10472 @vindex org-export-preserve-breaks
10473 toggle line-break-preservation (@var{org-export-preserve-breaks}).
10475 @item ^:
10476 @vindex org-export-with-sub-superscripts
10477 toggle @TeX{}-like syntax for sub- and superscripts.  If you write "^:@{@}",
10478 @samp{a_@{b@}} will be interpreted, but the simple @samp{a_b} will be left as
10479 it is (@var{org-export-with-sub-superscripts}).
10481 @item arch:
10482 @vindex org-export-with-archived-trees
10483 configure export of archived trees.  Can be set to @code{headline} to only
10484 process the headline, skipping its contents
10485 (@var{org-export-with-archived-trees}).
10487 @item author:
10488 @vindex org-export-with-author
10489 toggle inclusion of author name into exported file
10490 (@var{org-export-with-author}).
10492 @item c:
10493 @vindex org-export-with-clocks
10494 toggle inclusion of CLOCK keywords (@var{org-export-with-clocks}).
10496 @item creator:
10497 @vindex org-export-with-creator
10498 configure inclusion of creator info into exported file.  It may be set to
10499 @code{comment} (@var{org-export-with-creator}).
10501 @item d:
10502 @vindex org-export-with-drawers
10503 toggle inclusion of drawers, or list drawers to include
10504 (@var{org-export-with-drawers}).
10506 @item e:
10507 @vindex org-export-with-entities
10508 toggle inclusion of entities (@var{org-export-with-entities}).
10510 @item email:
10511 @vindex org-export-with-email
10512 toggle inclusion of author email into exported file
10513 (@var{org-export-with-email}).
10515 @item f:
10516 @vindex org-export-with-footnotes
10517 toggle footnotes (@var{org-export-with-footnotes}).
10519 @item H:
10520 @vindex org-export-headline-levels
10521 set the number of headline levels for export
10522 (@var{org-export-headline-levels}).
10524 @item inline:
10525 @vindex org-export-with-inlinetasks
10526 toggle inclusion of inlinetasks (@var{org-export-with-inlinetasks}).
10528 @item num:
10529 @vindex org-export-with-section-numbers
10530 toggle section-numbers (@var{org-export-with-section-numbers}).
10532 @item p:
10533 @vindex org-export-with-planning
10534 toggle export of planning information (@var{org-export-with-planning}).
10535 ``Planning information'' is the line containing the @code{SCHEDULED:}, the
10536 @code{DEADLINE:} or the @code{CLOSED:} cookies or a combination of them.
10538 @item pri:
10539 @vindex org-export-with-priority
10540 toggle priority cookies (@var{org-export-with-priority}).
10542 @item stat:
10543 @vindex org-export-with-statistics-cookies
10544 toggle inclusion of statistics cookies
10545 (@var{org-export-with-statistics-cookies}).
10547 @item tags:
10548 @vindex org-export-with-tags
10549 toggle inclusion of tags, may also be @code{not-in-toc}
10550 (@var{org-export-with-tags}).
10552 @item tasks:
10553 @vindex org-export-with-tasks
10554 toggle inclusion of tasks (TODO items), can be @code{nil} to remove all
10555 tasks, @code{todo} to remove DONE tasks, or a list of keywords to keep
10556 (@var{org-export-with-tasks}).
10558 @item tex:
10559 @vindex org-export-with-latex
10560 configure export of @LaTeX{} fragments and environments.  It may be set to
10561 @code{verbatim} (@var{org-export-with-latex}).
10563 @item timestamp:
10564 @vindex org-export-time-stamp-file
10565 toggle inclusion creation time into exported file
10566 (@var{org-export-time-stamp-file}).
10568 @item toc:
10569 @vindex org-export-with-toc
10570 toggle table of contents, or set level limit (@var{org-export-with-toc}).
10572 @item todo:
10573 @vindex org-export-with-todo-keywords
10574 toggle inclusion of TODO keywords into exported text
10575 (@var{org-export-with-todo-keywords}).
10577 @item |:
10578 @vindex org-export-with-tables
10579 toggle tables (@var{org-export-with-tables}).
10581 @end table
10583 A more general mechanism is also provided.  Indeed, Emacs variables can
10584 become buffer-local during export by using the BIND keyword.  Its syntax is
10585 @samp{#+BIND: variable value}.  This is particularly useful for in-buffer
10586 settings that cannot be changed using specific keywords.
10588 You can place commonly-used export settings in a separate file which can be
10589 included using @samp{#+SETUPFILE: filename} syntax.
10591 These settings affect all buffer's export processes.  Though, it is
10592 possible to override them locally when exporting only a subtree.  This is
10593 done by adding a headline property named after the keyword with the
10594 @samp{EXPORT_} prefix.  For example, @samp{DATE} and @samp{OPTIONS}
10595 keywords become, respectively @samp{EXPORT_DATE} and @samp{EXPORT_OPTIONS}
10596 properties.  Subtree export also supports the self-explicit
10597 @samp{EXPORT_FILE_NAME} property@footnote{There is no buffer-wide
10598 equivalent for this property.  The file name in this case is derived from
10599 the file associated to the buffer, if possible, or asked to the user
10600 otherwise.}.
10602 @node ASCII/Latin-1/UTF-8 export, Beamer export, Export settings, Exporting
10603 @section ASCII/Latin-1/UTF-8 export
10604 @cindex ASCII export
10605 @cindex Latin-1 export
10606 @cindex UTF-8 export
10608 ASCII export produces a simple and very readable version of an Org mode
10609 file, containing only plain ASCII@.  Latin-1 and UTF-8 export augment the file
10610 with special characters and symbols available in these encodings.
10612 @vindex org-ascii-links-to-notes
10613 Links are exported in a footnote-like style, with the descriptive part in the
10614 text and the link in a note before the next heading.  See the variable
10615 @code{org-ascii-links-to-notes} for details and other options.
10617 @subheading ASCII export commands
10619 @table @kbd
10620 @orgcmd{C-c C-e t a/l/u,org-ascii-export-to-ascii}
10621 Export as an ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
10622 will be @file{myfile.txt}.  The file will be overwritten without warning.
10623 When the original file is @file{myfile.txt}, the resulting file becomes
10624 @file{myfile.txt.txt} in order to prevent data loss.
10625 @orgcmd{C-c C-e t A/L/U,org-ascii-export-as-ascii}
10626 Export to a temporary buffer.  Do not create a file.
10627 @end table
10629 @subheading Header and sectioning structure
10631 In the exported version, the first three outline levels become headlines,
10632 defining a general document structure.  Additional levels are exported as
10633 lists.  The transition can also occur at a different level (@pxref{Export
10634 settings}).
10636 @subheading Quoting ASCII text
10638 You can insert text that will only appear when using @code{ASCII} back-end
10639 with the following constructs:
10641 @cindex #+ASCII
10642 @cindex #+BEGIN_ASCII
10643 @example
10644 Text @@@@ascii:and additional text@@@@ within a paragraph.
10646 #+ASCII: Some text
10648 #+BEGIN_ASCII
10649 All lines in this block will appear only when using this back-end.
10650 #+END_ASCII
10651 @end example
10653 @subheading ASCII specific attributes
10654 @cindex #+ATTR_ASCII
10655 @cindex horizontal rules, in ASCII export
10657 @code{ASCII} back-end only understands one attribute, @code{:width}, which
10658 specifies the length, in characters, of a given horizontal rule.  It must be
10659 specified using an @code{ATTR_ASCII} line, directly preceding the rule.
10661 @example
10662 #+ATTR_ASCII: :width 10
10663 -----
10664 @end example
10666 @node Beamer export, HTML export, ASCII/Latin-1/UTF-8 export, Exporting
10667 @section Beamer export
10668 @cindex Beamer export
10670 The @LaTeX{} class @emph{Beamer} allows production of high quality
10671 presentations using @LaTeX{} and pdf processing.  Org mode has special
10672 support for turning an Org mode file or tree into a Beamer presentation.
10674 @subheading Beamer export commands
10676 @table @kbd
10677 @orgcmd{C-c C-e l b,org-beamer-export-to-latex}
10678 Export as a @LaTeX{} file.  For an Org file @file{myfile.org}, the @LaTeX{}
10679 file will be @file{myfile.tex}.  The file will be overwritten without
10680 warning.
10681 @orgcmd{C-c C-e l B,org-beamer-export-as-latex}
10682 Export to a temporary buffer.  Do not create a file.
10683 @orgcmd{C-c C-e l P,org-beamer-export-to-pdf}
10684 Export as @LaTeX{} and then process to PDF.
10685 @item C-c C-e l O
10686 Export as @LaTeX{} and then process to PDF, then open the resulting PDF file.
10687 @end table
10689 @subheading Sectioning, Frames and Blocks
10691 Any tree with not-too-deep level nesting should in principle be exportable as
10692 a Beamer presentation.  Headlines fall into three categories: sectioning
10693 elements, frames and blocks.
10695 @itemize @minus
10696 @item
10697 @vindex org-beamer-frame-level
10698 Headlines become frames when their level is equal to
10699 @var{org-beamer-frame-level} or @code{H} value in an @code{OPTIONS} line
10700 (@pxref{Export settings}).
10702 @cindex property, BEAMER_ENV
10703 Though, if a headline in the current tree has a @code{BEAMER_ENV} property
10704 set to either to @code{frame} or @code{fullframe}, its level overrides the
10705 variable.  A @code{fullframe} is a frame with an empty (ignored) title.
10707 @item
10708 @vindex org-beamer-environments-default
10709 @vindex org-beamer-environments-extra
10710 All frame's children become @code{block} environments.  Special block types
10711 can be enforced by setting headline's @code{BEAMER_ENV} property@footnote{If
10712 this property is set, the entry will also get a @code{:B_environment:} tag to
10713 make this visible.  This tag has no semantic meaning, it is only a visual
10714 aid.} to an appropriate value (see @var{org-beamer-environments-default} for
10715 supported values and @var{org-beamer-environments-extra} for adding more).
10717 @item
10718 @cindex property, BEAMER_REF
10719 As a special case, if the @code{BEAMER_ENV} property is set to either
10720 @code{appendix}, @code{note}, @code{noteNH} or @code{againframe}, the
10721 headline will become, respectively, an appendix, a note (within frame or
10722 between frame, depending on its level), a note with its title ignored or an
10723 @code{\againframe} command.  In the latter case, a @code{BEAMER_REF} property
10724 is mandatory in order to refer to the frame being resumed, and contents are
10725 ignored.
10727 Also, a headline with an @code{ignoreheading} environment will have its
10728 contents only inserted in the output.  This special value is useful to have
10729 data between frames, or to properly close a @code{column} environment.
10730 @end itemize
10732 @cindex property, BEAMER_ACT
10733 @cindex property, BEAMER_OPT
10734 Headlines also support @code{BEAMER_ACT} and @code{BEAMER_OPT} properties.
10735 The former is translated as an overlay/action specification, or a default
10736 overlay specification when enclosed within square brackets.  The latter
10737 specifies options for the current frame.  Though, @code{fragile} option is
10738 added automatically if it contains source code that uses any verbatim
10739 environment.
10741 @cindex property, BEAMER_COL
10742 Moreover, headlines handle the @code{BEAMER_COL} property.  Its value should
10743 be a decimal number representing the width of the column as a fraction of the
10744 total text width.  If the headline has no specific environment, its title
10745 will be ignored and its contents will fill the column created.  Otherwise,
10746 the block will fill the whole column and the title will be preserved.  Two
10747 contiguous headlines with a non-nil @code{BEAMER_COL} value share the same
10748 @code{columns} @LaTeX{} environment.  It will end before the next headline
10749 without such a property.  This environment is generated automatically.
10750 Although, it can also be explicitly created, with a special @code{columns}
10751 value for @code{BEAMER_ENV} property (if it needs to be set up with some
10752 specific options, for example).
10754 @subheading Beamer specific syntax
10756 Beamer back-end is an extension of @LaTeX{} back-end.  As such, all @LaTeX{}
10757 specific syntax (e.g., @samp{#+LATEX:} or @samp{#+ATTR_LATEX:}) is
10758 recognized.  See @ref{@LaTeX{} and PDF export} for more information.
10760 @cindex #+BEAMER_THEME
10761 @cindex #+BEAMER_COLOR_THEME
10762 @cindex #+BEAMER_FONT_THEME
10763 @cindex #+BEAMER_INNER_THEME
10764 @cindex #+BEAMER_OUTER_THEME
10765 Beamer export introduces a number of keywords to insert code in the
10766 document's header.  Four control appearance of the presentantion:
10767 @code{#+BEAMER_THEME}, @code{#+BEAMER_COLOR_THEME},
10768 @code{#+BEAMER_FONT_THEME}, @code{#+BEAMER_INNER_THEME} and
10769 @code{#+BEAMER_OUTER_THEME}.  All of them accept optional arguments within
10770 square brackets.  The last one, @code{#+BEAMER_HEADER}, is more generic and
10771 allows to append any line of code in the header.
10773 @example
10774 #+BEAMER_THEME: Rochester [height=20pt]
10775 #+BEAMER_COLOR_THEME: spruce
10776 @end example
10778 Table of contents generated from @code{toc:t} @code{OPTION} keyword are
10779 wrapped within a @code{frame} environment.  Those generated from a @code{TOC}
10780 keyword (@pxref{Table of contents}) are not.  In that case, it is also
10781 possible to specify options, enclosed within square brackets.
10783 @example
10784 #+TOC: headlines [currentsection]
10785 @end example
10787 Beamer specific code can be inserted with the following constructs:
10789 @cindex #+BEAMER
10790 @cindex #+BEGIN_BEAMER
10791 @example
10792 #+BEAMER: \pause
10794 #+BEGIN_BEAMER
10795 All lines in this block will appear only when using this back-end.
10796 #+END_BEAMER
10798 Text @@@@beamer:some code@@@@ within a paragraph.
10799 @end example
10801 In particular, this last example can be used to add overlay specifications to
10802 objects whose type is among @code{bold}, @code{item}, @code{link},
10803 @code{radio-target} and @code{target}, when the value is enclosed within
10804 angular brackets and put at the beginning the object.
10806 @example
10807 A *@@@@beamer:<2->@@@@useful* feature
10808 @end example
10810 @cindex #+ATTR_BEAMER
10811 Eventually, every plain list has support for @code{:environment},
10812 @code{:overlay} and @code{:options} attributes through @code{ATTR_BEAMER}
10813 affiliated keyword.  The first one allows to use a different environment, the
10814 second sets overlay specifications and the last one inserts optional
10815 arguments in current list environment.
10817 @example
10818 #+ATTR_BEAMER: :overlay +-
10819 - item 1
10820 - item 2
10821 @end example
10823 @subheading Editing support
10825 You can turn on a special minor mode @code{org-beamer-mode} for faster
10826 editing with:
10828 @example
10829 #+STARTUP: beamer
10830 @end example
10832 @table @kbd
10833 @orgcmd{C-c C-b,org-beamer-select-environment}
10834 In @code{org-beamer-mode}, this key offers fast selection of a Beamer
10835 environment or the @code{BEAMER_COL} property.
10836 @end table
10838 Also, a template for useful in-buffer settings or properties can be inserted
10839 into the buffer with @kbd{M-x org-beamer-insert-options-template}.  Among
10840 other things, this will install a column view format which is very handy for
10841 editing special properties used by Beamer.
10843 @subheading An example
10845 Here is a simple example Org document that is intended for Beamer export.
10847 @smallexample
10848 #+TITLE: Example Presentation
10849 #+AUTHOR: Carsten Dominik
10850 #+OPTIONS: H:2
10851 #+LATEX_CLASS: beamer
10852 #+LATEX_CLASS_OPTIONS: [presentation]
10853 #+BEAMER_THEME: Madrid
10854 #+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
10856 * This is the first structural section
10858 ** Frame 1
10859 *** Thanks to Eric Fraga                                           :B_block:BMCOL:
10860     :PROPERTIES:
10861     :BEAMER_COL: 0.48
10862     :BEAMER_ENV: block
10863     :END:
10864     for the first viable Beamer setup in Org
10865 *** Thanks to everyone else                                        :B_block:BMCOL:
10866     :PROPERTIES:
10867     :BEAMER_COL: 0.48
10868     :BEAMER_ACT: <2->
10869     :BEAMER_ENV: block
10870     :END:
10871     for contributing to the discussion
10872 **** This will be formatted as a beamer note                              :B_note:
10873      :PROPERTIES:
10874      :BEAMER_env: note
10875      :END:
10876 ** Frame 2 (where we will not use columns)
10877 *** Request
10878     Please test this stuff!
10879 @end smallexample
10881 @node HTML export, @LaTeX{} and PDF export, Beamer export, Exporting
10882 @section HTML export
10883 @cindex HTML export
10885 Org mode contains a HTML (XHTML 1.0 strict) exporter with extensive
10886 HTML formatting, in ways similar to John Gruber's @emph{markdown}
10887 language, but with additional support for tables.
10889 @menu
10890 * HTML Export commands::        How to invoke HTML export
10891 * HTML preamble and postamble::  How to insert a preamble and a postamble
10892 * Quoting HTML tags::           Using direct HTML in Org mode
10893 * Links in HTML export::        How links will be interpreted and formatted
10894 * Tables in HTML export::       How to modify the formatting of tables
10895 * Images in HTML export::       How to insert figures into HTML output
10896 * Math formatting in HTML export::  Beautiful math also on the web
10897 * Text areas in HTML export::   An alternative way to show an example
10898 * CSS support::                 Changing the appearance of the output
10899 * JavaScript support::          Info and Folding in a web browser
10900 @end menu
10902 @node HTML Export commands, HTML preamble and postamble, HTML export, HTML export
10903 @subsection HTML export commands
10905 @cindex region, active
10906 @cindex active region
10907 @cindex transient-mark-mode
10908 @table @kbd
10909 @orgcmd{C-c C-e h h,org-html-export-to-html}
10910 @cindex property, EXPORT_FILE_NAME
10911 Export as a HTML file.  For an Org file @file{myfile.org},
10912 the HTML file will be @file{myfile.html}.  The file will be overwritten
10913 without warning.  If there is an active region@footnote{This requires
10914 @code{transient-mark-mode} be turned on.}, only the region will be
10915 exported.  If the selected region is a single tree@footnote{To select the
10916 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
10917 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
10918 property, that name will be used for the export.
10919 @kbd{C-c C-e h o}
10920 Export as a HTML file and immediately open it with a browser.
10921 @orgcmd{C-c C-e h H,org-html-export-as-html}
10922 Export to a temporary buffer.  Do not create a file.
10923 @item C-c C-e C-v h H/h h/h o
10924 Export only the visible part of the document.
10925 @end table
10927 @c FIXME Exporting sublevels
10928 @c @cindex headline levels, for exporting
10929 @c In the exported version, the first 3 outline levels will become headlines,
10930 @c defining a general document structure.  Additional levels will be exported as
10931 @c itemized lists.  If you want that transition to occur at a different level,
10932 @c specify it with a numeric prefix argument.  For example,
10934 @c @example
10935 @c @kbd{C-2 C-c C-e b}
10936 @c @end example
10938 @c @noindent
10939 @c creates two levels of headings and does the rest as items.
10941 @node HTML preamble and postamble, Quoting HTML tags, HTML Export commands, HTML export
10942 @subsection HTML preamble and postamble
10943 @vindex org-html-preamble
10944 @vindex org-html-postamble
10945 @vindex org-html-preamble-format
10946 @vindex org-html-postamble-format
10947 @vindex org-html-validation-link
10948 @vindex org-export-author-info
10949 @vindex org-export-email-info
10950 @vindex org-export-creator-info
10951 @vindex org-export-time-stamp-file
10953 The HTML exporter lets you define a preamble and a postamble.
10955 The default value for @code{org-html-preamble} is @code{t}, which means
10956 that the preamble is inserted depending on the relevant format string in
10957 @code{org-html-preamble-format}.
10959 Setting @code{org-html-preamble} to a string will override the default format
10960 string.  If you set it to a function, it will insert the output of the
10961 function, which must be a string.  Setting to @code{nil} will not insert any
10962 preamble.
10964 The default value for @code{org-html-postamble} is @code{'auto}, which means
10965 that the HTML exporter will look for information about the author, the email,
10966 the creator and the date, and build the postamble from these values.  Setting
10967 @code{org-html-postamble} to @code{t} will insert the postamble from the
10968 relevant format string found in @code{org-html-postamble-format}.  Setting it
10969 to @code{nil} will not insert any postamble.
10971 @node Quoting HTML tags, Links in HTML export, HTML preamble and postamble, HTML export
10972 @subsection Quoting HTML tags
10974 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
10975 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
10976 which should be interpreted as such, mark them with @samp{@@} as in
10977 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
10978 simple tags.  For more extensive HTML that should be copied verbatim to
10979 the exported file use either
10981 @cindex #+HTML
10982 @cindex #+BEGIN_HTML
10983 @example
10984 #+HTML: Literal HTML code for export
10985 @end example
10987 @noindent or
10988 @cindex #+BEGIN_HTML
10990 @example
10991 #+BEGIN_HTML
10992 All lines between these markers are exported literally
10993 #+END_HTML
10994 @end example
10997 @node Links in HTML export, Tables in HTML export, Quoting HTML tags, HTML export
10998 @subsection Links in HTML export
11000 @cindex links, in HTML export
11001 @cindex internal links, in HTML export
11002 @cindex external links, in HTML export
11003 Internal links (@pxref{Internal links}) will continue to work in HTML@.  This
11004 includes automatic links created by radio targets (@pxref{Radio
11005 targets}).  Links to external files will still work if the target file is on
11006 the same @i{relative} path as the published Org file.  Links to other
11007 @file{.org} files will be translated into HTML links under the assumption
11008 that a HTML version also exists of the linked file, at the same relative
11009 path.  @samp{id:} links can then be used to jump to specific entries across
11010 files.  For information related to linking files while publishing them to a
11011 publishing directory see @ref{Publishing links}.
11013 If you want to specify attributes for links, you can do so using a special
11014 @code{#+ATTR_HTML} line to define attributes that will be added to the
11015 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
11016 and @code{style} attributes for a link:
11018 @cindex #+ATTR_HTML
11019 @example
11020 #+ATTR_HTML: :title The Org mode homepage :style color:red;
11021 [[http://orgmode.org]]
11022 @end example
11024 @node Tables in HTML export, Images in HTML export, Links in HTML export, HTML export
11025 @subsection Tables
11026 @cindex tables, in HTML
11027 @vindex org-html-table-default-attributes
11029 Org mode tables are exported to HTML using the table attributes defined in
11030 @code{org-html-table-default-attributes}.  The default setting makes tables
11031 without cell borders and frame.  If you would like to change this for
11032 individual tables, place something like the following before the table:
11034 @cindex #+CAPTION
11035 @cindex #+ATTR_HTML
11036 @example
11037 #+CAPTION: This is a table with lines around and between cells
11038 #+ATTR_HTML: :border 2 :rules all :frame border
11039 @end example
11041 @vindex org-html-table-row-tags
11042 You can also modify the default tags used for each row by setting
11043 @var{org-html-table-row-tags}.  See the docstring for an example on
11044 how to use this option.
11046 @node Images in HTML export, Math formatting in HTML export, Tables in HTML export, HTML export
11047 @subsection Images in HTML export
11049 @cindex images, inline in HTML
11050 @cindex inlining images in HTML
11051 @vindex org-html-inline-images
11052 HTML export can inline images given as links in the Org file, and
11053 it can make an image the clickable part of a link.  By
11054 default@footnote{But see the variable
11055 @code{org-html-inline-images}.}, images are inlined if a link does
11056 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
11057 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
11058 @samp{the image} that points to the image.  If the description part
11059 itself is a @code{file:} link or a @code{http:} URL pointing to an
11060 image, this image will be inlined and activated so that clicking on the
11061 image will activate the link.  For example, to include a thumbnail that
11062 will link to a high resolution version of the image, you could use:
11064 @example
11065 [[file:highres.jpg][file:thumb.jpg]]
11066 @end example
11068 If you need to add attributes to an inlined image, use a @code{#+ATTR_HTML}.
11069 In the example below we specify the @code{alt} and @code{title} attributes to
11070 support text viewers and accessibility, and align it to the right.
11072 @cindex #+CAPTION
11073 @cindex #+ATTR_HTML
11074 @example
11075 #+CAPTION: A black cat stalking a spider
11076 #+ATTR_HTML: :alt cat/spider image :title Action! :align right
11077 [[./img/a.jpg]]
11078 @end example
11080 @noindent
11081 You could use @code{http} addresses just as well.
11083 @node Math formatting in HTML export, Text areas in HTML export, Images in HTML export, HTML export
11084 @subsection Math formatting in HTML export
11085 @cindex MathJax
11086 @cindex dvipng
11088 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
11089 different ways on HTML pages.  The default is to use the
11090 @uref{http://www.mathjax.org, MathJax system} which should work out of the
11091 box with Org mode installation because @code{http://orgmode.org} serves
11092 @file{MathJax} for Org mode users for small applications and for testing
11093 purposes.  @b{If you plan to use this regularly or on pages with significant
11094 page views, you should install@footnote{Installation instructions can be
11095 found on the MathJax website, see
11096 @uref{http://www.mathjax.org/resources/docs/?installation.html}.} MathJax on
11097 your own server in order to limit the load of our server.}  To configure
11098 @file{MathJax}, use the variable @code{org-html-mathjax-options} or
11099 insert something like the following into the buffer:
11101 @example
11102 #+HTML_MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js"
11103 @end example
11105 @noindent See the docstring of the variable
11106 @code{org-html-mathjax-options} for the meaning of the parameters in
11107 this line.
11109 If you prefer, you can also request that @LaTeX{} fragments are processed
11110 into small images that will be inserted into the browser page.  Before the
11111 availability of MathJax, this was the default method for Org files.  This
11112 method requires that the @file{dvipng} program is available on your system.
11113 You can still get this processing with
11115 @example
11116 #+OPTIONS: LaTeX:dvipng
11117 @end example
11119 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
11120 @subsection Text areas in HTML export
11122 @cindex text areas, in HTML
11123 An alternative way to publish literal code examples in HTML is to use text
11124 areas, where the example can even be edited before pasting it into an
11125 application.  It is triggered by a @code{-t} switch at an @code{example} or
11126 @code{src} block.  Using this switch disables any options for syntax and
11127 label highlighting, and line numbering, which may be present.  You may also
11128 use @code{-h} and @code{-w} switches to specify the height and width of the
11129 text area, which default to the number of lines in the example, and 80,
11130 respectively.  For example
11132 @example
11133 #+BEGIN_EXAMPLE -t -w 40
11134   (defun org-xor (a b)
11135      "Exclusive or."
11136      (if a (not b) b))
11137 #+END_EXAMPLE
11138 @end example
11141 @node CSS support, JavaScript support, Text areas in HTML export, HTML export
11142 @subsection CSS support
11143 @cindex CSS, for HTML export
11144 @cindex HTML export, CSS
11146 @vindex org-html-todo-kwd-class-prefix
11147 @vindex org-html-tag-class-prefix
11148 You can also give style information for the exported file.  The HTML exporter
11149 assigns the following special CSS classes@footnote{If the classes on TODO
11150 keywords and tags lead to conflicts, use the variables
11151 @code{org-html-todo-kwd-class-prefix} and
11152 @code{org-html-tag-class-prefix} to make them unique.} to appropriate
11153 parts of the document---your style specifications may change these, in
11154 addition to any of the standard classes like for headlines, tables, etc.
11155 @example
11156 p.author            @r{author information, including email}
11157 p.date              @r{publishing date}
11158 p.creator           @r{creator info, about org mode version}
11159 .title              @r{document title}
11160 .todo               @r{TODO keywords, all not-done states}
11161 .done               @r{the DONE keywords, all states that count as done}
11162 .WAITING            @r{each TODO keyword also uses a class named after itself}
11163 .timestamp          @r{timestamp}
11164 .timestamp-kwd      @r{keyword associated with a timestamp, like SCHEDULED}
11165 .timestamp-wrapper  @r{span around keyword plus timestamp}
11166 .tag                @r{tag in a headline}
11167 ._HOME              @r{each tag uses itself as a class, "@@" replaced by "_"}
11168 .target             @r{target for links}
11169 .linenr             @r{the line number in a code example}
11170 .code-highlighted   @r{for highlighting referenced code lines}
11171 div.outline-N       @r{div for outline level N (headline plus text))}
11172 div.outline-text-N  @r{extra div for text at outline level N}
11173 .section-number-N   @r{section number in headlines, different for each level}
11174 div.figure          @r{how to format an inlined image}
11175 pre.src             @r{formatted source code}
11176 pre.example         @r{normal example}
11177 p.verse             @r{verse paragraph}
11178 div.footnotes       @r{footnote section headline}
11179 p.footnote          @r{footnote definition paragraph, containing a footnote}
11180 .footref            @r{a footnote reference number (always a <sup>)}
11181 .footnum            @r{footnote number in footnote definition (always <sup>)}
11182 @end example
11184 @vindex org-html-style-default
11185 @vindex org-html-head-include-default-style
11186 @vindex org-html-head
11187 @vindex org-html-head-extra
11188 @cindex #+HTML_INCLUDE_STYLE
11189 Each exported file contains a compact default style that defines these
11190 classes in a basic way@footnote{This style is defined in the constant
11191 @code{org-html-style-default}, which you should not modify.  To turn
11192 inclusion of these defaults off, customize
11193 @code{org-html-head-include-default-style} or set @code{#+HTML_INCLUDE_STYLE}
11194 to nil on a per-file basis.}.  You may overwrite these settings, or add to
11195 them by using the variables @code{org-html-head} and
11196 @code{org-html-head-extra}.  You can override the global values of these
11197 variables for each file by using these keywords:
11199 @cindex #+HTML_HEAD
11200 @cindex #+HTML_HEAD_EXTRA
11201 @example
11202 #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
11203 #+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
11204 @end example
11206 @noindent
11207 For longer style definitions, you can use several such lines.  You could also
11208 directly write a @code{<style>} @code{</style>} section in this way, without
11209 referring to an external file.
11211 In order to add styles to a subtree, use the @code{:HTML_CONTAINER_CLASS:}
11212 property to assign a class to the tree.  In order to specify CSS styles for a
11213 particular headline, you can use the id specified in a @code{:CUSTOM_ID:}
11214 property.
11216 @c FIXME: More about header and footer styles
11217 @c FIXME: Talk about links and targets.
11219 @node JavaScript support,  , CSS support, HTML export
11220 @subsection JavaScript supported display of web pages
11222 @cindex Rose, Sebastian
11223 Sebastian Rose has written a JavaScript program especially designed to
11224 enhance the web viewing experience of HTML files created with Org.  This
11225 program allows you to view large files in two different ways.  The first one
11226 is an @emph{Info}-like mode where each section is displayed separately and
11227 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
11228 as well, press @kbd{?} for an overview of the available keys).  The second
11229 view type is a @emph{folding} view much like Org provides inside Emacs.  The
11230 script is available at @url{http://orgmode.org/org-info.js} and you can find
11231 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
11232 We host the script at our site, but if you use it a lot, you might not want
11233 to be dependent on @url{http://orgmode.org} and prefer to install a local
11234 copy on your own web server.
11236 All it then takes to use this program is adding a single line to the Org
11237 file:
11239 @cindex #+INFOJS_OPT
11240 @example
11241 #+INFOJS_OPT: view:info toc:nil
11242 @end example
11244 @noindent
11245 If this line is found, the HTML header will automatically contain the code
11246 needed to invoke the script.  Using the line above, you can set the following
11247 viewing options:
11249 @example
11250 path:    @r{The path to the script.  The default is to grab the script from}
11251          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
11252          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
11253 view:    @r{Initial view when the website is first shown.  Possible values are:}
11254          info      @r{Info-like interface with one section per page.}
11255          overview  @r{Folding interface, initially showing only top-level.}
11256          content   @r{Folding interface, starting with all headlines visible.}
11257          showall   @r{Folding interface, all headlines and text visible.}
11258 sdepth:  @r{Maximum headline level that will still become an independent}
11259          @r{section for info and folding modes.  The default is taken from}
11260          @r{@code{org-export-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
11261          @r{If this is smaller than in @code{org-export-headline-levels}, each}
11262          @r{info/folding section can still contain child headlines.}
11263 toc:     @r{Should the table of contents @emph{initially} be visible?}
11264          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
11265 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
11266          @r{the variables @code{org-export-headline-levels} and @code{org-export-with-toc}.}
11267 ftoc:    @r{Does the CSS of the page specify a fixed position for the "toc"?}
11268          @r{If yes, the toc will never be displayed as a section.}
11269 ltoc:    @r{Should there be short contents (children) in each section?}
11270          @r{Make this @code{above} if the section should be above initial text.}
11271 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
11272          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
11273 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
11274          @r{default), only one such button will be present.}
11275 @end example
11276 @noindent
11277 @vindex org-html-infojs-options
11278 @vindex org-html-use-infojs
11279 You can choose default values for these options by customizing the variable
11280 @code{org-html-infojs-options}.  If you always want to apply the script to your
11281 pages, configure the variable @code{org-html-use-infojs}.
11283 @node @LaTeX{} and PDF export, Markdown export, HTML export, Exporting
11284 @section @LaTeX{} and PDF export
11285 @cindex @LaTeX{} export
11286 @cindex PDF export
11288 Org mode contains a @LaTeX{} exporter.  With further processing@footnote{The
11289 default @LaTeX{} output is designed for processing with @code{pdftex} or
11290 @LaTeX{}.  It includes packages that are not compatible with @code{xetex} and
11291 possibly @code{luatex}.  See the variables
11292 @code{org-latex-default-packages-alist} and
11293 @code{org-latex-packages-alist}.}, this back-end is also used to produce PDF
11294 output.  Since the @LaTeX{} output uses @file{hyperref} to implement links
11295 and cross references, the PDF output file will be fully linked.
11297 As is @LaTeX{}, blank lines are meaningful for this back-end: a paragraph
11298 will not be started if two contiguous syntactical elements are not separated
11299 by an empty line.
11301 This back-end also offers enhanced support for footnotes.  Thus, it handles
11302 nested footnotes, footnotes in tables and footnotes in items' description.
11304 @menu
11305 * @LaTeX{}/PDF export commands::
11306 * Header and sectioning::       Setting up the export file structure
11307 * Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
11308 * @LaTeX{} specific attributes::   Controlling @LaTeX{} output
11309 @end menu
11311 @node @LaTeX{}/PDF export commands, Header and sectioning, @LaTeX{} and PDF export, @LaTeX{} and PDF export
11312 @subsection @LaTeX{} export commands
11314 @table @kbd
11315 @orgcmd{C-c C-e l l,org-latex-export-to-latex}
11316 Export as a @LaTeX{} file.  For an Org file @file{myfile.org}, the @LaTeX{}
11317 file will be @file{myfile.tex}.  The file will be overwritten without
11318 warning.
11319 @orgcmd{C-c C-e l L,org-latex-export-as-latex}
11320 Export to a temporary buffer.  Do not create a file.
11321 @orgcmd{C-c C-e l p,org-latex-export-to-pdf}
11322 Export as @LaTeX{} and then process to PDF.
11323 @item C-c C-e l o
11324 Export as @LaTeX{} and then process to PDF, then open the resulting PDF file.
11325 @end table
11327 @node Header and sectioning, Quoting @LaTeX{} code, @LaTeX{}/PDF export commands, @LaTeX{} and PDF export
11328 @subsection Header and sectioning structure
11329 @cindex @LaTeX{} class
11330 @cindex @LaTeX{} sectioning structure
11331 @cindex @LaTeX{} header
11332 @cindex header, for @LaTeX{} files
11333 @cindex sectioning structure, for @LaTeX{} export
11335 The first three outline levels become headlines, defining a general document
11336 structure.  Additional levels are exported as @code{itemize} or
11337 @code{enumerate} lists.  The transition can also occur at a different level
11338 (@pxref{Export settings}).
11340 By default, the @LaTeX{} output uses the class @code{article}.
11342 @vindex org-latex-default-class
11343 @vindex org-latex-classes
11344 @vindex org-latex-default-packages-alist
11345 @vindex org-latex-packages-alist
11346 You can change this globally by setting a different value for
11347 @code{org-latex-default-class} or locally by adding an option like
11348 @code{#+LATEX_CLASS: myclass} in your file, or with
11349 a @code{EXPORT_LATEX_CLASS} property that applies when exporting a region
11350 containing only this (sub)tree.  The class must be listed in
11351 @code{org-latex-classes}.  This variable defines a header template for each
11352 class@footnote{Into which the values of
11353 @code{org-latex-default-packages-alist} and @code{org-latex-packages-alist}
11354 are spliced.}, and allows you to define the sectioning structure for each
11355 class.  You can also define your own classes there.
11357 @cindex #+LATEX_CLASS
11358 @cindex #+LATEX_CLASS_OPTIONS
11359 @cindex property, EXPORT_LATEX_CLASS
11360 @cindex property, EXPORT_LATEX_CLASS_OPTIONS
11361 @code{LATEX_CLASS_OPTIONS} keyword or @code{EXPORT_LATEX_CLASS_OPTIONS}
11362 property can specify the options for the @code{\documentclass} macro.  These
11363 options have to be provided, as expected by @LaTeX{}, within square brackets.
11365 @cindex #+LATEX_HEADER
11366 @cindex #+LATEX_HEADER_EXTRA
11367 You can also use LATEX_HEADER and LATEX_HEADER_EXTRA keywords in order to add
11368 lines to the header.  See the docstring of @code{org-latex-classes} for more
11369 information.
11371 An example is shown below.
11373 @example
11374 #+LATEX_CLASS: article
11375 #+LATEX_CLASS_OPTIONS: [a4paper]
11376 #+LATEX_HEADER: \usepackage@{xyz@}
11378 * Headline 1
11379   some text
11380 @end example
11382 @node Quoting @LaTeX{} code, @LaTeX{} specific attributes, Header and sectioning, @LaTeX{} and PDF export
11383 @subsection Quoting @LaTeX{} code
11385 Embedded @LaTeX{} as described in @ref{Embedded @LaTeX{}}, will be correctly
11386 inserted into the @LaTeX{} file.  Furthermore, you can add special code that
11387 should only be present in @LaTeX{} export with the following constructs:
11389 @cindex #+LATEX
11390 @cindex #+BEGIN_LATEX
11391 @example
11392 Code within @@@@latex:some code@@@@ a paragraph.
11394 #+LATEX: Literal @LaTeX{} code for export
11396 #+BEGIN_LATEX
11397 All lines between these markers are exported literally
11398 #+END_LATEX
11399 @end example
11401 @node @LaTeX{} specific attributes, , Quoting @LaTeX{} code, @LaTeX{} and PDF export
11402 @subsection @LaTeX{} specific attributes
11403 @cindex #+ATTR_LATEX
11405 @LaTeX{} understands attributes specified in an @code{ATTR_LATEX} line.  They
11406 affect tables, images, plain lists, special blocks and source blocks.
11408 @subsubheading Tables in @LaTeX{} export
11409 @cindex tables, in @LaTeX{} export
11411 For @LaTeX{} export of a table, you can specify a label and a caption
11412 (@pxref{Images and tables}).  You can also use attributes to control table
11413 layout and contents.  Valid properties are:
11415 @table @code
11416 @item :mode
11417 @vindex org-latex-default-table-mode
11418 Nature of table's contents.  It can be set to @code{table}, @code{math},
11419 @code{inline-math} or @code{verbatim}.  In particular, when in @code{math} or
11420 @code{inline-math} mode, every cell is exported as-is, horizontal rules are
11421 ignored and the table will be wrapped in a math environment.  Also,
11422 contiguous tables sharing the same math mode will be wrapped within the same
11423 environment.  Default mode is determined in
11424 @var{org-latex-default-table-mode}.
11425 @item :environment
11426 @vindex org-latex-default-table-environment
11427 Environment used for the table.  It can be to any @LaTeX{} table
11428 environment, like @code{tabularx}, @code{longtable}, @code{array},
11429 @code{tabu}, @code{bmatrix}@enddots{}  It defaults to
11430 @var{org-latex-default-table-environment} value.
11431 @item :float
11432 Float environment for the table.  Possible values are @code{sidewaystable},
11433 @code{multicolumn} and @code{table}.  If unspecified, a table with a caption
11434 will have a @code{table} environment.  Moreover, @code{:placement} attribute
11435 can specify the positioning of the float.
11436 @item :align
11437 @itemx :font
11438 @itemx :width
11439 set, respectively, the alignment string of the table, its font size and its
11440 width.  They only apply on regular tables.
11441 @item :spread
11442 Boolean specific to the @code{tabu} and @code{longtabu} environments, and
11443 only takes effect when used in conjunction with the @code{:width} attribute.
11444 When @code{:spread} is non-nil, the table will be spread or shrunk by the
11445 value of @code{:width}.
11446 @item :booktabs
11447 @itemx :center
11448 @itemx :rmlines
11449 @vindex org-latex-tables-booktabs
11450 @vindex org-latex-tables-centered
11451 They toggle, respectively, @code{booktabs} usage (assuming the package is
11452 properly loaded), table centering and removal of every horizontal rule but
11453 the first one (in a "table.el" table only).  In particular,
11454 @var{org-latex-tables-booktabs} (resp.@: @var{org-latex-tables-centered})
11455 activates the first (resp.@: second) attribute globally.
11456 @item :math-prefix
11457 @itemx :math-suffix
11458 @itemx :math-arguments
11459 string which will be inserted, respectively, before the table within the math
11460 environment, after the table within the math environment, and between the
11461 macro name and the contents of the table.  The latter attribute is necessary
11462 to matrix macros that require more than one argument (e.g.,
11463 @code{qbordermatrix}).
11464 @end table
11466 Thus, attributes can be used in a wide array of situations, like writing
11467 a table that will span over multiple pages, or a matrix product:
11469 @example
11470 #+ATTR_LATEX: :environment longtable :align l|lp@{3cm@}r|l
11471 | ..... | ..... |
11472 | ..... | ..... |
11474 #+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
11475 | a | b |
11476 | c | d |
11477 #+ATTR_LATEX: :mode math :environment bmatrix
11478 | 1 | 2 |
11479 | 3 | 4 |
11480 @end example
11482 @subsubheading Images in @LaTeX{} export
11483 @cindex images, inline in @LaTeX{}
11484 @cindex inlining images in @LaTeX{}
11486 Images that are linked to without a description part in the link, like
11487 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
11488 output file resulting from @LaTeX{} processing.  Org will use an
11489 @code{\includegraphics} macro to insert the image@footnote{In the case of
11490 TikZ (@url{http://sourceforge.net/projects/pgf/}) images, it will become an
11491 @code{\input} macro wrapped within a @code{tikzpicture} environment.}.
11493 You can specify specify image width or height with, respectively,
11494 @code{:width} and @code{:height} attributes.  It is also possible to add any
11495 other option with the @code{:options} attribute, as shown in the following
11496 example:
11498 @example
11499 #+ATTR_LATEX: :width 5cm :options angle=90
11500 [[./img/sed-hr4049.pdf]]
11501 @end example
11503 If you have specified a caption as described in @ref{Images and tables}, the
11504 picture will be wrapped into a @code{figure} environment and thus become
11505 a floating element.  You can also ask Org to export an image as a float
11506 without specifying caption by setting the @code{:float} attribute.  You may
11507 also set it to:
11508 @itemize @minus
11509 @item
11510 @code{wrap}: if you would like to let text flow around the image.  It will
11511 make the figure occupy the left half of the page.
11512 @item
11513 @code{multicolumn}: if you wish to include an image which spans multiple
11514 columns in a page.  This will export the image wrapped in a @code{figure*}
11515 environment.
11516 @end itemize
11517 @noindent
11518 To modify the placement option of any floating environment, set the
11519 @code{placement} attribute.
11521 @example
11522 #+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement @{r@}@{0.4\textwidth@}
11523 [[./img/hst.png]]
11524 @end example
11526 Eventually, in the @code{:comment-include} attributes has a non-nil value,
11527 the code actually including the image will be commented out.
11529 @subsubheading Plain lists in @LaTeX{} export
11530 @cindex plain lists, in @LaTeX{} export
11532 Plain lists accept two optional attributes: @code{:environment} and
11533 @code{:options}.  The first one allows to use a non-standard environment
11534 (e.g., @samp{inparaenum}).  The second one allows to specify optional
11535 arguments for that environment (square brackets may be omitted).
11537 @example
11538 #+ATTR_LATEX: :environment compactitem :options $\circ$
11539 - you need ``paralist'' package to reproduce this example.
11540 @end example
11542 @subsubheading Source blocks in @LaTeX{} export
11543 @cindex source blocks, in @LaTeX{} export
11545 In addition to syntax defined in @ref{Literal examples}, names and captions
11546 (@pxref{Images and tables}), source blocks also accept @code{:long-listing}
11547 attribute, which prevents the block to become a float when non nil.
11549 @example
11550 #+ATTR_LATEX: :long-listing t
11551 #+BEGIN_SRC emacs-lisp
11552 Code that may not fit in a single page.
11553 #+END_SRC
11554 @end example
11556 @subsubheading Special blocks in @LaTeX{} export
11557 @cindex special blocks, in @LaTeX{} export
11559 In @LaTeX{} back-end, special blocks become environments of the same name.
11560 Value of @code{:options} attribute will be appended as-is to that
11561 environment's opening string.  For example:
11563 @example
11564 #+ATTR_LATEX: :options [Proof of important theorem]
11565 #+BEGIN_PROOF
11567 Therefore, any natural number above 4 is the sum of two primes.
11568 #+END_PROOF
11569 @end example
11571 @noindent
11572 becomes
11574 @example
11575 \begin@{proof@}[Proof of important theorem]
11577 Therefore, any natural number above 4 is the sum of two primes.
11578 \end@{proof@}
11579 @end example
11581 @subsubheading Horizontal rules
11582 @cindex horizontal rules, in @LaTeX{} export
11584 Width and thickness of a given horizontal rule can be controlled with,
11585 respectively, @code{:width} and @code{:thickness} attributes:
11587 @example
11588 #+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
11589 -----
11590 @end example
11592 @node Markdown export, OpenDocument Text export, @LaTeX{} and PDF export, Exporting
11593 @section Markdown export
11594 @cindex Markdown export
11596 @code{md} export back-end generates Markdown syntax@footnote{Vanilla flavour,
11597 as defined at @url{http://daringfireball.net/projects/markdown/}.} for an Org
11598 mode buffer.
11600 It is built over HTML back-end: any construct not supported by Markdown
11601 syntax (e.g., tables) will be controlled and translated by @code{html}
11602 back-end (@pxref{HTML export}).
11604 @subheading Markdown export commands
11606 @table @kbd
11607 @orgcmd{C-c C-e m m,org-md-export-to-markdown}
11608 Export as a text file written in Markdown syntax.  For an Org file,
11609 @file{myfile.org}, the resulting file will be @file{myfile.md}.  The file
11610 will be overwritten without warning.
11611 @orgcmd{C-c C-e m M,org-md-export-as-markdown}
11612 Export to a temporary buffer.  Do not create a file.
11613 @item C-c C-e m o
11614 Export as a text file with Markdown syntax, then open it.
11615 @end table
11617 @subheading Header and sectioning structure
11619 @vindex org-md-headline-style
11620 Markdown export can generate both @code{atx} and @code{setext} types for
11621 headlines, according to @var{org-md-headline-style}.  The former introduces
11622 a hard limit of two levels, whereas the latter pushes it to six.  Headlines
11623 below that limit are exported as lists.  You can also set a soft limit before
11624 that one (@pxref{Export settings}).
11626 @c begin opendocument
11628 @node OpenDocument Text export, iCalendar export, Markdown export, Exporting
11629 @section OpenDocument Text export
11630 @cindex ODT
11631 @cindex OpenDocument
11632 @cindex export, OpenDocument
11633 @cindex LibreOffice
11635 Org mode@footnote{Versions 7.8 or later} supports export to OpenDocument Text
11636 (ODT) format.  Documents created by this exporter use the
11637 @cite{OpenDocument-v1.2
11638 specification}@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
11639 Open Document Format for Office Applications (OpenDocument) Version 1.2}} and
11640 are compatible with LibreOffice 3.4.
11642 @menu
11643 * Pre-requisites for ODT export::  What packages ODT exporter relies on
11644 * ODT export commands::         How to invoke ODT export
11645 * Extending ODT export::        How to produce @samp{doc}, @samp{pdf} files
11646 * Applying custom styles::      How to apply custom styles to the output
11647 * Links in ODT export::         How links will be interpreted and formatted
11648 * Tables in ODT export::        How Tables are exported
11649 * Images in ODT export::        How to insert images
11650 * Math formatting in ODT export::  How @LaTeX{} fragments are formatted
11651 * Labels and captions in ODT export::  How captions are rendered
11652 * Literal examples in ODT export::  How source and example blocks are formatted
11653 * Advanced topics in ODT export::  Read this if you are a power user
11654 @end menu
11656 @node Pre-requisites for ODT export, ODT export commands, OpenDocument Text export, OpenDocument Text export
11657 @subsection Pre-requisites for ODT export
11658 @cindex zip
11659 The ODT exporter relies on the @file{zip} program to create the final
11660 output.  Check the availability of this program before proceeding further.
11662 @node ODT export commands, Extending ODT export, Pre-requisites for ODT export, OpenDocument Text export
11663 @subsection ODT export commands
11665 @subsubheading Exporting to ODT
11666 @anchor{x-export-to-odt}
11668 @cindex region, active
11669 @cindex active region
11670 @cindex transient-mark-mode
11671 @table @kbd
11672 @orgcmd{C-c C-e o o,org-odt-export-to-odt}
11673 @cindex property EXPORT_FILE_NAME
11675 Export as OpenDocument Text file.
11677 @vindex org-odt-preferred-output-format
11678 If @code{org-preferred-output-format} is specified, automatically convert
11679 the exported file to that format.  @xref{x-export-to-other-formats, ,
11680 Automatically exporting to other formats}.
11682 For an Org file @file{myfile.org}, the ODT file will be
11683 @file{myfile.odt}.  The file will be overwritten without warning.  If there
11684 is an active region,@footnote{This requires @code{transient-mark-mode} to be
11685 turned on} only the region will be exported.  If the selected region is a
11686 single tree,@footnote{To select the current subtree, use @kbd{C-c @@}} the
11687 tree head will become the document title.  If the tree head entry has, or
11688 inherits, an @code{EXPORT_FILE_NAME} property, that name will be used for the
11689 export.
11691 @kbd{C-c C-e o O}
11692 Export as an OpenDocument Text file and open the resulting file.
11694 @vindex org-odt-preferred-output-format
11695 If @code{org-odt-preferred-output-format} is specified, open the converted
11696 file instead.  @xref{x-export-to-other-formats, , Automatically exporting to
11697 other formats}.
11698 @end table
11700 @node Extending ODT export, Applying custom styles, ODT export commands, OpenDocument Text export
11701 @subsection Extending ODT export
11703 The ODT exporter can interface with a variety of document
11704 converters and supports popular converters out of the box.  As a result, you
11705 can use it to export to formats like @samp{doc} or convert a document from
11706 one format (say @samp{csv}) to another format (say @samp{ods} or @samp{xls}).
11708 @cindex @file{unoconv}
11709 @cindex LibreOffice
11710 If you have a working installation of LibreOffice, a document converter is
11711 pre-configured for you and you can use it right away.  If you would like to
11712 use @file{unoconv} as your preferred converter, customize the variable
11713 @code{org-odt-convert-process} to point to @code{unoconv}.  You can
11714 also use your own favorite converter or tweak the default settings of the
11715 @file{LibreOffice} and @samp{unoconv} converters.  @xref{Configuring a
11716 document converter}.
11718 @subsubsection Automatically exporting to other formats
11719 @anchor{x-export-to-other-formats}
11721 @vindex org-odt-preferred-output-format
11722 Very often, you will find yourself exporting to ODT format, only to
11723 immediately save the exported document to other formats like @samp{doc},
11724 @samp{docx}, @samp{rtf}, @samp{pdf} etc.  In such cases, you can specify your
11725 preferred output format by customizing the variable
11726 @code{org-odt-preferred-output-format}.  This way, the export commands
11727 (@pxref{x-export-to-odt,,Exporting to ODT}) can be extended to export to a
11728 format that is of immediate interest to you.
11730 @subsubsection Converting between document formats
11731 @anchor{x-convert-to-other-formats}
11733 There are many document converters in the wild which support conversion to
11734 and from various file formats, including, but not limited to the
11735 ODT format.  LibreOffice converter, mentioned above, is one such
11736 converter.  Once a converter is configured, you can interact with it using
11737 the following command.
11739 @vindex org-odt-convert
11740 @table @kbd
11742 @item M-x org-odt-convert RET
11743 Convert an existing document from one format to another.  With a prefix
11744 argument, also open the newly produced file.
11745 @end table
11747 @node Applying custom styles, Links in ODT export, Extending ODT export, OpenDocument Text export
11748 @subsection Applying custom styles
11749 @cindex styles, custom
11750 @cindex template, custom
11752 The ODT exporter ships with a set of OpenDocument styles
11753 (@pxref{Working with OpenDocument style files}) that ensure a well-formatted
11754 output.  These factory styles, however, may not cater to your specific
11755 tastes.  To customize the output, you can either modify the above styles
11756 files directly, or generate the required styles using an application like
11757 LibreOffice.  The latter method is suitable for expert and non-expert
11758 users alike, and is described here.
11760 @subsubsection Applying custom styles: the easy way
11762 @enumerate
11763 @item
11764 Create a sample @file{example.org} file with the below settings and export it
11765 to ODT format.
11767 @example
11768 #+OPTIONS: H:10 num:t
11769 @end example
11771 @item
11772 Open the above @file{example.odt} using LibreOffice.  Use the @file{Stylist}
11773 to locate the target styles---these typically have the @samp{Org} prefix---and
11774 modify those to your taste.  Save the modified file either as an
11775 OpenDocument Text (@file{.odt}) or OpenDocument Template (@file{.ott}) file.
11777 @item
11778 @cindex #+ODT_STYLES_FILE
11779 @vindex org-odt-styles-file
11780 Customize the variable @code{org-odt-styles-file} and point it to the
11781 newly created file.  For additional configuration options
11782 @pxref{x-overriding-factory-styles,,Overriding factory styles}.
11784 If you would like to choose a style on a per-file basis, you can use the
11785 @code{#+ODT_STYLES_FILE} option.  A typical setting will look like
11787 @example
11788 #+ODT_STYLES_FILE: "/path/to/example.ott"
11789 @end example
11793 @example
11794 #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
11795 @end example
11797 @end enumerate
11799 @subsubsection Using third-party styles and templates
11801 You can use third-party styles and templates for customizing your output.
11802 This will produce the desired output only if the template provides all
11803 style names that the @samp{ODT} exporter relies on.  Unless this condition is
11804 met, the output is going to be less than satisfactory.  So it is highly
11805 recommended that you only work with templates that are directly derived from
11806 the factory settings.
11808 @node Links in ODT export, Tables in ODT export, Applying custom styles, OpenDocument Text export
11809 @subsection Links in ODT export
11810 @cindex links, in ODT export
11812 ODT exporter creates native cross-references for internal links.  It creates
11813 Internet-style links for all other links.
11815 A link with no description and destined to a regular (un-itemized) outline
11816 heading is replaced with a cross-reference and section number of the heading.
11818 A @samp{\ref@{label@}}-style reference to an image, table etc. is replaced
11819 with a cross-reference and sequence number of the labeled entity.
11820 @xref{Labels and captions in ODT export}.
11822 @node Tables in ODT export, Images in ODT export, Links in ODT export, OpenDocument Text export
11823 @subsection Tables in ODT export
11824 @cindex tables, in ODT export
11826 Export of native Org mode tables (@pxref{Tables}) and simple @file{table.el}
11827 tables is supported.  However, export of complex @file{table.el} tables---tables
11828 that have column or row spans---is not supported.  Such tables are
11829 stripped from the exported document.
11831 By default, a table is exported with top and bottom frames and with rules
11832 separating row and column groups (@pxref{Column groups}).  Furthermore, all
11833 tables are typeset to occupy the same width.  If the table specifies
11834 alignment and relative width for its columns (@pxref{Column width and
11835 alignment}) then these are honored on export.@footnote{The column widths are
11836 interpreted as weighted ratios with the default weight being 1}
11838 @cindex #+ATTR_ODT
11839 You can control the width of the table by specifying @code{:rel-width}
11840 property using an @code{#+ATTR_ODT} line.
11842 For example, consider the following table which makes use of all the rules
11843 mentioned above.
11845 @example
11846 #+ATTR_ODT: :rel-width 50
11847 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
11848 |---------------+-------+-------+-------+-------|
11849 | /             |     < |       |       |     < |
11850 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
11851 | North America |     1 |    21 |   926 |   948 |
11852 | Middle East   |     6 |    75 |   844 |   925 |
11853 | Asia Pacific  |     9 |    27 |   790 |   826 |
11854 |---------------+-------+-------+-------+-------|
11855 | Sum           |    16 |   123 |  2560 |  2699 |
11856 @end example
11858 On export, the table will occupy 50% of text area.  The columns will be sized
11859 (roughly) in the ratio of 13:5:5:5:6.  The first column will be left-aligned
11860 and rest of the columns will be right-aligned.  There will be vertical rules
11861 after separating the header and last columns from other columns.  There will
11862 be horizontal rules separating the header and last rows from other rows.
11864 If you are not satisfied with the above formatting options, you can create
11865 custom table styles and associate them with a table using the
11866 @code{#+ATTR_ODT} line.  @xref{Customizing tables in ODT export}.
11868 @node Images in ODT export, Math formatting in ODT export, Tables in ODT export, OpenDocument Text export
11869 @subsection Images in ODT export
11870 @cindex images, embedding in ODT
11871 @cindex embedding images in ODT
11873 @subsubheading Embedding images
11874 You can embed images within the exported document by providing a link to the
11875 desired image file with no link description.  For example, to embed
11876 @samp{img.png} do either of the following:
11878 @example
11879 [[file:img.png]]
11880 @end example
11882 @example
11883 [[./img.png]]
11884 @end example
11886 @subsubheading Embedding clickable images
11887 You can create clickable images by providing a link whose description is a
11888 link to an image file.  For example, to embed a image
11889 @file{org-mode-unicorn.png} which when clicked jumps to
11890 @uref{http://Orgmode.org} website, do the following
11892 @example
11893 [[http://orgmode.org][./org-mode-unicorn.png]]
11894 @end example
11896 @subsubheading Sizing and scaling of embedded images
11898 @cindex #+ATTR_ODT
11899 You can control the size and scale of the embedded images using the
11900 @code{#+ATTR_ODT} attribute.
11902 @cindex identify, ImageMagick
11903 @vindex org-odt-pixels-per-inch
11904 The exporter specifies the desired size of the image in the final document in
11905 units of centimeters.  In order to scale the embedded images, the exporter
11906 queries for pixel dimensions of the images using one of a) ImageMagick's
11907 @file{identify} program or b) Emacs `create-image' and `image-size'
11908 APIs.@footnote{Use of @file{ImageMagick} is only desirable.  However, if you
11909 routinely produce documents that have large images or you export your Org
11910 files that has images using a Emacs batch script, then the use of
11911 @file{ImageMagick} is mandatory.} The pixel dimensions are subsequently
11912 converted in to units of centimeters using
11913 @code{org-odt-pixels-per-inch}.  The default value of this variable is
11914 set to @code{display-pixels-per-inch}.  You can tweak this variable to
11915 achieve the best results.
11917 The examples below illustrate the various possibilities.
11919 @table @asis
11920 @item Explicitly size the image
11921 To embed @file{img.png} as a 10 cm x 10 cm image, do the following:
11923 @example
11924 #+ATTR_ODT: :width 10 :height 10
11925 [[./img.png]]
11926 @end example
11928 @item Scale the image
11929 To embed @file{img.png} at half its size, do the following:
11931 @example
11932 #+ATTR_ODT: :scale 0.5
11933 [[./img.png]]
11934 @end example
11936 @item Scale the image to a specific width
11937 To embed @file{img.png} with a width of 10 cm while retaining the original
11938 height:width ratio, do the following:
11940 @example
11941 #+ATTR_ODT: :width 10
11942 [[./img.png]]
11943 @end example
11945 @item Scale the image to a specific height
11946 To embed @file{img.png} with a height of 10 cm while retaining the original
11947 height:width ratio, do the following
11949 @example
11950 #+ATTR_ODT: :height 10
11951 [[./img.png]]
11952 @end example
11953 @end table
11955 @subsubheading Anchoring of images
11957 @cindex #+ATTR_ODT
11958 You can control the manner in which an image is anchored by setting the
11959 @code{:anchor} property of it's @code{#+ATTR_ODT} line.  You can specify one
11960 of the the following three values for the @code{:anchor} property:
11961 @samp{"as-char"}, @samp{"paragraph"} and @samp{"page"}.
11963 To create an image that is anchored to a page, do the following:
11964 @example
11965 #+ATTR_ODT: :anchor "page"
11966 [[./img.png]]
11967 @end example
11969 @node Math formatting in ODT export, Labels and captions in ODT export, Images in ODT export, OpenDocument Text export
11970 @subsection Math formatting in ODT export
11972 The ODT exporter has special support for handling math.
11974 @menu
11975 * Working with @LaTeX{} math snippets::  How to embed @LaTeX{} math fragments
11976 * Working with MathML or OpenDocument formula files::  How to embed equations in native format
11977 @end menu
11979 @node Working with @LaTeX{} math snippets, Working with MathML or OpenDocument formula files, Math formatting in ODT export, Math formatting in ODT export
11980 @subsubsection Working with @LaTeX{} math snippets
11982 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be embedded in the ODT
11983 document in one of the following ways:
11985 @cindex MathML
11986 @enumerate
11987 @item MathML
11989 This option is activated on a per-file basis with
11991 @example
11992 #+OPTIONS: LaTeX:t
11993 @end example
11995 With this option, @LaTeX{} fragments are first converted into MathML
11996 fragments using an external @LaTeX{}-to-MathML converter program.  The
11997 resulting MathML fragments are then embedded as an OpenDocument Formula in
11998 the exported document.
12000 @vindex org-latex-to-mathml-convert-command
12001 @vindex org-latex-to-mathml-jar-file
12003 You can specify the @LaTeX{}-to-MathML converter by customizing the variables
12004 @code{org-latex-to-mathml-convert-command} and
12005 @code{org-latex-to-mathml-jar-file}.
12007 If you prefer to use @file{MathToWeb}@footnote{See
12008 @uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}} as your
12009 converter, you can configure the above variables as shown below.
12011 @lisp
12012 (setq org-latex-to-mathml-convert-command
12013       "java -jar %j -unicode -force -df %o %I"
12014       org-latex-to-mathml-jar-file
12015       "/path/to/mathtoweb.jar")
12016 @end lisp
12018 You can use the following commands to quickly verify the reliability of
12019 the @LaTeX{}-to-MathML converter.
12021 @table @kbd
12022 @item M-x org-odt-export-as-odf RET
12023 Convert a @LaTeX{} math snippet to an OpenDocument formula (@file{.odf}) file.
12025 @item M-x org-odt-export-as-odf-and-open RET
12026 Convert a @LaTeX{} math snippet to an OpenDocument formula (@file{.odf}) file
12027 and open the formula file with the system-registered application.
12028 @end table
12030 @cindex dvipng
12031 @item PNG images
12033 This option is activated on a per-file basis with
12035 @example
12036 #+OPTIONS: LaTeX:dvipng
12037 @end example
12039 With this option, @LaTeX{} fragments are processed into PNG images and the
12040 resulting images are embedded in the exported document.  This method requires
12041 that the @file{dvipng} program be available on your system.
12042 @end enumerate
12044 @node Working with MathML or OpenDocument formula files,  , Working with @LaTeX{} math snippets, Math formatting in ODT export
12045 @subsubsection Working with MathML or OpenDocument formula files
12047 For various reasons, you may find embedding @LaTeX{} math snippets in an
12048 ODT document less than reliable.  In that case, you can embed a
12049 math equation by linking to its MathML (@file{.mml}) source or its
12050 OpenDocument formula (@file{.odf}) file as shown below:
12052 @example
12053 [[./equation.mml]]
12054 @end example
12058 @example
12059 [[./equation.odf]]
12060 @end example
12062 @node Labels and captions in ODT export, Literal examples in ODT export, Math formatting in ODT export, OpenDocument Text export
12063 @subsection Labels and captions in ODT export
12065 You can label and caption various category of objects---an inline image, a
12066 table, a @LaTeX{} fragment or a Math formula---using @code{#+LABEL} and
12067 @code{#+CAPTION} lines.  @xref{Images and tables}.  ODT exporter enumerates
12068 each labeled or captioned object of a given category separately.  As a
12069 result, each such object is assigned a sequence number based on order of it's
12070 appearance in the Org file.
12072 In the exported document, a user-provided caption is augmented with the
12073 category and sequence number.  Consider the following inline image in an Org
12074 file.
12076 @example
12077 #+CAPTION: Bell curve
12078 #+LABEL:   fig:SED-HR4049
12079 [[./img/a.png]]
12080 @end example
12082 It could be rendered as shown below in the exported document.
12084 @example
12085 Figure 2: Bell curve
12086 @end example
12088 @vindex org-odt-category-map-alist
12089 You can modify the category component of the caption by customizing the
12090 option @code{org-odt-category-map-alist}.  For example, to tag all embedded
12091 images with the string @samp{Illustration} (instead of the default
12092 @samp{Figure}) use the following setting:
12094 @lisp
12095 (setq org-odt-category-map-alist
12096       (("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
12097 @end lisp
12099 With this, previous image will be captioned as below in the exported
12100 document.
12102 @example
12103 Illustration 2: Bell curve
12104 @end example
12106 @node Literal examples in ODT export, Advanced topics in ODT export, Labels and captions in ODT export, OpenDocument Text export
12107 @subsection Literal examples in ODT export
12109 Export of literal examples (@pxref{Literal examples}) with full fontification
12110 is supported.  Internally, the exporter relies on @file{htmlfontify.el} to
12111 generate all style definitions needed for a fancy listing.@footnote{Your
12112 @file{htmlfontify.el} library must at least be at Emacs 24.1 levels for
12113 fontification to be turned on.}  The auto-generated styles have @samp{OrgSrc}
12114 as prefix and inherit their color from the faces used by Emacs
12115 @code{font-lock} library for the source language.
12117 @vindex org-odt-fontify-srcblocks
12118 If you prefer to use your own custom styles for fontification, you can do
12119 so by customizing the variable
12120 @code{org-odt-create-custom-styles-for-srcblocks}.
12122 @vindex org-odt-create-custom-styles-for-srcblocks
12123 You can turn off fontification of literal examples by customizing the
12124 option @code{org-odt-fontify-srcblocks}.
12126 @node Advanced topics in ODT export,  , Literal examples in ODT export, OpenDocument Text export
12127 @subsection Advanced topics in ODT export
12129 If you rely heavily on ODT export, you may want to exploit the full
12130 set of features that the exporter offers.  This section describes features
12131 that would be of interest to power users.
12133 @menu
12134 * Configuring a document converter::  How to register a document converter
12135 * Working with OpenDocument style files::  Explore the internals
12136 * Creating one-off styles::     How to produce custom highlighting etc
12137 * Customizing tables in ODT export::  How to define and use Table templates
12138 * Validating OpenDocument XML::  How to debug corrupt OpenDocument files
12139 @end menu
12141 @node Configuring a document converter, Working with OpenDocument style files, Advanced topics in ODT export, Advanced topics in ODT export
12142 @subsubsection Configuring a document converter
12143 @cindex convert
12144 @cindex doc, docx, rtf
12145 @cindex converter
12147 The ODT exporter can work with popular converters with little or no
12148 extra configuration from your side. @xref{Extending ODT export}.
12149 If you are using a converter that is not supported by default or if you would
12150 like to tweak the default converter settings, proceed as below.
12152 @enumerate
12153 @item Register the converter
12155 @vindex org-odt-convert-processes
12156 Name your converter and add it to the list of known converters by
12157 customizing the option @code{org-odt-convert-processes}.  Also specify how
12158 the converter can be invoked via command-line to effect the conversion.
12160 @item Configure its capabilities
12162 @vindex org-odt-convert-capabilities
12163 @anchor{x-odt-converter-capabilities} Specify the set of formats the
12164 converter can handle by customizing the variable
12165 @code{org-odt-convert-capabilities}.  Use the default value for this
12166 variable as a guide for configuring your converter.  As suggested by the
12167 default setting, you can specify the full set of formats supported by the
12168 converter and not limit yourself to specifying formats that are related to
12169 just the OpenDocument Text format.
12171 @item Choose the converter
12173 @vindex org-odt-convert-process
12174 Select the newly added converter as the preferred one by customizing the
12175 option @code{org-odt-convert-process}.
12176 @end enumerate
12178 @node Working with OpenDocument style files, Creating one-off styles, Configuring a document converter, Advanced topics in ODT export
12179 @subsubsection Working with OpenDocument style files
12180 @cindex styles, custom
12181 @cindex template, custom
12183 This section explores the internals of the ODT exporter and the
12184 means by which it produces styled documents.  Read this section if you are
12185 interested in exploring the automatic and custom OpenDocument styles used by
12186 the exporter.
12188 @anchor{x-factory-styles}
12189 @subsubheading Factory styles
12191 The ODT exporter relies on two files for generating its output.
12192 These files are bundled with the distribution under the directory pointed to
12193 by the variable @code{org-odt-styles-dir}.  The two files are:
12195 @itemize
12196 @anchor{x-orgodtstyles-xml}
12197 @item
12198 @file{OrgOdtStyles.xml}
12200 This file contributes to the @file{styles.xml} file of the final @samp{ODT}
12201 document.  This file gets modified for the following purposes:
12202 @enumerate
12204 @item
12205 To control outline numbering based on user settings.
12207 @item
12208 To add styles generated by @file{htmlfontify.el} for fontification of code
12209 blocks.
12210 @end enumerate
12212 @anchor{x-orgodtcontenttemplate-xml}
12213 @item
12214 @file{OrgOdtContentTemplate.xml}
12216 This file contributes to the @file{content.xml} file of the final @samp{ODT}
12217 document.  The contents of the Org outline are inserted between the
12218 @samp{<office:text>}@dots{}@samp{</office:text>} elements of this file.
12220 Apart from serving as a template file for the final @file{content.xml}, the
12221 file serves the following purposes:
12222 @enumerate
12224 @item
12225 It contains automatic styles for formatting of tables which are referenced by
12226 the exporter.
12228 @item
12229 It contains @samp{<text:sequence-decl>}@dots{}@samp{</text:sequence-decl>}
12230 elements that control how various entities---tables, images, equations,
12231 etc.---are numbered.
12232 @end enumerate
12233 @end itemize
12235 @anchor{x-overriding-factory-styles}
12236 @subsubheading Overriding factory styles
12237 The following two variables control the location from which the ODT
12238 exporter picks up the custom styles and content template files.  You can
12239 customize these variables to override the factory styles used by the
12240 exporter.
12242 @itemize
12243 @anchor{x-org-odt-styles-file}
12244 @item
12245 @code{org-odt-styles-file}
12247 Use this variable to specify the @file{styles.xml} that will be used in the
12248 final output.  You can specify one of the following values:
12250 @enumerate
12251 @item A @file{styles.xml} file
12253 Use this file instead of the default @file{styles.xml}
12255 @item A @file{.odt} or @file{.ott} file
12257 Use the @file{styles.xml} contained in the specified OpenDocument Text or
12258 Template file
12260 @item A @file{.odt} or @file{.ott} file and a subset of files contained within them
12262 Use the @file{styles.xml} contained in the specified OpenDocument Text or
12263 Template file.  Additionally extract the specified member files and embed
12264 those within the final @samp{ODT} document.
12266 Use this option if the @file{styles.xml} file references additional files
12267 like header and footer images.
12269 @item @code{nil}
12271 Use the default @file{styles.xml}
12272 @end enumerate
12274 @anchor{x-org-odt-content-template-file}
12275 @item
12276 @code{org-odt-content-template-file}
12278 Use this variable to specify the blank @file{content.xml} that will be used
12279 in the final output.
12280 @end itemize
12282 @node Creating one-off styles, Customizing tables in ODT export, Working with OpenDocument style files, Advanced topics in ODT export
12283 @subsubsection Creating one-off styles
12285 There are times when you would want one-off formatting in the exported
12286 document.  You can achieve this by embedding raw OpenDocument XML in the Org
12287 file.  The use of this feature is better illustrated with couple of examples.
12289 @enumerate
12290 @item Embedding ODT tags as part of regular text
12292 You can include simple OpenDocument tags by prefixing them with
12293 @samp{@@}.  For example, to highlight a region of text do the following:
12295 @example
12296 @@<text:span text:style-name="Highlight">This is a
12297 highlighted text@@</text:span>.  But this is a
12298 regular text.
12299 @end example
12301 @strong{Hint:} To see the above example in action, edit your
12302 @file{styles.xml} (@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
12303 custom @samp{Highlight} style as shown below.
12305 @example
12306 <style:style style:name="Highlight" style:family="text">
12307   <style:text-properties fo:background-color="#ff0000"/>
12308 </style:style>
12309 @end example
12311 @item Embedding a one-line OpenDocument XML
12313 You can add a simple OpenDocument one-liner using the @code{#+ODT:}
12314 directive.  For example, to force a page break do the following:
12316 @example
12317 #+ODT: <text:p text:style-name="PageBreak"/>
12318 @end example
12320 @strong{Hint:} To see the above example in action, edit your
12321 @file{styles.xml} (@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
12322 custom @samp{PageBreak} style as shown below.
12324 @example
12325 <style:style style:name="PageBreak" style:family="paragraph"
12326              style:parent-style-name="Text_20_body">
12327   <style:paragraph-properties fo:break-before="page"/>
12328 </style:style>
12329 @end example
12331 @item Embedding a block of OpenDocument XML
12333 You can add a large block of OpenDocument XML using the
12334 @code{#+BEGIN_ODT}@dots{}@code{#+END_ODT} construct.
12336 For example, to create a one-off paragraph that uses bold text, do the
12337 following:
12339 @example
12340 #+BEGIN_ODT
12341 <text:p text:style-name="Text_20_body_20_bold">
12342 This paragraph is specially formatted and uses bold text.
12343 </text:p>
12344 #+END_ODT
12345 @end example
12347 @end enumerate
12349 @node Customizing tables in ODT export, Validating OpenDocument XML, Creating one-off styles, Advanced topics in ODT export
12350 @subsubsection Customizing tables in ODT export
12351 @cindex tables, in ODT export
12353 @cindex #+ATTR_ODT
12354 You can override the default formatting of the table by specifying a custom
12355 table style with the @code{#+ATTR_ODT} line.  For a discussion on default
12356 formatting of tables @pxref{Tables in ODT export}.
12358 This feature closely mimics the way table templates are defined in the
12359 OpenDocument-v1.2
12360 specification.@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
12361 OpenDocument-v1.2 Specification}}
12363 @subsubheading Custom table styles: an illustration
12365 @vindex org-odt-table-styles
12366 To have a quick preview of this feature, install the below setting and
12367 export the table that follows:
12369 @lisp
12370 (setq org-odt-table-styles
12371       (append org-odt-table-styles
12372             '(("TableWithHeaderRowAndColumn" "Custom"
12373                 ((use-first-row-styles . t)
12374                  (use-first-column-styles . t)))
12375                 ("TableWithFirstRowandLastRow" "Custom"
12376                  ((use-first-row-styles . t)
12377                  (use-last-row-styles . t))))))
12378 @end lisp
12380 @example
12381 #+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
12382 | Name  | Phone | Age |
12383 | Peter |  1234 |  17 |
12384 | Anna  |  4321 |  25 |
12385 @end example
12387 In the above example, you used a template named @samp{Custom} and installed
12388 two table styles with the names @samp{TableWithHeaderRowAndColumn} and
12389 @samp{TableWithFirstRowandLastRow}.  (@strong{Important:} The OpenDocument
12390 styles needed for producing the above template have been pre-defined for
12391 you.  These styles are available under the section marked @samp{Custom
12392 Table Template} in @file{OrgOdtContentTemplate.xml}
12393 (@pxref{x-orgodtcontenttemplate-xml,,Factory styles}).  If you need
12394 additional templates you have to define these styles yourselves.
12396 @subsubheading Custom table styles: the nitty-gritty
12397 To use this feature proceed as follows:
12399 @enumerate
12400 @item
12401 Create a table template@footnote{See the @code{<table:table-template>}
12402 element of the OpenDocument-v1.2 specification}
12404 A table template is nothing but a set of @samp{table-cell} and
12405 @samp{paragraph} styles for each of the following table cell categories:
12407 @itemize @minus
12408 @item Body
12409 @item First column
12410 @item Last column
12411 @item First row
12412 @item Last row
12413 @item Even row
12414 @item Odd row
12415 @item Even column
12416 @item Odd Column
12417 @end itemize
12419 The names for the above styles must be chosen based on the name of the table
12420 template using a well-defined convention.
12422 The naming convention is better illustrated with an example.  For a table
12423 template with the name @samp{Custom}, the needed style names are listed in
12424 the following table.
12426 @multitable  {Table cell type} {CustomEvenColumnTableCell} {CustomEvenColumnTableParagraph}
12427 @headitem Table cell type
12428 @tab @code{table-cell} style
12429 @tab @code{paragraph} style
12430 @item
12431 @tab
12432 @tab
12433 @item Body
12434 @tab @samp{CustomTableCell}
12435 @tab @samp{CustomTableParagraph}
12436 @item First column
12437 @tab @samp{CustomFirstColumnTableCell}
12438 @tab @samp{CustomFirstColumnTableParagraph}
12439 @item Last column
12440 @tab @samp{CustomLastColumnTableCell}
12441 @tab @samp{CustomLastColumnTableParagraph}
12442 @item First row
12443 @tab @samp{CustomFirstRowTableCell}
12444 @tab @samp{CustomFirstRowTableParagraph}
12445 @item Last row
12446 @tab @samp{CustomLastRowTableCell}
12447 @tab @samp{CustomLastRowTableParagraph}
12448 @item Even row
12449 @tab @samp{CustomEvenRowTableCell}
12450 @tab @samp{CustomEvenRowTableParagraph}
12451 @item Odd row
12452 @tab @samp{CustomOddRowTableCell}
12453 @tab @samp{CustomOddRowTableParagraph}
12454 @item Even column
12455 @tab @samp{CustomEvenColumnTableCell}
12456 @tab @samp{CustomEvenColumnTableParagraph}
12457 @item Odd column
12458 @tab @samp{CustomOddColumnTableCell}
12459 @tab @samp{CustomOddColumnTableParagraph}
12460 @end multitable
12462 To create a table template with the name @samp{Custom}, define the above
12463 styles in the
12464 @code{<office:automatic-styles>}...@code{</office:automatic-styles>} element
12465 of the content template file (@pxref{x-orgodtcontenttemplate-xml,,Factory
12466 styles}).
12468 @item
12469 Define a table style@footnote{See the attributes @code{table:template-name},
12470 @code{table:use-first-row-styles}, @code{table:use-last-row-styles},
12471 @code{table:use-first-column-styles}, @code{table:use-last-column-styles},
12472 @code{table:use-banding-rows-styles}, and
12473 @code{table:use-banding-column-styles} of the @code{<table:table>} element in
12474 the OpenDocument-v1.2 specification}
12476 @vindex org-odt-table-styles
12477 To define a table style, create an entry for the style in the variable
12478 @code{org-odt-table-styles} and specify the following:
12480 @itemize @minus
12481 @item the name of the table template created in step (1)
12482 @item the set of cell styles in that template that are to be activated
12483 @end itemize
12485 For example, the entry below defines two different table styles
12486 @samp{TableWithHeaderRowAndColumn} and @samp{TableWithFirstRowandLastRow}
12487 based on the same template @samp{Custom}.  The styles achieve their intended
12488 effect by selectively activating the individual cell styles in that template.
12490 @lisp
12491 (setq org-odt-table-styles
12492       (append org-odt-table-styles
12493               '(("TableWithHeaderRowAndColumn" "Custom"
12494                  ((use-first-row-styles . t)
12495                   (use-first-column-styles . t)))
12496                 ("TableWithFirstRowandLastRow" "Custom"
12497                  ((use-first-row-styles . t)
12498                   (use-last-row-styles . t))))))
12499 @end lisp
12501 @item
12502 Associate a table with the table style
12504 To do this, specify the table style created in step (2) as part of
12505 the @code{ATTR_ODT} line as shown below.
12507 @example
12508 #+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
12509 | Name  | Phone | Age |
12510 | Peter |  1234 |  17 |
12511 | Anna  |  4321 |  25 |
12512 @end example
12513 @end enumerate
12515 @node Validating OpenDocument XML,  , Customizing tables in ODT export, Advanced topics in ODT export
12516 @subsubsection Validating OpenDocument XML
12518 Occasionally, you will discover that the document created by the
12519 ODT exporter cannot be opened by your favorite application.  One of
12520 the common reasons for this is that the @file{.odt} file is corrupt.  In such
12521 cases, you may want to validate the document against the OpenDocument RELAX
12522 NG Compact Syntax (RNC) schema.
12524 For de-compressing the @file{.odt} file@footnote{@file{.odt} files are
12525 nothing but @samp{zip} archives}: @inforef{File Archives,,emacs}.  For
12526 general help with validation (and schema-sensitive editing) of XML files:
12527 @inforef{Introduction,,nxml-mode}.
12529 @vindex org-odt-schema-dir
12530 If you have ready access to OpenDocument @file{.rnc} files and the needed
12531 schema-locating rules in a single folder, you can customize the variable
12532 @code{org-odt-schema-dir} to point to that directory.  The ODT exporter
12533 will take care of updating the @code{rng-schema-locating-files} for you.
12535 @c end opendocument
12537 @node iCalendar export,  , OpenDocument Text export, Exporting
12538 @section iCalendar export
12539 @cindex iCalendar export
12541 @vindex org-icalendar-include-todo
12542 @vindex org-icalendar-use-deadline
12543 @vindex org-icalendar-use-scheduled
12544 @vindex org-icalendar-categories
12545 @vindex org-icalendar-alarm-time
12546 Some people use Org mode for keeping track of projects, but still prefer a
12547 standard calendar application for anniversaries and appointments.  In this
12548 case it can be useful to show deadlines and other time-stamped items in Org
12549 files in the calendar application.  Org mode can export calendar information
12550 in the standard iCalendar format.  If you also want to have TODO entries
12551 included in the export, configure the variable
12552 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
12553 and TODO items as VTODO@.  It will also create events from deadlines that are
12554 in non-TODO items.  Deadlines and scheduling dates in TODO items will be used
12555 to set the start and due dates for the TODO entry@footnote{See the variables
12556 @code{org-icalendar-use-deadline} and @code{org-icalendar-use-scheduled}.}.
12557 As categories, it will use the tags locally defined in the heading, and the
12558 file/tree category@footnote{To add inherited tags or the TODO state,
12559 configure the variable @code{org-icalendar-categories}.}.  See the variable
12560 @code{org-icalendar-alarm-time} for a way to assign alarms to entries with a
12561 time.
12563 @vindex org-icalendar-store-UID
12564 @cindex property, ID
12565 The iCalendar standard requires each entry to have a globally unique
12566 identifier (UID).  Org creates these identifiers during export.  If you set
12567 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
12568 @code{:ID:} property of the entry and re-used next time you report this
12569 entry.  Since a single entry can give rise to multiple iCalendar entries (as
12570 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
12571 prefixes to the UID, depending on what triggered the inclusion of the entry.
12572 In this way the UID remains unique, but a synchronization program can still
12573 figure out from which entry all the different instances originate.
12575 @table @kbd
12576 @orgcmd{C-c C-e c f,org-icalendar-export-to-ics}
12577 Create iCalendar entries for the current buffer and store them in the same
12578 directory, using a file extension @file{.ics}.
12579 @orgcmd{C-c C-e c a, org-icalendar-export-agenda-files}
12580 @vindex org-agenda-files
12581 Like @kbd{C-c C-e c f}, but do this for all files in
12582 @code{org-agenda-files}.  For each of these files, a separate iCalendar
12583 file will be written.
12584 @orgcmd{C-c C-e c c,org-icalendar-combine-agenda-files}
12585 @vindex org-icalendar-combined-agenda-file
12586 Create a single large iCalendar file from all files in
12587 @code{org-agenda-files} and write it to the file given by
12588 @code{org-icalendar-combined-agenda-file}.
12589 @end table
12591 @vindex org-use-property-inheritance
12592 @vindex org-icalendar-include-body
12593 @cindex property, SUMMARY
12594 @cindex property, DESCRIPTION
12595 @cindex property, LOCATION
12596 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
12597 property can be inherited from higher in the hierarchy if you configure
12598 @code{org-use-property-inheritance} accordingly.} properties if the selected
12599 entries have them.  If not, the summary will be derived from the headline,
12600 and the description from the body (limited to
12601 @code{org-icalendar-include-body} characters).
12603 How this calendar is best read and updated, depends on the application
12604 you are using.  The FAQ covers this issue.
12606 @node Publishing, Working With Source Code, Exporting, Top
12607 @chapter Publishing
12608 @cindex publishing
12610 Org includes a publishing management system that allows you to configure
12611 automatic HTML conversion of @emph{projects} composed of interlinked org
12612 files.  You can also configure Org to automatically upload your exported HTML
12613 pages and related attachments, such as images and source code files, to a web
12614 server.
12616 You can also use Org to convert files into PDF, or even combine HTML and PDF
12617 conversion so that files are available in both formats on the server.
12619 Publishing has been contributed to Org by David O'Toole.
12621 @menu
12622 * Configuration::               Defining projects
12623 * Uploading files::             How to get files up on the server
12624 * Sample configuration::        Example projects
12625 * Triggering publication::      Publication commands
12626 @end menu
12628 @node Configuration, Uploading files, Publishing, Publishing
12629 @section Configuration
12631 Publishing needs significant configuration to specify files, destination
12632 and many other properties of a project.
12634 @menu
12635 * Project alist::               The central configuration variable
12636 * Sources and destinations::    From here to there
12637 * Selecting files::             What files are part of the project?
12638 * Publishing action::           Setting the function doing the publishing
12639 * Publishing options::          Tweaking HTML/@LaTeX{} export
12640 * Publishing links::            Which links keep working after publishing?
12641 * Sitemap::                     Generating a list of all pages
12642 * Generating an index::         An index that reaches across pages
12643 @end menu
12645 @node Project alist, Sources and destinations, Configuration, Configuration
12646 @subsection The variable @code{org-publish-project-alist}
12647 @cindex org-publish-project-alist
12648 @cindex projects, for publishing
12650 @vindex org-publish-project-alist
12651 Publishing is configured almost entirely through setting the value of one
12652 variable, called @code{org-publish-project-alist}.  Each element of the list
12653 configures one project, and may be in one of the two following forms:
12655 @lisp
12656    ("project-name" :property value :property value ...)
12657      @r{i.e., a well-formed property list with alternating keys and values}
12658 @r{or}
12659    ("project-name" :components ("project-name" "project-name" ...))
12661 @end lisp
12663 In both cases, projects are configured by specifying property values.  A
12664 project defines the set of files that will be published, as well as the
12665 publishing configuration to use when publishing those files.  When a project
12666 takes the second form listed above, the individual members of the
12667 @code{:components} property are taken to be sub-projects, which group
12668 together files requiring different publishing options.  When you publish such
12669 a ``meta-project'', all the components will also be published, in the
12670 sequence given.
12672 @node Sources and destinations, Selecting files, Project alist, Configuration
12673 @subsection Sources and destinations for files
12674 @cindex directories, for publishing
12676 Most properties are optional, but some should always be set.  In
12677 particular, Org needs to know where to look for source files,
12678 and where to put published files.
12680 @multitable @columnfractions 0.3 0.7
12681 @item @code{:base-directory}
12682 @tab Directory containing publishing source files
12683 @item @code{:publishing-directory}
12684 @tab Directory where output files will be published.  You can directly
12685 publish to a web server using a file name syntax appropriate for
12686 the Emacs @file{tramp} package.  Or you can publish to a local directory and
12687 use external tools to upload your website (@pxref{Uploading files}).
12688 @item @code{:preparation-function}
12689 @tab Function or list of functions to be called before starting the
12690 publishing process, for example, to run @code{make} for updating files to be
12691 published.  The project property list is scoped into this call as the
12692 variable @code{project-plist}.
12693 @item @code{:completion-function}
12694 @tab Function or list of functions called after finishing the publishing
12695 process, for example, to change permissions of the resulting files.  The
12696 project property list is scoped into this call as the variable
12697 @code{project-plist}.
12698 @end multitable
12699 @noindent
12701 @node Selecting files, Publishing action, Sources and destinations, Configuration
12702 @subsection Selecting files
12703 @cindex files, selecting for publishing
12705 By default, all files with extension @file{.org} in the base directory
12706 are considered part of the project.  This can be modified by setting the
12707 properties
12708 @multitable @columnfractions 0.25 0.75
12709 @item @code{:base-extension}
12710 @tab Extension (without the dot!) of source files.  This actually is a
12711 regular expression.  Set this to the symbol @code{any} if you want to get all
12712 files in @code{:base-directory}, even without extension.
12714 @item @code{:exclude}
12715 @tab Regular expression to match file names that should not be
12716 published, even though they have been selected on the basis of their
12717 extension.
12719 @item @code{:include}
12720 @tab List of files to be included regardless of @code{:base-extension}
12721 and @code{:exclude}.
12723 @item @code{:recursive}
12724 @tab Non-nil means, check base-directory recursively for files to publish.
12725 @end multitable
12727 @node Publishing action, Publishing options, Selecting files, Configuration
12728 @subsection Publishing action
12729 @cindex action, for publishing
12731 Publishing means that a file is copied to the destination directory and
12732 possibly transformed in the process.  The default transformation is to export
12733 Org files as HTML files, and this is done by the function
12734 @code{org-html-publish-to-html}, which calls the HTML exporter (@pxref{HTML
12735 export}).  But you also can publish your content as PDF files using
12736 @code{org-latex-publish-to-pdf} or as @code{ascii}, @code{Texinfo}, etc.,
12737 using the corresponding functions.
12739 If you want to publish the Org file as an @code{.org} file but with the
12740 @i{archived}, @i{commented} and @i{tag-excluded} trees removed, use the
12741 function @code{org-org-publish-to-org}.  This will produce @file{file.org}
12742 and put it in the publishing directory.  If you want a htmlized version of
12743 this file, set the parameter @code{:htmlized-source} to @code{t}, it will
12744 produce @file{file.org.html} in the publishing directory@footnote{If the
12745 publishing directory is the same than the source directory, @file{file.org}
12746 will be exported as @file{file.org.org}, so probably don't want to do this.}.
12748 Other files like images only need to be copied to the publishing destination.
12749 For this you can use @code{org-publish-attachment}.  For non-org files, you
12750 always need to specify the publishing function:
12752 @multitable @columnfractions 0.3 0.7
12753 @item @code{:publishing-function}
12754 @tab Function executing the publication of a file.  This may also be a
12755 list of functions, which will all be called in turn.
12756 @item @code{:htmlized-source}
12757 @tab Non-nil means, publish htmlized source.
12758 @end multitable
12760 The function must accept three arguments: a property list containing at least
12761 a @code{:publishing-directory} property, the name of the file to be published
12762 and the path to the publishing directory of the output file.  It should take
12763 the specified file, make the necessary transformation (if any) and place the
12764 result into the destination folder.
12766 @node Publishing options, Publishing links, Publishing action, Configuration
12767 @subsection Options for the exporters
12768 @cindex options, for publishing
12770 The property list can be used to set many export options for the exporters.
12771 In most cases, these properties correspond to user variables in Org.  The
12772 first table below lists these properties along with the variable they belong
12773 to.  The second table list HTML specific properties.  See the documentation
12774 string for the respective variable for details.
12776 @vindex org-export-with-archived-trees
12777 @vindex org-export-with-author
12778 @vindex org-export-with-creator
12779 @vindex org-display-custom-times
12780 @vindex org-export-with-drawers
12781 @vindex org-export-with-email
12782 @vindex user-mail-address
12783 @vindex org-export-with-emphasize
12784 @vindex org-export-exclude-tags
12785 @vindex org-export-with-fixed-width
12786 @vindex org-export-with-footnotes
12787 @vindex org-export-headline-levels
12788 @vindex org-export-default-language
12789 @vindex org-export-with-latex
12790 @vindex org-export-preserve-breaks
12791 @vindex org-export-with-priority
12792 @vindex org-export-publishing-directory
12793 @vindex org-export-with-section-numbers
12794 @vindex org-export-select-tags
12795 @vindex org-export-with-special-strings
12796 @vindex org-export-with-sub-superscripts
12797 @vindex org-export-with-toc
12798 @vindex org-export-with-tables
12799 @vindex org-export-with-tags
12800 @vindex org-export-with-tasks
12801 @vindex org-export-with-timestamps
12802 @vindex org-export-with-todo-keywords
12804 @multitable @columnfractions 0.32 0.68
12805 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
12806 @item @code{:author}                @tab @code{org-export-with-author}
12807 @item @code{:creator}               @tab @code{org-export-with-creator}
12808 @item @code{:customtime}            @tab @code{org-display-custom-times}
12809 @item @code{:drawers}               @tab @code{org-export-with-drawers}
12810 @item @code{:email}                 @tab @code{org-export-with-email}
12811 @item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
12812 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
12813 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
12814 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
12815 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
12816 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
12817 @item @code{:language}              @tab @code{org-export-default-language}
12818 @item @code{:latex-fragments}       @tab @code{org-export-with-latex}
12819 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
12820 @item @code{:priority}              @tab @code{org-export-with-priority}
12821 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
12822 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
12823 @item @code{:select-tags}           @tab @code{org-export-select-tags}
12824 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
12825 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
12826 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
12827 @item @code{:tables}                @tab @code{org-export-with-tables}
12828 @item @code{:tags}                  @tab @code{org-export-with-tags}
12829 @item @code{:tasks}                 @tab @code{org-export-with-tasks}
12830 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
12831 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
12832 @end multitable
12834 @vindex org-html-doctype
12835 @vindex org-html-xml-declaration
12836 @vindex org-html-link-up
12837 @vindex org-html-link-home
12838 @vindex org-html-link-org-files-as-html
12839 @vindex org-html-head
12840 @vindex org-html-head-extra
12841 @vindex org-html-inline-images
12842 @vindex org-html-extension
12843 @vindex org-html-preamble
12844 @vindex org-html-postamble
12845 @vindex org-html-table-default-attributes
12846 @vindex org-html-style-include-default
12847 @vindex org-html-style-include-scripts
12848 @multitable @columnfractions 0.32 0.68
12849 @item @code{:html-doctype}          @tab @code{org-html-doctype}
12850 @item @code{:html-xml-declaration}  @tab @code{org-html-xml-declaration}
12851 @item @code{:html-link-up}          @tab @code{org-html-link-up}
12852 @item @code{:html-link-home}        @tab @code{org-html-link-home}
12853 @item @code{:html-link-org-as-html} @tab @code{org-html-link-org-files-as-html}
12854 @item @code{:html-head}             @tab @code{org-html-head}
12855 @item @code{:html-head-extra}       @tab @code{org-html-head-extra}
12856 @item @code{:html-inline-images}    @tab @code{org-html-inline-images}
12857 @item @code{:html-extension}        @tab @code{org-html-extension}
12858 @item @code{:html-preamble}         @tab @code{org-html-preamble}
12859 @item @code{:html-postamble}        @tab @code{org-html-postamble}
12860 @item @code{:html-table-attributes}        @tab @code{org-html-table-default-attributes}
12861 @item @code{:html-head-include-default-style} @tab @code{org-html-style-include-default}
12862 @item @code{:html-head-include-scripts} @tab @code{org-html-style-include-scripts}
12863 @end multitable
12865 Most of the @code{org-export-with-*} variables have the same effect in each
12866 exporter.
12868 @vindex org-publish-project-alist
12869 When a property is given a value in @code{org-publish-project-alist}, its
12870 setting overrides the value of the corresponding user variable (if any)
12871 during publishing.  Options set within a file (@pxref{Export settings}),
12872 however, override everything.
12874 @node Publishing links, Sitemap, Publishing options, Configuration
12875 @subsection Links between published files
12876 @cindex links, publishing
12878 To create a link from one Org file to another, you would use something like
12879 @samp{[[file:foo.org][The foo]]} or simply @samp{file:foo.org.}
12880 (@pxref{Hyperlinks}).  When published, this link becomes a link to
12881 @file{foo.html}.  You can thus interlink the pages of your "org web" project
12882 and the links will work as expected when you publish them to HTML@.  If you
12883 also publish the Org source file and want to link to it, use an @code{http:}
12884 link instead of a @code{file:} link, because @code{file:} links are converted
12885 to link to the corresponding @file{html} file.
12887 You may also link to related files, such as images.  Provided you are careful
12888 with relative file names, and provided you have also configured Org to upload
12889 the related files, these links will work too.  See @ref{Complex example}, for
12890 an example of this usage.
12892 @node Sitemap, Generating an index, Publishing links, Configuration
12893 @subsection Generating a sitemap
12894 @cindex sitemap, of published pages
12896 The following properties may be used to control publishing of
12897 a map of files for a given project.
12899 @multitable @columnfractions 0.35 0.65
12900 @item @code{:auto-sitemap}
12901 @tab When non-nil, publish a sitemap during @code{org-publish-current-project}
12902 or @code{org-publish-all}.
12904 @item @code{:sitemap-filename}
12905 @tab Filename for output of sitemap.  Defaults to @file{sitemap.org} (which
12906 becomes @file{sitemap.html}).
12908 @item @code{:sitemap-title}
12909 @tab Title of sitemap page.  Defaults to name of file.
12911 @item @code{:sitemap-function}
12912 @tab Plug-in function to use for generation of the sitemap.
12913 Defaults to @code{org-publish-org-sitemap}, which generates a plain list
12914 of links to all files in the project.
12916 @item @code{:sitemap-sort-folders}
12917 @tab Where folders should appear in the sitemap.  Set this to @code{first}
12918 (default) or @code{last} to display folders first or last,
12919 respectively.  Any other value will mix files and folders.
12921 @item @code{:sitemap-sort-files}
12922 @tab How the files are sorted in the site map.  Set this to
12923 @code{alphabetically} (default), @code{chronologically} or
12924 @code{anti-chronologically}.  @code{chronologically} sorts the files with
12925 older date first while @code{anti-chronologically} sorts the files with newer
12926 date first.  @code{alphabetically} sorts the files alphabetically.  The date of
12927 a file is retrieved with @code{org-publish-find-date}.
12929 @item @code{:sitemap-ignore-case}
12930 @tab Should sorting be case-sensitive?  Default @code{nil}.
12932 @item @code{:sitemap-file-entry-format}
12933 @tab With this option one can tell how a sitemap's entry is formatted in the
12934 sitemap.  This is a format string with some escape sequences: @code{%t} stands
12935 for the title of the file, @code{%a} stands for the author of the file and
12936 @code{%d} stands for the date of the file.  The date is retrieved with the
12937 @code{org-publish-find-date} function and formatted with
12938 @code{org-publish-sitemap-date-format}.  Default @code{%t}.
12940 @item @code{:sitemap-date-format}
12941 @tab Format string for the @code{format-time-string} function that tells how
12942 a sitemap entry's date is to be formatted.  This property bypasses
12943 @code{org-publish-sitemap-date-format} which defaults to @code{%Y-%m-%d}.
12945 @item @code{:sitemap-sans-extension}
12946 @tab When non-nil, remove filenames' extensions from the generated sitemap.
12947 Useful to have cool URIs (see @uref{http://www.w3.org/Provider/Style/URI}).
12948 Defaults to @code{nil}.
12950 @end multitable
12952 @node Generating an index,  , Sitemap, Configuration
12953 @subsection Generating an index
12954 @cindex index, in a publishing project
12956 Org mode can generate an index across the files of a publishing project.
12958 @multitable @columnfractions 0.25 0.75
12959 @item @code{:makeindex}
12960 @tab When non-nil, generate in index in the file @file{theindex.org} and
12961 publish it as @file{theindex.html}.
12962 @end multitable
12964 The file will be created when first publishing a project with the
12965 @code{:makeindex} set.  The file only contains a statement @code{#+INCLUDE:
12966 "theindex.inc"}.  You can then build around this include statement by adding
12967 a title, style information, etc.
12969 @node Uploading files, Sample configuration, Configuration, Publishing
12970 @section Uploading files
12971 @cindex rsync
12972 @cindex unison
12974 For those people already utilizing third party sync tools such as
12975 @command{rsync} or @command{unison}, it might be preferable not to use the built in
12976 @i{remote} publishing facilities of Org mode which rely heavily on
12977 Tramp.  Tramp, while very useful and powerful, tends not to be
12978 so efficient for multiple file transfer and has been known to cause problems
12979 under heavy usage.
12981 Specialized synchronization utilities offer several advantages.  In addition
12982 to timestamp comparison, they also do content and permissions/attribute
12983 checks.  For this reason you might prefer to publish your web to a local
12984 directory (possibly even @i{in place} with your Org files) and then use
12985 @file{unison} or @file{rsync} to do the synchronization with the remote host.
12987 Since Unison (for example) can be configured as to which files to transfer to
12988 a certain remote destination, it can greatly simplify the project publishing
12989 definition.  Simply keep all files in the correct location, process your Org
12990 files with @code{org-publish} and let the synchronization tool do the rest.
12991 You do not need, in this scenario, to include attachments such as @file{jpg},
12992 @file{css} or @file{gif} files in the project definition since the 3rd party
12993 tool syncs them.
12995 Publishing to a local directory is also much faster than to a remote one, so
12996 that you can afford more easily to republish entire projects.  If you set
12997 @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the main
12998 benefit of re-including any changed external files such as source example
12999 files you might include with @code{#+INCLUDE:}.  The timestamp mechanism in
13000 Org is not smart enough to detect if included files have been modified.
13002 @node Sample configuration, Triggering publication, Uploading files, Publishing
13003 @section Sample configuration
13005 Below we provide two example configurations.  The first one is a simple
13006 project publishing only a set of Org files.  The second example is
13007 more complex, with a multi-component project.
13009 @menu
13010 * Simple example::              One-component publishing
13011 * Complex example::             A multi-component publishing example
13012 @end menu
13014 @node Simple example, Complex example, Sample configuration, Sample configuration
13015 @subsection Example: simple publishing configuration
13017 This example publishes a set of Org files to the @file{public_html}
13018 directory on the local machine.
13020 @lisp
13021 (setq org-publish-project-alist
13022       '(("org"
13023          :base-directory "~/org/"
13024          :publishing-directory "~/public_html"
13025          :section-numbers nil
13026          :table-of-contents nil
13027          :style "<link rel=\"stylesheet\"
13028                 href=\"../other/mystyle.css\"
13029                 type=\"text/css\"/>")))
13030 @end lisp
13032 @node Complex example,  , Simple example, Sample configuration
13033 @subsection Example: complex publishing configuration
13035 This more complicated example publishes an entire website, including
13036 Org files converted to HTML, image files, Emacs Lisp source code, and
13037 style sheets.  The publishing directory is remote and private files are
13038 excluded.
13040 To ensure that links are preserved, care should be taken to replicate
13041 your directory structure on the web server, and to use relative file
13042 paths.  For example, if your Org files are kept in @file{~/org} and your
13043 publishable images in @file{~/images}, you would link to an image with
13045 @example
13046 file:../images/myimage.png
13047 @end example
13049 On the web server, the relative path to the image should be the
13050 same.  You can accomplish this by setting up an "images" folder in the
13051 right place on the web server, and publishing images to it.
13053 @lisp
13054 (setq org-publish-project-alist
13055       '(("orgfiles"
13056           :base-directory "~/org/"
13057           :base-extension "org"
13058           :publishing-directory "/ssh:user@@host:~/html/notebook/"
13059           :publishing-function org-html-publish-to-html
13060           :exclude "PrivatePage.org"   ;; regexp
13061           :headline-levels 3
13062           :section-numbers nil
13063           :table-of-contents nil
13064           :style "<link rel=\"stylesheet\"
13065                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
13066           :html-preamble t)
13068          ("images"
13069           :base-directory "~/images/"
13070           :base-extension "jpg\\|gif\\|png"
13071           :publishing-directory "/ssh:user@@host:~/html/images/"
13072           :publishing-function org-publish-attachment)
13074          ("other"
13075           :base-directory "~/other/"
13076           :base-extension "css\\|el"
13077           :publishing-directory "/ssh:user@@host:~/html/other/"
13078           :publishing-function org-publish-attachment)
13079          ("website" :components ("orgfiles" "images" "other"))))
13080 @end lisp
13082 @node Triggering publication,  , Sample configuration, Publishing
13083 @section Triggering publication
13085 Once properly configured, Org can publish with the following commands:
13087 @table @kbd
13088 @orgcmd{C-c C-e P x,org-publish}
13089 Prompt for a specific project and publish all files that belong to it.
13090 @orgcmd{C-c C-e P p,org-publish-current-project}
13091 Publish the project containing the current file.
13092 @orgcmd{C-c C-e P f,org-publish-current-file}
13093 Publish only the current file.
13094 @orgcmd{C-c C-e P a,org-publish-all}
13095 Publish every project.
13096 @end table
13098 @vindex org-publish-use-timestamps-flag
13099 Org uses timestamps to track when a file has changed.  The above functions
13100 normally only publish changed files.  You can override this and force
13101 publishing of all files by giving a prefix argument to any of the commands
13102 above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
13103 This may be necessary in particular if files include other files via
13104 @code{#+SETUPFILE:} or @code{#+INCLUDE:}.
13106 @comment  node-name,  next,  previous,  up
13107 @comment Working With Source Code, Miscellaneous, Publishing, Top
13109 @node Working With Source Code, Miscellaneous, Publishing, Top
13110 @chapter Working with source code
13111 @cindex Schulte, Eric
13112 @cindex Davison, Dan
13113 @cindex source code, working with
13115 Source code can be included in Org mode documents using a @samp{src} block,
13116 e.g.:
13118 @example
13119 #+BEGIN_SRC emacs-lisp
13120   (defun org-xor (a b)
13121      "Exclusive or."
13122      (if a (not b) b))
13123 #+END_SRC
13124 @end example
13126 Org mode provides a number of features for working with live source code,
13127 including editing of code blocks in their native major-mode, evaluation of
13128 code blocks, converting code blocks into source files (known as @dfn{tangling}
13129 in literate programming), and exporting code blocks and their
13130 results in several formats.  This functionality was contributed by Eric
13131 Schulte and Dan Davison, and was originally named Org-babel.
13133 The following sections describe Org mode's code block handling facilities.
13135 @menu
13136 * Structure of code blocks::    Code block syntax described
13137 * Editing source code::         Language major-mode editing
13138 * Exporting code blocks::       Export contents and/or results
13139 * Extracting source code::      Create pure source code files
13140 * Evaluating code blocks::      Place results of evaluation in the Org mode buffer
13141 * Library of Babel::            Use and contribute to a library of useful code blocks
13142 * Languages::                   List of supported code block languages
13143 * Header arguments::            Configure code block functionality
13144 * Results of evaluation::       How evaluation results are handled
13145 * Noweb reference syntax::      Literate programming in Org mode
13146 * Key bindings and useful functions::  Work quickly with code blocks
13147 * Batch execution::             Call functions from the command line
13148 @end menu
13150 @comment  node-name,  next,  previous,  up
13151 @comment  Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
13153 @node Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
13154 @section Structure of code blocks
13155 @cindex code block, structure
13156 @cindex source code, block structure
13157 @cindex #+NAME
13158 @cindex #+BEGIN_SRC
13160 Live code blocks can be specified with a @samp{src} block or
13161 inline.@footnote{Note that @samp{src} blocks may be inserted using Org mode's
13162 @ref{Easy Templates} system}  The structure of a @samp{src} block is
13164 @example
13165 #+NAME: <name>
13166 #+BEGIN_SRC <language> <switches> <header arguments>
13167   <body>
13168 #+END_SRC
13169 @end example
13171 The @code{#+NAME:} line is optional, and can be used to name the code
13172 block.  Live code blocks require that a language be specified on the
13173 @code{#+BEGIN_SRC} line.  Switches and header arguments are optional.
13174 @cindex source code, inline
13176 Live code blocks can also be specified inline using
13178 @example
13179 src_<language>@{<body>@}
13180 @end example
13184 @example
13185 src_<language>[<header arguments>]@{<body>@}
13186 @end example
13188 @table @code
13189 @item <#+NAME: name>
13190 This line associates a name with the code block.  This is similar to the
13191 @code{#+NAME: Name} lines that can be used to name tables in Org mode
13192 files.  Referencing the name of a code block makes it possible to evaluate
13193 the block from other places in the file, from other files, or from Org mode
13194 table formulas (see @ref{The spreadsheet}).  Names are assumed to be unique
13195 and the behavior of Org mode when two or more blocks share the same name is
13196 undefined.
13197 @cindex #+NAME
13198 @item <language>
13199 The language of the code in the block (see @ref{Languages}).
13200 @cindex source code, language
13201 @item <switches>
13202 Optional switches control code block export (see the discussion of switches in
13203 @ref{Literal examples})
13204 @cindex source code, switches
13205 @item <header arguments>
13206 Optional header arguments control many aspects of evaluation, export and
13207 tangling of code blocks (see @ref{Header arguments}).
13208 Header arguments can also be set on a per-buffer or per-subtree
13209 basis using properties.
13210 @item source code, header arguments
13211 @item <body>
13212 Source code in the specified language.
13213 @end table
13215 @comment  node-name,  next,  previous,  up
13216 @comment  Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
13218 @node Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
13219 @section Editing source code
13220 @cindex code block, editing
13221 @cindex source code, editing
13223 @kindex C-c '
13224 Use @kbd{C-c '} to edit the current code block.  This brings up
13225 a language major-mode edit buffer containing the body of the code
13226 block.  Saving this buffer will write the new contents back to the Org
13227 buffer.  Use @kbd{C-c '} again to exit.
13229 The @code{org-src-mode} minor mode will be active in the edit buffer.  The
13230 following variables can be used to configure the behavior of the edit
13231 buffer.  See also the customization group @code{org-edit-structure} for
13232 further configuration options.
13234 @table @code
13235 @item org-src-lang-modes
13236 If an Emacs major-mode named @code{<lang>-mode} exists, where
13237 @code{<lang>} is the language named in the header line of the code block,
13238 then the edit buffer will be placed in that major-mode.  This variable
13239 can be used to map arbitrary language names to existing major modes.
13240 @item org-src-window-setup
13241 Controls the way Emacs windows are rearranged when the edit buffer is created.
13242 @item org-src-preserve-indentation
13243 This variable is especially useful for tangling languages such as
13244 Python, in which whitespace indentation in the output is critical.
13245 @item org-src-ask-before-returning-to-edit-buffer
13246 By default, Org will ask before returning to an open edit buffer.  Set this
13247 variable to nil to switch without asking.
13248 @end table
13250 To turn on native code fontification in the @emph{Org} buffer, configure the
13251 variable @code{org-src-fontify-natively}.
13253 @comment  node-name,  next,  previous,  up
13254 @comment  Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
13256 @node Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
13257 @section Exporting code blocks
13258 @cindex code block, exporting
13259 @cindex source code, exporting
13261 It is possible to export the @emph{code} of code blocks, the @emph{results}
13262 of code block evaluation, @emph{both} the code and the results of code block
13263 evaluation, or @emph{none}.  For most languages, the default exports code.
13264 However, for some languages (e.g., @code{ditaa}) the default exports the
13265 results of code block evaluation.  For information on exporting code block
13266 bodies, see @ref{Literal examples}.
13268 The @code{:exports} header argument can be used to specify export
13269 behavior:
13271 @subsubheading Header arguments:
13273 @table @code
13274 @item :exports code
13275 The default in most languages.  The body of the code block is exported, as
13276 described in @ref{Literal examples}.
13277 @item :exports results
13278 The code block will be evaluated and the results will be placed in the
13279 Org mode buffer for export, either updating previous results of the code
13280 block located anywhere in the buffer or, if no previous results exist,
13281 placing the results immediately after the code block.  The body of the code
13282 block will not be exported.
13283 @item :exports both
13284 Both the code block and its results will be exported.
13285 @item :exports none
13286 Neither the code block nor its results will be exported.
13287 @end table
13289 It is possible to inhibit the evaluation of code blocks during export.
13290 Setting the @code{org-export-babel-evaluate} variable to @code{nil} will
13291 ensure that no code blocks are evaluated as part of the export process.  This
13292 can be useful in situations where potentially untrusted Org mode files are
13293 exported in an automated fashion, for example when Org mode is used as the
13294 markup language for a wiki.
13296 @comment  node-name,  next,  previous,  up
13297 @comment  Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
13298 @node Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
13299 @section Extracting source code
13300 @cindex tangling
13301 @cindex source code, extracting
13302 @cindex code block, extracting source code
13304 Creating pure source code files by extracting code from source blocks is
13305 referred to as ``tangling''---a term adopted from the literate programming
13306 community.  During ``tangling'' of code blocks their bodies are expanded
13307 using @code{org-babel-expand-src-block} which can expand both variable and
13308 ``noweb'' style references  (see @ref{Noweb reference syntax}).
13310 @subsubheading Header arguments
13312 @table @code
13313 @item :tangle no
13314 The default.  The code block is not included in the tangled output.
13315 @item :tangle yes
13316 Include the code block in the tangled output.  The output file name is the
13317 name of the org file with the extension @samp{.org} replaced by the extension
13318 for the block language.
13319 @item :tangle filename
13320 Include the code block in the tangled output to file @samp{filename}.
13321 @end table
13323 @kindex  C-c C-v t
13324 @subsubheading Functions
13326 @table @code
13327 @item org-babel-tangle
13328 Tangle the current file.  Bound to @kbd{C-c C-v t}.
13330 With prefix argument only tangle the current code block.
13331 @item org-babel-tangle-file
13332 Choose a file to tangle.  Bound to @kbd{C-c C-v f}.
13333 @end table
13335 @subsubheading Hooks
13337 @table @code
13338 @item org-babel-post-tangle-hook
13339 This hook is run from within code files tangled by @code{org-babel-tangle}.
13340 Example applications could include post-processing, compilation or evaluation
13341 of tangled code files.
13342 @end table
13344 @node Evaluating code blocks, Library of Babel, Extracting source code, Working With Source Code
13345 @section Evaluating code blocks
13346 @cindex code block, evaluating
13347 @cindex source code, evaluating
13348 @cindex #+RESULTS
13350 Code blocks can be evaluated@footnote{Whenever code is evaluated there is a
13351 potential for that code to do harm.  Org mode provides safeguards to ensure
13352 that code is only evaluated after explicit confirmation from the user.  For
13353 information on these safeguards (and on how to disable them) see @ref{Code
13354 evaluation security}.} and the results of evaluation optionally placed in the
13355 Org mode buffer.  The results of evaluation are placed following a line that
13356 begins by default with @code{#+RESULTS} and optionally a cache identifier
13357 and/or the name of the evaluated code block.  The default value of
13358 @code{#+RESULTS} can be changed with the customizable variable
13359 @code{org-babel-results-keyword}.
13361 By default, the evaluation facility is only enabled for Lisp code blocks
13362 specified as @code{emacs-lisp}.  However, source code blocks in many languages
13363 can be evaluated within Org mode (see @ref{Languages} for a list of supported
13364 languages and @ref{Structure of code blocks} for information on the syntax
13365 used to define a code block).
13367 @kindex C-c C-c
13368 There are a number of ways to evaluate code blocks.  The simplest is to press
13369 @kbd{C-c C-c} or @kbd{C-c C-v e} with the point on a code block@footnote{The
13370 @code{org-babel-no-eval-on-ctrl-c-ctrl-c} variable can be used to remove code
13371 evaluation from the @kbd{C-c C-c} key binding.}.  This will call the
13372 @code{org-babel-execute-src-block} function to evaluate the block and insert
13373 its results into the Org mode buffer.
13374 @cindex #+CALL
13376 It is also possible to evaluate named code blocks from anywhere in an Org
13377 mode buffer or an Org mode table.  Live code blocks located in the current
13378 Org mode buffer or in the ``Library of Babel'' (see @ref{Library of Babel})
13379 can be executed.  Named code blocks can be executed with a separate
13380 @code{#+CALL:} line or inline within a block of text.
13382 The syntax of the @code{#+CALL:} line is
13384 @example
13385 #+CALL: <name>(<arguments>)
13386 #+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
13387 @end example
13389 The syntax for inline evaluation of named code blocks is
13391 @example
13392 ... call_<name>(<arguments>) ...
13393 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
13394 @end example
13396 @table @code
13397 @item <name>
13398 The name of the code block to be evaluated (see @ref{Structure of code blocks}).
13399 @item <arguments>
13400 Arguments specified in this section will be passed to the code block.  These
13401 arguments use standard function call syntax, rather than
13402 header argument syntax.  For example, a @code{#+CALL:} line that passes the
13403 number four to a code block named @code{double}, which declares the header
13404 argument @code{:var n=2}, would be written as @code{#+CALL: double(n=4)}.
13405 @item <inside header arguments>
13406 Inside header arguments are passed through and applied to the named code
13407 block.  These arguments use header argument syntax rather than standard
13408 function call syntax.  Inside header arguments affect how the code block is
13409 evaluated.  For example, @code{[:results output]} will collect the results of
13410 everything printed to @code{STDOUT} during execution of the code block.
13411 @item <end header arguments>
13412 End header arguments are applied to the calling instance and do not affect
13413 evaluation of the named code block.  They affect how the results are
13414 incorporated into the Org mode buffer and how the call line is exported.  For
13415 example, @code{:results html} will insert the results of the call line
13416 evaluation in the Org buffer, wrapped in a @code{BEGIN_HTML:} block.
13418 For more examples of passing header arguments to @code{#+CALL:} lines see
13419 @ref{Header arguments in function calls}.
13420 @end table
13422 @node Library of Babel, Languages, Evaluating code blocks, Working With Source Code
13423 @section Library of Babel
13424 @cindex babel, library of
13425 @cindex source code, library
13426 @cindex code block, library
13428 The ``Library of Babel'' consists of code blocks that can be called from any
13429 Org mode file.  Code blocks defined in the ``Library of Babel'' can be called
13430 remotely as if they were in the current Org mode buffer (see @ref{Evaluating
13431 code blocks} for information on the syntax of remote code block evaluation).
13434 The central repository of code blocks in the ``Library of Babel'' is housed
13435 in an Org mode file located in the @samp{contrib} directory of Org mode.
13437 Users can add code blocks they believe to be generally useful to their
13438 ``Library of Babel.''  The code blocks can be stored in any Org mode file and
13439 then loaded into the library with @code{org-babel-lob-ingest}.
13442 @kindex C-c C-v i
13443 Code blocks located in any Org mode file can be loaded into the ``Library of
13444 Babel'' with the @code{org-babel-lob-ingest} function, bound to @kbd{C-c C-v
13447 @node Languages, Header arguments, Library of Babel, Working With Source Code
13448 @section Languages
13449 @cindex babel, languages
13450 @cindex source code, languages
13451 @cindex code block, languages
13453 Code blocks in the following languages are supported.
13455 @multitable @columnfractions 0.28 0.3 0.22 0.2
13456 @item @b{Language} @tab @b{Identifier} @tab @b{Language} @tab @b{Identifier}
13457 @item Asymptote @tab asymptote @tab Awk @tab awk
13458 @item Emacs Calc @tab calc @tab C @tab C
13459 @item C++ @tab C++ @tab Clojure @tab clojure
13460 @item CSS @tab css @tab ditaa @tab ditaa
13461 @item Graphviz @tab dot @tab Emacs Lisp @tab emacs-lisp
13462 @item gnuplot @tab gnuplot @tab Haskell @tab haskell
13463 @item Java @tab java @tab @tab
13464 @item Javascript @tab js @tab LaTeX @tab latex
13465 @item Ledger @tab ledger @tab Lisp @tab lisp
13466 @item Lilypond @tab lilypond @tab MATLAB @tab matlab
13467 @item Mscgen @tab mscgen @tab Objective Caml @tab ocaml
13468 @item Octave @tab octave @tab Org mode @tab org
13469 @item Oz @tab oz @tab Perl @tab perl
13470 @item Plantuml @tab plantuml @tab Python @tab python
13471 @item R @tab R @tab Ruby @tab ruby
13472 @item Sass @tab sass @tab Scheme @tab scheme
13473 @item GNU Screen @tab screen @tab shell @tab sh
13474 @item SQL @tab sql @tab SQLite @tab sqlite
13475 @end multitable
13477 Language-specific documentation is available for some languages.  If
13478 available, it can be found at
13479 @uref{http://orgmode.org/worg/org-contrib/babel/languages.html}.
13481 The @code{org-babel-load-languages} controls which languages are enabled for
13482 evaluation (by default only @code{emacs-lisp} is enabled).  This variable can
13483 be set using the customization interface or by adding code like the following
13484 to your emacs configuration.
13486 @quotation
13487 The following disables @code{emacs-lisp} evaluation and enables evaluation of
13488 @code{R} code blocks.
13489 @end quotation
13491 @lisp
13492 (org-babel-do-load-languages
13493  'org-babel-load-languages
13494  '((emacs-lisp . nil)
13495    (R . t)))
13496 @end lisp
13498 It is also possible to enable support for a language by loading the related
13499 elisp file with @code{require}.
13501 @quotation
13502 The following adds support for evaluating @code{clojure} code blocks.
13503 @end quotation
13505 @lisp
13506 (require 'ob-clojure)
13507 @end lisp
13509 @node Header arguments, Results of evaluation, Languages, Working With Source Code
13510 @section Header arguments
13511 @cindex code block, header arguments
13512 @cindex source code, block header arguments
13514 Code block functionality can be configured with header arguments.  This
13515 section provides an overview of the use of header arguments, and then
13516 describes each header argument in detail.
13518 @menu
13519 * Using header arguments::      Different ways to set header arguments
13520 * Specific header arguments::   List of header arguments
13521 @end menu
13523 @node Using header arguments, Specific header arguments, Header arguments, Header arguments
13524 @subsection Using header arguments
13526 The values of header arguments can be set in six different ways, each more
13527 specific (and having higher priority) than the last.
13528 @menu
13529 * System-wide header arguments::  Set global default values
13530 * Language-specific header arguments::  Set default values by language
13531 * Buffer-wide header arguments::  Set default values for a specific buffer
13532 * Header arguments in Org mode properties::  Set default values for a buffer or heading
13533 * Code block specific header arguments::  The most common way to set values
13534 * Header arguments in function calls::  The most specific level
13535 @end menu
13538 @node System-wide header arguments, Language-specific header arguments, Using header arguments, Using header arguments
13539 @subsubheading System-wide header arguments
13540 @vindex org-babel-default-header-args
13541 System-wide values of header arguments can be specified by adapting the
13542 @code{org-babel-default-header-args} variable:
13544 @example
13545 :session    => "none"
13546 :results    => "replace"
13547 :exports    => "code"
13548 :cache      => "no"
13549 :noweb      => "no"
13550 @end example
13552 For example, the following example could be used to set the default value of
13553 @code{:noweb} header arguments to @code{yes}.  This would have the effect of
13554 expanding @code{:noweb} references by default when evaluating source code
13555 blocks.
13557 @lisp
13558 (setq org-babel-default-header-args
13559       (cons '(:noweb . "yes")
13560             (assq-delete-all :noweb org-babel-default-header-args)))
13561 @end lisp
13563 @node Language-specific header arguments, Buffer-wide header arguments, System-wide header arguments, Using header arguments
13564 @subsubheading Language-specific header arguments
13565 Each language can define its own set of default header arguments.  See the
13566 language-specific documentation available online at
13567 @uref{http://orgmode.org/worg/org-contrib/babel}.
13569 @node Buffer-wide header arguments, Header arguments in Org mode properties, Language-specific header arguments, Using header arguments
13570 @subsubheading Buffer-wide header arguments
13571 Buffer-wide header arguments may be specified as properties through the use
13572 of @code{#+PROPERTY:} lines placed anywhere in an Org mode file (see
13573 @ref{Property syntax}).
13575 For example the following would set @code{session} to @code{*R*}, and
13576 @code{results} to @code{silent} for every code block in the buffer, ensuring
13577 that all execution took place in the same session, and no results would be
13578 inserted into the buffer.
13580 @example
13581 #+PROPERTY: session *R*
13582 #+PROPERTY: results silent
13583 @end example
13585 @node Header arguments in Org mode properties, Code block specific header arguments, Buffer-wide header arguments, Using header arguments
13586 @subsubheading Header arguments in Org mode properties
13588 Header arguments are also read from Org mode properties (see @ref{Property
13589 syntax}), which can be set on a buffer-wide or per-heading basis.  An example
13590 of setting a header argument for all code blocks in a buffer is
13592 @example
13593 #+PROPERTY: tangle yes
13594 @end example
13596 @vindex org-use-property-inheritance
13597 When properties are used to set default header arguments, they are looked up
13598 with inheritance, regardless of the value of
13599 @code{org-use-property-inheritance}.  In the following example the value of
13600 the @code{:cache} header argument will default to @code{yes} in all code
13601 blocks in the subtree rooted at the following heading:
13603 @example
13604 * outline header
13605   :PROPERTIES:
13606   :cache:    yes
13607   :END:
13608 @end example
13610 @kindex C-c C-x p
13611 @vindex org-babel-default-header-args
13612 Properties defined in this way override the properties set in
13613 @code{org-babel-default-header-args}.  It is convenient to use the
13614 @code{org-set-property} function bound to @kbd{C-c C-x p} to set properties
13615 in Org mode documents.
13617 @node Code block specific header arguments, Header arguments in function calls, Header arguments in Org mode properties, Using header arguments
13618 @subsubheading Code block specific header arguments
13620 The most common way to assign values to header arguments is at the
13621 code block level.  This can be done by listing a sequence of header
13622 arguments and their values as part of the @code{#+BEGIN_SRC} line.
13623 Properties set in this way override both the values of
13624 @code{org-babel-default-header-args} and header arguments specified as
13625 properties.  In the following example, the @code{:results} header argument
13626 is set to @code{silent}, meaning the results of execution will not be
13627 inserted in the buffer, and the @code{:exports} header argument is set to
13628 @code{code}, meaning only the body of the code block will be
13629 preserved on export to HTML or @LaTeX{}.
13631 @example
13632 #+NAME: factorial
13633 #+BEGIN_SRC haskell :results silent :exports code :var n=0
13634 fac 0 = 1
13635 fac n = n * fac (n-1)
13636 #+END_SRC
13637 @end example
13638 Similarly, it is possible to set header arguments for inline code blocks
13640 @example
13641 src_haskell[:exports both]@{fac 5@}
13642 @end example
13644 Code block header arguments can span multiple lines using @code{#+HEADER:} or
13645 @code{#+HEADERS:} lines preceding a code block or nested between the
13646 @code{#+NAME:} line and the @code{#+BEGIN_SRC} line of a named code block.
13647 @cindex #+HEADER:
13648 @cindex #+HEADERS:
13650 Multi-line header arguments on an un-named code block:
13652 @example
13653  #+HEADERS: :var data1=1
13654  #+BEGIN_SRC emacs-lisp :var data2=2
13655    (message "data1:%S, data2:%S" data1 data2)
13656  #+END_SRC
13658  #+RESULTS:
13659  : data1:1, data2:2
13660 @end example
13662 Multi-line header arguments on a named code block:
13664 @example
13665    #+NAME: named-block
13666    #+HEADER: :var data=2
13667    #+BEGIN_SRC emacs-lisp
13668      (message "data:%S" data)
13669    #+END_SRC
13671    #+RESULTS: named-block
13672    : data:2
13673 @end example
13675 @node Header arguments in function calls,  , Code block specific header arguments, Using header arguments
13676 @comment  node-name,  next,  previous,  up
13677 @subsubheading Header arguments in function calls
13679 At the most specific level, header arguments for ``Library of Babel'' or
13680 @code{#+CALL:} lines can be set as shown in the two examples below.  For more
13681 information on the structure of @code{#+CALL:} lines see @ref{Evaluating code
13682 blocks}.
13684 The following will apply the @code{:exports results} header argument to the
13685 evaluation of the @code{#+CALL:} line.
13687 @example
13688 #+CALL: factorial(n=5) :exports results
13689 @end example
13691 The following will apply the @code{:session special} header argument to the
13692 evaluation of the @code{factorial} code block.
13694 @example
13695 #+CALL: factorial[:session special](n=5)
13696 @end example
13698 @node Specific header arguments,  , Using header arguments, Header arguments
13699 @subsection Specific header arguments
13700 Header arguments consist of an initial colon followed by the name of the
13701 argument in lowercase letters.  The following header arguments are defined:
13703 @menu
13704 * var::                         Pass arguments to code blocks
13705 * results::                     Specify the type of results and how they will
13706                                 be collected and handled
13707 * file::                        Specify a path for file output
13708 * file-desc::                   Specify a description for file results
13709 * dir::                         Specify the default (possibly remote)
13710                                 directory for code block execution
13711 * exports::                     Export code and/or results
13712 * tangle::                      Toggle tangling and specify file name
13713 * mkdirp::                      Toggle creation of parent directories of target
13714                                 files during tangling
13715 * comments::                    Toggle insertion of comments in tangled
13716                                 code files
13717 * padline::                     Control insertion of padding lines in tangled
13718                                 code files
13719 * no-expand::                   Turn off variable assignment and noweb
13720                                 expansion during tangling
13721 * session::                     Preserve the state of code evaluation
13722 * noweb::                       Toggle expansion of noweb references
13723 * noweb-ref::                   Specify block's noweb reference resolution target
13724 * noweb-sep::                   String used to separate noweb references
13725 * cache::                       Avoid re-evaluating unchanged code blocks
13726 * sep::                         Delimiter for writing tabular results outside Org
13727 * hlines::                      Handle horizontal lines in tables
13728 * colnames::                    Handle column names in tables
13729 * rownames::                    Handle row names in tables
13730 * shebang::                     Make tangled files executable
13731 * eval::                        Limit evaluation of specific code blocks
13732 * wrap::                        Mark source block evaluation results
13733 * post::                        Post processing of code block results
13734 @end menu
13736 Additional header arguments are defined on a language-specific basis, see
13737 @ref{Languages}.
13739 @node var, results, Specific header arguments, Specific header arguments
13740 @subsubsection @code{:var}
13741 The @code{:var} header argument is used to pass arguments to code blocks.
13742 The specifics of how arguments are included in a code block vary by language;
13743 these are addressed in the language-specific documentation.  However, the
13744 syntax used to specify arguments is the same across all languages.  In every
13745 case, variables require a default value when they are declared.
13747 The values passed to arguments can either be literal values, references, or
13748 Emacs Lisp code (see @ref{var, Emacs Lisp evaluation of variables}).
13749 References include anything in the Org mode file that takes a @code{#+NAME:}
13750 or @code{#+RESULTS:} line: tables, lists, @code{#+BEGIN_EXAMPLE} blocks,
13751 other code blocks and the results of other code blocks.
13753 Note: When a reference is made to another code block, the referenced block
13754 will be evaluated unless it has current cached results (see @ref{cache}).
13756 Argument values can be indexed in a manner similar to arrays (see @ref{var,
13757 Indexable variable values}).
13759 The following syntax is used to pass arguments to code blocks using the
13760 @code{:var} header argument.
13762 @example
13763 :var name=assign
13764 @end example
13766 The argument, @code{assign}, can either be a literal value, such as a string
13767 @samp{"string"} or a number @samp{9}, or a reference to a table, a list, a
13768 literal example, another code block (with or without arguments), or the
13769 results of evaluating another code block.
13771 Here are examples of passing values by reference:
13773 @table @dfn
13775 @item table
13776 an Org mode table named with either a @code{#+NAME:} line
13778 @example
13779 #+NAME: example-table
13780 | 1 |
13781 | 2 |
13782 | 3 |
13783 | 4 |
13785 #+NAME: table-length
13786 #+BEGIN_SRC emacs-lisp :var table=example-table
13787 (length table)
13788 #+END_SRC
13790 #+RESULTS: table-length
13791 : 4
13792 @end example
13794 @item list
13795 a simple list named with a @code{#+NAME:} line (note that nesting is not
13796 carried through to the source code block)
13798 @example
13799 #+NAME: example-list
13800   - simple
13801     - not
13802     - nested
13803   - list
13805 #+BEGIN_SRC emacs-lisp :var x=example-list
13806   (print x)
13807 #+END_SRC
13809 #+RESULTS:
13810 | simple | list |
13811 @end example
13813 @item code block without arguments
13814 a code block name (from the example above), as assigned by @code{#+NAME:},
13815 optionally followed by parentheses
13817 @example
13818 #+BEGIN_SRC emacs-lisp :var length=table-length()
13819 (* 2 length)
13820 #+END_SRC
13822 #+RESULTS:
13823 : 8
13824 @end example
13826 @item code block with arguments
13827 a code block name, as assigned by @code{#+NAME:}, followed by parentheses and
13828 optional arguments passed within the parentheses following the
13829 code block name using standard function call syntax
13831 @example
13832 #+NAME: double
13833 #+BEGIN_SRC emacs-lisp :var input=8
13834 (* 2 input)
13835 #+END_SRC
13837 #+RESULTS: double
13838 : 16
13840 #+NAME: squared
13841 #+BEGIN_SRC emacs-lisp :var input=double(input=1)
13842 (* input input)
13843 #+END_SRC
13845 #+RESULTS: squared
13846 : 4
13847 @end example
13849 @item literal example
13850 a literal example block named with a @code{#+NAME:} line
13852 @example
13853 #+NAME: literal-example
13854 #+BEGIN_EXAMPLE
13855 A literal example
13856 on two lines
13857 #+END_EXAMPLE
13859 #+NAME: read-literal-example
13860 #+BEGIN_SRC emacs-lisp :var x=literal-example
13861   (concatenate 'string x " for you.")
13862 #+END_SRC
13864 #+RESULTS: read-literal-example
13865 : A literal example
13866 : on two lines for you.
13868 @end example
13870 @end table
13872 @subsubheading Indexable variable values
13873 It is possible to reference portions of variable values by ``indexing'' into
13874 the variables.  Indexes are 0 based with negative values counting back from
13875 the end.  If an index is separated by @code{,}s then each subsequent section
13876 will index into the next deepest nesting or dimension of the value.  Note
13877 that this indexing occurs @emph{before} other table related header arguments
13878 like @code{:hlines}, @code{:colnames} and @code{:rownames} are applied.  The
13879 following example assigns the last cell of the first row the table
13880 @code{example-table} to the variable @code{data}:
13882 @example
13883 #+NAME: example-table
13884 | 1 | a |
13885 | 2 | b |
13886 | 3 | c |
13887 | 4 | d |
13889 #+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
13890   data
13891 #+END_SRC
13893 #+RESULTS:
13894 : a
13895 @end example
13897 Ranges of variable values can be referenced using two integers separated by a
13898 @code{:}, in which case the entire inclusive range is referenced.  For
13899 example the following assigns the middle three rows of @code{example-table}
13900 to @code{data}.
13902 @example
13903 #+NAME: example-table
13904 | 1 | a |
13905 | 2 | b |
13906 | 3 | c |
13907 | 4 | d |
13908 | 5 | 3 |
13910 #+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
13911   data
13912 #+END_SRC
13914 #+RESULTS:
13915 | 2 | b |
13916 | 3 | c |
13917 | 4 | d |
13918 @end example
13920 Additionally, an empty index, or the single character @code{*}, are both
13921 interpreted to mean the entire range and as such are equivalent to
13922 @code{0:-1}, as shown in the following example in which the entire first
13923 column is referenced.
13925 @example
13926 #+NAME: example-table
13927 | 1 | a |
13928 | 2 | b |
13929 | 3 | c |
13930 | 4 | d |
13932 #+BEGIN_SRC emacs-lisp :var data=example-table[,0]
13933   data
13934 #+END_SRC
13936 #+RESULTS:
13937 | 1 | 2 | 3 | 4 |
13938 @end example
13940 It is possible to index into the results of code blocks as well as tables.
13941 Any number of dimensions can be indexed.  Dimensions are separated from one
13942 another by commas, as shown in the following example.
13944 @example
13945 #+NAME: 3D
13946 #+BEGIN_SRC emacs-lisp
13947   '(((1  2  3)  (4  5  6)  (7  8  9))
13948     ((10 11 12) (13 14 15) (16 17 18))
13949     ((19 20 21) (22 23 24) (25 26 27)))
13950 #+END_SRC
13952 #+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
13953   data
13954 #+END_SRC
13956 #+RESULTS:
13957 | 11 | 14 | 17 |
13958 @end example
13960 @subsubheading Emacs Lisp evaluation of variables
13962 Emacs lisp code can be used to initialize variable values.  When a variable
13963 value starts with @code{(}, @code{[}, @code{'} or @code{`} it will be
13964 evaluated as Emacs Lisp and the result of the evaluation will be assigned as
13965 the variable value.  The following example demonstrates use of this
13966 evaluation to reliably pass the file-name of the Org mode buffer to a code
13967 block---note that evaluation of header arguments is guaranteed to take place
13968 in the original Org mode file, while there is no such guarantee for
13969 evaluation of the code block body.
13971 @example
13972 #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
13973   wc -w $filename
13974 #+END_SRC
13975 @end example
13977 Note that values read from tables and lists will not be evaluated as
13978 Emacs Lisp, as shown in the following example.
13980 @example
13981 #+NAME: table
13982 | (a b c) |
13984 #+HEADERS: :var data=table[0,0]
13985 #+BEGIN_SRC perl
13986   $data
13987 #+END_SRC
13989 #+RESULTS:
13990 : (a b c)
13991 @end example
13993 @node results, file, var, Specific header arguments
13994 @subsubsection @code{:results}
13996 There are four classes of @code{:results} header argument.  Only one option
13997 per class may be supplied per code block.
13999 @itemize @bullet
14000 @item
14001 @b{collection} header arguments specify how the results should be collected
14002 from the code block
14003 @item
14004 @b{type} header arguments specify what type of result the code block will
14005 return---which has implications for how they will be processed before
14006 insertion into the Org mode buffer
14007 @item
14008 @b{format} header arguments specify what type of result the code block will
14009 return---which has implications for how they will be inserted into the
14010 Org mode buffer
14011 @item
14012 @b{handling} header arguments specify how the results of evaluating the code
14013 block should be handled.
14014 @end itemize
14016 @subsubheading Collection
14017 The following options are mutually exclusive, and specify how the results
14018 should be collected from the code block.
14020 @itemize @bullet
14021 @item @code{value}
14022 This is the default.  The result is the value of the last statement in the
14023 code block.  This header argument places the evaluation in functional
14024 mode.  Note that in some languages, e.g., Python, use of this result type
14025 requires that a @code{return} statement be included in the body of the source
14026 code block.  E.g., @code{:results value}.
14027 @item @code{output}
14028 The result is the collection of everything printed to STDOUT during the
14029 execution of the code block.  This header argument places the
14030 evaluation in scripting mode.  E.g., @code{:results output}.
14031 @end itemize
14033 @subsubheading Type
14035 The following options are mutually exclusive and specify what type of results
14036 the code block will return.  By default, results are inserted as either a
14037 table or scalar depending on their value.
14039 @itemize @bullet
14040 @item @code{table}, @code{vector}
14041 The results should be interpreted as an Org mode table.  If a single value is
14042 returned, it will be converted into a table with one row and one column.
14043 E.g., @code{:results value table}.
14044 @item @code{list}
14045 The results should be interpreted as an Org mode list.  If a single scalar
14046 value is returned it will be converted into a list with only one element.
14047 @item @code{scalar}, @code{verbatim}
14048 The results should be interpreted literally---they will not be
14049 converted into a table.  The results will be inserted into the Org mode
14050 buffer as quoted text.  E.g., @code{:results value verbatim}.
14051 @item @code{file}
14052 The results will be interpreted as the path to a file, and will be inserted
14053 into the Org mode buffer as a file link.  E.g., @code{:results value file}.
14054 @end itemize
14056 @subsubheading Format
14058 The following options are mutually exclusive and specify what type of results
14059 the code block will return.  By default, results are inserted according to the
14060 type as specified above.
14062 @itemize @bullet
14063 @item @code{raw}
14064 The results are interpreted as raw Org mode code and are inserted directly
14065 into the buffer.  If the results look like a table they will be aligned as
14066 such by Org mode.  E.g., @code{:results value raw}.
14067 @item @code{org}
14068 The results are will be enclosed in a @code{BEGIN_SRC org} block.
14069 They are not comma-escaped by default but they will be if you hit @kbd{TAB}
14070 in the block and/or if you export the file.  E.g., @code{:results value org}.
14071 @item @code{html}
14072 Results are assumed to be HTML and will be enclosed in a @code{BEGIN_HTML}
14073 block.  E.g., @code{:results value html}.
14074 @item @code{latex}
14075 Results assumed to be @LaTeX{} and are enclosed in a @code{BEGIN_LaTeX} block.
14076 E.g., @code{:results value latex}.
14077 @item @code{code}
14078 Result are assumed to be parsable code and are enclosed in a code block.
14079 E.g., @code{:results value code}.
14080 @item @code{pp}
14081 The result is converted to pretty-printed code and is enclosed in a code
14082 block.  This option currently supports Emacs Lisp, Python, and Ruby.  E.g.,
14083 @code{:results value pp}.
14084 @item @code{drawer}
14085 The result is wrapped in a RESULTS drawer.  This can be useful for
14086 inserting @code{raw} or @code{org} syntax results in such a way that their
14087 extent is known and they can be automatically removed or replaced.
14088 @end itemize
14090 @subsubheading Handling
14091 The following results options indicate what happens with the
14092 results once they are collected.
14094 @itemize @bullet
14095 @item @code{silent}
14096 The results will be echoed in the minibuffer but will not be inserted into
14097 the Org mode buffer.  E.g., @code{:results output silent}.
14098 @item @code{replace}
14099 The default value.  Any existing results will be removed, and the new results
14100 will be inserted into the Org mode buffer in their place.  E.g.,
14101 @code{:results output replace}.
14102 @item @code{append}
14103 If there are pre-existing results of the code block then the new results will
14104 be appended to the existing results.  Otherwise the new results will be
14105 inserted as with @code{replace}.
14106 @item @code{prepend}
14107 If there are pre-existing results of the code block then the new results will
14108 be prepended to the existing results.  Otherwise the new results will be
14109 inserted as with @code{replace}.
14110 @end itemize
14112 @node file, file-desc, results, Specific header arguments
14113 @subsubsection @code{:file}
14115 The header argument @code{:file} is used to specify an external file in which
14116 to save code block results.  After code block evaluation an Org mode style
14117 @code{[[file:]]} link (see @ref{Link format}) to the file will be inserted
14118 into the Org mode buffer.  Some languages including R, gnuplot, dot, and
14119 ditaa provide special handling of the @code{:file} header argument
14120 automatically wrapping the code block body in the boilerplate code required
14121 to save output to the specified file.  This is often useful for saving
14122 graphical output of a code block to the specified file.
14124 The argument to @code{:file} should be either a string specifying the path to
14125 a file, or a list of two strings in which case the first element of the list
14126 should be the path to a file and the second a description for the link.
14128 @node file-desc, dir, file, Specific header arguments
14129 @subsubsection @code{:file-desc}
14131 The value of the @code{:file-desc} header argument is used to provide a
14132 description for file code block results which are inserted as Org mode links
14133 (see @ref{Link format}).  If the @code{:file-desc} header argument is given
14134 with no value the link path will be placed in both the ``link'' and the
14135 ``description'' portion of the Org mode link.
14137 @node dir, exports, file-desc, Specific header arguments
14138 @subsubsection @code{:dir} and remote execution
14140 While the @code{:file} header argument can be used to specify the path to the
14141 output file, @code{:dir} specifies the default directory during code block
14142 execution.  If it is absent, then the directory associated with the current
14143 buffer is used.  In other words, supplying @code{:dir path} temporarily has
14144 the same effect as changing the current directory with @kbd{M-x cd path RET}, and
14145 then not supplying @code{:dir}.  Under the surface, @code{:dir} simply sets
14146 the value of the Emacs variable @code{default-directory}.
14148 When using @code{:dir}, you should supply a relative path for file output
14149 (e.g., @code{:file myfile.jpg} or @code{:file results/myfile.jpg}) in which
14150 case that path will be interpreted relative to the default directory.
14152 In other words, if you want your plot to go into a folder called @file{Work}
14153 in your home directory, you could use
14155 @example
14156 #+BEGIN_SRC R :file myplot.png :dir ~/Work
14157 matplot(matrix(rnorm(100), 10), type="l")
14158 #+END_SRC
14159 @end example
14161 @subsubheading Remote execution
14162 A directory on a remote machine can be specified using tramp file syntax, in
14163 which case the code will be evaluated on the remote machine.  An example is
14165 @example
14166 #+BEGIN_SRC R :file plot.png :dir /dand@@yakuba.princeton.edu:
14167 plot(1:10, main=system("hostname", intern=TRUE))
14168 #+END_SRC
14169 @end example
14171 Text results will be returned to the local Org mode buffer as usual, and file
14172 output will be created on the remote machine with relative paths interpreted
14173 relative to the remote directory.  An Org mode link to the remote file will be
14174 created.
14176 So, in the above example a plot will be created on the remote machine,
14177 and a link of the following form will be inserted in the org buffer:
14179 @example
14180 [[file:/scp:dand@@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
14181 @end example
14183 Most of this functionality follows immediately from the fact that @code{:dir}
14184 sets the value of the Emacs variable @code{default-directory}, thanks to
14185 tramp.  Those using XEmacs, or GNU Emacs prior to version 23 may need to
14186 install tramp separately in order for these features to work correctly.
14188 @subsubheading Further points
14190 @itemize @bullet
14191 @item
14192 If @code{:dir} is used in conjunction with @code{:session}, although it will
14193 determine the starting directory for a new session as expected, no attempt is
14194 currently made to alter the directory associated with an existing session.
14195 @item
14196 @code{:dir} should typically not be used to create files during export with
14197 @code{:exports results} or @code{:exports both}.  The reason is that, in order
14198 to retain portability of exported material between machines, during export
14199 links inserted into the buffer will @emph{not} be expanded against @code{default
14200 directory}.  Therefore, if @code{default-directory} is altered using
14201 @code{:dir}, it is probable that the file will be created in a location to
14202 which the link does not point.
14203 @end itemize
14205 @node exports, tangle, dir, Specific header arguments
14206 @subsubsection @code{:exports}
14208 The @code{:exports} header argument specifies what should be included in HTML
14209 or @LaTeX{} exports of the Org mode file.
14211 @itemize @bullet
14212 @item @code{code}
14213 The default.  The body of code is included into the exported file.  E.g.,
14214 @code{:exports code}.
14215 @item @code{results}
14216 The result of evaluating the code is included in the exported file.  E.g.,
14217 @code{:exports results}.
14218 @item @code{both}
14219 Both the code and results are included in the exported file.  E.g.,
14220 @code{:exports both}.
14221 @item @code{none}
14222 Nothing is included in the exported file.  E.g., @code{:exports none}.
14223 @end itemize
14225 @node tangle, mkdirp, exports, Specific header arguments
14226 @subsubsection @code{:tangle}
14228 The @code{:tangle} header argument specifies whether or not the code
14229 block should be included in tangled extraction of source code files.
14231 @itemize @bullet
14232 @item @code{tangle}
14233 The code block is exported to a source code file named after the full path
14234 (including the directory) and file name (w/o extension) of the Org mode file.
14235 E.g., @code{:tangle yes}.
14236 @item @code{no}
14237 The default.  The code block is not exported to a source code file.
14238 E.g., @code{:tangle no}.
14239 @item other
14240 Any other string passed to the @code{:tangle} header argument is interpreted
14241 as a path (directory and file name relative to the directory of the Org mode
14242 file) to which the block will be exported.  E.g., @code{:tangle path}.
14243 @end itemize
14245 @node mkdirp, comments, tangle, Specific header arguments
14246 @subsubsection @code{:mkdirp}
14248 The @code{:mkdirp} header argument can be used to create parent directories
14249 of tangled files when missing.  This can be set to @code{yes} to enable
14250 directory creation or to @code{no} to inhibit directory creation.
14252 @node comments, padline, mkdirp, Specific header arguments
14253 @subsubsection @code{:comments}
14254 By default code blocks are tangled to source-code files without any insertion
14255 of comments beyond those which may already exist in the body of the code
14256 block.  The @code{:comments} header argument can be set as follows to control
14257 the insertion of extra comments into the tangled code file.
14259 @itemize @bullet
14260 @item @code{no}
14261 The default.  No extra comments are inserted during tangling.
14262 @item @code{link}
14263 The code block is wrapped in comments which contain pointers back to the
14264 original Org file from which the code was tangled.
14265 @item @code{yes}
14266 A synonym for ``link'' to maintain backwards compatibility.
14267 @item @code{org}
14268 Include text from the Org mode file as a comment.
14269 The text is picked from the leading context of the tangled code and is
14270 limited by the nearest headline or source block as the case may be.
14271 @item @code{both}
14272 Turns on both the ``link'' and ``org'' comment options.
14273 @item @code{noweb}
14274 Turns on the ``link'' comment option, and additionally wraps expanded noweb
14275 references in the code block body in link comments.
14276 @end itemize
14278 @node padline, no-expand, comments, Specific header arguments
14279 @subsubsection @code{:padline}
14280 Control in insertion of padding lines around code block bodies in tangled
14281 code files.  The default value is @code{yes} which results in insertion of
14282 newlines before and after each tangled code block.  The following arguments
14283 are accepted.
14285 @itemize @bullet
14286 @item @code{yes}
14287 Insert newlines before and after each code block body in tangled code files.
14288 @item @code{no}
14289 Do not insert any newline padding in tangled output.
14290 @end itemize
14292 @node no-expand, session, padline, Specific header arguments
14293 @subsubsection @code{:no-expand}
14295 By default, code blocks are expanded with @code{org-babel-expand-src-block}
14296 during tangling.  This has the effect of assigning values to variables
14297 specified with @code{:var} (see @ref{var}), and of replacing ``noweb''
14298 references (see @ref{Noweb reference syntax}) with their targets.  The
14299 @code{:no-expand} header argument can be used to turn off this behavior.
14301 @node session, noweb, no-expand, Specific header arguments
14302 @subsubsection @code{:session}
14304 The @code{:session} header argument starts a session for an interpreted
14305 language where state is preserved.
14307 By default, a session is not started.
14309 A string passed to the @code{:session} header argument will give the session
14310 a name.  This makes it possible to run concurrent sessions for each
14311 interpreted language.
14313 @node noweb, noweb-ref, session, Specific header arguments
14314 @subsubsection @code{:noweb}
14316 The @code{:noweb} header argument controls expansion of ``noweb'' syntax
14317 references (see @ref{Noweb reference syntax}) when the code block is
14318 evaluated, tangled, or exported.  The @code{:noweb} header argument can have
14319 one of the five values: @code{no}, @code{yes}, @code{tangle}, or
14320 @code{no-export} @code{strip-export}.
14322 @itemize @bullet
14323 @item @code{no}
14324 The default.  ``Noweb'' syntax references in the body of the code block will
14325 not be expanded before the code block is evaluated, tangled or exported.
14326 @item @code{yes}
14327 ``Noweb'' syntax references in the body of the code block will be
14328 expanded before the code block is evaluated, tangled or exported.
14329 @item @code{tangle}
14330 ``Noweb'' syntax references in the body of the code block will be expanded
14331 before the code block is tangled.  However, ``noweb'' syntax references will
14332 not be expanded when the code block is evaluated or exported.
14333 @item @code{no-export}
14334 ``Noweb'' syntax references in the body of the code block will be expanded
14335 before the block is evaluated or tangled.  However, ``noweb'' syntax
14336 references will not be expanded when the code block is exported.
14337 @item @code{strip-export}
14338 ``Noweb'' syntax references in the body of the code block will be expanded
14339 before the block is evaluated or tangled.  However, ``noweb'' syntax
14340 references will not be removed when the code block is exported.
14341 @item @code{eval}
14342 ``Noweb'' syntax references in the body of the code block will only be
14343 expanded before the block is evaluated.
14344 @end itemize
14346 @subsubheading Noweb prefix lines
14347 Noweb insertions are now placed behind the line prefix of the
14348 @code{<<reference>>}.
14349 This behavior is illustrated in the following example.  Because the
14350 @code{<<example>>} noweb reference appears behind the SQL comment syntax,
14351 each line of the expanded noweb reference will be commented.
14353 This code block:
14355 @example
14356 -- <<example>>
14357 @end example
14359 expands to:
14361 @example
14362 -- this is the
14363 -- multi-line body of example
14364 @end example
14366 Note that noweb replacement text that does not contain any newlines will not
14367 be affected by this change, so it is still possible to use inline noweb
14368 references.
14370 @node noweb-ref, noweb-sep, noweb, Specific header arguments
14371 @subsubsection @code{:noweb-ref}
14372 When expanding ``noweb'' style references the bodies of all code block with
14373 @emph{either} a block name matching the reference name @emph{or} a
14374 @code{:noweb-ref} header argument matching the reference name will be
14375 concatenated together to form the replacement text.
14377 By setting this header argument at the sub-tree or file level, simple code
14378 block concatenation may be achieved.  For example, when tangling the
14379 following Org mode file, the bodies of code blocks will be concatenated into
14380 the resulting pure code file@footnote{(The example needs property inheritance
14381 to be turned on for the @code{noweb-ref} property, see @ref{Property
14382 inheritance}).}.
14384 @example
14385  #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
14386    <<fullest-disk>>
14387  #+END_SRC
14388  * the mount point of the fullest disk
14389    :PROPERTIES:
14390    :noweb-ref: fullest-disk
14391    :END:
14393  ** query all mounted disks
14394  #+BEGIN_SRC sh
14395    df \
14396  #+END_SRC
14398  ** strip the header row
14399  #+BEGIN_SRC sh
14400    |sed '1d' \
14401  #+END_SRC
14403  ** sort by the percent full
14404  #+BEGIN_SRC sh
14405    |awk '@{print $5 " " $6@}'|sort -n |tail -1 \
14406  #+END_SRC
14408  ** extract the mount point
14409  #+BEGIN_SRC sh
14410    |awk '@{print $2@}'
14411  #+END_SRC
14412 @end example
14414 The @code{:noweb-sep} (see @ref{noweb-sep}) header argument holds the string
14415 used to separate accumulate noweb references like those above.  By default a
14416 newline is used.
14418 @node noweb-sep, cache, noweb-ref, Specific header arguments
14419 @subsubsection @code{:noweb-sep}
14421 The @code{:noweb-sep} header argument holds the string used to separate
14422 accumulate noweb references (see @ref{noweb-ref}).  By default a newline is
14423 used.
14425 @node cache, sep, noweb-sep, Specific header arguments
14426 @subsubsection @code{:cache}
14428 The @code{:cache} header argument controls the use of in-buffer caching of
14429 the results of evaluating code blocks.  It can be used to avoid re-evaluating
14430 unchanged code blocks.  Note that the @code{:cache} header argument will not
14431 attempt to cache results when the @code{:session} header argument is used,
14432 because the results of the code block execution may be stored in the session
14433 outside of the Org mode buffer.  The @code{:cache} header argument can have
14434 one of two values: @code{yes} or @code{no}.
14436 @itemize @bullet
14437 @item @code{no}
14438 The default.  No caching takes place, and the code block will be evaluated
14439 every time it is called.
14440 @item @code{yes}
14441 Every time the code block is run a SHA1 hash of the code and arguments
14442 passed to the block will be generated.  This hash is packed into the
14443 @code{#+RESULTS:} line and will be checked on subsequent
14444 executions of the code block.  If the code block has not
14445 changed since the last time it was evaluated, it will not be re-evaluated.
14446 @end itemize
14448 Code block caches notice if the value of a variable argument
14449 to the code block has changed.  If this is the case, the cache is
14450 invalidated and the code block is re-run.  In the following example,
14451 @code{caller} will not be re-run unless the results of @code{random} have
14452 changed since it was last run.
14454 @example
14455  #+NAME: random
14456  #+BEGIN_SRC R :cache yes
14457  runif(1)
14458  #+END_SRC
14460  #+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
14461  0.4659510825295
14463  #+NAME: caller
14464  #+BEGIN_SRC emacs-lisp :var x=random :cache yes
14466  #+END_SRC
14468  #+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
14469  0.254227238707244
14470 @end example
14472 @node sep, hlines, cache, Specific header arguments
14473 @subsubsection @code{:sep}
14475 The @code{:sep} header argument can be used to control the delimiter used
14476 when writing tabular results out to files external to Org mode.  This is used
14477 either when opening tabular results of a code block by calling the
14478 @code{org-open-at-point} function bound to @kbd{C-c C-o} on the code block,
14479 or when writing code block results to an external file (see @ref{file})
14480 header argument.
14482 By default, when @code{:sep} is not specified output tables are tab
14483 delimited.
14485 @node hlines, colnames, sep, Specific header arguments
14486 @subsubsection @code{:hlines}
14488 Tables are frequently represented with one or more horizontal lines, or
14489 hlines.  The @code{:hlines} argument to a code block accepts the
14490 values @code{yes} or @code{no}, with a default value of @code{no}.
14492 @itemize @bullet
14493 @item @code{no}
14494 Strips horizontal lines from the input table.  In most languages this is the
14495 desired effect because an @code{hline} symbol is interpreted as an unbound
14496 variable and raises an error.  Setting @code{:hlines no} or relying on the
14497 default value yields the following results.
14499 @example
14500 #+NAME: many-cols
14501 | a | b | c |
14502 |---+---+---|
14503 | d | e | f |
14504 |---+---+---|
14505 | g | h | i |
14507 #+NAME: echo-table
14508 #+BEGIN_SRC python :var tab=many-cols
14509   return tab
14510 #+END_SRC
14512 #+RESULTS: echo-table
14513 | a | b | c |
14514 | d | e | f |
14515 | g | h | i |
14516 @end example
14518 @item @code{yes}
14519 Leaves hlines in the table.  Setting @code{:hlines yes} has this effect.
14521 @example
14522 #+NAME: many-cols
14523 | a | b | c |
14524 |---+---+---|
14525 | d | e | f |
14526 |---+---+---|
14527 | g | h | i |
14529 #+NAME: echo-table
14530 #+BEGIN_SRC python :var tab=many-cols :hlines yes
14531   return tab
14532 #+END_SRC
14534 #+RESULTS: echo-table
14535 | a | b | c |
14536 |---+---+---|
14537 | d | e | f |
14538 |---+---+---|
14539 | g | h | i |
14540 @end example
14541 @end itemize
14543 @node colnames, rownames, hlines, Specific header arguments
14544 @subsubsection @code{:colnames}
14546 The @code{:colnames} header argument accepts the values @code{yes},
14547 @code{no}, or @code{nil} for unassigned.  The default value is @code{nil}.
14548 Note that the behavior of the @code{:colnames} header argument may differ
14549 across languages.
14551 @itemize @bullet
14552 @item @code{nil}
14553 If an input table looks like it has column names
14554 (because its second row is an hline), then the column
14555 names will be removed from the table before
14556 processing, then reapplied to the results.
14558 @example
14559 #+NAME: less-cols
14560 | a |
14561 |---|
14562 | b |
14563 | c |
14565 #+NAME: echo-table-again
14566 #+BEGIN_SRC python :var tab=less-cols
14567   return [[val + '*' for val in row] for row in tab]
14568 #+END_SRC
14570 #+RESULTS: echo-table-again
14571 | a  |
14572 |----|
14573 | b* |
14574 | c* |
14575 @end example
14577 Please note that column names are not removed before the table is indexed
14578 using variable indexing @xref{var, Indexable variable values}.
14580 @item @code{no}
14581 No column name pre-processing takes place
14583 @item @code{yes}
14584 Column names are removed and reapplied as with @code{nil} even if the table
14585 does not ``look like'' it has column names (i.e., the second row is not an
14586 hline)
14587 @end itemize
14589 @node rownames, shebang, colnames, Specific header arguments
14590 @subsubsection @code{:rownames}
14592 The @code{:rownames} header argument can take on the values @code{yes} or
14593 @code{no}, with a default value of @code{no}.  Note that Emacs Lisp code
14594 blocks ignore the @code{:rownames} header argument entirely given the ease
14595 with which tables with row names may be handled directly in Emacs Lisp.
14597 @itemize @bullet
14598 @item @code{no}
14599 No row name pre-processing will take place.
14601 @item @code{yes}
14602 The first column of the table is removed from the table before processing,
14603 and is then reapplied to the results.
14605 @example
14606 #+NAME: with-rownames
14607 | one | 1 | 2 | 3 | 4 |  5 |
14608 | two | 6 | 7 | 8 | 9 | 10 |
14610 #+NAME: echo-table-once-again
14611 #+BEGIN_SRC python :var tab=with-rownames :rownames yes
14612   return [[val + 10 for val in row] for row in tab]
14613 #+END_SRC
14615 #+RESULTS: echo-table-once-again
14616 | one | 11 | 12 | 13 | 14 | 15 |
14617 | two | 16 | 17 | 18 | 19 | 20 |
14618 @end example
14620 Please note that row names are not removed before the table is indexed using
14621 variable indexing @xref{var, Indexable variable values}.
14623 @end itemize
14625 @node shebang, eval, rownames, Specific header arguments
14626 @subsubsection @code{:shebang}
14628 Setting the @code{:shebang} header argument to a string value
14629 (e.g., @code{:shebang "#!/bin/bash"}) causes the string to be inserted as the
14630 first line of any tangled file holding the code block, and the file
14631 permissions of the tangled file are set to make it executable.
14633 @node eval, wrap, shebang, Specific header arguments
14634 @subsubsection @code{:eval}
14635 The @code{:eval} header argument can be used to limit the evaluation of
14636 specific code blocks.  The @code{:eval} header argument can be useful for
14637 protecting against the evaluation of dangerous code blocks or to ensure that
14638 evaluation will require a query regardless of the value of the
14639 @code{org-confirm-babel-evaluate} variable.  The possible values of
14640 @code{:eval} and their effects are shown below.
14642 @table @code
14643 @item never or no
14644 The code block will not be evaluated under any circumstances.
14645 @item query
14646 Evaluation of the code block will require a query.
14647 @item never-export or no-export
14648 The code block will not be evaluated during export but may still be called
14649 interactively.
14650 @item query-export
14651 Evaluation of the code block during export will require a query.
14652 @end table
14654 If this header argument is not set then evaluation is determined by the value
14655 of the @code{org-confirm-babel-evaluate} variable see @ref{Code evaluation
14656 security}.
14658 @node wrap, post, eval, Specific header arguments
14659 @subsubsection @code{:wrap}
14660 The @code{:wrap} header argument is used to mark the results of source block
14661 evaluation.  The header argument can be passed a string that will be appended
14662 to @code{#+BEGIN_} and @code{#+END_}, which will then be used to wrap the
14663 results.  If not string is specified then the results will be wrapped in a
14664 @code{#+BEGIN/END_RESULTS} block.
14666 @node post,  , wrap, Specific header arguments
14667 @subsubsection @code{:post}
14668 The @code{:post} header argument is used to post-process the results of a
14669 code block execution.  When a post argument is given, the results of the code
14670 block will temporarily be bound to the @code{*this*} variable.  This variable
14671 may then be included in header argument forms such as those used in @ref{var}
14672 header argument specifications allowing passing of results to other code
14673 blocks, or direct execution via Emacs Lisp.
14675 The following example illustrates the usage of the @code{:post} header
14676 argument.
14678 @example
14679 #+name: attr_wrap
14680 #+begin_src sh :var data="" :var width="\\textwidth" :results output
14681   echo "#+ATTR_LATEX :width $width"
14682   echo "$data"
14683 #+end_src
14685 #+header: :file /tmp/it.png
14686 #+begin_src dot :post attr_wrap(width="5cm", data=*this*) :results drawer
14687   digraph@{
14688           a -> b;
14689           b -> c;
14690           c -> a;
14691   @}
14692 #+end_src
14694 #+RESULTS:
14695 :RESULTS:
14696 #+ATTR_LATEX :width 5cm
14697 [[file:/tmp/it.png]]
14698 :END:
14699 @end example
14701 @node Results of evaluation, Noweb reference syntax, Header arguments, Working With Source Code
14702 @section Results of evaluation
14703 @cindex code block, results of evaluation
14704 @cindex source code, results of evaluation
14706 The way in which results are handled depends on whether a session is invoked,
14707 as well as on whether @code{:results value} or @code{:results output} is
14708 used.  The following table shows the table possibilities.  For a full listing
14709 of the possible results header arguments see @ref{results}.
14711 @multitable @columnfractions 0.26 0.33 0.41
14712 @item @tab @b{Non-session} @tab @b{Session}
14713 @item @code{:results value} @tab value of last expression @tab value of last expression
14714 @item @code{:results output} @tab contents of STDOUT @tab concatenation of interpreter output
14715 @end multitable
14717 Note: With @code{:results value}, the result in both @code{:session} and
14718 non-session is returned to Org mode as a table (a one- or two-dimensional
14719 vector of strings or numbers) when appropriate.
14721 @subsection Non-session
14722 @subsubsection @code{:results value}
14723 This is the default.  Internally, the value is obtained by wrapping the code
14724 in a function definition in the external language, and evaluating that
14725 function.  Therefore, code should be written as if it were the body of such a
14726 function.  In particular, note that Python does not automatically return a
14727 value from a function unless a @code{return} statement is present, and so a
14728 @samp{return} statement will usually be required in Python.
14730 This is the only one of the four evaluation contexts in which the code is
14731 automatically wrapped in a function definition.
14733 @subsubsection @code{:results output}
14734 The code is passed to the interpreter as an external process, and the
14735 contents of the standard output stream are returned as text.  (In certain
14736 languages this also contains the error output stream; this is an area for
14737 future work.)
14739 @subsection Session
14740 @subsubsection @code{:results value}
14741 The code is passed to an interpreter running as an interactive Emacs inferior
14742 process.  Only languages which provide tools for interactive evaluation of
14743 code have session support, so some language (e.g., C and ditaa) do not
14744 support the @code{:session} header argument, and in other languages (e.g.,
14745 Python and Haskell) which have limitations on the code which may be entered
14746 into interactive sessions, those limitations apply to the code in code blocks
14747 using the @code{:session} header argument as well.
14749 Unless the @code{:results output} option is supplied (see below) the result
14750 returned is the result of the last evaluation performed by the
14751 interpreter.  (This is obtained in a language-specific manner: the value of
14752 the variable @code{_} in Python and Ruby, and the value of @code{.Last.value}
14753 in R).
14755 @subsubsection @code{:results output}
14756 The code is passed to the interpreter running as an interactive Emacs
14757 inferior process.  The result returned is the concatenation of the sequence of
14758 (text) output from the interactive interpreter.  Notice that this is not
14759 necessarily the same as what would be sent to @code{STDOUT} if the same code
14760 were passed to a non-interactive interpreter running as an external
14761 process.  For example, compare the following two blocks:
14763 @example
14764 #+BEGIN_SRC python :results output
14765  print "hello"
14767  print "bye"
14768 #+END_SRC
14770 #+RESULTS:
14771 : hello
14772 : bye
14773 @end example
14775 In non-session mode, the `2' is not printed and does not appear.
14777 @example
14778 #+BEGIN_SRC python :results output :session
14779  print "hello"
14781  print "bye"
14782 #+END_SRC
14784 #+RESULTS:
14785 : hello
14786 : 2
14787 : bye
14788 @end example
14790 But in @code{:session} mode, the interactive interpreter receives input `2'
14791 and prints out its value, `2'.  (Indeed, the other print statements are
14792 unnecessary here).
14794 @node Noweb reference syntax, Key bindings and useful functions, Results of evaluation, Working With Source Code
14795 @section Noweb reference syntax
14796 @cindex code block, noweb reference
14797 @cindex syntax, noweb
14798 @cindex source code, noweb reference
14800 The ``noweb'' (see @uref{http://www.cs.tufts.edu/~nr/noweb/}) Literate
14801 Programming system allows named blocks of code to be referenced by using the
14802 familiar Noweb syntax:
14804 @example
14805 <<code-block-name>>
14806 @end example
14808 When a code block is tangled or evaluated, whether or not ``noweb''
14809 references are expanded depends upon the value of the @code{:noweb} header
14810 argument.  If @code{:noweb yes}, then a Noweb reference is expanded before
14811 evaluation.  If @code{:noweb no}, the default, then the reference is not
14812 expanded before evaluation.  See the @ref{noweb-ref} header argument for
14813 a more flexible way to resolve noweb references.
14815 It is possible to include the @emph{results} of a code block rather than the
14816 body.  This is done by appending parenthesis to the code block name which may
14817 optionally contain arguments to the code block as shown below.
14819 @example
14820 <<code-block-name(optional arguments)>>
14821 @end example
14823 Note: the default value, @code{:noweb no}, was chosen to ensure that
14824 correct code is not broken in a language, such as Ruby, where
14825 @code{<<arg>>} is a syntactically valid construct.  If @code{<<arg>>} is not
14826 syntactically valid in languages that you use, then please consider setting
14827 the default value.
14829 Note: if noweb tangling is slow in large Org mode files consider setting the
14830 @code{*org-babel-use-quick-and-dirty-noweb-expansion*} variable to true.
14831 This will result in faster noweb reference resolution at the expense of not
14832 correctly resolving inherited values of the @code{:noweb-ref} header
14833 argument.
14835 @node Key bindings and useful functions, Batch execution, Noweb reference syntax, Working With Source Code
14836 @section Key bindings and useful functions
14837 @cindex code block, key bindings
14839 Many common Org mode key sequences are re-bound depending on
14840 the context.
14842 Within a code block, the following key bindings
14843 are active:
14845 @multitable @columnfractions 0.25 0.75
14846 @kindex C-c C-c
14847 @item @kbd{C-c C-c} @tab @code{org-babel-execute-src-block}
14848 @kindex C-c C-o
14849 @item @kbd{C-c C-o} @tab @code{org-babel-open-src-block-result}
14850 @kindex C-up
14851 @item @kbd{C-@key{up}}    @tab @code{org-babel-load-in-session}
14852 @kindex M-down
14853 @item @kbd{M-@key{down}}  @tab @code{org-babel-pop-to-session}
14854 @end multitable
14856 In an Org mode buffer, the following key bindings are active:
14858 @multitable @columnfractions 0.45 0.55
14859 @kindex C-c C-v p
14860 @kindex C-c C-v C-p
14861 @item @kbd{C-c C-v p} @ @ @r{or} @ @ @kbd{C-c C-v C-p} @tab @code{org-babel-previous-src-block}
14862 @kindex C-c C-v n
14863 @kindex C-c C-v C-n
14864 @item @kbd{C-c C-v n} @ @ @r{or} @ @ @kbd{C-c C-v C-n} @tab @code{org-babel-next-src-block}
14865 @kindex C-c C-v e
14866 @kindex C-c C-v C-e
14867 @item @kbd{C-c C-v e} @ @ @r{or} @ @ @kbd{C-c C-v C-e} @tab @code{org-babel-execute-maybe}
14868 @kindex C-c C-v o
14869 @kindex C-c C-v C-o
14870 @item @kbd{C-c C-v o} @ @ @r{or} @ @ @kbd{C-c C-v C-o} @tab @code{org-babel-open-src-block-result}
14871 @kindex C-c C-v v
14872 @kindex C-c C-v C-v
14873 @item @kbd{C-c C-v v} @ @ @r{or} @ @ @kbd{C-c C-v C-v} @tab @code{org-babel-expand-src-block}
14874 @kindex C-c C-v u
14875 @kindex C-c C-v C-u
14876 @item @kbd{C-c C-v u} @ @ @r{or} @ @ @kbd{C-c C-v C-u} @tab @code{org-babel-goto-src-block-head}
14877 @kindex C-c C-v g
14878 @kindex C-c C-v C-g
14879 @item @kbd{C-c C-v g} @ @ @r{or} @ @ @kbd{C-c C-v C-g} @tab @code{org-babel-goto-named-src-block}
14880 @kindex C-c C-v r
14881 @kindex C-c C-v C-r
14882 @item @kbd{C-c C-v r} @ @ @r{or} @ @ @kbd{C-c C-v C-r} @tab @code{org-babel-goto-named-result}
14883 @kindex C-c C-v b
14884 @kindex C-c C-v C-b
14885 @item @kbd{C-c C-v b} @ @ @r{or} @ @ @kbd{C-c C-v C-b} @tab @code{org-babel-execute-buffer}
14886 @kindex C-c C-v s
14887 @kindex C-c C-v C-s
14888 @item @kbd{C-c C-v s} @ @ @r{or} @ @ @kbd{C-c C-v C-s} @tab @code{org-babel-execute-subtree}
14889 @kindex C-c C-v d
14890 @kindex C-c C-v C-d
14891 @item @kbd{C-c C-v d} @ @ @r{or} @ @ @kbd{C-c C-v C-d} @tab @code{org-babel-demarcate-block}
14892 @kindex C-c C-v t
14893 @kindex C-c C-v C-t
14894 @item @kbd{C-c C-v t} @ @ @r{or} @ @ @kbd{C-c C-v C-t} @tab @code{org-babel-tangle}
14895 @kindex C-c C-v f
14896 @kindex C-c C-v C-f
14897 @item @kbd{C-c C-v f} @ @ @r{or} @ @ @kbd{C-c C-v C-f} @tab @code{org-babel-tangle-file}
14898 @kindex C-c C-v c
14899 @kindex C-c C-v C-c
14900 @item @kbd{C-c C-v c} @ @ @r{or} @ @ @kbd{C-c C-v C-c} @tab @code{org-babel-check-src-block}
14901 @kindex C-c C-v j
14902 @kindex C-c C-v C-j
14903 @item @kbd{C-c C-v j} @ @ @r{or} @ @ @kbd{C-c C-v C-j} @tab @code{org-babel-insert-header-arg}
14904 @kindex C-c C-v l
14905 @kindex C-c C-v C-l
14906 @item @kbd{C-c C-v l} @ @ @r{or} @ @ @kbd{C-c C-v C-l} @tab @code{org-babel-load-in-session}
14907 @kindex C-c C-v i
14908 @kindex C-c C-v C-i
14909 @item @kbd{C-c C-v i} @ @ @r{or} @ @ @kbd{C-c C-v C-i} @tab @code{org-babel-lob-ingest}
14910 @kindex C-c C-v I
14911 @kindex C-c C-v C-I
14912 @item @kbd{C-c C-v I} @ @ @r{or} @ @ @kbd{C-c C-v C-I} @tab @code{org-babel-view-src-block-info}
14913 @kindex C-c C-v z
14914 @kindex C-c C-v C-z
14915 @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}
14916 @kindex C-c C-v a
14917 @kindex C-c C-v C-a
14918 @item @kbd{C-c C-v a} @ @ @r{or} @ @ @kbd{C-c C-v C-a} @tab @code{org-babel-sha1-hash}
14919 @kindex C-c C-v h
14920 @kindex C-c C-v C-h
14921 @item @kbd{C-c C-v h} @ @ @r{or} @ @ @kbd{C-c C-v C-h} @tab @code{org-babel-describe-bindings}
14922 @kindex C-c C-v x
14923 @kindex C-c C-v C-x
14924 @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}
14925 @end multitable
14927 @c When possible these keybindings were extended to work when the control key is
14928 @c kept pressed, resulting in the following additional keybindings.
14930 @c @multitable @columnfractions 0.25 0.75
14931 @c @item @kbd{C-c C-v C-a} @tab @code{org-babel-sha1-hash}
14932 @c @item @kbd{C-c C-v C-b} @tab @code{org-babel-execute-buffer}
14933 @c @item @kbd{C-c C-v C-f} @tab @code{org-babel-tangle-file}
14934 @c @item @kbd{C-c C-v C-l} @tab @code{org-babel-lob-ingest}
14935 @c @item @kbd{C-c C-v C-p} @tab @code{org-babel-expand-src-block}
14936 @c @item @kbd{C-c C-v C-s} @tab @code{org-babel-execute-subtree}
14937 @c @item @kbd{C-c C-v C-t} @tab @code{org-babel-tangle}
14938 @c @item @kbd{C-c C-v C-z} @tab @code{org-babel-switch-to-session}
14939 @c @end multitable
14941 @node Batch execution,  , Key bindings and useful functions, Working With Source Code
14942 @section Batch execution
14943 @cindex code block, batch execution
14944 @cindex source code, batch execution
14946 It is possible to call functions from the command line.  This shell
14947 script calls @code{org-babel-tangle} on every one of its arguments.
14949 Be sure to adjust the paths to fit your system.
14951 @example
14952 #!/bin/sh
14953 # -*- mode: shell-script -*-
14955 # tangle files with org-mode
14957 DIR=`pwd`
14958 FILES=""
14960 # wrap each argument in the code required to call tangle on it
14961 for i in $@@; do
14962     FILES="$FILES \"$i\""
14963 done
14965 emacs -Q --batch \
14966 --eval "(progn
14967 (add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\"))
14968 (add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\" t))
14969 (require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle)
14970 (mapc (lambda (file)
14971        (find-file (expand-file-name file \"$DIR\"))
14972        (org-babel-tangle)
14973        (kill-buffer)) '($FILES)))" 2>&1 |grep tangled
14974 @end example
14976 @node Miscellaneous, Hacking, Working With Source Code, Top
14977 @chapter Miscellaneous
14979 @menu
14980 * Completion::                  M-TAB knows what you need
14981 * Easy Templates::              Quick insertion of structural elements
14982 * Speed keys::                  Electric commands at the beginning of a headline
14983 * Code evaluation security::    Org mode files evaluate inline code
14984 * Customization::               Adapting Org to your taste
14985 * In-buffer settings::          Overview of the #+KEYWORDS
14986 * The very busy C-c C-c key::   When in doubt, press C-c C-c
14987 * Clean view::                  Getting rid of leading stars in the outline
14988 * TTY keys::                    Using Org on a tty
14989 * Interaction::                 Other Emacs packages
14990 * org-crypt.el::                Encrypting Org files
14991 @end menu
14994 @node Completion, Easy Templates, Miscellaneous, Miscellaneous
14995 @section Completion
14996 @cindex completion, of @TeX{} symbols
14997 @cindex completion, of TODO keywords
14998 @cindex completion, of dictionary words
14999 @cindex completion, of option keywords
15000 @cindex completion, of tags
15001 @cindex completion, of property keys
15002 @cindex completion, of link abbreviations
15003 @cindex @TeX{} symbol completion
15004 @cindex TODO keywords completion
15005 @cindex dictionary word completion
15006 @cindex option keyword completion
15007 @cindex tag completion
15008 @cindex link abbreviations, completion of
15010 Emacs would not be Emacs without completion, and Org mode uses it whenever it
15011 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
15012 some of the completion prompts, you can specify your preference by setting at
15013 most one of the variables @code{org-completion-use-iswitchb}
15014 @code{org-completion-use-ido}.
15016 Org supports in-buffer completion.  This type of completion does
15017 not make use of the minibuffer.  You simply type a few letters into
15018 the buffer and use the key to complete text right there.
15020 @table @kbd
15021 @kindex M-@key{TAB}
15022 @item M-@key{TAB}
15023 Complete word at point
15024 @itemize @bullet
15025 @item
15026 At the beginning of a headline, complete TODO keywords.
15027 @item
15028 After @samp{\}, complete @TeX{} symbols supported by the exporter.
15029 @item
15030 After @samp{*}, complete headlines in the current buffer so that they
15031 can be used in search links like @samp{[[*find this headline]]}.
15032 @item
15033 After @samp{:} in a headline, complete tags.  The list of tags is taken
15034 from the variable @code{org-tag-alist} (possibly set through the
15035 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
15036 dynamically from all tags used in the current buffer.
15037 @item
15038 After @samp{:} and not in a headline, complete property keys.  The list
15039 of keys is constructed dynamically from all keys used in the current
15040 buffer.
15041 @item
15042 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
15043 @item
15044 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
15045 @samp{OPTIONS} which set file-specific options for Org mode.  When the
15046 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
15047 will insert example settings for this keyword.
15048 @item
15049 In the line after @samp{#+STARTUP: }, complete startup keywords,
15050 i.e., valid keys for this line.
15051 @item
15052 Elsewhere, complete dictionary words using Ispell.
15053 @end itemize
15054 @end table
15056 @node Easy Templates, Speed keys, Completion, Miscellaneous
15057 @section Easy Templates
15058 @cindex template insertion
15059 @cindex insertion, of templates
15061 Org mode supports insertion of empty structural elements (like
15062 @code{#+BEGIN_SRC} and @code{#+END_SRC} pairs) with just a few key
15063 strokes.  This is achieved through a native template expansion mechanism.
15064 Note that Emacs has several other template mechanisms which could be used in
15065 a similar way, for example @file{yasnippet}.
15067 To insert a structural element, type a @samp{<}, followed by a template
15068 selector and @kbd{@key{TAB}}.  Completion takes effect only when the above
15069 keystrokes are typed on a line by itself.
15071 The following template selectors are currently supported.
15073 @multitable @columnfractions 0.1 0.9
15074 @item @kbd{s} @tab @code{#+BEGIN_SRC     ... #+END_SRC}
15075 @item @kbd{e} @tab @code{#+BEGIN_EXAMPLE ... #+END_EXAMPLE}
15076 @item @kbd{q} @tab @code{#+BEGIN_QUOTE   ... #+END_QUOTE}
15077 @item @kbd{v} @tab @code{#+BEGIN_VERSE   ... #+END_VERSE}
15078 @item @kbd{c} @tab @code{#+BEGIN_CENTER  ... #+END_CENTER}
15079 @item @kbd{l} @tab @code{#+BEGIN_LaTeX   ... #+END_LaTeX}
15080 @item @kbd{L} @tab @code{#+LaTeX:}
15081 @item @kbd{h} @tab @code{#+BEGIN_HTML    ... #+END_HTML}
15082 @item @kbd{H} @tab @code{#+HTML:}
15083 @item @kbd{a} @tab @code{#+BEGIN_ASCII   ... #+END_ASCII}
15084 @item @kbd{A} @tab @code{#+ASCII:}
15085 @item @kbd{i} @tab @code{#+INDEX:} line
15086 @item @kbd{I} @tab @code{#+INCLUDE:} line
15087 @end multitable
15089 For example, on an empty line, typing "<e" and then pressing TAB, will expand
15090 into a complete EXAMPLE template.
15092 You can install additional templates by customizing the variable
15093 @code{org-structure-template-alist}.  See the docstring of the variable for
15094 additional details.
15096 @node Speed keys, Code evaluation security, Easy Templates, Miscellaneous
15097 @section Speed keys
15098 @cindex speed keys
15099 @vindex org-use-speed-commands
15100 @vindex org-speed-commands-user
15102 Single keys can be made to execute commands when the cursor is at the
15103 beginning of a headline, i.e., before the first star.  Configure the variable
15104 @code{org-use-speed-commands} to activate this feature.  There is a
15105 pre-defined list of commands, and you can add more such commands using the
15106 variable @code{org-speed-commands-user}.  Speed keys do not only speed up
15107 navigation and other commands, but they also provide an alternative way to
15108 execute commands bound to keys that are not or not easily available on a TTY,
15109 or on a small mobile device with a limited keyboard.
15111 To see which commands are available, activate the feature and press @kbd{?}
15112 with the cursor at the beginning of a headline.
15114 @node Code evaluation security, Customization, Speed keys, Miscellaneous
15115 @section Code evaluation and security issues
15117 Org provides tools to work with the code snippets, including evaluating them.
15119 Running code on your machine always comes with a security risk.  Badly
15120 written or malicious code can be executed on purpose or by accident.  Org has
15121 default settings which will only evaluate such code if you give explicit
15122 permission to do so, and as a casual user of these features you should leave
15123 these precautions intact.
15125 For people who regularly work with such code, the confirmation prompts can
15126 become annoying, and you might want to turn them off.  This can be done, but
15127 you must be aware of the risks that are involved.
15129 Code evaluation can happen under the following circumstances:
15131 @table @i
15132 @item Source code blocks
15133 Source code blocks can be evaluated during export, or when pressing @kbd{C-c
15134 C-c} in the block.  The most important thing to realize here is that Org mode
15135 files which contain code snippets are, in a certain sense, like executable
15136 files.  So you should accept them and load them into Emacs only from trusted
15137 sources---just like you would do with a program you install on your computer.
15139 Make sure you know what you are doing before customizing the variables
15140 which take off the default security brakes.
15142 @defopt org-confirm-babel-evaluate
15143 When t (the default), the user is asked before every code block evaluation.
15144 When nil, the user is not asked.  When set to a function, it is called with
15145 two arguments (language and body of the code block) and should return t to
15146 ask and nil not to ask.
15147 @end defopt
15149 For example, here is how to execute "ditaa" code (which is considered safe)
15150 without asking:
15152 @lisp
15153 (defun my-org-confirm-babel-evaluate (lang body)
15154   (not (string= lang "ditaa")))  ; don't ask for ditaa
15155 (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
15156 @end lisp
15158 @item Following @code{shell} and @code{elisp} links
15159 Org has two link types that can directly evaluate code (@pxref{External
15160 links}).  These links can be problematic because the code to be evaluated is
15161 not visible.
15163 @defopt org-confirm-shell-link-function
15164 Function to queries user about shell link execution.
15165 @end defopt
15166 @defopt org-confirm-elisp-link-function
15167 Functions to query user for Emacs Lisp link execution.
15168 @end defopt
15170 @item Formulas in tables
15171 Formulas in tables (@pxref{The spreadsheet}) are code that is evaluated
15172 either by the @i{calc} interpreter, or by the @i{Emacs Lisp} interpreter.
15173 @end table
15175 @node Customization, In-buffer settings, Code evaluation security, Miscellaneous
15176 @section Customization
15177 @cindex customization
15178 @cindex options, for customization
15179 @cindex variables, for customization
15181 There are more than 500 variables that can be used to customize
15182 Org.  For the sake of compactness of the manual, I am not
15183 describing the variables here.  A structured overview of customization
15184 variables is available with @kbd{M-x org-customize RET}.  Or select
15185 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
15186 settings can also be activated on a per-file basis, by putting special
15187 lines into the buffer (@pxref{In-buffer settings}).
15189 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
15190 @section Summary of in-buffer settings
15191 @cindex in-buffer settings
15192 @cindex special keywords
15194 Org mode uses special lines in the buffer to define settings on a
15195 per-file basis.  These lines start with a @samp{#+} followed by a
15196 keyword, a colon, and then individual words defining a setting.  Several
15197 setting words can be in the same line, but you can also have multiple
15198 lines for the keyword.  While these settings are described throughout
15199 the manual, here is a summary.  After changing any of those lines in the
15200 buffer, press @kbd{C-c C-c} with the cursor still in the line to
15201 activate the changes immediately.  Otherwise they become effective only
15202 when the file is visited again in a new Emacs session.
15204 @vindex org-archive-location
15205 @table @kbd
15206 @item #+ARCHIVE: %s_done::
15207 This line sets the archive location for the agenda file.  It applies for
15208 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
15209 of the file.  The first such line also applies to any entries before it.
15210 The corresponding variable is @code{org-archive-location}.
15211 @item #+CATEGORY:
15212 This line sets the category for the agenda file.  The category applies
15213 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
15214 end of the file.  The first such line also applies to any entries before it.
15215 @item #+COLUMNS: %25ITEM .....
15216 @cindex property, COLUMNS
15217 Set the default format for columns view.  This format applies when
15218 columns view is invoked in locations where no @code{COLUMNS} property
15219 applies.
15220 @item #+CONSTANTS: name1=value1 ...
15221 @vindex org-table-formula-constants
15222 @vindex org-table-formula
15223 Set file-local values for constants to be used in table formulas.  This
15224 line sets the local variable @code{org-table-formula-constants-local}.
15225 The global version of this variable is
15226 @code{org-table-formula-constants}.
15227 @item #+FILETAGS: :tag1:tag2:tag3:
15228 Set tags that can be inherited by any entry in the file, including the
15229 top-level entries.
15230 @item #+DRAWERS: NAME1 .....
15231 @vindex org-drawers
15232 Set the file-local set of additional drawers.  The corresponding global
15233 variable is @code{org-drawers}.
15234 @item #+LINK:  linkword replace
15235 @vindex org-link-abbrev-alist
15236 These lines (several are allowed) specify link abbreviations.
15237 @xref{Link abbreviations}.  The corresponding variable is
15238 @code{org-link-abbrev-alist}.
15239 @item #+PRIORITIES: highest lowest default
15240 @vindex org-highest-priority
15241 @vindex org-lowest-priority
15242 @vindex org-default-priority
15243 This line sets the limits and the default for the priorities.  All three
15244 must be either letters A--Z or numbers 0--9.  The highest priority must
15245 have a lower ASCII number than the lowest priority.
15246 @item #+PROPERTY: Property_Name Value
15247 This line sets a default inheritance value for entries in the current
15248 buffer, most useful for specifying the allowed values of a property.
15249 @cindex #+SETUPFILE
15250 @item #+SETUPFILE: file
15251 This line defines a file that holds more in-buffer setup.  Normally this is
15252 entirely ignored.  Only when the buffer is parsed for option-setting lines
15253 (i.e., when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
15254 settings line, or when exporting), then the contents of this file are parsed
15255 as if they had been included in the buffer.  In particular, the file can be
15256 any other Org mode file with internal setup.  You can visit the file the
15257 cursor is in the line with @kbd{C-c '}.
15258 @item #+STARTUP:
15259 @cindex #+STARTUP:
15260 This line sets options to be used at startup of Org mode, when an
15261 Org file is being visited.
15263 The first set of options deals with the initial visibility of the outline
15264 tree.  The corresponding variable for global default settings is
15265 @code{org-startup-folded}, with a default value @code{t}, which means
15266 @code{overview}.
15267 @vindex org-startup-folded
15268 @cindex @code{overview}, STARTUP keyword
15269 @cindex @code{content}, STARTUP keyword
15270 @cindex @code{showall}, STARTUP keyword
15271 @cindex @code{showeverything}, STARTUP keyword
15272 @example
15273 overview         @r{top-level headlines only}
15274 content          @r{all headlines}
15275 showall          @r{no folding of any entries}
15276 showeverything   @r{show even drawer contents}
15277 @end example
15279 @vindex org-startup-indented
15280 @cindex @code{indent}, STARTUP keyword
15281 @cindex @code{noindent}, STARTUP keyword
15282 Dynamic virtual indentation is controlled by the variable
15283 @code{org-startup-indented}@footnote{Emacs 23 and Org mode 6.29 are required}
15284 @example
15285 indent     @r{start with @code{org-indent-mode} turned on}
15286 noindent   @r{start with @code{org-indent-mode} turned off}
15287 @end example
15289 @vindex org-startup-align-all-tables
15290 Then there are options for aligning tables upon visiting a file.  This
15291 is useful in files containing narrowed table columns.  The corresponding
15292 variable is @code{org-startup-align-all-tables}, with a default value
15293 @code{nil}.
15294 @cindex @code{align}, STARTUP keyword
15295 @cindex @code{noalign}, STARTUP keyword
15296 @example
15297 align      @r{align all tables}
15298 noalign    @r{don't align tables on startup}
15299 @end example
15301 @vindex org-startup-with-inline-images
15302 When visiting a file, inline images can be automatically displayed.  The
15303 corresponding variable is @code{org-startup-with-inline-images}, with a
15304 default value @code{nil} to avoid delays when visiting a file.
15305 @cindex @code{inlineimages}, STARTUP keyword
15306 @cindex @code{noinlineimages}, STARTUP keyword
15307 @example
15308 inlineimages   @r{show inline images}
15309 noinlineimages @r{don't show inline images on startup}
15310 @end example
15312 @vindex org-startup-with-latex-preview
15313 When visiting a file, @LaTeX{} fragments can be converted to images
15314 automatically.  The variable @code{org-startup-with-latex-preview} which
15315 controls this behavior, is set to @code{nil} by default to avoid delays on
15316 startup.
15317 @cindex @code{latexpreview}, STARTUP keyword
15318 @cindex @code{nolatexpreview}, STARTUP keyword
15319 @example
15320 latexpreview   @r{preview @LaTeX{} fragments}
15321 nolatexpreview @r{don't preview @LaTeX{} fragments}
15322 @end example
15324 @vindex org-log-done
15325 @vindex org-log-note-clock-out
15326 @vindex org-log-repeat
15327 Logging the closing and reopening of TODO items and clock intervals can be
15328 configured using these options (see variables @code{org-log-done},
15329 @code{org-log-note-clock-out} and @code{org-log-repeat})
15330 @cindex @code{logdone}, STARTUP keyword
15331 @cindex @code{lognotedone}, STARTUP keyword
15332 @cindex @code{nologdone}, STARTUP keyword
15333 @cindex @code{lognoteclock-out}, STARTUP keyword
15334 @cindex @code{nolognoteclock-out}, STARTUP keyword
15335 @cindex @code{logrepeat}, STARTUP keyword
15336 @cindex @code{lognoterepeat}, STARTUP keyword
15337 @cindex @code{nologrepeat}, STARTUP keyword
15338 @cindex @code{logreschedule}, STARTUP keyword
15339 @cindex @code{lognotereschedule}, STARTUP keyword
15340 @cindex @code{nologreschedule}, STARTUP keyword
15341 @cindex @code{logredeadline}, STARTUP keyword
15342 @cindex @code{lognoteredeadline}, STARTUP keyword
15343 @cindex @code{nologredeadline}, STARTUP keyword
15344 @cindex @code{logrefile}, STARTUP keyword
15345 @cindex @code{lognoterefile}, STARTUP keyword
15346 @cindex @code{nologrefile}, STARTUP keyword
15347 @cindex @code{logdrawer}, STARTUP keyword
15348 @cindex @code{nologdrawer}, STARTUP keyword
15349 @cindex @code{logstatesreversed}, STARTUP keyword
15350 @cindex @code{nologstatesreversed}, STARTUP keyword
15351 @example
15352 logdone             @r{record a timestamp when an item is marked DONE}
15353 lognotedone         @r{record timestamp and a note when DONE}
15354 nologdone           @r{don't record when items are marked DONE}
15355 logrepeat           @r{record a time when reinstating a repeating item}
15356 lognoterepeat       @r{record a note when reinstating a repeating item}
15357 nologrepeat         @r{do not record when reinstating repeating item}
15358 lognoteclock-out    @r{record a note when clocking out}
15359 nolognoteclock-out  @r{don't record a note when clocking out}
15360 logreschedule       @r{record a timestamp when scheduling time changes}
15361 lognotereschedule   @r{record a note when scheduling time changes}
15362 nologreschedule     @r{do not record when a scheduling date changes}
15363 logredeadline       @r{record a timestamp when deadline changes}
15364 lognoteredeadline   @r{record a note when deadline changes}
15365 nologredeadline     @r{do not record when a deadline date changes}
15366 logrefile           @r{record a timestamp when refiling}
15367 lognoterefile       @r{record a note when refiling}
15368 nologrefile         @r{do not record when refiling}
15369 logdrawer           @r{store log into drawer}
15370 nologdrawer         @r{store log outside of drawer}
15371 logstatesreversed   @r{reverse the order of states notes}
15372 nologstatesreversed @r{do not reverse the order of states notes}
15373 @end example
15375 @vindex org-hide-leading-stars
15376 @vindex org-odd-levels-only
15377 Here are the options for hiding leading stars in outline headings, and for
15378 indenting outlines.  The corresponding variables are
15379 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
15380 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
15381 @cindex @code{hidestars}, STARTUP keyword
15382 @cindex @code{showstars}, STARTUP keyword
15383 @cindex @code{odd}, STARTUP keyword
15384 @cindex @code{even}, STARTUP keyword
15385 @example
15386 hidestars  @r{make all but one of the stars starting a headline invisible.}
15387 showstars  @r{show all stars starting a headline}
15388 indent     @r{virtual indentation according to outline level}
15389 noindent   @r{no virtual indentation according to outline level}
15390 odd        @r{allow only odd outline levels (1,3,...)}
15391 oddeven    @r{allow all outline levels}
15392 @end example
15394 @vindex org-put-time-stamp-overlays
15395 @vindex org-time-stamp-overlay-formats
15396 To turn on custom format overlays over timestamps (variables
15397 @code{org-put-time-stamp-overlays} and
15398 @code{org-time-stamp-overlay-formats}), use
15399 @cindex @code{customtime}, STARTUP keyword
15400 @example
15401 customtime @r{overlay custom time format}
15402 @end example
15404 @vindex constants-unit-system
15405 The following options influence the table spreadsheet (variable
15406 @code{constants-unit-system}).
15407 @cindex @code{constcgs}, STARTUP keyword
15408 @cindex @code{constSI}, STARTUP keyword
15409 @example
15410 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
15411 constSI    @r{@file{constants.el} should use the SI unit system}
15412 @end example
15414 @vindex org-footnote-define-inline
15415 @vindex org-footnote-auto-label
15416 @vindex org-footnote-auto-adjust
15417 To influence footnote settings, use the following keywords.  The
15418 corresponding variables are @code{org-footnote-define-inline},
15419 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
15420 @cindex @code{fninline}, STARTUP keyword
15421 @cindex @code{nofninline}, STARTUP keyword
15422 @cindex @code{fnlocal}, STARTUP keyword
15423 @cindex @code{fnprompt}, STARTUP keyword
15424 @cindex @code{fnauto}, STARTUP keyword
15425 @cindex @code{fnconfirm}, STARTUP keyword
15426 @cindex @code{fnplain}, STARTUP keyword
15427 @cindex @code{fnadjust}, STARTUP keyword
15428 @cindex @code{nofnadjust}, STARTUP keyword
15429 @example
15430 fninline    @r{define footnotes inline}
15431 fnnoinline  @r{define footnotes in separate section}
15432 fnlocal     @r{define footnotes near first reference, but not inline}
15433 fnprompt    @r{prompt for footnote labels}
15434 fnauto      @r{create @code{[fn:1]}-like labels automatically (default)}
15435 fnconfirm   @r{offer automatic label for editing or confirmation}
15436 fnplain     @r{create @code{[1]}-like labels automatically}
15437 fnadjust    @r{automatically renumber and sort footnotes}
15438 nofnadjust  @r{do not renumber and sort automatically}
15439 @end example
15441 @cindex org-hide-block-startup
15442 To hide blocks on startup, use these keywords.  The corresponding variable is
15443 @code{org-hide-block-startup}.
15444 @cindex @code{hideblocks}, STARTUP keyword
15445 @cindex @code{nohideblocks}, STARTUP keyword
15446 @example
15447 hideblocks   @r{Hide all begin/end blocks on startup}
15448 nohideblocks @r{Do not hide blocks on startup}
15449 @end example
15451 @cindex org-pretty-entities
15452 The display of entities as UTF-8 characters is governed by the variable
15453 @code{org-pretty-entities} and the keywords
15454 @cindex @code{entitiespretty}, STARTUP keyword
15455 @cindex @code{entitiesplain}, STARTUP keyword
15456 @example
15457 entitiespretty  @r{Show entities as UTF-8 characters where possible}
15458 entitiesplain   @r{Leave entities plain}
15459 @end example
15461 @item #+TAGS:  TAG1(c1) TAG2(c2)
15462 @vindex org-tag-alist
15463 These lines (several such lines are allowed) specify the valid tags in
15464 this file, and (potentially) the corresponding @emph{fast tag selection}
15465 keys.  The corresponding variable is @code{org-tag-alist}.
15466 @cindex #+TBLFM
15467 @item #+TBLFM:
15468 This line contains the formulas for the table directly above the line.
15470 Table can have multiple lines containing @samp{#+TBLFM:}.  Note
15471 that only the first line of @samp{#+TBLFM:} will be applied when
15472 you recalculate the table.  For more details see @ref{Using
15473 multiple #+TBLFM lines} in @ref{Editing and debugging formulas}.
15475 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+DATE:,
15476 @itemx #+OPTIONS:, #+BIND:,
15477 @itemx #+DESCRIPTION:, #+KEYWORDS:,
15478 @itemx #+LaTeX_HEADER:, #+LaTeX_HEADER_EXTRA:,
15479 @itemx #+HTML_HEAD:, #+HTML_LINK_UP:, #+HTML_LINK_HOME:,
15480 @itemx #+SELECT_TAGS:, #+EXCLUDE_TAGS:
15481 These lines provide settings for exporting files.  For more details see
15482 @ref{Export settings}.
15483 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
15484 @vindex org-todo-keywords
15485 These lines set the TODO keywords and their interpretation in the
15486 current file.  The corresponding variable is @code{org-todo-keywords}.
15487 @end table
15489 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
15490 @section The very busy C-c C-c key
15491 @kindex C-c C-c
15492 @cindex C-c C-c, overview
15494 The key @kbd{C-c C-c} has many purposes in Org, which are all
15495 mentioned scattered throughout this manual.  One specific function of
15496 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
15497 other circumstances it means something like @emph{``Hey Org, look
15498 here and update according to what you see here''}.  Here is a summary of
15499 what this means in different contexts.
15501 @itemize @minus
15502 @item
15503 If there are highlights in the buffer from the creation of a sparse
15504 tree, or from clock display, remove these highlights.
15505 @item
15506 If the cursor is in one of the special @code{#+KEYWORD} lines, this
15507 triggers scanning the buffer for these lines and updating the
15508 information.
15509 @item
15510 If the cursor is inside a table, realign the table.  This command
15511 works even if the automatic table editor has been turned off.
15512 @item
15513 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
15514 the entire table.
15515 @item
15516 If the current buffer is a capture buffer, close the note and file it.
15517 With a prefix argument, file it, without further interaction, to the
15518 default location.
15519 @item
15520 If the cursor is on a @code{<<<target>>>}, update radio targets and
15521 corresponding links in this buffer.
15522 @item
15523 If the cursor is in a property line or at the start or end of a property
15524 drawer, offer property commands.
15525 @item
15526 If the cursor is at a footnote reference, go to the corresponding
15527 definition, and @emph{vice versa}.
15528 @item
15529 If the cursor is on a statistics cookie, update it.
15530 @item
15531 If the cursor is in a plain list item with a checkbox, toggle the status
15532 of the checkbox.
15533 @item
15534 If the cursor is on a numbered item in a plain list, renumber the
15535 ordered list.
15536 @item
15537 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
15538 block is updated.
15539 @item
15540 If the cursor is at a timestamp, fix the day name in the timestamp.
15541 @end itemize
15543 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
15544 @section A cleaner outline view
15545 @cindex hiding leading stars
15546 @cindex dynamic indentation
15547 @cindex odd-levels-only outlines
15548 @cindex clean outline view
15550 Some people find it noisy and distracting that the Org headlines start with a
15551 potentially large number of stars, and that text below the headlines is not
15552 indented.  While this is no problem when writing a @emph{book-like} document
15553 where the outline headings are really section headings, in a more
15554 @emph{list-oriented} outline, indented structure is a lot cleaner:
15556 @example
15557 @group
15558 * Top level headline             |    * Top level headline
15559 ** Second level                  |      * Second level
15560 *** 3rd level                    |        * 3rd level
15561 some text                        |          some text
15562 *** 3rd level                    |        * 3rd level
15563 more text                        |          more text
15564 * Another top level headline     |    * Another top level headline
15565 @end group
15566 @end example
15568 @noindent
15570 If you are using at least Emacs 23.2@footnote{Emacs 23.1 can actually crash
15571 with @code{org-indent-mode}} and version 6.29 of Org, this kind of view can
15572 be achieved dynamically at display time using @code{org-indent-mode}.  In
15573 this minor mode, all lines are prefixed for display with the necessary amount
15574 of space@footnote{@code{org-indent-mode} also sets the @code{wrap-prefix}
15575 property, such that @code{visual-line-mode} (or purely setting
15576 @code{word-wrap}) wraps long lines (including headlines) correctly indented.
15577 }.  Also headlines are prefixed with additional stars, so that the amount of
15578 indentation shifts by two@footnote{See the variable
15579 @code{org-indent-indentation-per-level}.}  spaces per level.  All headline
15580 stars but the last one are made invisible using the @code{org-hide}
15581 face@footnote{Turning on @code{org-indent-mode} sets
15582 @code{org-hide-leading-stars} to @code{t} and @code{org-adapt-indentation} to
15583 @code{nil}.}; see below under @samp{2.} for more information on how this
15584 works.  You can turn on @code{org-indent-mode} for all files by customizing
15585 the variable @code{org-startup-indented}, or you can turn it on for
15586 individual files using
15588 @example
15589 #+STARTUP: indent
15590 @end example
15592 If you want a similar effect in an earlier version of Emacs and/or Org, or if
15593 you want the indentation to be hard space characters so that the plain text
15594 file looks as similar as possible to the Emacs display, Org supports you in
15595 the following way:
15597 @enumerate
15598 @item
15599 @emph{Indentation of text below headlines}@*
15600 You may indent text below each headline to make the left boundary line up
15601 with the headline, like
15603 @example
15604 *** 3rd level
15605     more text, now indented
15606 @end example
15608 @vindex org-adapt-indentation
15609 Org supports this with paragraph filling, line wrapping, and structure
15610 editing@footnote{See also the variable @code{org-adapt-indentation}.},
15611 preserving or adapting the indentation as appropriate.
15613 @item
15614 @vindex org-hide-leading-stars
15615 @emph{Hiding leading stars}@* You can modify the display in such a way that
15616 all leading stars become invisible.  To do this in a global way, configure
15617 the variable @code{org-hide-leading-stars} or change this on a per-file basis
15618 with
15620 @example
15621 #+STARTUP: hidestars
15622 #+STARTUP: showstars
15623 @end example
15625 With hidden stars, the tree becomes:
15627 @example
15628 @group
15629 * Top level headline
15630  * Second level
15631   * 3rd level
15632   ...
15633 @end group
15634 @end example
15636 @noindent
15637 @vindex org-hide @r{(face)}
15638 The leading stars are not truly replaced by whitespace, they are only
15639 fontified with the face @code{org-hide} that uses the background color as
15640 font color.  If you are not using either white or black background, you may
15641 have to customize this face to get the wanted effect.  Another possibility is
15642 to set this font such that the extra stars are @i{almost} invisible, for
15643 example using the color @code{grey90} on a white background.
15645 @item
15646 @vindex org-odd-levels-only
15647 Things become cleaner still if you skip all the even levels and use only odd
15648 levels 1, 3, 5..., effectively adding two stars to go from one outline level
15649 to the next@footnote{When you need to specify a level for a property search
15650 or refile targets, @samp{LEVEL=2} will correspond to 3 stars, etc.}.  In this
15651 way we get the outline view shown at the beginning of this section.  In order
15652 to make the structure editing and export commands handle this convention
15653 correctly, configure the variable @code{org-odd-levels-only}, or set this on
15654 a per-file basis with one of the following lines:
15656 @example
15657 #+STARTUP: odd
15658 #+STARTUP: oddeven
15659 @end example
15661 You can convert an Org file from single-star-per-level to the
15662 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
15663 RET} in that file.  The reverse operation is @kbd{M-x
15664 org-convert-to-oddeven-levels}.
15665 @end enumerate
15667 @node TTY keys, Interaction, Clean view, Miscellaneous
15668 @section Using Org on a tty
15669 @cindex tty key bindings
15671 Because Org contains a large number of commands, by default many of
15672 Org's core commands are bound to keys that are generally not
15673 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
15674 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
15675 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
15676 these commands on a tty when special keys are unavailable, the following
15677 alternative bindings can be used.  The tty bindings below will likely be
15678 more cumbersome; you may find for some of the bindings below that a
15679 customized workaround suits you better.  For example, changing a timestamp
15680 is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
15681 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
15683 @multitable @columnfractions 0.15 0.2 0.1 0.2
15684 @item @b{Default} @tab @b{Alternative 1} @tab @b{Speed key} @tab @b{Alternative 2}
15685 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab @kbd{C} @tab
15686 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{l} @tab @kbd{@key{Esc} @key{left}}
15687 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab @kbd{L} @tab
15688 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{r} @tab @kbd{@key{Esc} @key{right}}
15689 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab @kbd{R} @tab
15690 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{up}}
15691 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab @kbd{U} @tab
15692 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{down}}
15693 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab @kbd{D} @tab
15694 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab @kbd{ } @tab
15695 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{RET}}
15696 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab @kbd{ } @tab
15697 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab @kbd{ } @tab
15698 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab @kbd{ } @tab
15699 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab @kbd{ } @tab
15700 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab @kbd{ } @tab
15701 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab @kbd{ } @tab
15702 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab @kbd{ } @tab
15703 @end multitable
15706 @node Interaction, org-crypt.el, TTY keys, Miscellaneous
15707 @section Interaction with other packages
15708 @cindex packages, interaction with other
15709 Org lives in the world of GNU Emacs and interacts in various ways
15710 with other code out there.
15712 @menu
15713 * Cooperation::                 Packages Org cooperates with
15714 * Conflicts::                   Packages that lead to conflicts
15715 @end menu
15717 @node Cooperation, Conflicts, Interaction, Interaction
15718 @subsection Packages that Org cooperates with
15720 @table @asis
15721 @cindex @file{calc.el}
15722 @cindex Gillespie, Dave
15723 @item @file{calc.el} by Dave Gillespie
15724 Org uses the Calc package for implementing spreadsheet
15725 functionality in its tables (@pxref{The spreadsheet}).  Org
15726 checks for the availability of Calc by looking for the function
15727 @code{calc-eval} which will have been autoloaded during setup if Calc has
15728 been installed properly.  As of Emacs 22, Calc is part of the Emacs
15729 distribution.  Another possibility for interaction between the two
15730 packages is using Calc for embedded calculations.  @xref{Embedded Mode,
15731 , Embedded Mode, calc, GNU Emacs Calc Manual}.
15732 @item @file{constants.el} by Carsten Dominik
15733 @cindex @file{constants.el}
15734 @cindex Dominik, Carsten
15735 @vindex org-table-formula-constants
15736 In a table formula (@pxref{The spreadsheet}), it is possible to use
15737 names for natural constants or units.  Instead of defining your own
15738 constants in the variable @code{org-table-formula-constants}, install
15739 the @file{constants} package which defines a large number of constants
15740 and units, and lets you use unit prefixes like @samp{M} for
15741 @samp{Mega}, etc.  You will need version 2.0 of this package, available
15742 at @url{http://www.astro.uva.nl/~dominik/Tools}.  Org checks for
15743 the function @code{constants-get}, which has to be autoloaded in your
15744 setup.  See the installation instructions in the file
15745 @file{constants.el}.
15746 @item @file{cdlatex.el} by Carsten Dominik
15747 @cindex @file{cdlatex.el}
15748 @cindex Dominik, Carsten
15749 Org mode can make use of the CD@LaTeX{} package to efficiently enter
15750 @LaTeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
15751 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
15752 @cindex @file{imenu.el}
15753 Imenu allows menu access to an index of items in a file.  Org mode
15754 supports Imenu---all you need to do to get the index is the following:
15755 @lisp
15756 (add-hook 'org-mode-hook
15757           (lambda () (imenu-add-to-menubar "Imenu")))
15758 @end lisp
15759 @vindex org-imenu-depth
15760 By default the index is two levels deep---you can modify the depth using
15761 the option @code{org-imenu-depth}.
15762 @item @file{remember.el} by John Wiegley
15763 @cindex @file{remember.el}
15764 @cindex Wiegley, John
15765 Org used to use this package for capture, but no longer does.
15766 @item @file{speedbar.el} by Eric M. Ludlam
15767 @cindex @file{speedbar.el}
15768 @cindex Ludlam, Eric M.
15769 Speedbar is a package that creates a special frame displaying files and
15770 index items in files.  Org mode supports Speedbar and allows you to
15771 drill into Org files directly from the Speedbar.  It also allows you to
15772 restrict the scope of agenda commands to a file or a subtree by using
15773 the command @kbd{<} in the Speedbar frame.
15774 @cindex @file{table.el}
15775 @item @file{table.el} by Takaaki Ota
15776 @kindex C-c C-c
15777 @cindex table editor, @file{table.el}
15778 @cindex @file{table.el}
15779 @cindex Ota, Takaaki
15781 Complex ASCII tables with automatic line wrapping, column- and row-spanning,
15782 and alignment can be created using the Emacs table package by Takaaki Ota
15783 (@uref{http://sourceforge.net/projects/table}, and also part of Emacs 22).
15784 Org mode will recognize these tables and export them properly.  Because of
15785 interference with other Org mode functionality, you unfortunately cannot edit
15786 these tables directly in the buffer.  Instead, you need to use the command
15787 @kbd{C-c '} to edit them, similar to source code snippets.
15789 @table @kbd
15790 @orgcmd{C-c ',org-edit-special}
15791 Edit a @file{table.el} table.  Works when the cursor is in a table.el table.
15793 @orgcmd{C-c ~,org-table-create-with-table.el}
15794 Insert a @file{table.el} table.  If there is already a table at point, this
15795 command converts it between the @file{table.el} format and the Org mode
15796 format.  See the documentation string of the command
15797 @code{org-convert-table} for the restrictions under which this is
15798 possible.
15799 @end table
15800 @file{table.el} is part of Emacs since Emacs 22.
15801 @item @file{footnote.el} by Steven L. Baur
15802 @cindex @file{footnote.el}
15803 @cindex Baur, Steven L.
15804 Org mode recognizes numerical footnotes as provided by this package.
15805 However, Org mode also has its own footnote support (@pxref{Footnotes}),
15806 which makes using @file{footnote.el} unnecessary.
15807 @end table
15809 @node Conflicts,  , Cooperation, Interaction
15810 @subsection Packages that lead to conflicts with Org mode
15812 @table @asis
15814 @cindex @code{shift-selection-mode}
15815 @vindex org-support-shift-select
15816 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
15817 cursor motions combined with the shift key should start or enlarge regions.
15818 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
15819 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
15820 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
15821 special contexts don't do anything, but you can customize the variable
15822 @code{org-support-shift-select}.  Org mode then tries to accommodate shift
15823 selection by (i) using it outside of the special contexts where special
15824 commands apply, and by (ii) extending an existing active region even if the
15825 cursor moves across a special context.
15827 @item @file{CUA.el} by Kim. F. Storm
15828 @cindex @file{CUA.el}
15829 @cindex Storm, Kim. F.
15830 @vindex org-replace-disputed-keys
15831 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
15832 (as well as @code{pc-select-mode} and @code{s-region-mode}) to select and extend the
15833 region.  In fact, Emacs 23 has this built-in in the form of
15834 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
15835 23, you probably don't want to use another package for this purpose.  However,
15836 if you prefer to leave these keys to a different package while working in
15837 Org mode, configure the variable @code{org-replace-disputed-keys}.  When set,
15838 Org will move the following key bindings in Org files, and in the agenda
15839 buffer (but not during date selection).
15841 @example
15842 S-UP      @result{}  M-p             S-DOWN     @result{}  M-n
15843 S-LEFT    @result{}  M--             S-RIGHT    @result{}  M-+
15844 C-S-LEFT  @result{}  M-S--           C-S-RIGHT  @result{}  M-S-+
15845 @end example
15847 @vindex org-disputed-keys
15848 Yes, these are unfortunately more difficult to remember.  If you want
15849 to have other replacement keys, look at the variable
15850 @code{org-disputed-keys}.
15852 @item @file{filladapt.el} by Kyle Jones
15853 @cindex @file{filladapt.el}
15855 Org mode tries to do the right thing when filling paragraphs, list items and
15856 other elements.  Many users reported they had problems using both
15857 @file{filladapt.el} and Org mode, so a safe thing to do is to disable it like
15858 this:
15860 @lisp
15861 (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
15862 @end lisp
15864 @item @file{yasnippet.el}
15865 @cindex @file{yasnippet.el}
15866 The way Org mode binds the TAB key (binding to @code{[tab]} instead of
15867 @code{"\t"}) overrules YASnippet's access to this key.  The following code
15868 fixed this problem:
15870 @lisp
15871 (add-hook 'org-mode-hook
15872           (lambda ()
15873             (org-set-local 'yas/trigger-key [tab])
15874             (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
15875 @end lisp
15877 The latest version of yasnippet doesn't play well with Org mode.  If the
15878 above code does not fix the conflict, start by defining the following
15879 function:
15881 @lisp
15882 (defun yas/org-very-safe-expand ()
15883   (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
15884 @end lisp
15886 Then, tell Org mode what to do with the new function:
15888 @lisp
15889 (add-hook 'org-mode-hook
15890           (lambda ()
15891             (make-variable-buffer-local 'yas/trigger-key)
15892             (setq yas/trigger-key [tab])
15893             (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
15894             (define-key yas/keymap [tab] 'yas/next-field)))
15895 @end lisp
15897 @item @file{windmove.el} by Hovav Shacham
15898 @cindex @file{windmove.el}
15899 This package also uses the @kbd{S-<cursor>} keys, so everything written
15900 in the paragraph above about CUA mode also applies here.  If you want make
15901 the windmove function active in locations where Org mode does not have
15902 special functionality on @kbd{S-@key{cursor}}, add this to your
15903 configuration:
15905 @lisp
15906 ;; Make windmove work in org-mode:
15907 (add-hook 'org-shiftup-final-hook 'windmove-up)
15908 (add-hook 'org-shiftleft-final-hook 'windmove-left)
15909 (add-hook 'org-shiftdown-final-hook 'windmove-down)
15910 (add-hook 'org-shiftright-final-hook 'windmove-right)
15911 @end lisp
15913 @item @file{viper.el} by Michael Kifer
15914 @cindex @file{viper.el}
15915 @kindex C-c /
15916 Viper uses @kbd{C-c /} and therefore makes this key not access the
15917 corresponding Org mode command @code{org-sparse-tree}.  You need to find
15918 another key for this command, or override the key in
15919 @code{viper-vi-global-user-map} with
15921 @lisp
15922 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
15923 @end lisp
15925 @end table
15927 @node org-crypt.el,  , Interaction, Miscellaneous
15928 @section org-crypt.el
15929 @cindex @file{org-crypt.el}
15930 @cindex @code{org-decrypt-entry}
15932 Org-crypt will encrypt the text of an entry, but not the headline, or
15933 properties.  Org-crypt uses the Emacs EasyPG library to encrypt and decrypt
15934 files.
15936 Any text below a headline that has a @samp{:crypt:} tag will be automatically
15937 be encrypted when the file is saved.  If you want to use a different tag just
15938 customize the @code{org-crypt-tag-matcher} setting.
15940 To use org-crypt it is suggested that you have the following in your
15941 @file{.emacs}:
15943 @lisp
15944 (require 'org-crypt)
15945 (org-crypt-use-before-save-magic)
15946 (setq org-tags-exclude-from-inheritance (quote ("crypt")))
15948 (setq org-crypt-key nil)
15949   ;; GPG key to use for encryption
15950   ;; Either the Key ID or set to nil to use symmetric encryption.
15952 (setq auto-save-default nil)
15953   ;; Auto-saving does not cooperate with org-crypt.el: so you need
15954   ;; to turn it off if you plan to use org-crypt.el quite often.
15955   ;; Otherwise, you'll get an (annoying) message each time you
15956   ;; start Org.
15958   ;; To turn it off only locally, you can insert this:
15959   ;;
15960   ;; # -*- buffer-auto-save-file-name: nil; -*-
15961 @end lisp
15963 Excluding the crypt tag from inheritance prevents already encrypted text
15964 being encrypted again.
15966 @node Hacking, MobileOrg, Miscellaneous, Top
15967 @appendix Hacking
15968 @cindex hacking
15970 This appendix covers some aspects where users can extend the functionality of
15971 Org.
15973 @menu
15974 * Hooks::                       How to reach into Org's internals
15975 * Add-on packages::             Available extensions
15976 * Adding hyperlink types::      New custom link types
15977 * Adding export back-ends::     How to write new export back-ends
15978 * Context-sensitive commands::  How to add functionality to such commands
15979 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
15980 * Dynamic blocks::              Automatically filled blocks
15981 * Special agenda views::        Customized views
15982 * Speeding up your agendas::    Tips on how to speed up your agendas
15983 * Extracting agenda information::  Post-processing of agenda information
15984 * Using the property API::      Writing programs that use entry properties
15985 * Using the mapping API::       Mapping over all or selected entries
15986 @end menu
15988 @node Hooks, Add-on packages, Hacking, Hacking
15989 @section Hooks
15990 @cindex hooks
15992 Org has a large number of hook variables that can be used to add
15993 functionality.  This appendix about hacking is going to illustrate the
15994 use of some of them.  A complete list of all hooks with documentation is
15995 maintained by the Worg project and can be found at
15996 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
15998 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
15999 @section Add-on packages
16000 @cindex add-on packages
16002 A large number of add-on packages have been written by various authors.
16004 These packages are not part of Emacs, but they are distributed as contributed
16005 packages with the separate release available at @uref{http://orgmode.org}.
16006 See the @file{contrib/README} file in the source code directory for a list of
16007 contributed files.  You may also find some more information on the Worg page:
16008 @uref{http://orgmode.org/worg/org-contrib/}.
16010 @node Adding hyperlink types, Adding export back-ends, Add-on packages, Hacking
16011 @section Adding hyperlink types
16012 @cindex hyperlinks, adding new types
16014 Org has a large number of hyperlink types built-in
16015 (@pxref{Hyperlinks}).  If you would like to add new link types, Org
16016 provides an interface for doing so.  Let's look at an example file,
16017 @file{org-man.el}, that will add support for creating links like
16018 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
16019 Emacs:
16021 @lisp
16022 ;;; org-man.el - Support for links to manpages in Org
16024 (require 'org)
16026 (org-add-link-type "man" 'org-man-open)
16027 (add-hook 'org-store-link-functions 'org-man-store-link)
16029 (defcustom org-man-command 'man
16030   "The Emacs command to be used to display a man page."
16031   :group 'org-link
16032   :type '(choice (const man) (const woman)))
16034 (defun org-man-open (path)
16035   "Visit the manpage on PATH.
16036 PATH should be a topic that can be thrown at the man command."
16037   (funcall org-man-command path))
16039 (defun org-man-store-link ()
16040   "Store a link to a manpage."
16041   (when (memq major-mode '(Man-mode woman-mode))
16042     ;; This is a man page, we do make this link
16043     (let* ((page (org-man-get-page-name))
16044            (link (concat "man:" page))
16045            (description (format "Manpage for %s" page)))
16046       (org-store-link-props
16047        :type "man"
16048        :link link
16049        :description description))))
16051 (defun org-man-get-page-name ()
16052   "Extract the page name from the buffer name."
16053   ;; This works for both `Man-mode' and `woman-mode'.
16054   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
16055       (match-string 1 (buffer-name))
16056     (error "Cannot create link to this man page")))
16058 (provide 'org-man)
16060 ;;; org-man.el ends here
16061 @end lisp
16063 @noindent
16064 You would activate this new link type in @file{.emacs} with
16066 @lisp
16067 (require 'org-man)
16068 @end lisp
16070 @noindent
16071 Let's go through the file and see what it does.
16072 @enumerate
16073 @item
16074 It does @code{(require 'org)} to make sure that @file{org.el} has been
16075 loaded.
16076 @item
16077 The next line calls @code{org-add-link-type} to define a new link type
16078 with prefix @samp{man}.  The call also contains the name of a function
16079 that will be called to follow such a link.
16080 @item
16081 @vindex org-store-link-functions
16082 The next line adds a function to @code{org-store-link-functions}, in
16083 order to allow the command @kbd{C-c l} to record a useful link in a
16084 buffer displaying a man page.
16085 @end enumerate
16087 The rest of the file defines the necessary variables and functions.
16088 First there is a customization variable that determines which Emacs
16089 command should be used to display man pages.  There are two options,
16090 @code{man} and @code{woman}.  Then the function to follow a link is
16091 defined.  It gets the link path as an argument---in this case the link
16092 path is just a topic for the manual command.  The function calls the
16093 value of @code{org-man-command} to display the man page.
16095 Finally the function @code{org-man-store-link} is defined.  When you try
16096 to store a link with @kbd{C-c l}, this function will be called to
16097 try to make a link.  The function must first decide if it is supposed to
16098 create the link for this buffer type; we do this by checking the value
16099 of the variable @code{major-mode}.  If not, the function must exit and
16100 return the value @code{nil}.  If yes, the link is created by getting the
16101 manual topic from the buffer name and prefixing it with the string
16102 @samp{man:}.  Then it must call the command @code{org-store-link-props}
16103 and set the @code{:type} and @code{:link} properties.  Optionally you
16104 can also set the @code{:description} property to provide a default for
16105 the link description when the link is later inserted into an Org
16106 buffer with @kbd{C-c C-l}.
16108 When it makes sense for your new link type, you may also define a function
16109 @code{org-PREFIX-complete-link} that implements special (e.g., completion)
16110 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
16111 not accept any arguments, and return the full link with prefix.
16113 @node Adding export back-ends, Context-sensitive commands, Adding hyperlink types, Hacking
16114 @section Adding export back-ends
16115 @cindex Export, writing back-ends
16117 Org 8.0 comes with a completely rewritten export engine which makes it easy
16118 to write new export back-ends, either from scratch, or from deriving them
16119 from existing ones.
16121 Your two entry points are respectively @code{org-export-define-backend} and
16122 @code{org-export-define-derived-backend}.  To grok these functions, you
16123 should first have a look at @file{ox-latex.el} (for how to define a new
16124 back-end from scratch) and @file{ox-beamer.el} (for how to derive a new
16125 back-end from an existing one.
16127 When creating a new back-end from scratch, the basic idea is to set the name
16128 of the back-end (as a symbol) and an an alist of elements and export
16129 functions.  On top of this, you will need to set additional keywords like
16130 @code{:menu-entry} (to display the back-end in the export dispatcher),
16131 @code{:export-block} (to specify what blocks should not be exported by this
16132 back-end), and @code{:options-alist} (to let the user set export options that
16133 are specific to this back-end.)
16135 Deriving a new back-end is similar, except that you need to set
16136 @code{:translate-alist} to an alist of export functions that should be used
16137 instead of the parent back-end functions.
16139 For a complete reference documentation, see
16140 @url{http://orgmode.org/worg/dev/org-export-reference.html, the Org Export
16141 Reference on Worg}.
16143 @node Context-sensitive commands, Tables in arbitrary syntax, Adding export back-ends, Hacking
16144 @section Context-sensitive commands
16145 @cindex context-sensitive commands, hooks
16146 @cindex add-ons, context-sensitive commands
16147 @vindex org-ctrl-c-ctrl-c-hook
16149 Org has several commands that act differently depending on context.  The most
16150 important example is the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
16151 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
16153 Add-ons can tap into this functionality by providing a function that detects
16154 special context for that add-on and executes functionality appropriate for
16155 the context.  Here is an example from Dan Davison's @file{org-R.el} which
16156 allows you to evaluate commands based on the @file{R} programming language
16157 @footnote{@file{org-R.el} has been replaced by the Org mode functionality
16158 described in @ref{Working With Source Code} and is now obsolete.}.  For this
16159 package, special contexts are lines that start with @code{#+R:} or
16160 @code{#+RR:}.
16162 @lisp
16163 (defun org-R-apply-maybe ()
16164   "Detect if this is context for org-R and execute R commands."
16165   (if (save-excursion
16166         (beginning-of-line 1)
16167         (looking-at "#\\+RR?:"))
16168       (progn (call-interactively 'org-R-apply)
16169              t) ;; to signal that we took action
16170     nil)) ;; to signal that we did not
16172 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
16173 @end lisp
16175 The function first checks if the cursor is in such a line.  If that is the
16176 case, @code{org-R-apply} is called and the function returns @code{t} to
16177 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
16178 contexts.  If the function finds it should do nothing locally, it returns
16179 @code{nil} so that other, similar functions can have a try.
16182 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
16183 @section Tables and lists in arbitrary syntax
16184 @cindex tables, in other modes
16185 @cindex lists, in other modes
16186 @cindex Orgtbl mode
16188 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
16189 frequent feature request has been to make it work with native tables in
16190 specific languages, for example @LaTeX{}.  However, this is extremely
16191 hard to do in a general way, would lead to a customization nightmare,
16192 and would take away much of the simplicity of the Orgtbl mode table
16193 editor.
16195 This appendix describes a different approach.  We keep the Orgtbl mode
16196 table in its native format (the @i{source table}), and use a custom
16197 function to @i{translate} the table to the correct syntax, and to
16198 @i{install} it in the right location (the @i{target table}).  This puts
16199 the burden of writing conversion functions on the user, but it allows
16200 for a very flexible system.
16202 Bastien added the ability to do the same with lists, in Orgstruct mode.  You
16203 can use Org's facilities to edit and structure lists by turning
16204 @code{orgstruct-mode} on, then locally exporting such lists in another format
16205 (HTML, @LaTeX{} or Texinfo.)
16208 @menu
16209 * Radio tables::                Sending and receiving radio tables
16210 * A @LaTeX{} example::          Step by step, almost a tutorial
16211 * Translator functions::        Copy and modify
16212 * Radio lists::                 Sending and receiving lists
16213 @end menu
16215 @node Radio tables, A @LaTeX{} example, Tables in arbitrary syntax, Tables in arbitrary syntax
16216 @subsection Radio tables
16217 @cindex radio tables
16219 To define the location of the target table, you first need to create two
16220 lines that are comments in the current mode, but contain magic words for
16221 Orgtbl mode to find.  Orgtbl mode will insert the translated table
16222 between these lines, replacing whatever was there before.  For example:
16224 @example
16225 /* BEGIN RECEIVE ORGTBL table_name */
16226 /* END RECEIVE ORGTBL table_name */
16227 @end example
16229 @noindent
16230 Just above the source table, we put a special line that tells
16231 Orgtbl mode how to translate this table and where to install it.  For
16232 example:
16233 @cindex #+ORGTBL
16234 @example
16235 #+ORGTBL: SEND table_name translation_function arguments....
16236 @end example
16238 @noindent
16239 @code{table_name} is the reference name for the table that is also used
16240 in the receiver lines.  @code{translation_function} is the Lisp function
16241 that does the translation.  Furthermore, the line can contain a list of
16242 arguments (alternating key and value) at the end.  The arguments will be
16243 passed as a property list to the translation function for
16244 interpretation.  A few standard parameters are already recognized and
16245 acted upon before the translation function is called:
16247 @table @code
16248 @item :skip N
16249 Skip the first N lines of the table.  Hlines do count as separate lines for
16250 this parameter!
16252 @item :skipcols (n1 n2 ...)
16253 List of columns that should be skipped.  If the table has a column with
16254 calculation marks, that column is automatically discarded as well.
16255 Please note that the translator function sees the table @emph{after} the
16256 removal of these columns, the function never knows that there have been
16257 additional columns.
16259 @item :no-escape t
16260 When non-nil, do not escape special characters @code{&%#_^} when exporting
16261 the table.  The default value is nil.
16262 @end table
16264 @noindent
16265 The one problem remaining is how to keep the source table in the buffer
16266 without disturbing the normal workings of the file, for example during
16267 compilation of a C file or processing of a @LaTeX{} file.  There are a
16268 number of different solutions:
16270 @itemize @bullet
16271 @item
16272 The table could be placed in a block comment if that is supported by the
16273 language.  For example, in C mode you could wrap the table between
16274 @samp{/*} and @samp{*/} lines.
16275 @item
16276 Sometimes it is possible to put the table after some kind of @i{END}
16277 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
16278 in @LaTeX{}.
16279 @item
16280 You can just comment the table line-by-line whenever you want to process
16281 the file, and uncomment it whenever you need to edit the table.  This
16282 only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment RET}
16283 makes this comment-toggling very easy, in particular if you bind it to a
16284 key.
16285 @end itemize
16287 @node A @LaTeX{} example, Translator functions, Radio tables, Tables in arbitrary syntax
16288 @subsection A @LaTeX{} example of radio tables
16289 @cindex @LaTeX{}, and Orgtbl mode
16291 The best way to wrap the source table in @LaTeX{} is to use the
16292 @code{comment} environment provided by @file{comment.sty}.  It has to be
16293 activated by placing @code{\usepackage@{comment@}} into the document
16294 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
16295 default this works only for @LaTeX{}, HTML, and Texinfo.  Configure the
16296 variable @code{orgtbl-radio-tables} to install templates for other
16297 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table RET}.  You will
16298 be prompted for a table name, let's say we use @samp{salesfigures}.  You
16299 will then get the following template:
16301 @cindex #+ORGTBL, SEND
16302 @example
16303 % BEGIN RECEIVE ORGTBL salesfigures
16304 % END RECEIVE ORGTBL salesfigures
16305 \begin@{comment@}
16306 #+ORGTBL: SEND salesfigures orgtbl-to-latex
16307 | | |
16308 \end@{comment@}
16309 @end example
16311 @noindent
16312 @vindex @LaTeX{}-verbatim-environments
16313 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
16314 @code{orgtbl-to-latex} to convert the table into @LaTeX{} and to put it
16315 into the receiver location with name @code{salesfigures}.  You may now
16316 fill in the table---feel free to use the spreadsheet features@footnote{If
16317 the @samp{#+TBLFM} line contains an odd number of dollar characters,
16318 this may cause problems with font-lock in @LaTeX{} mode.  As shown in the
16319 example you can fix this by adding an extra line inside the
16320 @code{comment} environment that is used to balance the dollar
16321 expressions.  If you are using AUC@TeX{} with the font-latex library, a
16322 much better solution is to add the @code{comment} environment to the
16323 variable @code{LaTeX-verbatim-environments}.}:
16325 @example
16326 % BEGIN RECEIVE ORGTBL salesfigures
16327 % END RECEIVE ORGTBL salesfigures
16328 \begin@{comment@}
16329 #+ORGTBL: SEND salesfigures orgtbl-to-latex
16330 | Month | Days | Nr sold | per day |
16331 |-------+------+---------+---------|
16332 | Jan   |   23 |      55 |     2.4 |
16333 | Feb   |   21 |      16 |     0.8 |
16334 | March |   22 |     278 |    12.6 |
16335 #+TBLFM: $4=$3/$2;%.1f
16336 % $ (optional extra dollar to keep font-lock happy, see footnote)
16337 \end@{comment@}
16338 @end example
16340 @noindent
16341 When you are done, press @kbd{C-c C-c} in the table to get the converted
16342 table inserted between the two marker lines.
16344 Now let's assume you want to make the table header by hand, because you
16345 want to control how columns are aligned, etc.  In this case we make sure
16346 that the table translator skips the first 2 lines of the source
16347 table, and tell the command to work as a @i{splice}, i.e., to not produce
16348 header and footer commands of the target table:
16350 @example
16351 \begin@{tabular@}@{lrrr@}
16352 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
16353 % BEGIN RECEIVE ORGTBL salesfigures
16354 % END RECEIVE ORGTBL salesfigures
16355 \end@{tabular@}
16357 \begin@{comment@}
16358 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
16359 | Month | Days | Nr sold | per day |
16360 |-------+------+---------+---------|
16361 | Jan   |   23 |      55 |     2.4 |
16362 | Feb   |   21 |      16 |     0.8 |
16363 | March |   22 |     278 |    12.6 |
16364 #+TBLFM: $4=$3/$2;%.1f
16365 \end@{comment@}
16366 @end example
16368 The @LaTeX{} translator function @code{orgtbl-to-latex} is already part of
16369 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
16370 and marks horizontal lines with @code{\hline}.  Furthermore, it
16371 interprets the following parameters (see also @pxref{Translator functions}):
16373 @table @code
16374 @item :splice nil/t
16375 When set to t, return only table body lines, don't wrap them into a
16376 tabular environment.  Default is nil.
16378 @item :fmt fmt
16379 A format to be used to wrap each field, it should contain @code{%s} for the
16380 original field value.  For example, to wrap each field value in dollars,
16381 you could use @code{:fmt "$%s$"}.  This may also be a property list with
16382 column numbers and formats, for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
16383 A function of one argument can be used in place of the strings; the
16384 function must return a formatted string.
16386 @item :efmt efmt
16387 Use this format to print numbers with exponentials.  The format should
16388 have @code{%s} twice for inserting mantissa and exponent, for example
16389 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
16390 may also be a property list with column numbers and formats, for example
16391 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
16392 @code{efmt} has been applied to a value, @code{fmt} will also be
16393 applied.  Similar to @code{fmt}, functions of two arguments can be
16394 supplied instead of strings.
16395 @end table
16397 @node Translator functions, Radio lists, A @LaTeX{} example, Tables in arbitrary syntax
16398 @subsection Translator functions
16399 @cindex HTML, and Orgtbl mode
16400 @cindex translator function
16402 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
16403 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
16404 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
16405 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
16406 code that produces tables during HTML export.}, these all use a generic
16407 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
16408 itself is a very short function that computes the column definitions for the
16409 @code{tabular} environment, defines a few field and line separators and then
16410 hands processing over to the generic translator.  Here is the entire code:
16412 @lisp
16413 @group
16414 (defun orgtbl-to-latex (table params)
16415   "Convert the Orgtbl mode TABLE to LaTeX."
16416   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
16417                                org-table-last-alignment ""))
16418          (params2
16419           (list
16420            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
16421            :tend "\\end@{tabular@}"
16422            :lstart "" :lend " \\\\" :sep " & "
16423            :efmt "%s\\,(%s)" :hline "\\hline")))
16424     (orgtbl-to-generic table (org-combine-plists params2 params))))
16425 @end group
16426 @end lisp
16428 As you can see, the properties passed into the function (variable
16429 @var{PARAMS}) are combined with the ones newly defined in the function
16430 (variable @var{PARAMS2}).  The ones passed into the function (i.e., the
16431 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
16432 would like to use the @LaTeX{} translator, but wanted the line endings to
16433 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
16434 overrule the default with
16436 @example
16437 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
16438 @end example
16440 For a new language, you can either write your own converter function in
16441 analogy with the @LaTeX{} translator, or you can use the generic function
16442 directly.  For example, if you have a language where a table is started
16443 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
16444 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
16445 separator is a TAB, you could call the generic translator like this (on
16446 a single line!):
16448 @example
16449 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
16450                               :lstart "!BL! " :lend " !EL!" :sep "\t"
16451 @end example
16453 @noindent
16454 Please check the documentation string of the function
16455 @code{orgtbl-to-generic} for a full list of parameters understood by
16456 that function, and remember that you can pass each of them into
16457 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
16458 using the generic function.
16460 Of course you can also write a completely new function doing complicated
16461 things the generic translator cannot do.  A translator function takes
16462 two arguments.  The first argument is the table, a list of lines, each
16463 line either the symbol @code{hline} or a list of fields.  The second
16464 argument is the property list containing all parameters specified in the
16465 @samp{#+ORGTBL: SEND} line.  The function must return a single string
16466 containing the formatted table.  If you write a generally useful
16467 translator, please post it on @email{emacs-orgmode@@gnu.org} so that
16468 others can benefit from your work.
16470 @node Radio lists,  , Translator functions, Tables in arbitrary syntax
16471 @subsection Radio lists
16472 @cindex radio lists
16473 @cindex org-list-insert-radio-list
16475 Sending and receiving radio lists works exactly the same way as sending and
16476 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
16477 insert radio list templates in HTML, @LaTeX{} and Texinfo modes by calling
16478 @code{org-list-insert-radio-list}.
16480 Here are the differences with radio tables:
16482 @itemize @minus
16483 @item
16484 Orgstruct mode must be active.
16485 @item
16486 Use the @code{ORGLST} keyword instead of @code{ORGTBL}.
16487 @item
16488 The available translation functions for radio lists don't take
16489 parameters.
16490 @item
16491 @kbd{C-c C-c} will work when pressed on the first item of the list.
16492 @end itemize
16494 Here is a @LaTeX{} example.  Let's say that you have this in your
16495 @LaTeX{} file:
16497 @cindex #+ORGLST
16498 @example
16499 % BEGIN RECEIVE ORGLST to-buy
16500 % END RECEIVE ORGLST to-buy
16501 \begin@{comment@}
16502 #+ORGLST: SEND to-buy org-list-to-latex
16503 - a new house
16504 - a new computer
16505   + a new keyboard
16506   + a new mouse
16507 - a new life
16508 \end@{comment@}
16509 @end example
16511 Pressing @kbd{C-c C-c} on @code{a new house} and will insert the converted
16512 @LaTeX{} list between the two marker lines.
16514 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
16515 @section Dynamic blocks
16516 @cindex dynamic blocks
16518 Org documents can contain @emph{dynamic blocks}.  These are
16519 specially marked regions that are updated by some user-written function.
16520 A good example for such a block is the clock table inserted by the
16521 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
16523 Dynamic blocks are enclosed by a BEGIN-END structure that assigns a name
16524 to the block and can also specify parameters for the function producing
16525 the content of the block.
16527 @cindex #+BEGIN:dynamic block
16528 @example
16529 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
16531 #+END:
16532 @end example
16534 Dynamic blocks are updated with the following commands
16536 @table @kbd
16537 @orgcmd{C-c C-x C-u,org-dblock-update}
16538 Update dynamic block at point.
16539 @orgkey{C-u C-c C-x C-u}
16540 Update all dynamic blocks in the current file.
16541 @end table
16543 Updating a dynamic block means to remove all the text between BEGIN and
16544 END, parse the BEGIN line for parameters and then call the specific
16545 writer function for this block to insert the new content.  If you want
16546 to use the original content in the writer function, you can use the
16547 extra parameter @code{:content}.
16549 For a block with name @code{myblock}, the writer function is
16550 @code{org-dblock-write:myblock} with as only parameter a property list
16551 with the parameters given in the begin line.  Here is a trivial example
16552 of a block that keeps track of when the block update function was last
16553 run:
16555 @example
16556 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
16558 #+END:
16559 @end example
16561 @noindent
16562 The corresponding block writer function could look like this:
16564 @lisp
16565 (defun org-dblock-write:block-update-time (params)
16566   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
16567     (insert "Last block update at: "
16568             (format-time-string fmt (current-time)))))
16569 @end lisp
16571 If you want to make sure that all dynamic blocks are always up-to-date,
16572 you could add the function @code{org-update-all-dblocks} to a hook, for
16573 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
16574 written in a way such that it does nothing in buffers that are not in
16575 @code{org-mode}.
16577 You can narrow the current buffer to the current dynamic block (like any
16578 other block) with @code{org-narrow-to-block}.
16580 @node Special agenda views, Speeding up your agendas, Dynamic blocks, Hacking
16581 @section Special agenda views
16582 @cindex agenda views, user-defined
16584 @vindex org-agenda-skip-function
16585 @vindex org-agenda-skip-function-global
16586 Org provides a special hook that can be used to narrow down the selection
16587 made by these agenda views: @code{agenda}, @code{agenda*}@footnote{The
16588 @code{agenda*} view is the same than @code{agenda} except that it only
16589 considers @emph{appointments}, i.e., scheduled and deadline items that have a
16590 time specification @code{[h]h:mm} in their time-stamps.}, @code{todo},
16591 @code{alltodo}, @code{tags}, @code{tags-todo}, @code{tags-tree}.  You may
16592 specify a function that is used at each match to verify if the match should
16593 indeed be part of the agenda view, and if not, how much should be skipped.
16594 You can specify a global condition that will be applied to all agenda views,
16595 this condition would be stored in the variable
16596 @code{org-agenda-skip-function-global}.  More commonly, such a definition is
16597 applied only to specific custom searches, using
16598 @code{org-agenda-skip-function}.
16600 Let's say you want to produce a list of projects that contain a WAITING
16601 tag anywhere in the project tree.  Let's further assume that you have
16602 marked all tree headings that define a project with the TODO keyword
16603 PROJECT@.  In this case you would run a TODO search for the keyword
16604 PROJECT, but skip the match unless there is a WAITING tag anywhere in
16605 the subtree belonging to the project line.
16607 To achieve this, you must write a function that searches the subtree for
16608 the tag.  If the tag is found, the function must return @code{nil} to
16609 indicate that this match should not be skipped.  If there is no such
16610 tag, return the location of the end of the subtree, to indicate that
16611 search should continue from there.
16613 @lisp
16614 (defun my-skip-unless-waiting ()
16615   "Skip trees that are not waiting"
16616   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
16617     (if (re-search-forward ":waiting:" subtree-end t)
16618         nil          ; tag found, do not skip
16619       subtree-end))) ; tag not found, continue after end of subtree
16620 @end lisp
16622 Now you may use this function in an agenda custom command, for example
16623 like this:
16625 @lisp
16626 (org-add-agenda-custom-command
16627  '("b" todo "PROJECT"
16628    ((org-agenda-skip-function 'my-skip-unless-waiting)
16629     (org-agenda-overriding-header "Projects waiting for something: "))))
16630 @end lisp
16632 @vindex org-agenda-overriding-header
16633 Note that this also binds @code{org-agenda-overriding-header} to get a
16634 meaningful header in the agenda view.
16636 @vindex org-odd-levels-only
16637 @vindex org-agenda-skip-function
16638 A general way to create custom searches is to base them on a search for
16639 entries with a certain level limit.  If you want to study all entries with
16640 your custom search function, simply do a search for
16641 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
16642 level number corresponds to order in the hierarchy, not to the number of
16643 stars.}, and then use @code{org-agenda-skip-function} to select the entries
16644 you really want to have.
16646 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
16647 particular, you may use the functions @code{org-agenda-skip-entry-if}
16648 and @code{org-agenda-skip-subtree-if} in this form, for example:
16650 @table @code
16651 @item (org-agenda-skip-entry-if 'scheduled)
16652 Skip current entry if it has been scheduled.
16653 @item (org-agenda-skip-entry-if 'notscheduled)
16654 Skip current entry if it has not been scheduled.
16655 @item (org-agenda-skip-entry-if 'deadline)
16656 Skip current entry if it has a deadline.
16657 @item (org-agenda-skip-entry-if 'scheduled 'deadline)
16658 Skip current entry if it has a deadline, or if it is scheduled.
16659 @item (org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))
16660 Skip current entry if the TODO keyword is TODO or WAITING.
16661 @item (org-agenda-skip-entry-if 'todo 'done)
16662 Skip current entry if the TODO keyword marks a DONE state.
16663 @item (org-agenda-skip-entry-if 'timestamp)
16664 Skip current entry if it has any timestamp, may also be deadline or scheduled.
16665 @anchor{x-agenda-skip-entry-regexp}
16666 @item (org-agenda-skip-entry-if 'regexp "regular expression")
16667 Skip current entry if the regular expression matches in the entry.
16668 @item (org-agenda-skip-entry-if 'notregexp "regular expression")
16669 Skip current entry unless the regular expression matches.
16670 @item (org-agenda-skip-subtree-if 'regexp "regular expression")
16671 Same as above, but check and skip the entire subtree.
16672 @end table
16674 Therefore we could also have written the search for WAITING projects
16675 like this, even without defining a special function:
16677 @lisp
16678 (org-add-agenda-custom-command
16679  '("b" todo "PROJECT"
16680    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
16681                                 'regexp ":waiting:"))
16682     (org-agenda-overriding-header "Projects waiting for something: "))))
16683 @end lisp
16685 @node Speeding up your agendas, Extracting agenda information, Special agenda views, Hacking
16686 @section Speeding up your agendas
16687 @cindex agenda views, optimization
16689 When your Org files grow in both number and size, agenda commands may start
16690 to become slow.  Below are some tips on how to speed up the agenda commands.
16692 @enumerate
16693 @item
16694 Reduce the number of Org agenda files: this will reduce the slowliness caused
16695 by accessing to a hard drive.
16696 @item
16697 Reduce the number of DONE and archived headlines: this way the agenda does
16698 not need to skip them.
16699 @item
16700 @vindex org-agenda-dim-blocked-tasks
16701 Inhibit the dimming of blocked tasks:
16702 @lisp
16703 (setq org-agenda-dim-blocked-tasks nil)
16704 @end lisp
16705 @item
16706 @vindex org-startup-folded
16707 @vindex org-agenda-inhibit-startup
16708 Inhibit agenda files startup options:
16709 @lisp
16710 (setq org-agenda-inhibit-startup nil)
16711 @end lisp
16712 @item
16713 @vindex org-agenda-show-inherited-tags
16714 @vindex org-agenda-use-tag-inheritance
16715 Disable tag inheritance in agenda:
16716 @lisp
16717 (setq org-agenda-use-tag-inheritance nil)
16718 @end lisp
16719 @end enumerate
16721 You can set these options for specific agenda views only.  See the docstrings
16722 of these variables for details on why they affect the agenda generation, and
16723 this @uref{http://orgmode.org/worg/agenda-optimization.html, dedicated Worg
16724 page} for further explanations.
16726 @node Extracting agenda information, Using the property API, Speeding up your agendas, Hacking
16727 @section Extracting agenda information
16728 @cindex agenda, pipe
16729 @cindex Scripts, for agenda processing
16731 @vindex org-agenda-custom-commands
16732 Org provides commands to access agenda information for the command
16733 line in Emacs batch mode.  This extracted information can be sent
16734 directly to a printer, or it can be read by a program that does further
16735 processing of the data.  The first of these commands is the function
16736 @code{org-batch-agenda}, that produces an agenda view and sends it as
16737 ASCII text to STDOUT@.  The command takes a single string as parameter.
16738 If the string has length 1, it is used as a key to one of the commands
16739 you have configured in @code{org-agenda-custom-commands}, basically any
16740 key you can use after @kbd{C-c a}.  For example, to directly print the
16741 current TODO list, you could use
16743 @example
16744 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
16745 @end example
16747 If the parameter is a string with 2 or more characters, it is used as a
16748 tags/TODO match string.  For example, to print your local shopping list
16749 (all items with the tag @samp{shop}, but excluding the tag
16750 @samp{NewYork}), you could use
16752 @example
16753 emacs -batch -l ~/.emacs                                      \
16754       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
16755 @end example
16757 @noindent
16758 You may also modify parameters on the fly like this:
16760 @example
16761 emacs -batch -l ~/.emacs                                      \
16762    -eval '(org-batch-agenda "a"                               \
16763             org-agenda-span (quote month)                     \
16764             org-agenda-include-diary nil                      \
16765             org-agenda-files (quote ("~/org/project.org")))'  \
16766    | lpr
16767 @end example
16769 @noindent
16770 which will produce a 30-day agenda, fully restricted to the Org file
16771 @file{~/org/projects.org}, not even including the diary.
16773 If you want to process the agenda data in more sophisticated ways, you
16774 can use the command @code{org-batch-agenda-csv} to get a comma-separated
16775 list of values for each agenda item.  Each line in the output will
16776 contain a number of fields separated by commas.  The fields in a line
16777 are:
16779 @example
16780 category     @r{The category of the item}
16781 head         @r{The headline, without TODO keyword, TAGS and PRIORITY}
16782 type         @r{The type of the agenda entry, can be}
16783                 todo               @r{selected in TODO match}
16784                 tagsmatch          @r{selected in tags match}
16785                 diary              @r{imported from diary}
16786                 deadline           @r{a deadline}
16787                 scheduled          @r{scheduled}
16788                 timestamp          @r{appointment, selected by timestamp}
16789                 closed             @r{entry was closed on date}
16790                 upcoming-deadline  @r{warning about nearing deadline}
16791                 past-scheduled     @r{forwarded scheduled item}
16792                 block              @r{entry has date block including date}
16793 todo         @r{The TODO keyword, if any}
16794 tags         @r{All tags including inherited ones, separated by colons}
16795 date         @r{The relevant date, like 2007-2-14}
16796 time         @r{The time, like 15:00-16:50}
16797 extra        @r{String with extra planning info}
16798 priority-l   @r{The priority letter if any was given}
16799 priority-n   @r{The computed numerical priority}
16800 @end example
16802 @noindent
16803 Time and date will only be given if a timestamp (or deadline/scheduled)
16804 led to the selection of the item.
16806 A CSV list like this is very easy to use in a post-processing script.
16807 For example, here is a Perl program that gets the TODO list from
16808 Emacs/Org and prints all the items, preceded by a checkbox:
16810 @example
16811 #!/usr/bin/perl
16813 # define the Emacs command to run
16814 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
16816 # run it and capture the output
16817 $agenda = qx@{$cmd 2>/dev/null@};
16819 # loop over all lines
16820 foreach $line (split(/\n/,$agenda)) @{
16821   # get the individual values
16822   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
16823    $priority_l,$priority_n) = split(/,/,$line);
16824   # process and print
16825   print "[ ] $head\n";
16827 @end example
16829 @node Using the property API, Using the mapping API, Extracting agenda information, Hacking
16830 @section Using the property API
16831 @cindex API, for properties
16832 @cindex properties, API
16834 Here is a description of the functions that can be used to work with
16835 properties.
16837 @defun org-entry-properties &optional pom which
16838 Get all properties of the entry at point-or-marker POM.@*
16839 This includes the TODO keyword, the tags, time strings for deadline,
16840 scheduled, and clocking, and any additional properties defined in the
16841 entry.  The return value is an alist.  Keys may occur multiple times
16842 if the property key was used several times.@*
16843 POM may also be nil, in which case the current entry is used.
16844 If WHICH is nil or `all', get all properties.  If WHICH is
16845 `special' or `standard', only get that subclass.
16846 @end defun
16847 @vindex org-use-property-inheritance
16848 @findex org-insert-property-drawer
16849 @defun org-entry-get pom property &optional inherit
16850 Get value of PROPERTY for entry at point-or-marker POM@.  By default,
16851 this only looks at properties defined locally in the entry.  If INHERIT
16852 is non-nil and the entry does not have the property, then also check
16853 higher levels of the hierarchy.  If INHERIT is the symbol
16854 @code{selective}, use inheritance if and only if the setting of
16855 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
16856 @end defun
16858 @defun org-entry-delete pom property
16859 Delete the property PROPERTY from entry at point-or-marker POM.
16860 @end defun
16862 @defun org-entry-put pom property value
16863 Set PROPERTY to VALUE for entry at point-or-marker POM.
16864 @end defun
16866 @defun org-buffer-property-keys &optional include-specials
16867 Get all property keys in the current buffer.
16868 @end defun
16870 @defun org-insert-property-drawer
16871 Insert a property drawer for the current entry.  Also
16872 @end defun
16874 @defun org-entry-put-multivalued-property pom property &rest values
16875 Set PROPERTY at point-or-marker POM to VALUES@.  VALUES should be a list of
16876 strings.  They will be concatenated, with spaces as separators.
16877 @end defun
16879 @defun org-entry-get-multivalued-property pom property
16880 Treat the value of the property PROPERTY as a whitespace-separated list of
16881 values and return the values as a list of strings.
16882 @end defun
16884 @defun org-entry-add-to-multivalued-property pom property value
16885 Treat the value of the property PROPERTY as a whitespace-separated list of
16886 values and make sure that VALUE is in this list.
16887 @end defun
16889 @defun org-entry-remove-from-multivalued-property pom property value
16890 Treat the value of the property PROPERTY as a whitespace-separated list of
16891 values and make sure that VALUE is @emph{not} in this list.
16892 @end defun
16894 @defun org-entry-member-in-multivalued-property pom property value
16895 Treat the value of the property PROPERTY as a whitespace-separated list of
16896 values and check if VALUE is in this list.
16897 @end defun
16899 @defopt org-property-allowed-value-functions
16900 Hook for functions supplying allowed values for a specific property.
16901 The functions must take a single argument, the name of the property, and
16902 return a flat list of allowed values.  If @samp{:ETC} is one of
16903 the values, use the values as completion help, but allow also other values
16904 to be entered.  The functions must return @code{nil} if they are not
16905 responsible for this property.
16906 @end defopt
16908 @node Using the mapping API,  , Using the property API, Hacking
16909 @section Using the mapping API
16910 @cindex API, for mapping
16911 @cindex mapping entries, API
16913 Org has sophisticated mapping capabilities to find all entries satisfying
16914 certain criteria.  Internally, this functionality is used to produce agenda
16915 views, but there is also an API that can be used to execute arbitrary
16916 functions for each or selected entries.  The main entry point for this API
16919 @defun org-map-entries func &optional match scope &rest skip
16920 Call FUNC at each headline selected by MATCH in SCOPE.
16922 FUNC is a function or a Lisp form.  The function will be called without
16923 arguments, with the cursor positioned at the beginning of the headline.
16924 The return values of all calls to the function will be collected and
16925 returned as a list.
16927 The call to FUNC will be wrapped into a save-excursion form, so FUNC
16928 does not need to preserve point.  After evaluation, the cursor will be
16929 moved to the end of the line (presumably of the headline of the
16930 processed entry) and search continues from there.  Under some
16931 circumstances, this may not produce the wanted results.  For example,
16932 if you have removed (e.g., archived) the current (sub)tree it could
16933 mean that the next entry will be skipped entirely.  In such cases, you
16934 can specify the position from where search should continue by making
16935 FUNC set the variable `org-map-continue-from' to the desired buffer
16936 position.
16938 MATCH is a tags/property/todo match as it is used in the agenda match view.
16939 Only headlines that are matched by this query will be considered during
16940 the iteration.  When MATCH is nil or t, all headlines will be
16941 visited by the iteration.
16943 SCOPE determines the scope of this command.  It can be any of:
16945 @example
16946 nil     @r{the current buffer, respecting the restriction if any}
16947 tree    @r{the subtree started with the entry at point}
16948 region  @r{The entries within the active region, if any}
16949 file    @r{the current buffer, without restriction}
16950 file-with-archives
16951         @r{the current buffer, and any archives associated with it}
16952 agenda  @r{all agenda files}
16953 agenda-with-archives
16954         @r{all agenda files with any archive files associated with them}
16955 (file1 file2 ...)
16956         @r{if this is a list, all files in the list will be scanned}
16957 @end example
16958 @noindent
16959 The remaining args are treated as settings for the skipping facilities of
16960 the scanner.  The following items can be given here:
16962 @vindex org-agenda-skip-function
16963 @example
16964 archive   @r{skip trees with the archive tag}
16965 comment   @r{skip trees with the COMMENT keyword}
16966 function or Lisp form
16967           @r{will be used as value for @code{org-agenda-skip-function},}
16968           @r{so whenever the function returns t, FUNC}
16969           @r{will not be called for that entry and search will}
16970           @r{continue from the point where the function leaves it}
16971 @end example
16972 @end defun
16974 The function given to that mapping routine can really do anything you like.
16975 It can use the property API (@pxref{Using the property API}) to gather more
16976 information about the entry, or in order to change metadata in the entry.
16977 Here are a couple of functions that might be handy:
16979 @defun org-todo &optional arg
16980 Change the TODO state of the entry.  See the docstring of the functions for
16981 the many possible values for the argument ARG.
16982 @end defun
16984 @defun org-priority &optional action
16985 Change the priority of the entry.  See the docstring of this function for the
16986 possible values for ACTION.
16987 @end defun
16989 @defun org-toggle-tag tag &optional onoff
16990 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
16991 or @code{off} will not toggle tag, but ensure that it is either on or off.
16992 @end defun
16994 @defun org-promote
16995 Promote the current entry.
16996 @end defun
16998 @defun org-demote
16999 Demote the current entry.
17000 @end defun
17002 Here is a simple example that will turn all entries in the current file with
17003 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
17004 Entries in comment trees and in archive trees will be ignored.
17006 @lisp
17007 (org-map-entries
17008  '(org-todo "UPCOMING")
17009  "+TOMORROW" 'file 'archive 'comment)
17010 @end lisp
17012 The following example counts the number of entries with TODO keyword
17013 @code{WAITING}, in all agenda files.
17015 @lisp
17016 (length (org-map-entries t "/+WAITING" 'agenda))
17017 @end lisp
17019 @node MobileOrg, History and Acknowledgments, Hacking, Top
17020 @appendix MobileOrg
17021 @cindex iPhone
17022 @cindex MobileOrg
17024 @i{MobileOrg} is the name of the mobile companion app for Org mode, currently
17025 available for iOS and for Android.  @i{MobileOrg} offers offline viewing and
17026 capture support for an Org mode system rooted on a ``real'' computer.  It
17027 does also allow you to record changes to existing entries.
17028 The @uref{http://mobileorg.ncogni.to/, iOS implementation} for the
17029 @i{iPhone/iPod Touch/iPad} series of devices, was developed by Richard
17030 Moreland.  Android users should check out
17031 @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android}
17032 by Matt Jones.  The two implementations are not identical but offer similar
17033 features.
17035 This appendix describes the support Org has for creating agenda views in a
17036 format that can be displayed by @i{MobileOrg}, and for integrating notes
17037 captured and changes made by @i{MobileOrg} into the main system.
17039 For changing tags and TODO states in MobileOrg, you should have set up the
17040 customization variables @code{org-todo-keywords} and @code{org-tags-alist} to
17041 cover all important tags and TODO keywords, even if individual files use only
17042 part of these.  MobileOrg will also offer you states and tags set up with
17043 in-buffer settings, but it will understand the logistics of TODO state
17044 @i{sets} (@pxref{Per-file keywords}) and @i{mutually exclusive} tags
17045 (@pxref{Setting tags}) only for those set in these variables.
17047 @menu
17048 * Setting up the staging area::  Where to interact with the mobile device
17049 * Pushing to MobileOrg::        Uploading Org files and agendas
17050 * Pulling from MobileOrg::      Integrating captured and flagged items
17051 @end menu
17053 @node Setting up the staging area, Pushing to MobileOrg, MobileOrg, MobileOrg
17054 @section Setting up the staging area
17056 MobileOrg needs to interact with Emacs through a directory on a server.  If you
17057 are using a public server, you should consider to encrypt the files that are
17058 uploaded to the server.  This can be done with Org mode 7.02 and with
17059 @i{MobileOrg 1.5} (iPhone version), and you need an @file{openssl}
17060 installation on your system.  To turn on encryption, set a password in
17061 @i{MobileOrg} and, on the Emacs side, configure the variable
17062 @code{org-mobile-use-encryption}@footnote{If you can safely store the
17063 password in your Emacs setup, you might also want to configure
17064 @code{org-mobile-encryption-password}.  Please read the docstring of that
17065 variable.  Note that encryption will apply only to the contents of the
17066 @file{.org} files.  The file names themselves will remain visible.}.
17068 The easiest way to create that directory is to use a free
17069 @uref{http://dropbox.com,Dropbox.com} account@footnote{If you cannot use
17070 Dropbox, or if your version of MobileOrg does not support it, you can use a
17071 webdav server.  For more information, check out the documentation of MobileOrg and also this
17072 @uref{http://orgmode.org/worg/org-faq.html#mobileorg_webdav, FAQ entry}.}.
17073 When MobileOrg first connects to your Dropbox, it will create a directory
17074 @i{MobileOrg} inside the Dropbox.  After the directory has been created, tell
17075 Emacs about it:
17077 @lisp
17078 (setq org-mobile-directory "~/Dropbox/MobileOrg")
17079 @end lisp
17081 Org mode has commands to put files for @i{MobileOrg} into that directory,
17082 and to read captured notes from there.
17084 @node Pushing to MobileOrg, Pulling from MobileOrg, Setting up the staging area, MobileOrg
17085 @section Pushing to MobileOrg
17087 This operation copies all files currently listed in @code{org-mobile-files}
17088 to the directory @code{org-mobile-directory}.  By default this list contains
17089 all agenda files (as listed in @code{org-agenda-files}), but additional files
17090 can be included by customizing @code{org-mobile-files}.  File names will be
17091 staged with paths relative to @code{org-directory}, so all files should be
17092 inside this directory@footnote{Symbolic links in @code{org-directory} need to
17093 have the same name than their targets.}.
17095 The push operation also creates a special Org file @file{agendas.org} with
17096 all custom agenda view defined by the user@footnote{While creating the
17097 agendas, Org mode will force ID properties on all referenced entries, so that
17098 these entries can be uniquely identified if @i{MobileOrg} flags them for
17099 further action.  If you do not want to get these properties in so many
17100 entries, you can set the variable @code{org-mobile-force-id-on-agenda-items}
17101 to @code{nil}.  Org mode will then rely on outline paths, in the hope that
17102 these will be unique enough.}.
17104 Finally, Org writes the file @file{index.org}, containing links to all other
17105 files.  @i{MobileOrg} first reads this file from the server, and then
17106 downloads all agendas and Org files listed in it.  To speed up the download,
17107 MobileOrg will only read files whose checksums@footnote{Checksums are stored
17108 automatically in the file @file{checksums.dat}} have changed.
17110 @node Pulling from MobileOrg,  , Pushing to MobileOrg, MobileOrg
17111 @section Pulling from MobileOrg
17113 When @i{MobileOrg} synchronizes with the server, it not only pulls the Org
17114 files for viewing.  It also appends captured entries and pointers to flagged
17115 and changed entries to the file @file{mobileorg.org} on the server.  Org has
17116 a @emph{pull} operation that integrates this information into an inbox file
17117 and operates on the pointers to flagged entries.  Here is how it works:
17119 @enumerate
17120 @item
17121 Org moves all entries found in
17122 @file{mobileorg.org}@footnote{@file{mobileorg.org} will be empty after this
17123 operation.} and appends them to the file pointed to by the variable
17124 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing event
17125 will be a top-level entry in the inbox file.
17126 @item
17127 After moving the entries, Org will attempt to implement the changes made in
17128 @i{MobileOrg}.  Some changes are applied directly and without user
17129 interaction.  Examples are all changes to tags, TODO state, headline and body
17130 text that can be cleanly applied.  Entries that have been flagged for further
17131 action will receive a tag @code{:FLAGGED:}, so that they can be easily found
17132 again.  When there is a problem finding an entry or applying the change, the
17133 pointer entry will remain in the inbox and will be marked with an error
17134 message.  You need to later resolve these issues by hand.
17135 @item
17136 Org will then generate an agenda view with all flagged entries.  The user
17137 should then go through these entries and do whatever actions are necessary.
17138 If a note has been stored while flagging an entry in @i{MobileOrg}, that note
17139 will be displayed in the echo area when the cursor is on the corresponding
17140 agenda line.
17142 @table @kbd
17143 @kindex ?
17144 @item ?
17145 Pressing @kbd{?} in that special agenda will display the full flagging note in
17146 another window and also push it onto the kill ring.  So you could use @kbd{?
17147 z C-y C-c C-c} to store that flagging note as a normal note in the entry.
17148 Pressing @kbd{?} twice in succession will offer to remove the
17149 @code{:FLAGGED:} tag along with the recorded flagging note (which is stored
17150 in a property).  In this way you indicate that the intended processing for
17151 this flagged entry is finished.
17152 @end table
17153 @end enumerate
17155 @kindex C-c a ?
17156 If you are not able to process all flagged entries directly, you can always
17157 return to this agenda view@footnote{Note, however, that there is a subtle
17158 difference.  The view created automatically by @kbd{M-x org-mobile-pull RET}
17159 is guaranteed to search all files that have been addressed by the last pull.
17160 This might include a file that is not currently in your list of agenda files.
17161 If you later use @kbd{C-c a ?} to regenerate the view, only the current
17162 agenda files will be searched.} using @kbd{C-c a ?}.
17164 @node History and Acknowledgments, GNU Free Documentation License, MobileOrg, Top
17165 @appendix History and acknowledgments
17166 @cindex acknowledgments
17167 @cindex history
17168 @cindex thanks
17170 @section From Carsten
17172 Org was born in 2003, out of frustration over the user interface of the Emacs
17173 Outline mode.  I was trying to organize my notes and projects, and using
17174 Emacs seemed to be the natural way to go.  However, having to remember eleven
17175 different commands with two or three keys per command, only to hide and show
17176 parts of the outline tree, that seemed entirely unacceptable to me.  Also,
17177 when using outlines to take notes, I constantly wanted to restructure the
17178 tree, organizing it parallel to my thoughts and plans.  @emph{Visibility
17179 cycling} and @emph{structure editing} were originally implemented in the
17180 package @file{outline-magic.el}, but quickly moved to the more general
17181 @file{org.el}.  As this environment became comfortable for project planning,
17182 the next step was adding @emph{TODO entries}, basic @emph{timestamps}, and
17183 @emph{table support}.  These areas highlighted the two main goals that Org
17184 still has today: to be a new, outline-based, plain text mode with innovative
17185 and intuitive editing features, and to incorporate project planning
17186 functionality directly into a notes file.
17188 Since the first release, literally thousands of emails to me or to
17189 @email{emacs-orgmode@@gnu.org} have provided a constant stream of bug
17190 reports, feedback, new ideas, and sometimes patches and add-on code.
17191 Many thanks to everyone who has helped to improve this package.  I am
17192 trying to keep here a list of the people who had significant influence
17193 in shaping one or more aspects of Org.  The list may not be
17194 complete, if I have forgotten someone, please accept my apologies and
17195 let me know.
17197 Before I get to this list, a few special mentions are in order:
17199 @table @i
17200 @item Bastien Guerry
17201 Bastien has written a large number of extensions to Org (most of them
17202 integrated into the core by now), including the @LaTeX{} exporter and the plain
17203 list parser.  His support during the early days, when he basically acted as
17204 co-maintainer, was central to the success of this project.  Bastien also
17205 invented Worg, helped establishing the Web presence of Org, and sponsored
17206 hosting costs for the orgmode.org website.
17207 @item Eric Schulte and Dan Davison
17208 Eric and Dan are jointly responsible for the Org-babel system, which turns
17209 Org into a multi-language environment for evaluating code and doing literate
17210 programming and reproducible research.
17211 @item John Wiegley
17212 John has contributed a number of great ideas and patches directly to Org,
17213 including the attachment system (@file{org-attach.el}), integration with
17214 Apple Mail (@file{org-mac-message.el}), hierarchical dependencies of TODO
17215 items, habit tracking (@file{org-habits.el}), and encryption
17216 (@file{org-crypt.el}).  Also, the capture system is really an extended copy
17217 of his great @file{remember.el}.
17218 @item Sebastian Rose
17219 Without Sebastian, the HTML/XHTML publishing of Org would be the pitiful work
17220 of an ignorant amateur.  Sebastian has pushed this part of Org onto a much
17221 higher level.  He also wrote @file{org-info.js}, a Java script for displaying
17222 web pages derived from Org using an Info-like or a folding interface with
17223 single-key navigation.
17224 @end table
17226 @noindent See below for the full list of contributions!  Again, please
17227 let me know what I am missing here!
17229 @section From Bastien
17231 I (Bastien) have been maintaining Org since January 2011.  This appendix
17232 would not be complete without adding a few more acknowledgements and thanks
17233 to Carsten's ones above.
17235 I am first grateful to Carsten for his trust while handing me over the
17236 maintainership of Org.  His support as been great since day one of this new
17237 adventure, and it helped a lot.
17239 When I took over maintainership, I knew I would have to make Org more
17240 collaborative than ever, as I would have to rely on people that are more
17241 knowledgeable than I am on many parts of the code.  Here is a list of the
17242 persons I could rely on, they should really be considered co-maintainers,
17243 either of the code or the community:
17245 @table @i
17246 @item Eric Schulte
17247 Eric is maintaining the Babel parts of Org.  His reactivity here kept me away
17248 from worrying about possible bugs here and let me focus on other parts.
17250 @item Nicolas Goaziou
17251 Nicolas is maintaining the consistency of the deepest parts of Org.  His
17252 work on @file{org-element.el} and @file{ox.el} has been outstanding, and
17253 opened the doors for many new ideas and features.  He rewrote many of the
17254 old exporters to use the new export engine, and helped with documenting
17255 this major change.  More importantly (if that's possible), he has been more
17256 than reliable during all the work done for Org 8.0, and always very
17257 reactive on the mailing list.
17259 @item Achim Gratz
17260 Achim rewrote the building process of Org, turning some @emph{ad hoc} tools
17261 into a flexible and conceptually clean process.  He patiently coped with the
17262 many hiccups that such a change can create for users.
17264 @item Nick Dokos
17265 The Org mode mailing list would not be such a nice place without Nick, who
17266 patiently helped users so many times.  It is impossible to overestimate such
17267 a great help, and the list would not be so active without him.
17268 @end table
17270 I received support from so many users that it is clearly impossible to be
17271 fair when shortlisting a few of them, but Org's history would not be
17272 complete if the ones above were not mentioned in this manual.
17274 @section List of contributions
17276 @itemize @bullet
17278 @item
17279 @i{Russel Adams} came up with the idea for drawers.
17280 @item
17281 @i{Suvayu Ali} has steadily helped on the mailing list, providing useful
17282 feedback on many features and several patches.
17283 @item
17284 @i{Luis Anaya} wrote @file{ox-man.el}.
17285 @item
17286 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
17287 @item
17288 @i{Michael Brand} helped by reporting many bugs and testing many features.
17289 He also implemented the distinction between empty fields and 0-value fields
17290 in Org's spreadsheets.
17291 @item
17292 @i{Christophe Bataillon} created the great unicorn logo that we use on the
17293 Org mode website.
17294 @item
17295 @i{Alex Bochannek} provided a patch for rounding timestamps.
17296 @item
17297 @i{Jan Böcker} wrote @file{org-docview.el}.
17298 @item
17299 @i{Brad Bozarth} showed how to pull RSS feed data into Org mode files.
17300 @item
17301 @i{Tom Breton} wrote @file{org-choose.el}.
17302 @item
17303 @i{Charles Cave}'s suggestion sparked the implementation of templates
17304 for Remember, which are now templates for capture.
17305 @item
17306 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
17307 specified time.
17308 @item
17309 @i{Gregory Chernov} patched support for Lisp forms into table
17310 calculations and improved XEmacs compatibility, in particular by porting
17311 @file{nouline.el} to XEmacs.
17312 @item
17313 @i{Sacha Chua} suggested copying some linking code from Planner.
17314 @item
17315 @i{Toby S. Cubitt} contributed to the code for clock formats.
17316 @item
17317 @i{Baoqiu Cui} contributed the DocBook exporter.  It has been deleted from
17318 Org 8.0: you can now export to Texinfo and export the @code{.texi} file to
17319 DocBook using @code{makeinfo}.
17320 @item
17321 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
17322 came up with the idea of properties, and that there should be an API for
17323 them.
17324 @item
17325 @i{Nick Dokos} tracked down several nasty bugs.
17326 @item
17327 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
17328 inspired some of the early development, including HTML export.  He also
17329 asked for a way to narrow wide table columns.
17330 @item
17331 @i{Thomas S. Dye} contributed documentation on Worg and helped integrating
17332 the Org-Babel documentation into the manual.
17333 @item
17334 @i{Christian Egli} converted the documentation into Texinfo format, inspired
17335 the agenda, patched CSS formatting into the HTML exporter, and wrote
17336 @file{org-taskjuggler.el}, which has been rewritten by Nicolas Goaziou as
17337 @file{ox-taskjuggler.el} for Org 8.0.
17338 @item
17339 @i{David Emery} provided a patch for custom CSS support in exported
17340 HTML agendas.
17341 @item
17342 @i{Nic Ferrier} contributed mailcap and XOXO support.
17343 @item
17344 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
17345 @item
17346 @i{John Foerch} figured out how to make incremental search show context
17347 around a match in a hidden outline tree.
17348 @item
17349 @i{Raimar Finken} wrote @file{org-git-line.el}.
17350 @item
17351 @i{Mikael Fornius} works as a mailing list moderator.
17352 @item
17353 @i{Austin Frank} works as a mailing list moderator.
17354 @item
17355 @i{Eric Fraga} drove the development of BEAMER export with ideas and
17356 testing.
17357 @item
17358 @i{Barry Gidden} did proofreading the manual in preparation for the book
17359 publication through Network Theory Ltd.
17360 @item
17361 @i{Niels Giesen} had the idea to automatically archive DONE trees.
17362 @item
17363 @i{Nicolas Goaziou} rewrote much of the plain list code.  He also wrote
17364 @file{org-element.el} and @file{org-export.el}, which was a huge step forward
17365 in implementing a clean framework for Org exporters.
17366 @item
17367 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
17368 @item
17369 @i{Brian Gough} of Network Theory Ltd publishes the Org mode manual as a
17370 book.
17371 @item
17372 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
17373 task state change logging, and the clocktable.  His clear explanations have
17374 been critical when we started to adopt the Git version control system.
17375 @item
17376 @i{Manuel Hermenegildo} has contributed various ideas, small fixes and
17377 patches.
17378 @item
17379 @i{Phil Jackson} wrote @file{org-irc.el}.
17380 @item
17381 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
17382 folded entries, and column view for properties.
17383 @item
17384 @i{Matt Jones} wrote @i{MobileOrg Android}.
17385 @item
17386 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
17387 @item
17388 @i{Jonathan Leech-Pepin} wrote @file{ox-texinfo.el}.
17389 @item
17390 @i{Shidai Liu} ("Leo") asked for embedded @LaTeX{} and tested it.  He also
17391 provided frequent feedback and some patches.
17392 @item
17393 @i{Matt Lundin} has proposed last-row references for table formulas and named
17394 invisible anchors.  He has also worked a lot on the FAQ.
17395 @item
17396 @i{David Maus} wrote @file{org-atom.el}, maintains the issues file for Org,
17397 and is a prolific contributor on the mailing list with competent replies,
17398 small fixes and patches.
17399 @item
17400 @i{Jason F. McBrayer} suggested agenda export to CSV format.
17401 @item
17402 @i{Max Mikhanosha} came up with the idea of refiling and sticky agendas.
17403 @item
17404 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
17405 basis.
17406 @item
17407 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
17408 happy.
17409 @item
17410 @i{Richard Moreland} wrote @i{MobileOrg} for the iPhone.
17411 @item
17412 @i{Rick Moynihan} proposed allowing multiple TODO sequences in a file
17413 and being able to quickly restrict the agenda to a subtree.
17414 @item
17415 @i{Todd Neal} provided patches for links to Info files and Elisp forms.
17416 @item
17417 @i{Greg Newman} refreshed the unicorn logo into its current form.
17418 @item
17419 @i{Tim O'Callaghan} suggested in-file links, search options for general
17420 file links, and TAGS.
17421 @item
17422 @i{Osamu Okano} wrote @file{orgcard2ref.pl}, a Perl program to create a text
17423 version of the reference card.
17424 @item
17425 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
17426 into Japanese.
17427 @item
17428 @i{Oliver Oppitz} suggested multi-state TODO items.
17429 @item
17430 @i{Scott Otterson} sparked the introduction of descriptive text for
17431 links, among other things.
17432 @item
17433 @i{Pete Phillips} helped during the development of the TAGS feature, and
17434 provided frequent feedback.
17435 @item
17436 @i{Francesco Pizzolante} provided patches that helped speeding up the agenda
17437 generation.
17438 @item
17439 @i{Martin Pohlack} provided the code snippet to bundle character insertion
17440 into bundles of 20 for undo.
17441 @item
17442 @i{T.V. Raman} reported bugs and suggested improvements.
17443 @item
17444 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
17445 control.
17446 @item
17447 @i{Paul Rivier} provided the basic implementation of named footnotes.  He
17448 also acted as mailing list moderator for some time.
17449 @item
17450 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
17451 @item
17452 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
17453 conflict with @file{allout.el}.
17454 @item
17455 @i{Jason Riedy} generalized the send-receive mechanism for Orgtbl tables with
17456 extensive patches.
17457 @item
17458 @i{Philip Rooke} created the Org reference card, provided lots
17459 of feedback, developed and applied standards to the Org documentation.
17460 @item
17461 @i{Christian Schlauer} proposed angular brackets around links, among
17462 other things.
17463 @item
17464 @i{Christopher Schmidt} reworked @code{orgstruct-mode} so that users can
17465 enjoy folding in non-org buffers by using Org headlines in comments.
17466 @item
17467 @i{Paul Sexton} wrote @file{org-ctags.el}.
17468 @item
17469 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
17470 @file{organizer-mode.el}.
17471 @item
17472 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
17473 examples, and remote highlighting for referenced code lines.
17474 @item
17475 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
17476 now packaged into Org's @file{contrib} directory.
17477 @item
17478 @i{Daniel Sinder} came up with the idea of internal archiving by locking
17479 subtrees.
17480 @item
17481 @i{Dale Smith} proposed link abbreviations.
17482 @item
17483 @i{James TD Smith} has contributed a large number of patches for useful
17484 tweaks and features.
17485 @item
17486 @i{Adam Spiers} asked for global linking commands, inspired the link
17487 extension system, added support for mairix, and proposed the mapping API.
17488 @item
17489 @i{Ulf Stegemann} created the table to translate special symbols to HTML,
17490 @LaTeX{}, UTF-8, Latin-1 and ASCII.
17491 @item
17492 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
17493 with links transformation to Org syntax.
17494 @item
17495 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
17496 chapter about publishing.
17497 @item
17498 @i{Jambunathan K} contributed the ODT exporter and rewrote the HTML exporter.
17499 @item
17500 @i{Sebastien Vauban} reported many issues with @LaTeX{} and BEAMER export and
17501 enabled source code highlighting in Gnus.
17502 @item
17503 @i{Stefan Vollmar} organized a video-recorded talk at the
17504 Max-Planck-Institute for Neurology.  He also inspired the creation of a
17505 concept index for HTML export.
17506 @item
17507 @i{J@"urgen Vollmer} contributed code generating the table of contents
17508 in HTML output.
17509 @item
17510 @i{Samuel Wales} has provided important feedback and bug reports.
17511 @item
17512 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
17513 keyword.
17514 @item
17515 @i{David Wainberg} suggested archiving, and improvements to the linking
17516 system.
17517 @item
17518 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
17519 linking to Gnus.
17520 @item
17521 @i{Roland Winkler} requested additional key bindings to make Org
17522 work on a tty.
17523 @item
17524 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
17525 and contributed various ideas and code snippets.
17526 @end itemize
17529 @node GNU Free Documentation License, Main Index, History and Acknowledgments, Top
17530 @appendix GNU Free Documentation License
17531 @include doclicense.texi
17534 @node Main Index, Key Index, GNU Free Documentation License, Top
17535 @unnumbered Concept index
17537 @printindex cp
17539 @node Key Index, Command and Function Index, Main Index, Top
17540 @unnumbered Key index
17542 @printindex ky
17544 @node Command and Function Index, Variable Index, Key Index, Top
17545 @unnumbered Command and function index
17547 @printindex fn
17549 @node Variable Index,  , Command and Function Index, Top
17550 @unnumbered Variable index
17552 This is not a complete index of variables and faces, only the ones that are
17553 mentioned in the manual.  For a more complete list, use @kbd{M-x
17554 org-customize @key{RET}} and then click yourself through the tree.
17556 @printindex vr
17558 @bye
17560 @c Local variables:
17561 @c fill-column: 77
17562 @c indent-tabs-mode: nil
17563 @c paragraph-start:    "\b\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|\f\\|[  ]*$"
17564 @c paragraph-separate: "\b\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|[       \f]*$"
17565 @c End:
17568 @c  LocalWords:  webdavhost pre