org.texi: Delete XOXO documentation
[org-mode.git] / doc / org.texi
blobaa9da81f49f0bc730dbe47d3cbdbcfc85d184296
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @include org-version.inc
8 @c Use proper quote and backtick for code sections in PDF output
9 @c Cf. Texinfo manual 14.2
10 @set txicodequoteundirected
11 @set txicodequotebacktick
13 @c Version and Contact Info
14 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
15 @set AUTHOR Carsten Dominik
16 @set MAINTAINER Bastien Guerry
17 @set MAINTAINEREMAIL @email{bzg at gnu dot org}
18 @set MAINTAINERCONTACT @uref{mailto:bzg at gnu dot org,contact the maintainer}
19 @c %**end of header
20 @finalout
23 @c -----------------------------------------------------------------------------
25 @c Macro definitions for commands and keys
26 @c =======================================
28 @c The behavior of the key/command macros will depend on the flag cmdnames
29 @c When set, commands names are shown.  When clear, they are not shown.
31 @set cmdnames
33 @c Below we define the following macros for Org key tables:
35 @c orgkey{key}                        A key item
36 @c orgcmd{key,cmd}                    Key with command name
37 @c xorgcmd{key,cmd}                   Key with command name as @itemx
38 @c orgcmdnki{key,cmd}                 Like orgcmd, but do not index the key
39 @c orgcmdtkc{text,key,cmd}            Like orgcmd,special text instead of key
40 @c orgcmdkkc{key1,key2,cmd}           Two keys with one command name, use "or"
41 @c orgcmdkxkc{key1,key2,cmd}          Two keys with one command name, but
42 @c                                    different functions, so format as @itemx
43 @c orgcmdkskc{key1,key2,cmd}          Same as orgcmdkkc, but use "or short"
44 @c xorgcmdkskc{key1,key2,cmd}         Same as previous, but use @itemx
45 @c orgcmdkkcc{key1,key2,cmd1,cmd2}    Two keys and two commands
47 @c a key but no command
48 @c    Inserts:    @item key
49 @macro orgkey{key}
50 @kindex \key\
51 @item @kbd{\key\}
52 @end macro
54 @macro xorgkey{key}
55 @kindex \key\
56 @itemx @kbd{\key\}
57 @end macro
59 @c one key with a command
60 @c   Inserts:    @item KEY               COMMAND
61 @macro orgcmd{key,command}
62 @ifset cmdnames
63 @kindex \key\
64 @findex \command\
65 @iftex
66 @item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
67 @end iftex
68 @ifnottex
69 @item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
70 @end ifnottex
71 @end ifset
72 @ifclear cmdnames
73 @kindex \key\
74 @item @kbd{\key\}
75 @end ifclear
76 @end macro
78 @c One key with one command, formatted using @itemx
79 @c   Inserts:    @itemx KEY               COMMAND
80 @macro xorgcmd{key,command}
81 @ifset cmdnames
82 @kindex \key\
83 @findex \command\
84 @iftex
85 @itemx @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
86 @end iftex
87 @ifnottex
88 @itemx @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
89 @end ifnottex
90 @end ifset
91 @ifclear cmdnames
92 @kindex \key\
93 @itemx @kbd{\key\}
94 @end ifclear
95 @end macro
97 @c one key with a command, bit do not index the key
98 @c   Inserts:    @item KEY               COMMAND
99 @macro orgcmdnki{key,command}
100 @ifset cmdnames
101 @findex \command\
102 @iftex
103 @item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
104 @end iftex
105 @ifnottex
106 @item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
107 @end ifnottex
108 @end ifset
109 @ifclear cmdnames
110 @item @kbd{\key\}
111 @end ifclear
112 @end macro
114 @c one key with a command, and special text to replace key in item
115 @c   Inserts:    @item TEXT                    COMMAND
116 @macro orgcmdtkc{text,key,command}
117 @ifset cmdnames
118 @kindex \key\
119 @findex \command\
120 @iftex
121 @item @kbd{\text\} @hskip 0pt plus 1filll @code{\command\}
122 @end iftex
123 @ifnottex
124 @item @kbd{\text\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
125 @end ifnottex
126 @end ifset
127 @ifclear cmdnames
128 @kindex \key\
129 @item @kbd{\text\}
130 @end ifclear
131 @end macro
133 @c two keys with one command
134 @c   Inserts:    @item KEY1 or KEY2            COMMAND
135 @macro orgcmdkkc{key1,key2,command}
136 @ifset cmdnames
137 @kindex \key1\
138 @kindex \key2\
139 @findex \command\
140 @iftex
141 @item @kbd{\key1\} @ @r{or} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
142 @end iftex
143 @ifnottex
144 @item @kbd{\key1\} @ @r{or} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
145 @end ifnottex
146 @end ifset
147 @ifclear cmdnames
148 @kindex \key1\
149 @kindex \key2\
150 @item @kbd{\key1\} @ @r{or} @ @kbd{\key2\}
151 @end ifclear
152 @end macro
154 @c Two keys with one command name, but different functions, so format as
155 @c @itemx
156 @c   Inserts:    @item KEY1
157 @c               @itemx KEY2                COMMAND
158 @macro orgcmdkxkc{key1,key2,command}
159 @ifset cmdnames
160 @kindex \key1\
161 @kindex \key2\
162 @findex \command\
163 @iftex
164 @item @kbd{\key1\}
165 @itemx @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
166 @end iftex
167 @ifnottex
168 @item @kbd{\key1\}
169 @itemx @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
170 @end ifnottex
171 @end ifset
172 @ifclear cmdnames
173 @kindex \key1\
174 @kindex \key2\
175 @item @kbd{\key1\}
176 @itemx @kbd{\key2\}
177 @end ifclear
178 @end macro
180 @c Same as previous, but use "or short"
181 @c   Inserts:    @item KEY1 or short KEY2            COMMAND
182 @macro orgcmdkskc{key1,key2,command}
183 @ifset cmdnames
184 @kindex \key1\
185 @kindex \key2\
186 @findex \command\
187 @iftex
188 @item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
189 @end iftex
190 @ifnottex
191 @item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
192 @end ifnottex
193 @end ifset
194 @ifclear cmdnames
195 @kindex \key1\
196 @kindex \key2\
197 @item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\}
198 @end ifclear
199 @end macro
201 @c Same as previous, but use @itemx
202 @c   Inserts:    @itemx KEY1 or short KEY2            COMMAND
203 @macro xorgcmdkskc{key1,key2,command}
204 @ifset cmdnames
205 @kindex \key1\
206 @kindex \key2\
207 @findex \command\
208 @iftex
209 @itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
210 @end iftex
211 @ifnottex
212 @itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
213 @end ifnottex
214 @end ifset
215 @ifclear cmdnames
216 @kindex \key1\
217 @kindex \key2\
218 @itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\}
219 @end ifclear
220 @end macro
222 @c two keys with two commands
223 @c   Inserts:    @item KEY1                        COMMAND1
224 @c               @itemx KEY2                       COMMAND2
225 @macro orgcmdkkcc{key1,key2,command1,command2}
226 @ifset cmdnames
227 @kindex \key1\
228 @kindex \key2\
229 @findex \command1\
230 @findex \command2\
231 @iftex
232 @item @kbd{\key1\} @hskip 0pt plus 1filll @code{\command1\}
233 @itemx @kbd{\key2\} @hskip 0pt plus 1filll @code{\command2\}
234 @end iftex
235 @ifnottex
236 @item @kbd{\key1\} @tie{}@tie{}@tie{}@tie{}(@code{\command1\})
237 @itemx @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command2\})
238 @end ifnottex
239 @end ifset
240 @ifclear cmdnames
241 @kindex \key1\
242 @kindex \key2\
243 @item @kbd{\key1\}
244 @itemx @kbd{\key2\}
245 @end ifclear
246 @end macro
247 @c -----------------------------------------------------------------------------
249 @iftex
250 @c @hyphenation{time-stamp time-stamps time-stamp-ing time-stamp-ed}
251 @end iftex
253 @c Subheadings inside a table.
254 @macro tsubheading{text}
255 @ifinfo
256 @subsubheading \text\
257 @end ifinfo
258 @ifnotinfo
259 @item @b{\text\}
260 @end ifnotinfo
261 @end macro
263 @copying
264 This manual is for Org version @value{VERSION}.
266 Copyright @copyright{} 2004--2013 Free Software Foundation, Inc.
268 @quotation
269 Permission is granted to copy, distribute and/or modify this document
270 under the terms of the GNU Free Documentation License, Version 1.3 or
271 any later version published by the Free Software Foundation; with no
272 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
273 and with the Back-Cover Texts as in (a) below.  A copy of the license
274 is included in the section entitled ``GNU Free Documentation License.''
276 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
277 modify this GNU manual.''
278 @end quotation
279 @end copying
281 @dircategory Emacs editing modes
282 @direntry
283 * Org Mode: (org).      Outline-based notes management and organizer
284 @end direntry
286 @titlepage
287 @title The Org Manual
289 @subtitle Release @value{VERSION}
290 @author by Carsten Dominik
291 with contributions by David O'Toole, Bastien Guerry, Philip Rooke, Dan Davison, Eric Schulte, Thomas Dye and Jambunathan K.
293 @c The following two commands start the copyright page.
294 @page
295 @vskip 0pt plus 1filll
296 @insertcopying
297 @end titlepage
299 @c Output the table of contents at the beginning.
300 @contents
302 @ifnottex
303 @c FIXME These hand-written next,prev,up node pointers make editing a lot
304 @c harder.  There should be no need for them, makeinfo can do it
305 @c automatically for any document with a normal structure.
306 @node Top, Introduction, (dir), (dir)
307 @top Org Mode Manual
309 @insertcopying
310 @end ifnottex
312 @menu
313 * Introduction::                Getting started
314 * Document Structure::          A tree works like your brain
315 * Tables::                      Pure magic for quick formatting
316 * Hyperlinks::                  Notes in context
317 * TODO Items::                  Every tree branch can be a TODO item
318 * Tags::                        Tagging headlines and matching sets of tags
319 * Properties and Columns::      Storing information about an entry
320 * Dates and Times::             Making items useful for planning
321 * Capture - Refile - Archive::  The ins and outs for projects
322 * Agenda Views::                Collecting information into views
323 * Markup::                      Prepare text for rich export
324 * Exporting::                   Sharing and publishing of notes
325 * Publishing::                  Create a web site of linked Org files
326 * Working With Source Code::    Export, evaluate, and tangle code blocks
327 * Miscellaneous::               All the rest which did not fit elsewhere
328 * Hacking::                     How to hack your way around
329 * MobileOrg::                   Viewing and capture on a mobile device
330 * History and Acknowledgments::  How Org came into being
331 * GNU Free Documentation License::  The license for this documentation.
332 * Main Index::                  An index of Org's concepts and features
333 * Key Index::                   Key bindings and where they are described
334 * Command and Function Index::  Command names and some internal functions
335 * Variable Index::              Variables mentioned in the manual
337 @detailmenu
338  --- The Detailed Node Listing ---
340 Introduction
342 * Summary::                     Brief summary of what Org does
343 * Installation::                Installing Org
344 * Activation::                  How to activate Org for certain buffers
345 * Feedback::                    Bug reports, ideas, patches etc.
346 * Conventions::                 Typesetting conventions in the manual
348 Document structure
350 * Outlines::                    Org is based on Outline mode
351 * Headlines::                   How to typeset Org tree headlines
352 * Visibility cycling::          Show and hide, much simplified
353 * Motion::                      Jumping to other headlines
354 * Structure editing::           Changing sequence and level of headlines
355 * Sparse trees::                Matches embedded in context
356 * Plain lists::                 Additional structure within an entry
357 * Drawers::                     Tucking stuff away
358 * Blocks::                      Folding blocks
359 * Footnotes::                   How footnotes are defined in Org's syntax
360 * Orgstruct mode::              Structure editing outside Org
362 Tables
364 * Built-in table editor::       Simple tables
365 * Column width and alignment::  Overrule the automatic settings
366 * Column groups::               Grouping to trigger vertical lines
367 * Orgtbl mode::                 The table editor as minor mode
368 * The spreadsheet::             The table editor has spreadsheet capabilities
369 * Org-Plot::                    Plotting from org tables
371 The spreadsheet
373 * References::                  How to refer to another field or range
374 * Formula syntax for Calc::     Using Calc to compute stuff
375 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
376 * Durations and time values::   How to compute durations and time values
377 * Field and range formulas::    Formula for specific (ranges of) fields
378 * Column formulas::             Formulas valid for an entire column
379 * Lookup functions::            Lookup functions for searching tables
380 * Editing and debugging formulas::  Fixing formulas
381 * Updating the table::          Recomputing all dependent fields
382 * Advanced features::           Field and column names, parameters and automatic recalc
384 Hyperlinks
386 * Link format::                 How links in Org are formatted
387 * Internal links::              Links to other places in the current file
388 * External links::              URL-like links to the world
389 * Handling links::              Creating, inserting and following
390 * Using links outside Org::     Linking from my C source code?
391 * Link abbreviations::          Shortcuts for writing complex links
392 * Search options::              Linking to a specific location
393 * Custom searches::             When the default search is not enough
395 Internal links
397 * Radio targets::               Make targets trigger links in plain text
399 TODO items
401 * TODO basics::                 Marking and displaying TODO entries
402 * TODO extensions::             Workflow and assignments
403 * Progress logging::            Dates and notes for progress
404 * Priorities::                  Some things are more important than others
405 * Breaking down tasks::         Splitting a task into manageable pieces
406 * Checkboxes::                  Tick-off lists
408 Extended use of TODO keywords
410 * Workflow states::             From TODO to DONE in steps
411 * TODO types::                  I do this, Fred does the rest
412 * Multiple sets in one file::   Mixing it all, and still finding your way
413 * Fast access to TODO states::  Single letter selection of a state
414 * Per-file keywords::           Different files, different requirements
415 * Faces for TODO keywords::     Highlighting states
416 * TODO dependencies::           When one task needs to wait for others
418 Progress logging
420 * Closing items::               When was this entry marked DONE?
421 * Tracking TODO state changes::  When did the status change?
422 * Tracking your habits::        How consistent have you been?
424 Tags
426 * Tag inheritance::             Tags use the tree structure of the outline
427 * Setting tags::                How to assign tags to a headline
428 * Tag searches::                Searching for combinations of tags
430 Properties and columns
432 * Property syntax::             How properties are spelled out
433 * Special properties::          Access to other Org mode features
434 * Property searches::           Matching property values
435 * Property inheritance::        Passing values down the tree
436 * Column view::                 Tabular viewing and editing
437 * Property API::                Properties for Lisp programmers
439 Column view
441 * Defining columns::            The COLUMNS format property
442 * Using column view::           How to create and use column view
443 * Capturing column view::       A dynamic block for column view
445 Defining columns
447 * Scope of column definitions::  Where defined, where valid?
448 * Column attributes::           Appearance and content of a column
450 Dates and times
452 * Timestamps::                  Assigning a time to a tree entry
453 * Creating timestamps::         Commands which insert timestamps
454 * Deadlines and scheduling::    Planning your work
455 * Clocking work time::          Tracking how long you spend on a task
456 * Effort estimates::            Planning work effort in advance
457 * Relative timer::              Notes with a running timer
458 * Countdown timer::             Starting a countdown timer for a task
460 Creating timestamps
462 * The date/time prompt::        How Org mode helps you entering date and time
463 * Custom time format::          Making dates look different
465 Deadlines and scheduling
467 * Inserting deadline/schedule::  Planning items
468 * Repeated tasks::              Items that show up again and again
470 Clocking work time
472 * Clocking commands::           Starting and stopping a clock
473 * The clock table::             Detailed reports
474 * Resolving idle time::         Resolving time when you've been idle
476 Capture - Refile - Archive
478 * Capture::                     Capturing new stuff
479 * Attachments::                 Add files to tasks
480 * RSS Feeds::                   Getting input from RSS feeds
481 * Protocols::                   External (e.g., Browser) access to Emacs and Org
482 * Refile and copy::             Moving/copying a tree from one place to another
483 * Archiving::                   What to do with finished projects
485 Capture
487 * Setting up capture::          Where notes will be stored
488 * Using capture::               Commands to invoke and terminate capture
489 * Capture templates::           Define the outline of different note types
491 Capture templates
493 * Template elements::           What is needed for a complete template entry
494 * Template expansion::          Filling in information about time and context
495 * Templates in contexts::       Only show a template in a specific context
497 Archiving
499 * Moving subtrees::             Moving a tree to an archive file
500 * Internal archiving::          Switch off a tree but keep it in the file
502 Agenda views
504 * Agenda files::                Files being searched for agenda information
505 * Agenda dispatcher::           Keyboard access to agenda views
506 * Built-in agenda views::       What is available out of the box?
507 * Presentation and sorting::    How agenda items are prepared for display
508 * Agenda commands::             Remote editing of Org trees
509 * Custom agenda views::         Defining special searches and views
510 * Exporting Agenda Views::      Writing a view to a file
511 * Agenda column view::          Using column view for collected entries
513 The built-in agenda views
515 * Weekly/daily agenda::         The calendar page with current tasks
516 * Global TODO list::            All unfinished action items
517 * Matching tags and properties::  Structured information with fine-tuned search
518 * Timeline::                    Time-sorted view for single file
519 * Search view::                 Find entries by searching for text
520 * Stuck projects::              Find projects you need to review
522 Presentation and sorting
524 * Categories::                  Not all tasks are equal
525 * Time-of-day specifications::  How the agenda knows the time
526 * Sorting of agenda items::     The order of things
528 Custom agenda views
530 * Storing searches::            Type once, use often
531 * Block agenda::                All the stuff you need in a single buffer
532 * Setting Options::             Changing the rules
534 Markup for rich export
536 * Structural markup elements::  The basic structure as seen by the exporter
537 * Images and tables::           Tables and Images will be included
538 * Literal examples::            Source code examples with special formatting
539 * Include files::               Include additional files into a document
540 * Index entries::               Making an index
541 * Macro replacement::           Use macros to create complex output
542 * Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
544 Structural markup elements
546 * Document title::              Where the title is taken from
547 * Headings and sections::       The document structure as seen by the exporter
548 * Table of contents::           The if and where of the table of contents
549 * Initial text::                Text before the first heading?
550 * Lists::                       Lists
551 * Paragraphs::                  Paragraphs
552 * Footnote markup::             Footnotes
553 * Emphasis and monospace::      Bold, italic, etc.
554 * Horizontal rules::            Make a line
555 * Comment lines::               What will *not* be exported
557 Embedded @LaTeX{}
559 * Special symbols::             Greek letters and other symbols
560 * Subscripts and superscripts::  Simple syntax for raising/lowering text
561 * @LaTeX{} fragments::          Complex formulas made easy
562 * Previewing @LaTeX{} fragments::  What will this snippet look like?
563 * CDLaTeX mode::                Speed up entering of formulas
565 Exporting
567 * Selective export::            Using tags to select and exclude trees
568 * Export options::              Per-file export settings
569 * The export dispatcher::       How to access exporter commands
570 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
571 * HTML export::                 Exporting to HTML
572 * @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
573 * OpenDocument Text export::    Exporting to OpenDocument Text
574 * Freemind export::             Exporting to Freemind mind maps
575 * iCalendar export::            Exporting in iCalendar format
577 HTML export
579 * HTML Export commands::        How to invoke HTML export
580 * HTML preamble and postamble::  How to insert a preamble and a postamble
581 * Quoting HTML tags::           Using direct HTML in Org mode
582 * Links in HTML export::        How links will be interpreted and formatted
583 * Tables in HTML export::       How to modify the formatting of tables
584 * Images in HTML export::       How to insert figures into HTML output
585 * Math formatting in HTML export::  Beautiful math also on the web
586 * Text areas in HTML export::   An alternative way to show an example
587 * CSS support::                 Changing the appearance of the output
588 * JavaScript support::          Info and Folding in a web browser
590 @LaTeX{} and PDF export
592 * @LaTeX{}/PDF export commands::
593 * Header and sectioning::       Setting up the export file structure
594 * Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
595 * Tables in @LaTeX{} export::   Options for exporting tables to @LaTeX{}
596 * Images in @LaTeX{} export::   How to insert figures into @LaTeX{} output
597 * Beamer class export::         Turning the file into a presentation
599 OpenDocument Text export
601 * Pre-requisites for ODT export::  What packages ODT exporter relies on
602 * ODT export commands::         How to invoke ODT export
603 * Extending ODT export::        How to produce @samp{doc}, @samp{pdf} files
604 * Applying custom styles::      How to apply custom styles to the output
605 * Links in ODT export::         How links will be interpreted and formatted
606 * Tables in ODT export::        How Tables are exported
607 * Images in ODT export::        How to insert images
608 * Math formatting in ODT export::  How @LaTeX{} fragments are formatted
609 * Labels and captions in ODT export::  How captions are rendered
610 * Literal examples in ODT export::  How source and example blocks are formatted
611 * Advanced topics in ODT export::  Read this if you are a power user
613 Math formatting in ODT export
615 * Working with @LaTeX{} math snippets::  How to embed @LaTeX{} math fragments
616 * Working with MathML or OpenDocument formula files::  How to embed equations in native format
618 Advanced topics in ODT export
620 * Configuring a document converter::  How to register a document converter
621 * Working with OpenDocument style files::  Explore the internals
622 * Creating one-off styles::     How to produce custom highlighting etc
623 * Customizing tables in ODT export::  How to define and use Table templates
624 * Validating OpenDocument XML::  How to debug corrupt OpenDocument files
626 Publishing
628 * Configuration::               Defining projects
629 * Uploading files::             How to get files up on the server
630 * Sample configuration::        Example projects
631 * Triggering publication::      Publication commands
633 Configuration
635 * Project alist::               The central configuration variable
636 * Sources and destinations::    From here to there
637 * Selecting files::             What files are part of the project?
638 * Publishing action::           Setting the function doing the publishing
639 * Publishing options::          Tweaking HTML/@LaTeX{} export
640 * Publishing links::            Which links keep working after publishing?
641 * Sitemap::                     Generating a list of all pages
642 * Generating an index::         An index that reaches across pages
644 Sample configuration
646 * Simple example::              One-component publishing
647 * Complex example::             A multi-component publishing example
649 Working with source code
651 * Structure of code blocks::    Code block syntax described
652 * Editing source code::         Language major-mode editing
653 * Exporting code blocks::       Export contents and/or results
654 * Extracting source code::      Create pure source code files
655 * Evaluating code blocks::      Place results of evaluation in the Org mode buffer
656 * Library of Babel::            Use and contribute to a library of useful code blocks
657 * Languages::                   List of supported code block languages
658 * Header arguments::            Configure code block functionality
659 * Results of evaluation::       How evaluation results are handled
660 * Noweb reference syntax::      Literate programming in Org mode
661 * Key bindings and useful functions::  Work quickly with code blocks
662 * Batch execution::             Call functions from the command line
664 Header arguments
666 * Using header arguments::      Different ways to set header arguments
667 * Specific header arguments::   List of header arguments
669 Using header arguments
671 * System-wide header arguments::  Set global default values
672 * Language-specific header arguments::  Set default values by language
673 * Buffer-wide header arguments::  Set default values for a specific buffer
674 * Header arguments in Org mode properties::  Set default values for a buffer or heading
675 * Code block specific header arguments::  The most common way to set values
676 * Header arguments in function calls::  The most specific level
678 Specific header arguments
680 * var::                         Pass arguments to code blocks
681 * results::                     Specify the type of results and how they will
682                                 be collected and handled
683 * file::                        Specify a path for file output
684 * file-desc::                   Specify a description for file results
685 * dir::                         Specify the default (possibly remote)
686                                 directory for code block execution
687 * exports::                     Export code and/or results
688 * tangle::                      Toggle tangling and specify file name
689 * mkdirp::                      Toggle creation of parent directories of target
690                                 files during tangling
691 * comments::                    Toggle insertion of comments in tangled
692                                 code files
693 * padline::                     Control insertion of padding lines in tangled
694                                 code files
695 * no-expand::                   Turn off variable assignment and noweb
696                                 expansion during tangling
697 * session::                     Preserve the state of code evaluation
698 * noweb::                       Toggle expansion of noweb references
699 * noweb-ref::                   Specify block's noweb reference resolution target
700 * noweb-sep::                   String used to separate noweb references
701 * cache::                       Avoid re-evaluating unchanged code blocks
702 * sep::                         Delimiter for writing tabular results outside Org
703 * hlines::                      Handle horizontal lines in tables
704 * colnames::                    Handle column names in tables
705 * rownames::                    Handle row names in tables
706 * shebang::                     Make tangled files executable
707 * eval::                        Limit evaluation of specific code blocks
708 * wrap::                        Mark source block evaluation results
710 Miscellaneous
712 * Completion::                  M-TAB knows what you need
713 * Easy Templates::              Quick insertion of structural elements
714 * Speed keys::                  Electric commands at the beginning of a headline
715 * Code evaluation security::    Org mode files evaluate inline code
716 * Customization::               Adapting Org to your taste
717 * In-buffer settings::          Overview of the #+KEYWORDS
718 * The very busy C-c C-c key::   When in doubt, press C-c C-c
719 * Clean view::                  Getting rid of leading stars in the outline
720 * TTY keys::                    Using Org on a tty
721 * Interaction::                 Other Emacs packages
722 * org-crypt.el::                Encrypting Org files
724 Interaction with other packages
726 * Cooperation::                 Packages Org cooperates with
727 * Conflicts::                   Packages that lead to conflicts
729 Hacking
731 * Hooks::                       How to reach into Org's internals
732 * Add-on packages::             Available extensions
733 * Adding hyperlink types::      New custom link types
734 * Context-sensitive commands::  How to add functionality to such commands
735 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
736 * Dynamic blocks::              Automatically filled blocks
737 * Special agenda views::        Customized views
738 * Extracting agenda information::  Postprocessing of agenda information
739 * Using the property API::      Writing programs that use entry properties
740 * Using the mapping API::       Mapping over all or selected entries
742 Tables and lists in arbitrary syntax
744 * Radio tables::                Sending and receiving radio tables
745 * A @LaTeX{} example::          Step by step, almost a tutorial
746 * Translator functions::        Copy and modify
747 * Radio lists::                 Doing the same for lists
749 MobileOrg
751 * Setting up the staging area::  Where to interact with the mobile device
752 * Pushing to MobileOrg::        Uploading Org files and agendas
753 * Pulling from MobileOrg::      Integrating captured and flagged items
755 @end detailmenu
756 @end menu
758 @node Introduction, Document Structure, Top, Top
759 @chapter Introduction
760 @cindex introduction
762 @menu
763 * Summary::                     Brief summary of what Org does
764 * Installation::                Installing Org
765 * Activation::                  How to activate Org for certain buffers
766 * Feedback::                    Bug reports, ideas, patches etc.
767 * Conventions::                 Typesetting conventions in the manual
768 @end menu
770 @node Summary, Installation, Introduction, Introduction
771 @section Summary
772 @cindex summary
774 Org is a mode for keeping notes, maintaining TODO lists, and doing
775 project planning with a fast and effective plain-text system.
777 Org develops organizational tasks around NOTES files that contain
778 lists or information about projects as plain text.  Org is
779 implemented on top of Outline mode, which makes it possible to keep the
780 content of large files well structured.  Visibility cycling and
781 structure editing help to work with the tree.  Tables are easily created
782 with a built-in table editor.  Org supports TODO items, deadlines,
783 timestamps, and scheduling.  It dynamically compiles entries into an
784 agenda that utilizes and smoothly integrates much of the Emacs calendar
785 and diary.  Plain text URL-like links connect to websites, emails,
786 Usenet messages, BBDB entries, and any files related to the projects.
787 For printing and sharing of notes, an Org file can be exported as a
788 structured ASCII file, as HTML, or (TODO and agenda items only) as an
789 iCalendar file.  It can also serve as a publishing tool for a set of
790 linked web pages.
792 As a project planning environment, Org works by adding metadata to outline
793 nodes.  Based on this data, specific entries can be extracted in queries and
794 create dynamic @i{agenda views}.
796 Org mode contains the Org Babel environment which allows you to work with
797 embedded source code blocks in a file, to facilitate code evaluation,
798 documentation, and literate programming techniques.
800 Org's automatic, context-sensitive table editor with spreadsheet
801 capabilities can be integrated into any major mode by activating the
802 minor Orgtbl mode.  Using a translation step, it can be used to maintain
803 tables in arbitrary file types, for example in @LaTeX{}.  The structure
804 editing and list creation capabilities can be used outside Org with
805 the minor Orgstruct mode.
807 Org keeps simple things simple.  When first fired up, it should
808 feel like a straightforward, easy to use outliner.  Complexity is not
809 imposed, but a large amount of functionality is available when you need
810 it.  Org is a toolbox and can be used in different ways and for different
811 ends, for example:
813 @example
814 @r{@bullet{} an outline extension with visibility cycling and structure editing}
815 @r{@bullet{} an ASCII system and table editor for taking structured notes}
816 @r{@bullet{} a TODO list editor}
817 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
818 @pindex GTD, Getting Things Done
819 @r{@bullet{} an environment in which to implement David Allen's GTD system}
820 @r{@bullet{} a simple hypertext system, with HTML and @LaTeX{} export}
821 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
822 @r{@bullet{} an environment for literate programming}
823 @end example
825 @cindex FAQ
826 There is a website for Org which provides links to the newest
827 version of Org, as well as additional information, frequently asked
828 questions (FAQ), links to tutorials, etc.  This page is located at
829 @uref{http://orgmode.org}.
831 @cindex print edition
832 The version 7.3 of this manual is available as a
833 @uref{http://www.network-theory.co.uk/org/manual/, paperback book from Network
834 Theory Ltd.}
836 @page
839 @node Installation, Activation, Summary, Introduction
840 @section Installation
841 @cindex installation
842 @cindex XEmacs
844 Org is part of recent distributions of GNU Emacs, so you normally don't need
845 to install it.  If, for one reason or another, you want to install Org on top
846 of this pre-packaged version, there are three ways to do it:
848 @itemize @bullet
849 @item By using Emacs package system.
850 @item By downloading Org as an archive.
851 @item By using Org's git repository.
852 @end itemize
854 We @b{strongly recommend} to stick to a single installation method.
856 @subsubheading Using Emacs packaging system
858 Recent Emacs distributions include a packaging system which lets you install
859 Elisp libraries.  You can install Org with @kbd{M-x package-install RET org}.
860 To make sure your Org configuration is well taken into account, initialize
861 the package system with @code{(package-initialize)} before setting any Org
862 option.  If you want to use Org's package repository, check out the
863 @uref{http://orgmode.org/elpa.html, Org ELPA page}.
865 @subsubheading Downloading Org as an archive
867 You can download Org latest release from @uref{http://orgmode.org/, Org's
868 website}.  In this case, make sure you set the load-path correctly in your
869 @file{.emacs}:
871 @example
872 (add-to-list 'load-path "~/path/to/orgdir/lisp")
873 @end example
875 The downloaded archive contains contributed libraries that are not included
876 in Emacs.  If you want to use them, add the @file{contrib} directory to your
877 load-path:
879 @example
880 (add-to-list 'load-path "~/path/to/orgdir/contrib/lisp" t)
881 @end example
883 Optionally, you can compile the files and/or install them in your system.
884 Run @code{make help} to list compilation and installation options.
886 @subsubheading Using Org's git repository
888 You can clone Org's repository and install Org like this:
890 @example
891 $ cd ~/src/
892 $ git clone git://orgmode.org/org-mode.git
893 $ make autoloads
894 @end example
896 Note that in this case, @code{make autoloads} is mandatory: it defines Org's
897 version in @file{org-version.el} and Org's autoloads in
898 @file{org-loaddefs.el}.
900 Remember to add the correct load-path as described in the method above.
902 You can also compile with @code{make}, generate the documentation with
903 @code{make doc}, create a local configuration with @code{make config} and
904 install Org with @code{make install}.  Please run @code{make help} to get
905 the list of compilation/installation options.
907 For more detailed explanations on Org's build system, please check the Org
908 Build System page on @uref{http://orgmode.org/worg/dev/org-build-system.html,
909 Worg}.
911 @node Activation, Feedback, Installation, Introduction
912 @section Activation
913 @cindex activation
914 @cindex autoload
915 @cindex ELPA
916 @cindex global key bindings
917 @cindex key bindings, global
918 @findex org-agenda
919 @findex org-capture
920 @findex org-store-link
921 @findex org-iswitchb
923 Since Emacs 22.2, files with the @file{.org} extension use Org mode by
924 default.  If you are using an earlier version of Emacs, add this line to your
925 @file{.emacs} file:
927 @lisp
928 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
929 @end lisp
931 Org mode buffers need font-lock to be turned on: this is the default in
932 Emacs@footnote{If you don't use font-lock globally, turn it on in Org buffer
933 with @code{(add-hook 'org-mode-hook 'turn-on-font-lock)}}.
935 There are compatibility issues between Org mode and some other Elisp
936 packages, please take the time to check the list (@pxref{Conflicts}).
938 The four Org commands @command{org-store-link}, @command{org-capture},
939 @command{org-agenda}, and @command{org-iswitchb} should be accessible through
940 global keys (i.e., anywhere in Emacs, not just in Org buffers).  Here are
941 suggested bindings for these keys, please modify the keys to your own
942 liking.
943 @lisp
944 (global-set-key "\C-cl" 'org-store-link)
945 (global-set-key "\C-cc" 'org-capture)
946 (global-set-key "\C-ca" 'org-agenda)
947 (global-set-key "\C-cb" 'org-iswitchb)
948 @end lisp
950 @cindex Org mode, turning on
951 With this setup, all files with extension @samp{.org} will be put
952 into Org mode.  As an alternative, make the first line of a file look
953 like this:
955 @example
956 MY PROJECTS    -*- mode: org; -*-
957 @end example
959 @vindex org-insert-mode-line-in-empty-file
960 @noindent which will select Org mode for this buffer no matter what
961 the file's name is.  See also the variable
962 @code{org-insert-mode-line-in-empty-file}.
964 Many commands in Org work on the region if the region is @i{active}.  To make
965 use of this, you need to have @code{transient-mark-mode}
966 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
967 in Emacs 22 you need to do this yourself with
968 @lisp
969 (transient-mark-mode 1)
970 @end lisp
971 @noindent If you do not like @code{transient-mark-mode}, you can create an
972 active region by using the mouse to select a region, or pressing
973 @kbd{C-@key{SPC}} twice before moving the cursor.
975 @node Feedback, Conventions, Activation, Introduction
976 @section Feedback
977 @cindex feedback
978 @cindex bug reports
979 @cindex maintainer
980 @cindex author
982 If you find problems with Org, or if you have questions, remarks, or ideas
983 about it, please mail to the Org mailing list @email{emacs-orgmode@@gnu.org}.
984 If you are not a member of the mailing list, your mail will be passed to the
985 list after a moderator has approved it@footnote{Please consider subscribing
986 to the mailing list, in order to minimize the work the mailing list
987 moderators have to do.}.
989 For bug reports, please first try to reproduce the bug with the latest
990 version of Org available---if you are running an outdated version, it is
991 quite possible that the bug has been fixed already.  If the bug persists,
992 prepare a report and provide as much information as possible, including the
993 version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
994 (@kbd{M-x org-version @key{RET}}), as well as the Org related setup in
995 @file{.emacs}.  The easiest way to do this is to use the command
996 @example
997 @kbd{M-x org-submit-bug-report}
998 @end example
999 @noindent which will put all this information into an Emacs mail buffer so
1000 that you only need to add your description.  If you re not sending the Email
1001 from within Emacs, please copy and paste the content into your Email program.
1003 Sometimes you might face a problem due to an error in your Emacs or Org mode
1004 setup.  Before reporting a bug, it is very helpful to start Emacs with minimal
1005 customizations and reproduce the problem.  Doing so often helps you determine
1006 if the problem is with your customization or with Org mode itself.  You can
1007 start a typical minimal session with a command like the example below.
1009 @example
1010 $ emacs -Q -l /path/to/minimal-org.el
1011 @end example
1013 However if you are using Org mode as distributed with Emacs, a minimal setup
1014 is not necessary.  In that case it is sufficient to start Emacs as
1015 @code{emacs -Q}.  The @code{minimal-org.el} setup file can have contents as
1016 shown below.
1018 @example
1019 ;;; Minimal setup to load latest `org-mode'
1021 ;; activate debugging
1022 (setq debug-on-error t
1023       debug-on-signal nil
1024       debug-on-quit nil)
1026 ;; add latest org-mode to load path
1027 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
1028 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
1029 @end example
1031 If an error occurs, a backtrace can be very useful (see below on how to
1032 create one).  Often a small example file helps, along with clear information
1033 about:
1035 @enumerate
1036 @item What exactly did you do?
1037 @item What did you expect to happen?
1038 @item What happened instead?
1039 @end enumerate
1040 @noindent Thank you for helping to improve this program.
1042 @subsubheading How to create a useful backtrace
1044 @cindex backtrace of an error
1045 If working with Org produces an error with a message you don't
1046 understand, you may have hit a bug.  The best way to report this is by
1047 providing, in addition to what was mentioned above, a @emph{backtrace}.
1048 This is information from the built-in debugger about where and how the
1049 error occurred.  Here is how to produce a useful backtrace:
1051 @enumerate
1052 @item
1053 Reload uncompiled versions of all Org mode Lisp files.  The backtrace
1054 contains much more information if it is produced with uncompiled code.
1055 To do this, use
1056 @example
1057 C-u M-x org-reload RET
1058 @end example
1059 @noindent
1060 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
1061 menu.
1062 @item
1063 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
1064 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
1065 @item
1066 Do whatever you have to do to hit the error.  Don't forget to
1067 document the steps you take.
1068 @item
1069 When you hit the error, a @file{*Backtrace*} buffer will appear on the
1070 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
1071 attach it to your bug report.
1072 @end enumerate
1074 @node Conventions,  , Feedback, Introduction
1075 @section Typesetting conventions used in this manual
1077 @subsubheading TODO keywords, tags, properties, etc.
1079 Org mainly uses three types of keywords: TODO keywords, tags and property
1080 names.  In this manual we use the following conventions:
1082 @table @code
1083 @item TODO
1084 @itemx WAITING
1085 TODO keywords are written with all capitals, even if they are
1086 user-defined.
1087 @item boss
1088 @itemx ARCHIVE
1089 User-defined tags are written in lowercase; built-in tags with special
1090 meaning are written with all capitals.
1091 @item Release
1092 @itemx PRIORITY
1093 User-defined properties are capitalized; built-in properties with
1094 special meaning are written with all capitals.
1095 @end table
1097 Moreover, Org uses @i{option keywords} (like @code{#+TITLE} to set the title)
1098 and @i{environment keywords} (like @code{#+BEGIN_HTML} to start a @code{HTML}
1099 environment).  They are written in uppercase in the manual to enhance its
1100 readability, but you can use lowercase in your Org files@footnote{Easy
1101 templates insert lowercase keywords and Babel dynamically inserts
1102 @code{#+results}.}
1104 @subsubheading Keybindings and commands
1105 @kindex C-c a
1106 @findex org-agenda
1107 @kindex C-c c
1108 @findex org-capture
1110 The manual suggests two global keybindings: @kbd{C-c a} for @code{org-agenda}
1111 and @kbd{C-c c} for @code{org-capture}.  These are only suggestions, but the
1112 rest of the manual assumes that you are using these keybindings.
1114 Also, the manual lists both the keys and the corresponding commands for
1115 accessing a functionality.  Org mode often uses the same key for different
1116 functions, depending on context.  The command that is bound to such keys has
1117 a generic name, like @code{org-metaright}.  In the manual we will, wherever
1118 possible, give the function that is internally called by the generic command.
1119 For example, in the chapter on document structure, @kbd{M-@key{right}} will
1120 be listed to call @code{org-do-demote}, while in the chapter on tables, it
1121 will be listed to call @code{org-table-move-column-right}.  If you prefer,
1122 you can compile the manual without the command names by unsetting the flag
1123 @code{cmdnames} in @file{org.texi}.
1125 @node Document Structure, Tables, Introduction, Top
1126 @chapter Document structure
1127 @cindex document structure
1128 @cindex structure of document
1130 Org is based on Outline mode and provides flexible commands to
1131 edit the structure of the document.
1133 @menu
1134 * Outlines::                    Org is based on Outline mode
1135 * Headlines::                   How to typeset Org tree headlines
1136 * Visibility cycling::          Show and hide, much simplified
1137 * Motion::                      Jumping to other headlines
1138 * Structure editing::           Changing sequence and level of headlines
1139 * Sparse trees::                Matches embedded in context
1140 * Plain lists::                 Additional structure within an entry
1141 * Drawers::                     Tucking stuff away
1142 * Blocks::                      Folding blocks
1143 * Footnotes::                   How footnotes are defined in Org's syntax
1144 * Orgstruct mode::              Structure editing outside Org
1145 @end menu
1147 @node Outlines, Headlines, Document Structure, Document Structure
1148 @section Outlines
1149 @cindex outlines
1150 @cindex Outline mode
1152 Org is implemented on top of Outline mode.  Outlines allow a
1153 document to be organized in a hierarchical structure, which (at least
1154 for me) is the best representation of notes and thoughts.  An overview
1155 of this structure is achieved by folding (hiding) large parts of the
1156 document to show only the general document structure and the parts
1157 currently being worked on.  Org greatly simplifies the use of
1158 outlines by compressing the entire show/hide functionality into a single
1159 command, @command{org-cycle}, which is bound to the @key{TAB} key.
1161 @node Headlines, Visibility cycling, Outlines, Document Structure
1162 @section Headlines
1163 @cindex headlines
1164 @cindex outline tree
1165 @vindex org-special-ctrl-a/e
1166 @vindex org-special-ctrl-k
1167 @vindex org-ctrl-k-protect-subtree
1169 Headlines define the structure of an outline tree.  The headlines in Org
1170 start with one or more stars, on the left margin@footnote{See the variables
1171 @code{org-special-ctrl-a/e}, @code{org-special-ctrl-k}, and
1172 @code{org-ctrl-k-protect-subtree} to configure special behavior of @kbd{C-a},
1173 @kbd{C-e}, and @kbd{C-k} in headlines.} @footnote{Clocking only works with
1174 headings indented less then 30 stars.}.  For example:
1176 @example
1177 * Top level headline
1178 ** Second level
1179 *** 3rd level
1180     some text
1181 *** 3rd level
1182     more text
1184 * Another top level headline
1185 @end example
1187 @noindent Some people find the many stars too noisy and would prefer an
1188 outline that has whitespace followed by a single star as headline
1189 starters.  @ref{Clean view}, describes a setup to realize this.
1191 @vindex org-cycle-separator-lines
1192 An empty line after the end of a subtree is considered part of it and
1193 will be hidden when the subtree is folded.  However, if you leave at
1194 least two empty lines, one empty line will remain visible after folding
1195 the subtree, in order to structure the collapsed view.  See the
1196 variable @code{org-cycle-separator-lines} to modify this behavior.
1198 @node Visibility cycling, Motion, Headlines, Document Structure
1199 @section Visibility cycling
1200 @cindex cycling, visibility
1201 @cindex visibility cycling
1202 @cindex trees, visibility
1203 @cindex show hidden text
1204 @cindex hide text
1206 Outlines make it possible to hide parts of the text in the buffer.
1207 Org uses just two commands, bound to @key{TAB} and
1208 @kbd{S-@key{TAB}} to change the visibility in the buffer.
1210 @cindex subtree visibility states
1211 @cindex subtree cycling
1212 @cindex folded, subtree visibility state
1213 @cindex children, subtree visibility state
1214 @cindex subtree, subtree visibility state
1215 @table @asis
1216 @orgcmd{@key{TAB},org-cycle}
1217 @emph{Subtree cycling}: Rotate current subtree among the states
1219 @example
1220 ,-> FOLDED -> CHILDREN -> SUBTREE --.
1221 '-----------------------------------'
1222 @end example
1224 @vindex org-cycle-emulate-tab
1225 @vindex org-cycle-global-at-bob
1226 The cursor must be on a headline for this to work@footnote{see, however,
1227 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
1228 beginning of the buffer and the first line is not a headline, then
1229 @key{TAB} actually runs global cycling (see below)@footnote{see the
1230 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
1231 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
1233 @cindex global visibility states
1234 @cindex global cycling
1235 @cindex overview, global visibility state
1236 @cindex contents, global visibility state
1237 @cindex show all, global visibility state
1238 @orgcmd{S-@key{TAB},org-global-cycle}
1239 @itemx C-u @key{TAB}
1240 @emph{Global cycling}: Rotate the entire buffer among the states
1242 @example
1243 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
1244 '--------------------------------------'
1245 @end example
1247 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
1248 CONTENTS view up to headlines of level N will be shown.  Note that inside
1249 tables, @kbd{S-@key{TAB}} jumps to the previous field.
1251 @cindex show all, command
1252 @orgcmd{C-u C-u C-u @key{TAB},show-all}
1253 Show all, including drawers.
1254 @cindex revealing context
1255 @orgcmd{C-c C-r,org-reveal}
1256 Reveal context around point, showing the current entry, the following heading
1257 and the hierarchy above.  Useful for working near a location that has been
1258 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
1259 (@pxref{Agenda commands}).  With a prefix argument show, on each
1260 level, all sibling headings.  With a double prefix argument, also show the
1261 entire subtree of the parent.
1262 @cindex show branches, command
1263 @orgcmd{C-c C-k,show-branches}
1264 Expose all the headings of the subtree, CONTENT view for just one subtree.
1265 @cindex show children, command
1266 @orgcmd{C-c @key{TAB},show-children}
1267 Expose all direct children of the subtree.  With a numeric prefix argument N,
1268 expose all children down to level N@.
1269 @orgcmd{C-c C-x b,org-tree-to-indirect-buffer}
1270 Show the current subtree in an indirect buffer@footnote{The indirect
1271 buffer
1272 @ifinfo
1273 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
1274 @end ifinfo
1275 @ifnotinfo
1276 (see the Emacs manual for more information about indirect buffers)
1277 @end ifnotinfo
1278 will contain the entire buffer, but will be narrowed to the current
1279 tree.  Editing the indirect buffer will also change the original buffer,
1280 but without affecting visibility in that buffer.}.  With a numeric
1281 prefix argument N, go up to level N and then take that tree.  If N is
1282 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
1283 the previously used indirect buffer.
1284 @orgcmd{C-c C-x v,org-copy-visible}
1285 Copy the @i{visible} text in the region into the kill ring.
1286 @end table
1288 @vindex org-startup-folded
1289 @vindex org-agenda-inhibit-startup
1290 @cindex @code{overview}, STARTUP keyword
1291 @cindex @code{content}, STARTUP keyword
1292 @cindex @code{showall}, STARTUP keyword
1293 @cindex @code{showeverything}, STARTUP keyword
1295 When Emacs first visits an Org file, the global state is set to
1296 OVERVIEW, i.e., only the top level headlines are visible.  This can be
1297 configured through the variable @code{org-startup-folded}, or on a
1298 per-file basis by adding one of the following lines anywhere in the
1299 buffer:
1301 @example
1302 #+STARTUP: overview
1303 #+STARTUP: content
1304 #+STARTUP: showall
1305 #+STARTUP: showeverything
1306 @end example
1308 The startup visibility options are ignored when the file is open for the
1309 first time during the agenda generation: if you want the agenda to honor
1310 the startup visibility, set @code{org-agenda-inhibit-startup} to nil.
1312 @cindex property, VISIBILITY
1313 @noindent
1314 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
1315 and Columns}) will get their visibility adapted accordingly.  Allowed values
1316 for this property are @code{folded}, @code{children}, @code{content}, and
1317 @code{all}.
1318 @table @asis
1319 @orgcmd{C-u C-u @key{TAB},org-set-startup-visibility}
1320 Switch back to the startup visibility of the buffer, i.e., whatever is
1321 requested by startup options and @samp{VISIBILITY} properties in individual
1322 entries.
1323 @end table
1325 @node Motion, Structure editing, Visibility cycling, Document Structure
1326 @section Motion
1327 @cindex motion, between headlines
1328 @cindex jumping, to headlines
1329 @cindex headline navigation
1330 The following commands jump to other headlines in the buffer.
1332 @table @asis
1333 @orgcmd{C-c C-n,outline-next-visible-heading}
1334 Next heading.
1335 @orgcmd{C-c C-p,outline-previous-visible-heading}
1336 Previous heading.
1337 @orgcmd{C-c C-f,org-forward-same-level}
1338 Next heading same level.
1339 @orgcmd{C-c C-b,org-backward-same-level}
1340 Previous heading same level.
1341 @orgcmd{C-c C-u,outline-up-heading}
1342 Backward to higher level heading.
1343 @orgcmd{C-c C-j,org-goto}
1344 Jump to a different place without changing the current outline
1345 visibility.  Shows the document structure in a temporary buffer, where
1346 you can use the following keys to find your destination:
1347 @vindex org-goto-auto-isearch
1348 @example
1349 @key{TAB}         @r{Cycle visibility.}
1350 @key{down} / @key{up}   @r{Next/previous visible headline.}
1351 @key{RET}         @r{Select this location.}
1352 @kbd{/}           @r{Do a Sparse-tree search}
1353 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
1354 n / p        @r{Next/previous visible headline.}
1355 f / b        @r{Next/previous headline same level.}
1356 u            @r{One level up.}
1357 0-9          @r{Digit argument.}
1358 q            @r{Quit}
1359 @end example
1360 @vindex org-goto-interface
1361 @noindent
1362 See also the variable @code{org-goto-interface}.
1363 @end table
1365 @node Structure editing, Sparse trees, Motion, Document Structure
1366 @section Structure editing
1367 @cindex structure editing
1368 @cindex headline, promotion and demotion
1369 @cindex promotion, of subtrees
1370 @cindex demotion, of subtrees
1371 @cindex subtree, cut and paste
1372 @cindex pasting, of subtrees
1373 @cindex cutting, of subtrees
1374 @cindex copying, of subtrees
1375 @cindex sorting, of subtrees
1376 @cindex subtrees, cut and paste
1378 @table @asis
1379 @orgcmd{M-@key{RET},org-insert-heading}
1380 @vindex org-M-RET-may-split-line
1381 Insert new heading with same level as current.  If the cursor is in a plain
1382 list item, a new item is created (@pxref{Plain lists}).  To force creation of
1383 a new headline, use a prefix argument.  When this command is used in the
1384 middle of a line, the line is split and the rest of the line becomes the new
1385 headline@footnote{If you do not want the line to be split, customize the
1386 variable @code{org-M-RET-may-split-line}.}.  If the command is used at the
1387 beginning of a headline, the new headline is created before the current line.
1388 If at the beginning of any other line, the content of that line is made the
1389 new heading.  If the command is used at the end of a folded subtree (i.e.,
1390 behind the ellipses at the end of a headline), then a headline like the
1391 current one will be inserted after the end of the subtree.
1392 @orgcmd{C-@key{RET},org-insert-heading-respect-content}
1393 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
1394 current heading, the new heading is placed after the body instead of before
1395 it.  This command works from anywhere in the entry.
1396 @orgcmd{M-S-@key{RET},org-insert-todo-heading}
1397 @vindex org-treat-insert-todo-heading-as-state-change
1398 Insert new TODO entry with same level as current heading.  See also the
1399 variable @code{org-treat-insert-todo-heading-as-state-change}.
1400 @orgcmd{C-S-@key{RET},org-insert-todo-heading-respect-content}
1401 Insert new TODO entry with same level as current heading.  Like
1402 @kbd{C-@key{RET}}, the new headline will be inserted after the current
1403 subtree.
1404 @orgcmd{@key{TAB},org-cycle}
1405 In a new entry with no text yet, the first @key{TAB} demotes the entry to
1406 become a child of the previous one.  The next @key{TAB} makes it a parent,
1407 and so on, all the way to top level.  Yet another @key{TAB}, and you are back
1408 to the initial level.
1409 @orgcmd{M-@key{left},org-do-promote}
1410 Promote current heading by one level.
1411 @orgcmd{M-@key{right},org-do-demote}
1412 Demote current heading by one level.
1413 @orgcmd{M-S-@key{left},org-promote-subtree}
1414 Promote the current subtree by one level.
1415 @orgcmd{M-S-@key{right},org-demote-subtree}
1416 Demote the current subtree by one level.
1417 @orgcmd{M-S-@key{up},org-move-subtree-up}
1418 Move subtree up (swap with previous subtree of same
1419 level).
1420 @orgcmd{M-S-@key{down},org-move-subtree-down}
1421 Move subtree down (swap with next subtree of same level).
1422 @orgcmd{M-h,org-mark-element}
1423 Mark the element at point.  Hitting repeatedly will mark subsequent elements
1424 of the one just marked.  E.g., hitting @key{M-h} on a paragraph will mark it,
1425 hitting @key{M-h} immediately again will mark the next one.
1426 @orgcmd{C-c @@,org-mark-subtree}
1427 Mark the subtree at point.  Hitting repeatedly will mark subsequent subtrees
1428 of the same level than the marked subtree.
1429 @orgcmd{C-c C-x C-w,org-cut-subtree}
1430 Kill subtree, i.e., remove it from buffer but save in kill ring.
1431 With a numeric prefix argument N, kill N sequential subtrees.
1432 @orgcmd{C-c C-x M-w,org-copy-subtree}
1433 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
1434 sequential subtrees.
1435 @orgcmd{C-c C-x C-y,org-paste-subtree}
1436 Yank subtree from kill ring.  This does modify the level of the subtree to
1437 make sure the tree fits in nicely at the yank position.  The yank level can
1438 also be specified with a numeric prefix argument, or by yanking after a
1439 headline marker like @samp{****}.
1440 @orgcmd{C-y,org-yank}
1441 @vindex org-yank-adjusted-subtrees
1442 @vindex org-yank-folded-subtrees
1443 Depending on the variables @code{org-yank-adjusted-subtrees} and
1444 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
1445 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
1446 C-x C-y}.  With the default settings, no level adjustment will take place,
1447 but the yanked tree will be folded unless doing so would swallow text
1448 previously visible.  Any prefix argument to this command will force a normal
1449 @code{yank} to be executed, with the prefix passed along.  A good way to
1450 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
1451 yank, it will yank previous kill items plainly, without adjustment and
1452 folding.
1453 @orgcmd{C-c C-x c,org-clone-subtree-with-time-shift}
1454 Clone a subtree by making a number of sibling copies of it.  You will be
1455 prompted for the number of copies to make, and you can also specify if any
1456 timestamps in the entry should be shifted.  This can be useful, for example,
1457 to create a number of tasks related to a series of lectures to prepare.  For
1458 more details, see the docstring of the command
1459 @code{org-clone-subtree-with-time-shift}.
1460 @orgcmd{C-c C-w,org-refile}
1461 Refile entry or region to a different location.  @xref{Refile and copy}.
1462 @orgcmd{C-c ^,org-sort}
1463 Sort same-level entries.  When there is an active region, all entries in the
1464 region will be sorted.  Otherwise the children of the current headline are
1465 sorted.  The command prompts for the sorting method, which can be
1466 alphabetically, numerically, by time (first timestamp with active preferred,
1467 creation time, scheduled time, deadline time), by priority, by TODO keyword
1468 (in the sequence the keywords have been defined in the setup) or by the value
1469 of a property.  Reverse sorting is possible as well.  You can also supply
1470 your own function to extract the sorting key.  With a @kbd{C-u} prefix,
1471 sorting will be case-sensitive.
1472 @orgcmd{C-x n s,org-narrow-to-subtree}
1473 Narrow buffer to current subtree.
1474 @orgcmd{C-x n b,org-narrow-to-block}
1475 Narrow buffer to current block.
1476 @orgcmd{C-x n w,widen}
1477 Widen buffer to remove narrowing.
1478 @orgcmd{C-c *,org-toggle-heading}
1479 Turn a normal line or plain list item into a headline (so that it becomes a
1480 subheading at its location).  Also turn a headline into a normal line by
1481 removing the stars.  If there is an active region, turn all lines in the
1482 region into headlines.  If the first line in the region was an item, turn
1483 only the item lines into headlines.  Finally, if the first line is a
1484 headline, remove the stars from all headlines in the region.
1485 @end table
1487 @cindex region, active
1488 @cindex active region
1489 @cindex transient mark mode
1490 When there is an active region (Transient Mark mode), promotion and
1491 demotion work on all headlines in the region.  To select a region of
1492 headlines, it is best to place both point and mark at the beginning of a
1493 line, mark at the beginning of the first headline, and point at the line
1494 just after the last headline to change.  Note that when the cursor is
1495 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1496 functionality.
1499 @node Sparse trees, Plain lists, Structure editing, Document Structure
1500 @section Sparse trees
1501 @cindex sparse trees
1502 @cindex trees, sparse
1503 @cindex folding, sparse trees
1504 @cindex occur, command
1506 @vindex org-show-hierarchy-above
1507 @vindex org-show-following-heading
1508 @vindex org-show-siblings
1509 @vindex org-show-entry-below
1510 An important feature of Org mode is the ability to construct @emph{sparse
1511 trees} for selected information in an outline tree, so that the entire
1512 document is folded as much as possible, but the selected information is made
1513 visible along with the headline structure above it@footnote{See also the
1514 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1515 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1516 control on how much context is shown around each match.}.  Just try it out
1517 and you will see immediately how it works.
1519 Org mode contains several commands creating such trees, all these
1520 commands can be accessed through a dispatcher:
1522 @table @asis
1523 @orgcmd{C-c /,org-sparse-tree}
1524 This prompts for an extra key to select a sparse-tree creating command.
1525 @orgcmd{C-c / r,org-occur}
1526 @vindex org-remove-highlights-with-change
1527 Prompts for a regexp and shows a sparse tree with all matches.  If
1528 the match is in a headline, the headline is made visible.  If the match is in
1529 the body of an entry, headline and body are made visible.  In order to
1530 provide minimal context, also the full hierarchy of headlines above the match
1531 is shown, as well as the headline following the match.  Each match is also
1532 highlighted; the highlights disappear when the buffer is changed by an
1533 editing command@footnote{This depends on the option
1534 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1535 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1536 so several calls to this command can be stacked.
1537 @orgcmdkkc{M-g n,M-g M-n,next-error}
1538 Jump to the next sparse tree match in this buffer.
1539 @orgcmdkkc{M-g p,M-g M-p,previous-error}
1540 Jump to the previous sparse tree match in this buffer.
1541 @end table
1544 @noindent
1545 @vindex org-agenda-custom-commands
1546 For frequently used sparse trees of specific search strings, you can
1547 use the variable @code{org-agenda-custom-commands} to define fast
1548 keyboard access to specific sparse trees.  These commands will then be
1549 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1550 For example:
1552 @lisp
1553 (setq org-agenda-custom-commands
1554       '(("f" occur-tree "FIXME")))
1555 @end lisp
1557 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1558 a sparse tree matching the string @samp{FIXME}.
1560 The other sparse tree commands select headings based on TODO keywords,
1561 tags, or properties and will be discussed later in this manual.
1563 @kindex C-c C-e v
1564 @cindex printing sparse trees
1565 @cindex visible text, printing
1566 To print a sparse tree, you can use the Emacs command
1567 @code{ps-print-buffer-with-faces} which does not print invisible parts
1568 of the document @footnote{This does not work under XEmacs, because
1569 XEmacs uses selective display for outlining, not text properties.}.
1570 Or you can use the command @kbd{C-c C-e v} to export only the visible
1571 part of the document and print the resulting file.
1573 @node Plain lists, Drawers, Sparse trees, Document Structure
1574 @section Plain lists
1575 @cindex plain lists
1576 @cindex lists, plain
1577 @cindex lists, ordered
1578 @cindex ordered lists
1580 Within an entry of the outline tree, hand-formatted lists can provide
1581 additional structure.  They also provide a way to create lists of checkboxes
1582 (@pxref{Checkboxes}).  Org supports editing such lists, and every exporter
1583 (@pxref{Exporting}) can parse and format them.
1585 Org knows ordered lists, unordered lists, and description lists.
1586 @itemize @bullet
1587 @item
1588 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1589 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1590 they will be seen as top-level headlines.  Also, when you are hiding leading
1591 stars to get a clean outline view, plain list items starting with a star may
1592 be hard to distinguish from true headlines.  In short: even though @samp{*}
1593 is supported, it may be better to not use it for plain list items.}  as
1594 bullets.
1595 @item
1596 @vindex org-plain-list-ordered-item-terminator
1597 @vindex org-alphabetical-lists
1598 @emph{Ordered} list items start with a numeral followed by either a period or
1599 a right parenthesis@footnote{You can filter out any of them by configuring
1600 @code{org-plain-list-ordered-item-terminator}.}, such as @samp{1.} or
1601 @samp{1)}@footnote{You can also get @samp{a.}, @samp{A.}, @samp{a)} and
1602 @samp{A)} by configuring @code{org-alphabetical-lists}.  To minimize
1603 confusion with normal text, those are limited to one character only.  Beyond
1604 that limit, bullets will automatically fallback to numbers.}.  If you want a
1605 list to start with a different value (e.g., 20), start the text of the item
1606 with @code{[@@20]}@footnote{If there's a checkbox in the item, the cookie
1607 must be put @emph{before} the checkbox.  If you have activated alphabetical
1608 lists, you can also use counters like @code{[@@b]}.}.  Those constructs can
1609 be used in any item of the list in order to enforce a particular numbering.
1610 @item
1611 @emph{Description} list items are unordered list items, and contain the
1612 separator @samp{ :: } to distinguish the description @emph{term} from the
1613 description.
1614 @end itemize
1616 Items belonging to the same list must have the same indentation on the first
1617 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1618 2--digit numbers must be written left-aligned with the other numbers in the
1619 list.  An item ends before the next line that is less or equally indented
1620 than its bullet/number.
1622 @vindex org-empty-line-terminates-plain-lists
1623 A list ends whenever every item has ended, which means before any line less
1624 or equally indented than items at top level.  It also ends before two blank
1625 lines@footnote{See also @code{org-empty-line-terminates-plain-lists}.}.  In
1626 that case, all items are closed.  Here is an example:
1628 @example
1629 @group
1630 ** Lord of the Rings
1631    My favorite scenes are (in this order)
1632    1. The attack of the Rohirrim
1633    2. Eowyn's fight with the witch king
1634       + this was already my favorite scene in the book
1635       + I really like Miranda Otto.
1636    3. Peter Jackson being shot by Legolas
1637       - on DVD only
1638       He makes a really funny face when it happens.
1639    But in the end, no individual scenes matter but the film as a whole.
1640    Important actors in this film are:
1641    - @b{Elijah Wood} :: He plays Frodo
1642    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1643      him very well from his role as Mikey Walsh in @i{The Goonies}.
1644 @end group
1645 @end example
1647 Org supports these lists by tuning filling and wrapping commands to deal with
1648 them correctly@footnote{Org only changes the filling settings for Emacs.  For
1649 XEmacs, you should use Kyle E. Jones' @file{filladapt.el}.  To turn this on,
1650 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
1651 properly (@pxref{Exporting}).  Since indentation is what governs the
1652 structure of these lists, many structural constructs like @code{#+BEGIN_...}
1653 blocks can be indented to signal that they belong to a particular item.
1655 @vindex org-list-demote-modify-bullet
1656 @vindex org-list-indent-offset
1657 If you find that using a different bullet for a sub-list (than that used for
1658 the current list-level) improves readability, customize the variable
1659 @code{org-list-demote-modify-bullet}.  To get a greater difference of
1660 indentation between items and theirs sub-items, customize
1661 @code{org-list-indent-offset}.
1663 @vindex org-list-automatic-rules
1664 The following commands act on items when the cursor is in the first line of
1665 an item (the line with the bullet or number).  Some of them imply the
1666 application of automatic rules to keep list structure intact.  If some of
1667 these actions get in your way, configure @code{org-list-automatic-rules}
1668 to disable them individually.
1670 @table @asis
1671 @orgcmd{@key{TAB},org-cycle}
1672 @cindex cycling, in plain lists
1673 @vindex org-cycle-include-plain-lists
1674 Items can be folded just like headline levels.  Normally this works only if
1675 the cursor is on a plain list item.  For more details, see the variable
1676 @code{org-cycle-include-plain-lists}.  If this variable is set to
1677 @code{integrate}, plain list items will be treated like low-level
1678 headlines.  The level of an item is then given by the indentation of the
1679 bullet/number.  Items are always subordinate to real headlines, however; the
1680 hierarchies remain completely separated.  In a new item with no text yet, the
1681 first @key{TAB} demotes the item to become a child of the previous
1682 one.  Subsequent @key{TAB}s move the item to meaningful levels in the list
1683 and eventually get it back to its initial position.
1684 @orgcmd{M-@key{RET},org-insert-heading}
1685 @vindex org-M-RET-may-split-line
1686 @vindex org-list-automatic-rules
1687 Insert new item at current level.  With a prefix argument, force a new
1688 heading (@pxref{Structure editing}).  If this command is used in the middle
1689 of an item, that item is @emph{split} in two, and the second part becomes the
1690 new item@footnote{If you do not want the item to be split, customize the
1691 variable @code{org-M-RET-may-split-line}.}.  If this command is executed
1692 @emph{before item's body}, the new item is created @emph{before} the current
1693 one.
1694 @end table
1696 @table @kbd
1697 @kindex M-S-@key{RET}
1698 @item M-S-RET
1699 Insert a new item with a checkbox (@pxref{Checkboxes}).
1700 @kindex S-@key{down}
1701 @item S-up
1702 @itemx S-down
1703 @cindex shift-selection-mode
1704 @vindex org-support-shift-select
1705 @vindex org-list-use-circular-motion
1706 Jump to the previous/next item in the current list@footnote{If you want to
1707 cycle around items that way, you may customize
1708 @code{org-list-use-circular-motion}.}, but only if
1709 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1710 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1711 similar effect.
1712 @kindex M-@key{up}
1713 @kindex M-@key{down}
1714 @item M-up
1715 @itemx M-down
1716 Move the item including subitems up/down@footnote{See
1717 @code{org-liste-use-circular-motion} for a cyclic behavior.} (swap with
1718 previous/next item of same indentation).  If the list is ordered, renumbering
1719 is automatic.
1720 @kindex M-@key{left}
1721 @kindex M-@key{right}
1722 @item M-left
1723 @itemx M-right
1724 Decrease/increase the indentation of an item, leaving children alone.
1725 @kindex M-S-@key{left}
1726 @kindex M-S-@key{right}
1727 @item M-S-left
1728 @itemx M-S-right
1729 Decrease/increase the indentation of the item, including subitems.
1730 Initially, the item tree is selected based on current indentation.  When
1731 these commands are executed several times in direct succession, the initially
1732 selected region is used, even if the new indentation would imply a different
1733 hierarchy.  To use the new hierarchy, break the command chain with a cursor
1734 motion or so.
1736 As a special case, using this command on the very first item of a list will
1737 move the whole list.  This behavior can be disabled by configuring
1738 @code{org-list-automatic-rules}.  The global indentation of a list has no
1739 influence on the text @emph{after} the list.
1740 @kindex C-c C-c
1741 @item C-c C-c
1742 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1743 state of the checkbox.  In any case, verify bullets and indentation
1744 consistency in the whole list.
1745 @kindex C-c -
1746 @vindex org-plain-list-ordered-item-terminator
1747 @item C-c -
1748 Cycle the entire list level through the different itemize/enumerate bullets
1749 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}) or a subset of them,
1750 depending on @code{org-plain-list-ordered-item-terminator}, the type of list,
1751 and its indentation.  With a numeric prefix argument N, select the Nth bullet
1752 from this list.  If there is an active region when calling this, selected
1753 text will be changed into an item.  With a prefix argument, all lines will be
1754 converted to list items.  If the first line already was a list item, any item
1755 marker will be removed from the list.  Finally, even without an active
1756 region, a normal line will be converted into a list item.
1757 @kindex C-c *
1758 @item C-c *
1759 Turn a plain list item into a headline (so that it becomes a subheading at
1760 its location).  @xref{Structure editing}, for a detailed explanation.
1761 @kindex C-c C-*
1762 @item C-c C-*
1763 Turn the whole plain list into a subtree of the current heading.  Checkboxes
1764 (@pxref{Checkboxes}) will become TODO (resp. DONE) keywords when unchecked
1765 (resp. checked).
1766 @kindex S-@key{left}
1767 @kindex S-@key{right}
1768 @item S-left/right
1769 @vindex org-support-shift-select
1770 This command also cycles bullet styles when the cursor in on the bullet or
1771 anywhere in an item line, details depending on
1772 @code{org-support-shift-select}.
1773 @kindex C-c ^
1774 @item C-c ^
1775 Sort the plain list.  You will be prompted for the sorting method:
1776 numerically, alphabetically, by time, or by custom function.
1777 @end table
1779 @node Drawers, Blocks, Plain lists, Document Structure
1780 @section Drawers
1781 @cindex drawers
1782 @cindex #+DRAWERS
1783 @cindex visibility cycling, drawers
1785 @vindex org-drawers
1786 @cindex org-insert-drawer
1787 @kindex C-c C-x d
1788 Sometimes you want to keep information associated with an entry, but you
1789 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1790 Drawers need to be configured with the variable
1791 @code{org-drawers}@footnote{You can define additional drawers on a
1792 per-file basis with a line like @code{#+DRAWERS: HIDDEN STATE}}.  Drawers
1793 look like this:
1795 @example
1796 ** This is a headline
1797    Still outside the drawer
1798    :DRAWERNAME:
1799    This is inside the drawer.
1800    :END:
1801    After the drawer.
1802 @end example
1804 You can interactively insert drawers at point by calling
1805 @code{org-insert-drawer}, which is bound to @key{C-c C-x d}.  With an active
1806 region, this command will put the region inside the drawer.  With a prefix
1807 argument, this command calls @code{org-insert-property-drawer} and add a
1808 property drawer right below the current headline.  Completion over drawer
1809 keywords is also possible using @key{M-TAB}.
1811 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1812 show the entry, but keep the drawer collapsed to a single line.  In order to
1813 look inside the drawer, you need to move the cursor to the drawer line and
1814 press @key{TAB} there.  Org mode uses the @code{PROPERTIES} drawer for
1815 storing properties (@pxref{Properties and Columns}), and you can also arrange
1816 for state change notes (@pxref{Tracking TODO state changes}) and clock times
1817 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.  If you
1818 want to store a quick note in the LOGBOOK drawer, in a similar way to state changes, use
1820 @table @kbd
1821 @kindex C-c C-z
1822 @item C-c C-z
1823 Add a time-stamped note to the LOGBOOK drawer.
1824 @end table
1826 @node Blocks, Footnotes, Drawers, Document Structure
1827 @section Blocks
1829 @vindex org-hide-block-startup
1830 @cindex blocks, folding
1831 Org mode uses begin...end blocks for various purposes from including source
1832 code examples (@pxref{Literal examples}) to capturing time logging
1833 information (@pxref{Clocking work time}).  These blocks can be folded and
1834 unfolded by pressing TAB in the begin line.  You can also get all blocks
1835 folded at startup by configuring the variable @code{org-hide-block-startup}
1836 or on a per-file basis by using
1838 @cindex @code{hideblocks}, STARTUP keyword
1839 @cindex @code{nohideblocks}, STARTUP keyword
1840 @example
1841 #+STARTUP: hideblocks
1842 #+STARTUP: nohideblocks
1843 @end example
1845 @node Footnotes, Orgstruct mode, Blocks, Document Structure
1846 @section Footnotes
1847 @cindex footnotes
1849 Org mode supports the creation of footnotes.  In contrast to the
1850 @file{footnote.el} package, Org mode's footnotes are designed for work on a
1851 larger document, not only for one-off documents like emails.  The basic
1852 syntax is similar to the one used by @file{footnote.el}, i.e., a footnote is
1853 defined in a paragraph that is started by a footnote marker in square
1854 brackets in column 0, no indentation allowed.  If you need a paragraph break
1855 inside a footnote, use the @LaTeX{} idiom @samp{\par}.  The footnote reference
1856 is simply the marker in square brackets, inside text.  For example:
1858 @example
1859 The Org homepage[fn:1] now looks a lot better than it used to.
1861 [fn:1] The link is: http://orgmode.org
1862 @end example
1864 Org mode extends the number-based syntax to @emph{named} footnotes and
1865 optional inline definition.  Using plain numbers as markers (as
1866 @file{footnote.el} does) is supported for backward compatibility, but not
1867 encouraged because of possible conflicts with @LaTeX{} snippets (@pxref{Embedded
1868 @LaTeX{}}).  Here are the valid references:
1870 @table @code
1871 @item [1]
1872 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
1873 recommended because something like @samp{[1]} could easily be part of a code
1874 snippet.
1875 @item [fn:name]
1876 A named footnote reference, where @code{name} is a unique label word, or, for
1877 simplicity of automatic creation, a number.
1878 @item [fn:: This is the inline definition of this footnote]
1879 A @LaTeX{}-like anonymous footnote where the definition is given directly at the
1880 reference point.
1881 @item [fn:name: a definition]
1882 An inline definition of a footnote, which also specifies a name for the note.
1883 Since Org allows multiple references to the same note, you can then use
1884 @code{[fn:name]} to create additional references.
1885 @end table
1887 @vindex org-footnote-auto-label
1888 Footnote labels can be created automatically, or you can create names yourself.
1889 This is handled by the variable @code{org-footnote-auto-label} and its
1890 corresponding @code{#+STARTUP} keywords.  See the docstring of that variable
1891 for details.
1893 @noindent The following command handles footnotes:
1895 @table @kbd
1896 @kindex C-c C-x f
1897 @item C-c C-x f
1898 The footnote action command.
1900 When the cursor is on a footnote reference, jump to the definition.  When it
1901 is at a definition, jump to the (first) reference.
1903 @vindex org-footnote-define-inline
1904 @vindex org-footnote-section
1905 @vindex org-footnote-auto-adjust
1906 Otherwise, create a new footnote.  Depending on the variable
1907 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1908 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1909 definition will be placed right into the text as part of the reference, or
1910 separately into the location determined by the variable
1911 @code{org-footnote-section}.
1913 When this command is called with a prefix argument, a menu of additional
1914 options is offered:
1915 @example
1916 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1917     @r{Org makes no effort to sort footnote definitions into a particular}
1918     @r{sequence.  If you want them sorted, use this command, which will}
1919     @r{also move entries according to @code{org-footnote-section}.  Automatic}
1920     @r{sorting after each insertion/deletion can be configured using the}
1921     @r{variable @code{org-footnote-auto-adjust}.}
1922 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
1923     @r{after each insertion/deletion can be configured using the variable}
1924     @r{@code{org-footnote-auto-adjust}.}
1925 S   @r{Short for first @code{r}, then @code{s} action.}
1926 n   @r{Normalize the footnotes by collecting all definitions (including}
1927     @r{inline definitions) into a special section, and then numbering them}
1928     @r{in sequence.  The references will then also be numbers.  This is}
1929     @r{meant to be the final step before finishing a document (e.g., sending}
1930     @r{off an email).  The exporters do this automatically, and so could}
1931     @r{something like @code{message-send-hook}.}
1932 d   @r{Delete the footnote at point, and all definitions of and references}
1933     @r{to it.}
1934 @end example
1935 Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
1936 corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
1937 renumbering and sorting footnotes can be automatic after each insertion or
1938 deletion.
1940 @kindex C-c C-c
1941 @item C-c C-c
1942 If the cursor is on a footnote reference, jump to the definition.  If it is a
1943 the definition, jump back to the reference.  When called at a footnote
1944 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1945 @kindex C-c C-o
1946 @kindex mouse-1
1947 @kindex mouse-2
1948 @item C-c C-o  @r{or} mouse-1/2
1949 Footnote labels are also links to the corresponding definition/reference, and
1950 you can use the usual commands to follow these links.
1951 @end table
1953 @node Orgstruct mode,  , Footnotes, Document Structure
1954 @section The Orgstruct minor mode
1955 @cindex Orgstruct mode
1956 @cindex minor mode for structure editing
1958 If you like the intuitive way the Org mode structure editing and list
1959 formatting works, you might want to use these commands in other modes like
1960 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
1961 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
1962 turn it on by default, for example in Message mode, with one of:
1964 @lisp
1965 (add-hook 'message-mode-hook 'turn-on-orgstruct)
1966 (add-hook 'message-mode-hook 'turn-on-orgstruct++)
1967 @end lisp
1969 When this mode is active and the cursor is on a line that looks to Org like a
1970 headline or the first line of a list item, most structure editing commands
1971 will work, even if the same keys normally have different functionality in the
1972 major mode you are using.  If the cursor is not in one of those special
1973 lines, Orgstruct mode lurks silently in the shadows.  When you use
1974 @code{orgstruct++-mode}, Org will also export indentation and autofill
1975 settings into that mode, and detect item context after the first line of an
1976 item.
1978 @node Tables, Hyperlinks, Document Structure, Top
1979 @chapter Tables
1980 @cindex tables
1981 @cindex editing tables
1983 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1984 calculations are supported using the Emacs @file{calc} package
1985 (@pxref{Top, Calc, , calc, Gnu Emacs Calculator Manual}).
1987 @menu
1988 * Built-in table editor::       Simple tables
1989 * Column width and alignment::  Overrule the automatic settings
1990 * Column groups::               Grouping to trigger vertical lines
1991 * Orgtbl mode::                 The table editor as minor mode
1992 * The spreadsheet::             The table editor has spreadsheet capabilities
1993 * Org-Plot::                    Plotting from org tables
1994 @end menu
1996 @node Built-in table editor, Column width and alignment, Tables, Tables
1997 @section The built-in table editor
1998 @cindex table editor, built-in
2000 Org makes it easy to format tables in plain ASCII@.  Any line with @samp{|} as
2001 the first non-whitespace character is considered part of a table.  @samp{|}
2002 is also the column separator@footnote{To insert a vertical bar into a table
2003 field, use @code{\vert} or, inside a word @code{abc\vert@{@}def}.}.  A table
2004 might look like this:
2006 @example
2007 | Name  | Phone | Age |
2008 |-------+-------+-----|
2009 | Peter |  1234 |  17 |
2010 | Anna  |  4321 |  25 |
2011 @end example
2013 A table is re-aligned automatically each time you press @key{TAB} or
2014 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
2015 the next field (@key{RET} to the next row) and creates new table rows
2016 at the end of the table or before horizontal lines.  The indentation
2017 of the table is set by the first line.  Any line starting with
2018 @samp{|-} is considered as a horizontal separator line and will be
2019 expanded on the next re-align to span the whole table width.  So, to
2020 create the above table, you would only type
2022 @example
2023 |Name|Phone|Age|
2025 @end example
2027 @noindent and then press @key{TAB} to align the table and start filling in
2028 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
2029 @kbd{C-c @key{RET}}.
2031 @vindex org-enable-table-editor
2032 @vindex org-table-auto-blank-field
2033 When typing text into a field, Org treats @key{DEL},
2034 @key{Backspace}, and all character keys in a special way, so that
2035 inserting and deleting avoids shifting other fields.  Also, when
2036 typing @emph{immediately after the cursor was moved into a new field
2037 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
2038 field is automatically made blank.  If this behavior is too
2039 unpredictable for you, configure the variables
2040 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
2042 @table @kbd
2043 @tsubheading{Creation and conversion}
2044 @orgcmd{C-c |,org-table-create-or-convert-from-region}
2045 Convert the active region to table.  If every line contains at least one
2046 TAB character, the function assumes that the material is tab separated.
2047 If every line contains a comma, comma-separated values (CSV) are assumed.
2048 If not, lines are split at whitespace into fields.  You can use a prefix
2049 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
2050 C-u} forces TAB, and a numeric argument N indicates that at least N
2051 consecutive spaces, or alternatively a TAB will be the separator.
2053 If there is no active region, this command creates an empty Org
2054 table.  But it is easier just to start typing, like
2055 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
2057 @tsubheading{Re-aligning and field motion}
2058 @orgcmd{C-c C-c,org-table-align}
2059 Re-align the table and don't move to another field.
2061 @orgcmd{<TAB>,org-table-next-field}
2062 Re-align the table, move to the next field.  Creates a new row if
2063 necessary.
2065 @orgcmd{S-@key{TAB},org-table-previous-field}
2066 Re-align, move to previous field.
2068 @orgcmd{@key{RET},org-table-next-row}
2069 Re-align the table and move down to next row.  Creates a new row if
2070 necessary.  At the beginning or end of a line, @key{RET} still does
2071 NEWLINE, so it can be used to split a table.
2073 @orgcmd{M-a,org-table-beginning-of-field}
2074 Move to beginning of the current table field, or on to the previous field.
2075 @orgcmd{M-e,org-table-end-of-field}
2076 Move to end of the current table field, or on to the next field.
2078 @tsubheading{Column and row editing}
2079 @orgcmdkkcc{M-@key{left},M-@key{right},org-table-move-column-left,org-table-move-column-right}
2080 Move the current column left/right.
2082 @orgcmd{M-S-@key{left},org-table-delete-column}
2083 Kill the current column.
2085 @orgcmd{M-S-@key{right},org-table-insert-column}
2086 Insert a new column to the left of the cursor position.
2088 @orgcmdkkcc{M-@key{up},M-@key{down},org-table-move-row-up,org-table-move-row-down}
2089 Move the current row up/down.
2091 @orgcmd{M-S-@key{up},org-table-kill-row}
2092 Kill the current row or horizontal line.
2094 @orgcmd{M-S-@key{down},org-table-insert-row}
2095 Insert a new row above the current row.  With a prefix argument, the line is
2096 created below the current one.
2098 @orgcmd{C-c -,org-table-insert-hline}
2099 Insert a horizontal line below current row.  With a prefix argument, the line
2100 is created above the current line.
2102 @orgcmd{C-c @key{RET},org-table-hline-and-move}
2103 Insert a horizontal line below current row, and move the cursor into the row
2104 below that line.
2106 @orgcmd{C-c ^,org-table-sort-lines}
2107 Sort the table lines in the region.  The position of point indicates the
2108 column to be used for sorting, and the range of lines is the range
2109 between the nearest horizontal separator lines, or the entire table.  If
2110 point is before the first column, you will be prompted for the sorting
2111 column.  If there is an active region, the mark specifies the first line
2112 and the sorting column, while point should be in the last line to be
2113 included into the sorting.  The command prompts for the sorting type
2114 (alphabetically, numerically, or by time).  When called with a prefix
2115 argument, alphabetic sorting will be case-sensitive.
2117 @tsubheading{Regions}
2118 @orgcmd{C-c C-x M-w,org-table-copy-region}
2119 Copy a rectangular region from a table to a special clipboard.  Point and
2120 mark determine edge fields of the rectangle.  If there is no active region,
2121 copy just the current field.  The process ignores horizontal separator lines.
2123 @orgcmd{C-c C-x C-w,org-table-cut-region}
2124 Copy a rectangular region from a table to a special clipboard, and
2125 blank all fields in the rectangle.  So this is the ``cut'' operation.
2127 @orgcmd{C-c C-x C-y,org-table-paste-rectangle}
2128 Paste a rectangular region into a table.
2129 The upper left corner ends up in the current field.  All involved fields
2130 will be overwritten.  If the rectangle does not fit into the present table,
2131 the table is enlarged as needed.  The process ignores horizontal separator
2132 lines.
2134 @orgcmd{M-@key{RET},org-table-wrap-region}
2135 Split the current field at the cursor position and move the rest to the line
2136 below.  If there is an active region, and both point and mark are in the same
2137 column, the text in the column is wrapped to minimum width for the given
2138 number of lines.  A numeric prefix argument may be used to change the number
2139 of desired lines.  If there is no region, but you specify a prefix argument,
2140 the current field is made blank, and the content is appended to the field
2141 above.
2143 @tsubheading{Calculations}
2144 @cindex formula, in tables
2145 @cindex calculations, in tables
2146 @cindex region, active
2147 @cindex active region
2148 @cindex transient mark mode
2149 @orgcmd{C-c +,org-table-sum}
2150 Sum the numbers in the current column, or in the rectangle defined by
2151 the active region.  The result is shown in the echo area and can
2152 be inserted with @kbd{C-y}.
2154 @orgcmd{S-@key{RET},org-table-copy-down}
2155 @vindex org-table-copy-increment
2156 When current field is empty, copy from first non-empty field above.  When not
2157 empty, copy current field down to next row and move cursor along with it.
2158 Depending on the variable @code{org-table-copy-increment}, integer field
2159 values will be incremented during copy.  Integers that are too large will not
2160 be incremented.  Also, a @code{0} prefix argument temporarily disables the
2161 increment.  This key is also used by shift-selection and related modes
2162 (@pxref{Conflicts}).
2164 @tsubheading{Miscellaneous}
2165 @orgcmd{C-c `,org-table-edit-field}
2166 Edit the current field in a separate window.  This is useful for fields that
2167 are not fully visible (@pxref{Column width and alignment}).  When called with
2168 a @kbd{C-u} prefix, just make the full field visible, so that it can be
2169 edited in place.  When called with two @kbd{C-u} prefixes, make the editor
2170 window follow the cursor through the table and always show the current
2171 field.  The follow mode exits automatically when the cursor leaves the table,
2172 or when you repeat this command with @kbd{C-u C-u C-c `}.
2174 @item M-x org-table-import
2175 Import a file as a table.  The table should be TAB or whitespace
2176 separated.  Use, for example, to import a spreadsheet table or data
2177 from a database, because these programs generally can write
2178 TAB-separated text files.  This command works by inserting the file into
2179 the buffer and then converting the region to a table.  Any prefix
2180 argument is passed on to the converter, which uses it to determine the
2181 separator.
2182 @orgcmd{C-c |,org-table-create-or-convert-from-region}
2183 Tables can also be imported by pasting tabular text into the Org
2184 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
2185 @kbd{C-c |} command (see above under @i{Creation and conversion}).
2187 @item M-x org-table-export
2188 @findex org-table-export
2189 @vindex org-table-export-default-format
2190 Export the table, by default as a TAB-separated file.  Use for data
2191 exchange with, for example, spreadsheet or database programs.  The format
2192 used to export the file can be configured in the variable
2193 @code{org-table-export-default-format}.  You may also use properties
2194 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
2195 name and the format for table export in a subtree.  Org supports quite
2196 general formats for exported tables.  The exporter format is the same as the
2197 format used by Orgtbl radio tables, see @ref{Translator functions}, for a
2198 detailed description.
2199 @end table
2201 If you don't like the automatic table editor because it gets in your
2202 way on lines which you would like to start with @samp{|}, you can turn
2203 it off with
2205 @lisp
2206 (setq org-enable-table-editor nil)
2207 @end lisp
2209 @noindent Then the only table command that still works is
2210 @kbd{C-c C-c} to do a manual re-align.
2212 @node Column width and alignment, Column groups, Built-in table editor, Tables
2213 @section Column width and alignment
2214 @cindex narrow columns in tables
2215 @cindex alignment in tables
2217 The width of columns is automatically determined by the table editor.  And
2218 also the alignment of a column is determined automatically from the fraction
2219 of number-like versus non-number fields in the column.
2221 Sometimes a single field or a few fields need to carry more text, leading to
2222 inconveniently wide columns.  Or maybe you want to make a table with several
2223 columns having a fixed width, regardless of content.  To set@footnote{This
2224 feature does not work on XEmacs.} the width of a column, one field anywhere
2225 in the column may contain just the string @samp{<N>} where @samp{N} is an
2226 integer specifying the width of the column in characters.  The next re-align
2227 will then set the width of this column to this value.
2229 @example
2230 @group
2231 |---+------------------------------|               |---+--------|
2232 |   |                              |               |   | <6>    |
2233 | 1 | one                          |               | 1 | one    |
2234 | 2 | two                          |     ----\     | 2 | two    |
2235 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
2236 | 4 | four                         |               | 4 | four   |
2237 |---+------------------------------|               |---+--------|
2238 @end group
2239 @end example
2241 @noindent
2242 Fields that are wider become clipped and end in the string @samp{=>}.
2243 Note that the full text is still in the buffer but is hidden.
2244 To see the full text, hold the mouse over the field---a tool-tip window
2245 will show the full content.  To edit such a field, use the command
2246 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
2247 open a new window with the full field.  Edit it and finish with @kbd{C-c
2248 C-c}.
2250 @vindex org-startup-align-all-tables
2251 When visiting a file containing a table with narrowed columns, the
2252 necessary character hiding has not yet happened, and the table needs to
2253 be aligned before it looks nice.  Setting the option
2254 @code{org-startup-align-all-tables} will realign all tables in a file
2255 upon visiting, but also slow down startup.  You can also set this option
2256 on a per-file basis with:
2258 @example
2259 #+STARTUP: align
2260 #+STARTUP: noalign
2261 @end example
2263 If you would like to overrule the automatic alignment of number-rich columns
2264 to the right and of string-rich column to the left, you can use @samp{<r>},
2265 @samp{<c>}@footnote{Centering does not work inside Emacs, but it does have an
2266 effect when exporting to HTML.} or @samp{<l>} in a similar fashion.  You may
2267 also combine alignment and field width like this: @samp{<r10>}.
2269 Lines which only contain these formatting cookies will be removed
2270 automatically when exporting the document.
2272 @node Column groups, Orgtbl mode, Column width and alignment, Tables
2273 @section Column groups
2274 @cindex grouping columns in tables
2276 When Org exports tables, it does so by default without vertical
2277 lines because that is visually more satisfying in general.  Occasionally
2278 however, vertical lines can be useful to structure a table into groups
2279 of columns, much like horizontal lines can do for groups of rows.  In
2280 order to specify column groups, you can use a special row where the
2281 first field contains only @samp{/}.  The further fields can either
2282 contain @samp{<} to indicate that this column should start a group,
2283 @samp{>} to indicate the end of a column, or @samp{<>} (no space between @samp{<}
2284 and @samp{>}) to make a column
2285 a group of its own.  Boundaries between column groups will upon export be
2286 marked with vertical lines.  Here is an example:
2288 @example
2289 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2290 |---+-----+-----+-----+---------+------------|
2291 | / |   < |     |   > |       < |          > |
2292 | 1 |   1 |   1 |   1 |       1 |          1 |
2293 | 2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
2294 | 3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
2295 |---+-----+-----+-----+---------+------------|
2296 #+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
2297 @end example
2299 It is also sufficient to just insert the column group starters after
2300 every vertical line you would like to have:
2302 @example
2303 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2304 |----+-----+-----+-----+---------+------------|
2305 | /  | <   |     |     | <       |            |
2306 @end example
2308 @node Orgtbl mode, The spreadsheet, Column groups, Tables
2309 @section The Orgtbl minor mode
2310 @cindex Orgtbl mode
2311 @cindex minor mode for tables
2313 If you like the intuitive way the Org table editor works, you
2314 might also want to use it in other modes like Text mode or Mail mode.
2315 The minor mode Orgtbl mode makes this possible.  You can always toggle
2316 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
2317 example in Message mode, use
2319 @lisp
2320 (add-hook 'message-mode-hook 'turn-on-orgtbl)
2321 @end lisp
2323 Furthermore, with some special setup, it is possible to maintain tables
2324 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
2325 construct @LaTeX{} tables with the underlying ease and power of
2326 Orgtbl mode, including spreadsheet capabilities.  For details, see
2327 @ref{Tables in arbitrary syntax}.
2329 @node The spreadsheet, Org-Plot, Orgtbl mode, Tables
2330 @section The spreadsheet
2331 @cindex calculations, in tables
2332 @cindex spreadsheet capabilities
2333 @cindex @file{calc} package
2335 The table editor makes use of the Emacs @file{calc} package to implement
2336 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
2337 derive fields from other fields.  While fully featured, Org's implementation
2338 is not identical to other spreadsheets.  For example, Org knows the concept
2339 of a @emph{column formula} that will be applied to all non-header fields in a
2340 column without having to copy the formula to each relevant field.  There is
2341 also a formula debugger, and a formula editor with features for highlighting
2342 fields in the table corresponding to the references at the point in the
2343 formula, moving these references by arrow keys
2345 @menu
2346 * References::                  How to refer to another field or range
2347 * Formula syntax for Calc::     Using Calc to compute stuff
2348 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
2349 * Durations and time values::   How to compute durations and time values
2350 * Field and range formulas::    Formula for specific (ranges of) fields
2351 * Column formulas::             Formulas valid for an entire column
2352 * Lookup functions::            Lookup functions for searching tables
2353 * Editing and debugging formulas::  Fixing formulas
2354 * Updating the table::          Recomputing all dependent fields
2355 * Advanced features::           Field and column names, parameters and automatic recalc
2356 @end menu
2358 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
2359 @subsection References
2360 @cindex references
2362 To compute fields in the table from other fields, formulas must
2363 reference other fields or ranges.  In Org, fields can be referenced
2364 by name, by absolute coordinates, and by relative coordinates.  To find
2365 out what the coordinates of a field are, press @kbd{C-c ?} in that
2366 field, or press @kbd{C-c @}} to toggle the display of a grid.
2368 @subsubheading Field references
2369 @cindex field references
2370 @cindex references, to fields
2372 Formulas can reference the value of another field in two ways.  Like in
2373 any other spreadsheet, you may reference fields with a letter/number
2374 combination like @code{B3}, meaning the 2nd field in the 3rd row.
2375 @vindex org-table-use-standard-references
2376 However, Org prefers@footnote{Org will understand references typed by the
2377 user as @samp{B4}, but it will not use this syntax when offering a formula
2378 for editing.  You can customize this behavior using the variable
2379 @code{org-table-use-standard-references}.}  to use another, more general
2380 representation that looks like this:
2381 @example
2382 @@@var{row}$@var{column}
2383 @end example
2385 Column specifications can be absolute like @code{$1},
2386 @code{$2},...@code{$@var{N}}, or relative to the current column (i.e., the
2387 column of the field which is being computed) like @code{$+1} or @code{$-2}.
2388 @code{$<} and @code{$>} are immutable references to the first and last
2389 column, respectively, and you can use @code{$>>>} to indicate the third
2390 column from the right.
2392 The row specification only counts data lines and ignores horizontal separator
2393 lines (hlines).  Like with columns, you can use absolute row numbers
2394 @code{@@1}, @code{@@2},...@code{@@@var{N}}, and row numbers relative to the
2395 current row like @code{@@+3} or @code{@@-1}.  @code{@@<} and @code{@@>} are
2396 immutable references the first and last@footnote{For backward compatibility
2397 you can also use special names like @code{$LR5} and @code{$LR12} to refer in
2398 a stable way to the 5th and 12th field in the last row of the table.
2399 However, this syntax is deprecated, it should not be used for new documents.
2400 Use @code{@@>$} instead.} row in the table, respectively.  You may also
2401 specify the row relative to one of the hlines: @code{@@I} refers to the first
2402 hline, @code{@@II} to the second, etc.  @code{@@-I} refers to the first such
2403 line above the current line, @code{@@+I} to the first such line below the
2404 current line.  You can also write @code{@@III+2} which is the second data line
2405 after the third hline in the table.
2407 @code{@@0} and @code{$0} refer to the current row and column, respectively,
2408 i.e., to the row/column for the field being computed.  Also, if you omit
2409 either the column or the row part of the reference, the current row/column is
2410 implied.
2412 Org's references with @emph{unsigned} numbers are fixed references
2413 in the sense that if you use the same reference in the formula for two
2414 different fields, the same field will be referenced each time.
2415 Org's references with @emph{signed} numbers are floating
2416 references because the same reference operator can reference different
2417 fields depending on the field being calculated by the formula.
2419 Here are a few examples:
2421 @example
2422 @@2$3      @r{2nd row, 3rd column (same as @code{C2})}
2423 $5        @r{column 5 in the current row (same as @code{E&})}
2424 @@2        @r{current column, row 2}
2425 @@-1$-3    @r{the field one row up, three columns to the left}
2426 @@-I$2     @r{field just under hline above current row, column 2}
2427 @@>$5      @r{field in the last row, in column 5}
2428 @end example
2430 @subsubheading Range references
2431 @cindex range references
2432 @cindex references, to ranges
2434 You may reference a rectangular range of fields by specifying two field
2435 references connected by two dots @samp{..}.  If both fields are in the
2436 current row, you may simply use @samp{$2..$7}, but if at least one field
2437 is in a different row, you need to use the general @code{@@row$column}
2438 format at least for the first field (i.e the reference must start with
2439 @samp{@@} in order to be interpreted correctly).  Examples:
2441 @example
2442 $1..$3        @r{first three fields in the current row}
2443 $P..$Q        @r{range, using column names (see under Advanced)}
2444 $<<<..$>>     @r{start in third column, continue to the one but last}
2445 @@2$1..@@4$3    @r{6 fields between these two fields (same as @code{A2..C4})}
2446 @@-1$-2..@@-1   @r{3 fields in the row above, starting from 2 columns on the left}
2447 @@I..II        @r{between first and second hline, short for @code{@@I..@@II}}
2448 @end example
2450 @noindent Range references return a vector of values that can be fed
2451 into Calc vector functions.  Empty fields in ranges are normally
2452 suppressed, so that the vector contains only the non-empty fields (but
2453 see the @samp{E} mode switch below).  If there are no non-empty fields,
2454 @samp{[0]} is returned to avoid syntax errors in formulas.
2456 @subsubheading Field coordinates in formulas
2457 @cindex field coordinates
2458 @cindex coordinates, of field
2459 @cindex row, of field coordinates
2460 @cindex column, of field coordinates
2462 For Calc formulas and Lisp formulas @code{@@#} and @code{$#} can be used to
2463 get the row or column number of the field where the formula result goes.
2464 The traditional Lisp formula equivalents are @code{org-table-current-dline}
2465 and @code{org-table-current-column}.  Examples:
2467 @example
2468 if(@@# % 2, $#, string(""))   @r{column number on odd lines only}
2469 $3 = remote(FOO, @@@@#$2)      @r{copy column 2 from table FOO into}
2470                              @r{column 3 of the current table}
2471 @end example
2473 @noindent For the second example, table FOO must have at least as many rows
2474 as the current table.  Note that this is inefficient@footnote{The computation time scales as
2475 O(N^2) because table FOO is parsed for each field to be copied.} for large
2476 number of rows.
2478 @subsubheading Named references
2479 @cindex named references
2480 @cindex references, named
2481 @cindex name, of column or field
2482 @cindex constants, in calculations
2483 @cindex #+CONSTANTS
2485 @vindex org-table-formula-constants
2486 @samp{$name} is interpreted as the name of a column, parameter or
2487 constant.  Constants are defined globally through the variable
2488 @code{org-table-formula-constants}, and locally (for the file) through a
2489 line like
2491 @example
2492 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2493 @end example
2495 @noindent
2496 @vindex constants-unit-system
2497 @pindex constants.el
2498 Also properties (@pxref{Properties and Columns}) can be used as
2499 constants in table formulas: for a property @samp{:Xyz:} use the name
2500 @samp{$PROP_Xyz}, and the property will be searched in the current
2501 outline entry and in the hierarchy above it.  If you have the
2502 @file{constants.el} package, it will also be used to resolve constants,
2503 including natural constants like @samp{$h} for Planck's constant, and
2504 units like @samp{$km} for kilometers@footnote{@file{constants.el} can
2505 supply the values of constants in two different unit systems, @code{SI}
2506 and @code{cgs}.  Which one is used depends on the value of the variable
2507 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2508 @code{constSI} and @code{constcgs} to set this value for the current
2509 buffer.}.  Column names and parameters can be specified in special table
2510 lines.  These are described below, see @ref{Advanced features}.  All
2511 names must start with a letter, and further consist of letters and
2512 numbers.
2514 @subsubheading Remote references
2515 @cindex remote references
2516 @cindex references, remote
2517 @cindex references, to a different table
2518 @cindex name, of column or field
2519 @cindex constants, in calculations
2520 @cindex #+TBLNAME
2522 You may also reference constants, fields and ranges from a different table,
2523 either in the current file or even in a different file.  The syntax is
2525 @example
2526 remote(NAME-OR-ID,REF)
2527 @end example
2529 @noindent
2530 where NAME can be the name of a table in the current file as set by a
2531 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2532 entry, even in a different file, and the reference then refers to the first
2533 table in that entry.  REF is an absolute field or range reference as
2534 described above for example @code{@@3$3} or @code{$somename}, valid in the
2535 referenced table.
2537 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2538 @subsection Formula syntax for Calc
2539 @cindex formula syntax, Calc
2540 @cindex syntax, of formulas
2542 A formula can be any algebraic expression understood by the Emacs
2543 @file{Calc} package.  @b{Note that @file{calc} has the
2544 non-standard convention that @samp{/} has lower precedence than
2545 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2546 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2547 Your Programs, calc-eval, Calling Calc from Your Lisp Programs, calc, GNU
2548 Emacs Calc Manual}),
2549 variable substitution takes place according to the rules described above.
2550 @cindex vectors, in table calculations
2551 The range vectors can be directly fed into the Calc vector functions
2552 like @samp{vmean} and @samp{vsum}.
2554 @cindex format specifier
2555 @cindex mode, for @file{calc}
2556 @vindex org-calc-default-modes
2557 A formula can contain an optional mode string after a semicolon.  This
2558 string consists of flags to influence Calc and other modes during
2559 execution.  By default, Org uses the standard Calc modes (precision
2560 12, angular units degrees, fraction and symbolic modes off).  The display
2561 format, however, has been changed to @code{(float 8)} to keep tables
2562 compact.  The default settings can be configured using the variable
2563 @code{org-calc-default-modes}.
2565 @example
2566 p20           @r{set the internal Calc calculation precision to 20 digits}
2567 n3 s3 e2 f4   @r{Normal, scientific, engineering, or fixed}
2568               @r{format of the result of Calc passed back to Org.}
2569               @r{Calc formatting is unlimited in precision as}
2570               @r{long as the Calc calculation precision is greater.}
2571 D R           @r{angle modes: degrees, radians}
2572 F S           @r{fraction and symbolic modes}
2573 E             @r{keep empty fields in ranges and use nan (not a number)}
2574               @r{in Calc formulas for empty fields in range references and}
2575               @r{for empty field references; else suppress empty fields in}
2576               @r{range references and use 0 for empty field references, see}
2577               @r{also the notes for `Range references' in @pxref{References}}
2578 N             @r{interpret all fields as numbers, use 0 for non-numbers;}
2579               @r{N has higher precedence than E (for the value of the field)}
2580 L             @r{literal, for Lisp formulas only}
2581 @end example
2583 @noindent
2584 Unless you use large integer numbers or high-precision-calculation
2585 and -display for floating point numbers you may alternatively provide a
2586 @code{printf} format specifier to reformat the Calc result after it has been
2587 passed back to Org instead of letting Calc already do the
2588 formatting@footnote{The @code{printf} reformatting is limited in precision
2589 because the value passed to it is converted into an @code{integer} or
2590 @code{double}.  The @code{integer} is limited in size by truncating the
2591 signed value to 32 bits.  The @code{double} is limited in precision to 64
2592 bits overall which leaves approximately 16 significant decimal digits.}.
2593 A few examples:
2595 @example
2596 $1+$2                @r{Sum of first and second field}
2597 $1+$2;%.2f           @r{Same, format result to two decimals}
2598 exp($2)+exp($1)      @r{Math functions can be used}
2599 $0;%.1f              @r{Reformat current cell to 1 decimal}
2600 ($3-32)*5/9          @r{Degrees F -> C conversion}
2601 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2602 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2603 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2604 vmean($2..$7)        @r{Compute column range mean, suppress empty fields}
2605 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2606 taylor($3,x=7,2)     @r{Taylor series of $3, at x=7, second degree}
2607 @end example
2609 Calc also contains a complete set of logical operations.  For example
2611 @example
2612 if($1 < 20, teen, string(""))
2613                      @r{"teen" if age $1 is less than 20, else empty}
2614 if("$1" = "nan" || "$2" = "nan", string(""), $1 + $2); E
2615                      @r{sum of first two columns unless one or both empty}
2616 @end example
2618 Note that you can also use two org-specific flags @code{T} and @code{t} for
2619 durations computations @ref{Durations and time values}.
2621 You can add your own Calc functions defined in Emacs Lisp with @code{defmath}
2622 and use them in formula syntax for Calc.
2624 @node Formula syntax for Lisp, Durations and time values, Formula syntax for Calc, The spreadsheet
2625 @subsection Emacs Lisp forms as formulas
2626 @cindex Lisp forms, as table formulas
2628 It is also possible to write a formula in Emacs Lisp.  This can be useful
2629 for string manipulation and control structures, if Calc's functionality is
2630 not enough.
2632 If a formula starts with a single-quote followed by an opening parenthesis,
2633 then it is evaluated as a Lisp form.  The evaluation should return either a
2634 string or a number.  Just as with @file{calc} formulas, you can specify modes
2635 and a printf format after a semicolon.
2637 With Emacs Lisp forms, you need to be conscious about the way field
2638 references are interpolated into the form.  By default, a reference will be
2639 interpolated as a Lisp string (in double-quotes) containing the field.  If
2640 you provide the @samp{N} mode switch, all referenced elements will be numbers
2641 (non-number fields will be zero) and interpolated as Lisp numbers, without
2642 quotes.  If you provide the @samp{L} flag, all fields will be interpolated
2643 literally, without quotes.  I.e., if you want a reference to be interpreted
2644 as a string by the Lisp form, enclose the reference operator itself in
2645 double-quotes, like @code{"$3"}.  Ranges are inserted as space-separated
2646 fields, so you can embed them in list or vector syntax.
2648 Here are a few examples---note how the @samp{N} mode is used when we do
2649 computations in Lisp:
2651 @example
2652 @r{Swap the first two characters of the content of column 1}
2653   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2654 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2655   '(+ $1 $2);N
2656 @r{Compute the sum of columns 1--4, like Calc's @code{vsum($1..$4)}}
2657   '(apply '+ '($1..$4));N
2658 @end example
2660 @node Durations and time values, Field and range formulas, Formula syntax for Lisp, The spreadsheet
2661 @subsection Durations and time values
2662 @cindex Duration, computing
2663 @cindex Time, computing
2664 @vindex org-table-duration-custom-format
2666 If you want to compute time values use the @code{T} flag, either in Calc
2667 formulas or Elisp formulas:
2669 @example
2670 @group
2671   |  Task 1 |   Task 2 |    Total |
2672   |---------+----------+----------|
2673   |    2:12 |     1:47 | 03:59:00 |
2674   | 3:02:20 | -2:07:00 |     0.92 |
2675   #+TBLFM: @@2$3=$1+$2;T::@@3$3=$1+$2;t
2676 @end group
2677 @end example
2679 Input duration values must be of the form @code{[HH:MM[:SS]}, where seconds
2680 are optional.  With the @code{T} flag, computed durations will be displayed
2681 as @code{HH:MM:SS} (see the first formula above).  With the @code{t} flag,
2682 computed durations will be displayed according to the value of the variable
2683 @code{org-table-duration-custom-format}, which defaults to @code{'hours} and
2684 will display the result as a fraction of hours (see the second formula in the
2685 example above).
2687 Negative duration values can be manipulated as well, and integers will be
2688 considered as seconds in addition and subtraction.
2690 @node Field and range formulas, Column formulas, Durations and time values, The spreadsheet
2691 @subsection Field and range formulas
2692 @cindex field formula
2693 @cindex range formula
2694 @cindex formula, for individual table field
2695 @cindex formula, for range of fields
2697 To assign a formula to a particular field, type it directly into the field,
2698 preceded by @samp{:=}, for example @samp{:=vsum(@@II..III)}.  When you press
2699 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2700 the formula will be stored as the formula for this field, evaluated, and the
2701 current field will be replaced with the result.
2703 @cindex #+TBLFM
2704 Formulas are stored in a special line starting with @samp{#+TBLFM:} directly
2705 below the table.  If you type the equation in the 4th field of the 3rd data
2706 line in the table, the formula will look like @samp{@@3$4=$1+$2}.  When
2707 inserting/deleting/swapping column and rows with the appropriate commands,
2708 @i{absolute references} (but not relative ones) in stored formulas are
2709 modified in order to still reference the same field.  To avoid this from
2710 happening, in particular in range references, anchor ranges at the table
2711 borders (using @code{@@<}, @code{@@>}, @code{$<}, @code{$>}), or at hlines
2712 using the @code{@@I} notation.  Automatic adaptation of field references does
2713 of course not happen if you edit the table structure with normal editing
2714 commands---then you must fix the equations yourself.
2716 Instead of typing an equation into the field, you may also use the following
2717 command
2719 @table @kbd
2720 @orgcmd{C-u C-c =,org-table-eval-formula}
2721 Install a new formula for the current field.  The command prompts for a
2722 formula with default taken from the @samp{#+TBLFM:} line, applies
2723 it to the current field, and stores it.
2724 @end table
2726 The left-hand side of a formula can also be a special expression in order to
2727 assign the formula to a number of different fields.  There is no keyboard
2728 shortcut to enter such range formulas.  To add them, use the formula editor
2729 (@pxref{Editing and debugging formulas}) or edit the @code{#+TBLFM:} line
2730 directly.
2732 @table @code
2733 @item $2=
2734 Column formula, valid for the entire column.  This is so common that Org
2735 treats these formulas in a special way, see @ref{Column formulas}.
2736 @item @@3=
2737 Row formula, applies to all fields in the specified row.  @code{@@>=} means
2738 the last row.
2739 @item @@1$2..@@4$3=
2740 Range formula, applies to all fields in the given rectangular range.  This
2741 can also be used to assign a formula to some but not all fields in a row.
2742 @item $name=
2743 Named field, see @ref{Advanced features}.
2744 @end table
2746 @node Column formulas, Lookup functions, Field and range formulas, The spreadsheet
2747 @subsection Column formulas
2748 @cindex column formula
2749 @cindex formula, for table column
2751 When you assign a formula to a simple column reference like @code{$3=}, the
2752 same formula will be used in all fields of that column, with the following
2753 very convenient exceptions: (i) If the table contains horizontal separator
2754 hlines with rows above and below, everything before the first such hline is
2755 considered part of the table @emph{header} and will not be modified by column
2756 formulas.  Therefore a header is mandatory when you use column formulas and
2757 want to add hlines to group rows, like for example to separate a total row at
2758 the bottom from the summand rows above.  (ii) Fields that already get a value
2759 from a field/range formula will be left alone by column formulas.  These
2760 conditions make column formulas very easy to use.
2762 To assign a formula to a column, type it directly into any field in the
2763 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2764 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2765 the formula will be stored as the formula for the current column, evaluated
2766 and the current field replaced with the result.  If the field contains only
2767 @samp{=}, the previously stored formula for this column is used.  For each
2768 column, Org will only remember the most recently used formula.  In the
2769 @samp{#+TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The
2770 left-hand side of a column formula can not be the name of column, it must be
2771 the numeric column reference or @code{$>}.
2773 Instead of typing an equation into the field, you may also use the
2774 following command:
2776 @table @kbd
2777 @orgcmd{C-c =,org-table-eval-formula}
2778 Install a new formula for the current column and replace current field with
2779 the result of the formula.  The command prompts for a formula, with default
2780 taken from the @samp{#+TBLFM} line, applies it to the current field and
2781 stores it.  With a numeric prefix argument(e.g., @kbd{C-5 C-c =}) the command
2782 will apply it to that many consecutive fields in the current column.
2783 @end table
2785 @node Lookup functions, Editing and debugging formulas, Column formulas, The spreadsheet
2786 @subsection Lookup functions
2787 @cindex lookup functions in tables
2788 @cindex table lookup functions
2790 Org has three predefined Emacs Lisp functions for lookups in tables.
2791 @table @code
2792 @item (org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)
2793 @findex org-lookup-first
2794 Searches for the first element @code{S} in list @code{S-LIST} for which
2795 @lisp
2796 (PREDICATE VAL S)
2797 @end lisp
2798 is @code{t}; returns the value from the corresponding position in list
2799 @code{R-LIST}.  The default @code{PREDICATE} is @code{equal}.  Note that the
2800 parameters @code{VAL} and @code{S} are passed to @code{PREDICATE} in the same
2801 order as the correspoding parameters are in the call to
2802 @code{org-lookup-first}, where @code{VAL} precedes @code{S-LIST}.  If
2803 @code{R-LIST} is @code{nil}, the matching element @code{S} of @code{S-LIST}
2804 is returned.
2805 @item (org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)
2806 @findex org-lookup-last
2807 Similar to @code{org-lookup-first} above, but searches for the @i{last}
2808 element for which @code{PREDICATE} is @code{t}.
2809 @item (org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)
2810 @findex org-lookup-all
2811 Similar to @code{org-lookup-first}, but searches for @i{all} elements for
2812 which @code{PREDICATE} is @code{t}, and returns @i{all} corresponding
2813 values.  This function can not be used by itself in a formula, because it
2814 returns a list of values.  However, powerful lookups can be built when this
2815 function is combined with other Emacs Lisp functions.
2816 @end table
2818 If the ranges used in these functions contain empty fields, the @code{E} mode
2819 for the formula should usually be specified: otherwise empty fields will not be
2820 included in @code{S-LIST} and/or @code{R-LIST} which can, for example, result
2821 in an incorrect mapping from an element of @code{S-LIST} to the corresponding
2822 element of @code{R-LIST}.
2824 These three functions can be used to implement associative arrays, count
2825 matching cells, rank results, group data etc.  For practical examples
2826 see @uref{http://orgmode.org/worg/org-tutorials/org-lookups.html, this
2827 tutorial on Worg}.
2829 @node Editing and debugging formulas, Updating the table, Lookup functions, The spreadsheet
2830 @subsection Editing and debugging formulas
2831 @cindex formula editing
2832 @cindex editing, of table formulas
2834 @vindex org-table-use-standard-references
2835 You can edit individual formulas in the minibuffer or directly in the
2836 field.  Org can also prepare a special buffer with all active
2837 formulas of a table.  When offering a formula for editing, Org
2838 converts references to the standard format (like @code{B3} or @code{D&})
2839 if possible.  If you prefer to only work with the internal format (like
2840 @code{@@3$2} or @code{$4}), configure the variable
2841 @code{org-table-use-standard-references}.
2843 @table @kbd
2844 @orgcmdkkc{C-c =,C-u C-c =,org-table-eval-formula}
2845 Edit the formula associated with the current column/field in the
2846 minibuffer.  See @ref{Column formulas}, and @ref{Field and range formulas}.
2847 @orgcmd{C-u C-u C-c =,org-table-eval-formula}
2848 Re-insert the active formula (either a
2849 field formula, or a column formula) into the current field, so that you
2850 can edit it directly in the field.  The advantage over editing in the
2851 minibuffer is that you can use the command @kbd{C-c ?}.
2852 @orgcmd{C-c ?,org-table-field-info}
2853 While editing a formula in a table field, highlight the field(s)
2854 referenced by the reference at the cursor position in the formula.
2855 @kindex C-c @}
2856 @findex org-table-toggle-coordinate-overlays
2857 @item C-c @}
2858 Toggle the display of row and column numbers for a table, using overlays
2859 (@command{org-table-toggle-coordinate-overlays}).  These are updated each
2860 time the table is aligned; you can force it with @kbd{C-c C-c}.
2861 @kindex C-c @{
2862 @findex org-table-toggle-formula-debugger
2863 @item C-c @{
2864 Toggle the formula debugger on and off
2865 (@command{org-table-toggle-formula-debugger}).  See below.
2866 @orgcmd{C-c ',org-table-edit-formulas}
2867 Edit all formulas for the current table in a special buffer, where the
2868 formulas will be displayed one per line.  If the current field has an
2869 active formula, the cursor in the formula editor will mark it.
2870 While inside the special buffer, Org will automatically highlight
2871 any field or range reference at the cursor position.  You may edit,
2872 remove and add formulas, and use the following commands:
2873 @table @kbd
2874 @orgcmdkkc{C-c C-c,C-x C-s,org-table-fedit-finish}
2875 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2876 prefix, also apply the new formulas to the entire table.
2877 @orgcmd{C-c C-q,org-table-fedit-abort}
2878 Exit the formula editor without installing changes.
2879 @orgcmd{C-c C-r,org-table-fedit-toggle-ref-type}
2880 Toggle all references in the formula editor between standard (like
2881 @code{B3}) and internal (like @code{@@3$2}).
2882 @orgcmd{@key{TAB},org-table-fedit-lisp-indent}
2883 Pretty-print or indent Lisp formula at point.  When in a line containing
2884 a Lisp formula, format the formula according to Emacs Lisp rules.
2885 Another @key{TAB} collapses the formula back again.  In the open
2886 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
2887 @orgcmd{M-@key{TAB},lisp-complete-symbol}
2888 Complete Lisp symbols, just like in Emacs Lisp mode.
2889 @kindex S-@key{up}
2890 @kindex S-@key{down}
2891 @kindex S-@key{left}
2892 @kindex S-@key{right}
2893 @findex org-table-fedit-ref-up
2894 @findex org-table-fedit-ref-down
2895 @findex org-table-fedit-ref-left
2896 @findex org-table-fedit-ref-right
2897 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2898 Shift the reference at point.  For example, if the reference is
2899 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2900 This also works for relative references and for hline references.
2901 @orgcmdkkcc{M-S-@key{up},M-S-@key{down},org-table-fedit-line-up,org-table-fedit-line-down}
2902 Move the test line for column formulas in the Org buffer up and
2903 down.
2904 @orgcmdkkcc{M-@key{up},M-@key{down},org-table-fedit-scroll-down,org-table-fedit-scroll-up}
2905 Scroll the window displaying the table.
2906 @kindex C-c @}
2907 @findex org-table-toggle-coordinate-overlays
2908 @item C-c @}
2909 Turn the coordinate grid in the table on and off.
2910 @end table
2911 @end table
2913 Making a table field blank does not remove the formula associated with
2914 the field, because that is stored in a different line (the @samp{#+TBLFM}
2915 line)---during the next recalculation the field will be filled again.
2916 To remove a formula from a field, you have to give an empty reply when
2917 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2919 @kindex C-c C-c
2920 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2921 equations with @kbd{C-c C-c} in that line or with the normal
2922 recalculation commands in the table.
2924 @subsubheading Debugging formulas
2925 @cindex formula debugging
2926 @cindex debugging, of table formulas
2927 When the evaluation of a formula leads to an error, the field content
2928 becomes the string @samp{#ERROR}.  If you would like see what is going
2929 on during variable substitution and calculation in order to find a bug,
2930 turn on formula debugging in the @code{Tbl} menu and repeat the
2931 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2932 field.  Detailed information will be displayed.
2934 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2935 @subsection Updating the table
2936 @cindex recomputing table fields
2937 @cindex updating, table
2939 Recalculation of a table is normally not automatic, but needs to be
2940 triggered by a command.  See @ref{Advanced features}, for a way to make
2941 recalculation at least semi-automatic.
2943 In order to recalculate a line of a table or the entire table, use the
2944 following commands:
2946 @table @kbd
2947 @orgcmd{C-c *,org-table-recalculate}
2948 Recalculate the current row by first applying the stored column formulas
2949 from left to right, and all field/range formulas in the current row.
2951 @kindex C-u C-c *
2952 @item C-u C-c *
2953 @kindex C-u C-c C-c
2954 @itemx C-u C-c C-c
2955 Recompute the entire table, line by line.  Any lines before the first
2956 hline are left alone, assuming that these are part of the table header.
2958 @orgcmdkkc{C-u C-u C-c *,C-u C-u C-c C-c,org-table-iterate}
2959 Iterate the table by recomputing it until no further changes occur.
2960 This may be necessary if some computed fields use the value of other
2961 fields that are computed @i{later} in the calculation sequence.
2962 @item M-x org-table-recalculate-buffer-tables
2963 @findex org-table-recalculate-buffer-tables
2964 Recompute all tables in the current buffer.
2965 @item M-x org-table-iterate-buffer-tables
2966 @findex org-table-iterate-buffer-tables
2967 Iterate all tables in the current buffer, in order to converge table-to-table
2968 dependencies.
2969 @end table
2971 @node Advanced features,  , Updating the table, The spreadsheet
2972 @subsection Advanced features
2974 If you want the recalculation of fields to happen automatically, or if you
2975 want to be able to assign @i{names}@footnote{Such names must start by an
2976 alphabetic character and use only alphanumeric/underscore characters.} to
2977 fields and columns, you need to reserve the first column of the table for
2978 special marking characters.
2980 @table @kbd
2981 @orgcmd{C-#,org-table-rotate-recalc-marks}
2982 Rotate the calculation mark in first column through the states @samp{ },
2983 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
2984 change all marks in the region.
2985 @end table
2987 Here is an example of a table that collects exam results of students and
2988 makes use of these features:
2990 @example
2991 @group
2992 |---+---------+--------+--------+--------+-------+------|
2993 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2994 |---+---------+--------+--------+--------+-------+------|
2995 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2996 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2997 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2998 |---+---------+--------+--------+--------+-------+------|
2999 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
3000 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
3001 |---+---------+--------+--------+--------+-------+------|
3002 |   | Average |        |        |        |  25.0 |      |
3003 | ^ |         |        |        |        |    at |      |
3004 | $ | max=50  |        |        |        |       |      |
3005 |---+---------+--------+--------+--------+-------+------|
3006 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
3007 @end group
3008 @end example
3010 @noindent @b{Important}: please note that for these special tables,
3011 recalculating the table with @kbd{C-u C-c *} will only affect rows that
3012 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
3013 to the field itself.  The column formulas are not applied in rows with
3014 empty first field.
3016 @cindex marking characters, tables
3017 The marking characters have the following meaning:
3018 @table @samp
3019 @item !
3020 The fields in this line define names for the columns, so that you may
3021 refer to a column as @samp{$Tot} instead of @samp{$6}.
3022 @item ^
3023 This row defines names for the fields @emph{above} the row.  With such
3024 a definition, any formula in the table may use @samp{$m1} to refer to
3025 the value @samp{10}.  Also, if you assign a formula to a names field, it
3026 will be stored as @samp{$name=...}.
3027 @item _
3028 Similar to @samp{^}, but defines names for the fields in the row
3029 @emph{below}.
3030 @item $
3031 Fields in this row can define @emph{parameters} for formulas.  For
3032 example, if a field in a @samp{$} row contains @samp{max=50}, then
3033 formulas in this table can refer to the value 50 using @samp{$max}.
3034 Parameters work exactly like constants, only that they can be defined on
3035 a per-table basis.
3036 @item #
3037 Fields in this row are automatically recalculated when pressing
3038 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
3039 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
3040 lines will be left alone by this command.
3041 @item *
3042 Selects this line for global recalculation with @kbd{C-u C-c *}, but
3043 not for automatic recalculation.  Use this when automatic
3044 recalculation slows down editing too much.
3045 @item @w{ }
3046 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
3047 All lines that should be recalculated should be marked with @samp{#}
3048 or @samp{*}.
3049 @item /
3050 Do not export this line.  Useful for lines that contain the narrowing
3051 @samp{<N>} markers or column group markers.
3052 @end table
3054 Finally, just to whet your appetite for what can be done with the
3055 fantastic @file{calc.el} package, here is a table that computes the Taylor
3056 series of degree @code{n} at location @code{x} for a couple of
3057 functions.
3059 @example
3060 @group
3061 |---+-------------+---+-----+--------------------------------------|
3062 |   | Func        | n | x   | Result                               |
3063 |---+-------------+---+-----+--------------------------------------|
3064 | # | exp(x)      | 1 | x   | 1 + x                                |
3065 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
3066 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
3067 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
3068 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
3069 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
3070 |---+-------------+---+-----+--------------------------------------|
3071 #+TBLFM: $5=taylor($2,$4,$3);n3
3072 @end group
3073 @end example
3075 @node Org-Plot,  , The spreadsheet, Tables
3076 @section Org-Plot
3077 @cindex graph, in tables
3078 @cindex plot tables using Gnuplot
3079 @cindex #+PLOT
3081 Org-Plot can produce 2D and 3D graphs of information stored in org tables
3082 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
3083 @uref{http://xafs.org/BruceRavel/GnuplotMode}.  To see this in action, ensure
3084 that you have both Gnuplot and Gnuplot mode installed on your system, then
3085 call @code{org-plot/gnuplot} on the following table.
3087 @example
3088 @group
3089 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
3090 | Sede      | Max cites | H-index |
3091 |-----------+-----------+---------|
3092 | Chile     |    257.72 |   21.39 |
3093 | Leeds     |    165.77 |   19.68 |
3094 | Sao Paolo |     71.00 |   11.50 |
3095 | Stockholm |    134.19 |   14.33 |
3096 | Morelia   |    257.56 |   17.67 |
3097 @end group
3098 @end example
3100 Notice that Org Plot is smart enough to apply the table's headers as labels.
3101 Further control over the labels, type, content, and appearance of plots can
3102 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
3103 for a complete list of Org-plot options.  For more information and examples
3104 see the Org-plot tutorial at
3105 @uref{http://orgmode.org/worg/org-tutorials/org-plot.html}.
3107 @subsubheading Plot Options
3109 @table @code
3110 @item set
3111 Specify any @command{gnuplot} option to be set when graphing.
3113 @item title
3114 Specify the title of the plot.
3116 @item ind
3117 Specify which column of the table to use as the @code{x} axis.
3119 @item deps
3120 Specify the columns to graph as a Lisp style list, surrounded by parentheses
3121 and separated by spaces for example @code{dep:(3 4)} to graph the third and
3122 fourth columns (defaults to graphing all other columns aside from the @code{ind}
3123 column).
3125 @item type
3126 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
3128 @item with
3129 Specify a @code{with} option to be inserted for every col being plotted
3130 (e.g., @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
3131 Defaults to @code{lines}.
3133 @item file
3134 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
3136 @item labels
3137 List of labels to be used for the @code{deps} (defaults to the column headers
3138 if they exist).
3140 @item line
3141 Specify an entire line to be inserted in the Gnuplot script.
3143 @item map
3144 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
3145 flat mapping rather than a @code{3d} slope.
3147 @item timefmt
3148 Specify format of Org mode timestamps as they will be parsed by Gnuplot.
3149 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
3151 @item script
3152 If you want total control, you can specify a script file (place the file name
3153 between double-quotes) which will be used to plot.  Before plotting, every
3154 instance of @code{$datafile} in the specified script will be replaced with
3155 the path to the generated data file.  Note: even if you set this option, you
3156 may still want to specify the plot type, as that can impact the content of
3157 the data file.
3158 @end table
3160 @node Hyperlinks, TODO Items, Tables, Top
3161 @chapter Hyperlinks
3162 @cindex hyperlinks
3164 Like HTML, Org provides links inside a file, external links to
3165 other files, Usenet articles, emails, and much more.
3167 @menu
3168 * Link format::                 How links in Org are formatted
3169 * Internal links::              Links to other places in the current file
3170 * External links::              URL-like links to the world
3171 * Handling links::              Creating, inserting and following
3172 * Using links outside Org::     Linking from my C source code?
3173 * Link abbreviations::          Shortcuts for writing complex links
3174 * Search options::              Linking to a specific location
3175 * Custom searches::             When the default search is not enough
3176 @end menu
3178 @node Link format, Internal links, Hyperlinks, Hyperlinks
3179 @section Link format
3180 @cindex link format
3181 @cindex format, of links
3183 Org will recognize plain URL-like links and activate them as
3184 clickable links.  The general link format, however, looks like this:
3186 @example
3187 [[link][description]]       @r{or alternatively}           [[link]]
3188 @end example
3190 @noindent
3191 Once a link in the buffer is complete (all brackets present), Org
3192 will change the display so that @samp{description} is displayed instead
3193 of @samp{[[link][description]]} and @samp{link} is displayed instead of
3194 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
3195 which by default is an underlined face.  You can directly edit the
3196 visible part of a link.  Note that this can be either the @samp{link}
3197 part (if there is no description) or the @samp{description} part.  To
3198 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
3199 cursor on the link.
3201 If you place the cursor at the beginning or just behind the end of the
3202 displayed text and press @key{BACKSPACE}, you will remove the
3203 (invisible) bracket at that location.  This makes the link incomplete
3204 and the internals are again displayed as plain text.  Inserting the
3205 missing bracket hides the link internals again.  To show the
3206 internal structure of all links, use the menu entry
3207 @code{Org->Hyperlinks->Literal links}.
3209 @node Internal links, External links, Link format, Hyperlinks
3210 @section Internal links
3211 @cindex internal links
3212 @cindex links, internal
3213 @cindex targets, for links
3215 @cindex property, CUSTOM_ID
3216 If the link does not look like a URL, it is considered to be internal in the
3217 current file.  The most important case is a link like
3218 @samp{[[#my-custom-id]]} which will link to the entry with the
3219 @code{CUSTOM_ID} property @samp{my-custom-id}.  Such custom IDs are very good
3220 for HTML export (@pxref{HTML export}) where they produce pretty section
3221 links.  You are responsible yourself to make sure these custom IDs are unique
3222 in a file.
3224 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
3225 lead to a text search in the current file.
3227 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
3228 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
3229 point to the corresponding headline.  The preferred match for a text link is
3230 a @i{dedicated target}: the same string in double angular brackets.  Targets
3231 may be located anywhere; sometimes it is convenient to put them into a
3232 comment line.  For example
3234 @example
3235 # <<My Target>>
3236 @end example
3238 @noindent In HTML export (@pxref{HTML export}), such targets will become
3239 named anchors for direct access through @samp{http} links@footnote{Note that
3240 text before the first headline is usually not exported, so the first such
3241 target should be after the first headline, or in the line directly before the
3242 first headline.}.
3244 If no dedicated target exists, Org will search for a headline that is exactly
3245 the link text but may also include a TODO keyword and tags@footnote{To insert
3246 a link targeting a headline, in-buffer completion can be used.  Just type a
3247 star followed by a few optional letters into the buffer and press
3248 @kbd{M-@key{TAB}}.  All headlines in the current buffer will be offered as
3249 completions.}.  In non-Org files, the search will look for the words in the
3250 link text.  In the above example the search would be for @samp{my target}.
3252 Following a link pushes a mark onto Org's own mark ring.  You can
3253 return to the previous position with @kbd{C-c &}.  Using this command
3254 several times in direct succession goes back to positions recorded
3255 earlier.
3257 @menu
3258 * Radio targets::               Make targets trigger links in plain text
3259 @end menu
3261 @node Radio targets,  , Internal links, Internal links
3262 @subsection Radio targets
3263 @cindex radio targets
3264 @cindex targets, radio
3265 @cindex links, radio targets
3267 Org can automatically turn any occurrences of certain target names
3268 in normal text into a link.  So without explicitly creating a link, the
3269 text connects to the target radioing its position.  Radio targets are
3270 enclosed by triple angular brackets.  For example, a target @samp{<<<My
3271 Target>>>} causes each occurrence of @samp{my target} in normal text to
3272 become activated as a link.  The Org file is scanned automatically
3273 for radio targets only when the file is first loaded into Emacs.  To
3274 update the target list during editing, press @kbd{C-c C-c} with the
3275 cursor on or at a target.
3277 @node External links, Handling links, Internal links, Hyperlinks
3278 @section External links
3279 @cindex links, external
3280 @cindex external links
3281 @cindex links, external
3282 @cindex Gnus links
3283 @cindex BBDB links
3284 @cindex IRC links
3285 @cindex URL links
3286 @cindex file links
3287 @cindex VM links
3288 @cindex RMAIL links
3289 @cindex WANDERLUST links
3290 @cindex MH-E links
3291 @cindex USENET links
3292 @cindex SHELL links
3293 @cindex Info links
3294 @cindex Elisp links
3296 Org supports links to files, websites, Usenet and email messages,
3297 BBDB database entries and links to both IRC conversations and their
3298 logs.  External links are URL-like locators.  They start with a short
3299 identifying string followed by a colon.  There can be no space after
3300 the colon.  The following list shows examples for each link type.
3302 @example
3303 http://www.astro.uva.nl/~dominik          @r{on the web}
3304 doi:10.1000/182                           @r{DOI for an electronic resource}
3305 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
3306 /home/dominik/images/jupiter.jpg          @r{same as above}
3307 file:papers/last.pdf                      @r{file, relative path}
3308 ./papers/last.pdf                         @r{same as above}
3309 file:/myself@@some.where:papers/last.pdf   @r{file, path on remote machine}
3310 /myself@@some.where:papers/last.pdf        @r{same as above}
3311 file:sometextfile::NNN                    @r{file, jump to line number}
3312 file:projects.org                         @r{another Org file}
3313 file:projects.org::some words             @r{text search in Org file}@footnote{
3314 The actual behavior of the search will depend on the value of
3315 the variable @code{org-link-search-must-match-exact-headline}.  If its value
3316 is nil, then a fuzzy text search will be done.  If it is t, then only the
3317 exact headline will be matched.  If the value is @code{'query-to-create},
3318 then an exact headline will be searched; if it is not found, then the user
3319 will be queried to create it.}
3320 file:projects.org::*task title            @r{heading search in Org file}
3321 file+sys:/path/to/file                    @r{open via OS, like double-click}
3322 file+emacs:/path/to/file                  @r{force opening by Emacs}
3323 docview:papers/last.pdf::NNN              @r{open in doc-view mode at page}
3324 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
3325 news:comp.emacs                           @r{Usenet link}
3326 mailto:adent@@galaxy.net                   @r{Mail link}
3327 vm:folder                                 @r{VM folder link}
3328 vm:folder#id                              @r{VM message link}
3329 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
3330 vm-imap:account:folder                    @r{VM IMAP folder link}
3331 vm-imap:account:folder#id                 @r{VM IMAP message link}
3332 wl:folder                                 @r{WANDERLUST folder link}
3333 wl:folder#id                              @r{WANDERLUST message link}
3334 mhe:folder                                @r{MH-E folder link}
3335 mhe:folder#id                             @r{MH-E message link}
3336 rmail:folder                              @r{RMAIL folder link}
3337 rmail:folder#id                           @r{RMAIL message link}
3338 gnus:group                                @r{Gnus group link}
3339 gnus:group#id                             @r{Gnus article link}
3340 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
3341 irc:/irc.com/#emacs/bob                   @r{IRC link}
3342 info:org#External links                   @r{Info node link}
3343 shell:ls *.org                            @r{A shell command}
3344 elisp:org-agenda                          @r{Interactive Elisp command}
3345 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
3346 @end example
3348 For customizing Org to add new link types @ref{Adding hyperlink types}.
3350 A link should be enclosed in double brackets and may contain a
3351 descriptive text to be displayed instead of the URL (@pxref{Link
3352 format}), for example:
3354 @example
3355 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3356 @end example
3358 @noindent
3359 If the description is a file name or URL that points to an image, HTML
3360 export (@pxref{HTML export}) will inline the image as a clickable
3361 button.  If there is no description at all and the link points to an
3362 image,
3363 that image will be inlined into the exported HTML file.
3365 @cindex square brackets, around links
3366 @cindex plain text external links
3367 Org also finds external links in the normal text and activates them
3368 as links.  If spaces must be part of the link (for example in
3369 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
3370 about the end of the link, enclose them in square brackets.
3372 @node Handling links, Using links outside Org, External links, Hyperlinks
3373 @section Handling links
3374 @cindex links, handling
3376 Org provides methods to create a link in the correct syntax, to
3377 insert it into an Org file, and to follow the link.
3379 @table @kbd
3380 @orgcmd{C-c l,org-store-link}
3381 @cindex storing links
3382 Store a link to the current location.  This is a @emph{global} command (you
3383 must create the key binding yourself) which can be used in any buffer to
3384 create a link.  The link will be stored for later insertion into an Org
3385 buffer (see below).  What kind of link will be created depends on the current
3386 buffer:
3388 @b{Org mode buffers}@*
3389 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
3390 to the target.  Otherwise it points to the current headline, which will also
3391 be the description@footnote{If the headline contains a timestamp, it will be
3392 removed from the link and result in a wrong link---you should avoid putting
3393 timestamp in the headline.}.
3395 @vindex org-id-link-to-org-use-id
3396 @cindex property, CUSTOM_ID
3397 @cindex property, ID
3398 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
3399 will be stored.  In addition or alternatively (depending on the value of
3400 @code{org-id-link-to-org-use-id}), a globally unique @code{ID} property will
3401 be created and/or used to construct a link@footnote{The library @code{org-id}
3402 must first be loaded, either through @code{org-customize} by enabling
3403 @code{id} in @code{org-modules} , or by adding @code{(require 'org-id)} in
3404 your @file{.emacs}.}. So using this command in Org
3405 buffers will potentially create two links: a human-readable from the custom
3406 ID, and one that is globally unique and works even if the entry is moved from
3407 file to file.  Later, when inserting the link, you need to decide which one
3408 to use.
3410 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
3411 Pretty much all Emacs mail clients are supported.  The link will point to the
3412 current article, or, in some GNUS buffers, to the group.  The description is
3413 constructed from the author and the subject.
3415 @b{Web browsers: W3 and W3M}@*
3416 Here the link will be the current URL, with the page title as description.
3418 @b{Contacts: BBDB}@*
3419 Links created in a BBDB buffer will point to the current entry.
3421 @b{Chat: IRC}@*
3422 @vindex org-irc-link-to-logs
3423 For IRC links, if you set the variable @code{org-irc-link-to-logs} to
3424 @code{t}, a @samp{file:/} style link to the relevant point in the logs for
3425 the current conversation is created.  Otherwise an @samp{irc:/} style link to
3426 the user/channel/server under the point will be stored.
3428 @b{Other files}@*
3429 For any other files, the link will point to the file, with a search string
3430 (@pxref{Search options}) pointing to the contents of the current line.  If
3431 there is an active region, the selected words will form the basis of the
3432 search string.  If the automatically created link is not working correctly or
3433 accurately enough, you can write custom functions to select the search string
3434 and to do the search for particular file types---see @ref{Custom searches}.
3435 The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
3437 @b{Agenda view}@*
3438 When the cursor is in an agenda view, the created link points to the
3439 entry referenced by the current line.
3442 @orgcmd{C-c C-l,org-insert-link}
3443 @cindex link completion
3444 @cindex completion, of links
3445 @cindex inserting links
3446 @vindex org-keep-stored-link-after-insertion
3447 Insert a link@footnote{ Note that you don't have to use this command to
3448 insert a link.  Links in Org are plain text, and you can type or paste them
3449 straight into the buffer.  By using this command, the links are automatically
3450 enclosed in double brackets, and you will be asked for the optional
3451 descriptive text.}.  This prompts for a link to be inserted into the buffer.
3452 You can just type a link, using text for an internal link, or one of the link
3453 type prefixes mentioned in the examples above.  The link will be inserted
3454 into the buffer@footnote{After insertion of a stored link, the link will be
3455 removed from the list of stored links.  To keep it in the list later use, use
3456 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
3457 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
3458 If some text was selected when this command is called, the selected text
3459 becomes the default description.
3461 @b{Inserting stored links}@*
3462 All links stored during the
3463 current session are part of the history for this prompt, so you can access
3464 them with @key{up} and @key{down} (or @kbd{M-p/n}).
3466 @b{Completion support}@* Completion with @key{TAB} will help you to insert
3467 valid link prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
3468 defined through link abbreviations (@pxref{Link abbreviations}).  If you
3469 press @key{RET} after inserting only the @var{prefix}, Org will offer
3470 specific completion support for some link types@footnote{This works by
3471 calling a special function @code{org-PREFIX-complete-link}.}  For
3472 example, if you type @kbd{file @key{RET}}, file name completion (alternative
3473 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
3474 @key{RET}} you can complete contact names.
3475 @orgkey C-u C-c C-l
3476 @cindex file name completion
3477 @cindex completion, of file names
3478 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
3479 a file will be inserted and you may use file name completion to select
3480 the name of the file.  The path to the file is inserted relative to the
3481 directory of the current Org file, if the linked file is in the current
3482 directory or in a sub-directory of it, or if the path is written relative
3483 to the current directory using @samp{../}.  Otherwise an absolute path
3484 is used, if possible with @samp{~/} for your home directory.  You can
3485 force an absolute path with two @kbd{C-u} prefixes.
3487 @item C-c C-l @ @r{(with cursor on existing link)}
3488 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
3489 link and description parts of the link.
3491 @cindex following links
3492 @orgcmd{C-c C-o,org-open-at-point}
3493 @vindex org-file-apps
3494 @vindex org-link-frame-setup
3495 Open link at point.  This will launch a web browser for URLs (using
3496 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
3497 the corresponding links, and execute the command in a shell link.  When the
3498 cursor is on an internal link, this command runs the corresponding search.
3499 When the cursor is on a TAG list in a headline, it creates the corresponding
3500 TAGS view.  If the cursor is on a timestamp, it compiles the agenda for that
3501 date.  Furthermore, it will visit text and remote files in @samp{file:} links
3502 with Emacs and select a suitable application for local non-text files.
3503 Classification of files is based on file extension only.  See option
3504 @code{org-file-apps}.  If you want to override the default application and
3505 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
3506 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
3507 If the cursor is on a headline, but not on a link, offer all links in the
3508 headline and entry text.  If you want to setup the frame configuration for
3509 following links, customize @code{org-link-frame-setup}.
3511 @orgkey @key{RET}
3512 @vindex org-return-follows-link
3513 When @code{org-return-follows-link} is set, @kbd{@key{RET}} will also follow
3514 the link at point.
3516 @kindex mouse-2
3517 @kindex mouse-1
3518 @item mouse-2
3519 @itemx mouse-1
3520 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
3521 would.  Under Emacs 22 and later, @kbd{mouse-1} will also follow a link.
3523 @kindex mouse-3
3524 @item mouse-3
3525 @vindex org-display-internal-link-with-indirect-buffer
3526 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
3527 internal links to be displayed in another window@footnote{See the
3528 variable @code{org-display-internal-link-with-indirect-buffer}}.
3530 @orgcmd{C-c C-x C-v,org-toggle-inline-images}
3531 @cindex inlining images
3532 @cindex images, inlining
3533 @vindex org-startup-with-inline-images
3534 @cindex @code{inlineimages}, STARTUP keyword
3535 @cindex @code{noinlineimages}, STARTUP keyword
3536 Toggle the inline display of linked images.  Normally this will only inline
3537 images that have no description part in the link, i.e., images that will also
3538 be inlined during export.  When called with a prefix argument, also display
3539 images that do have a link description.  You can ask for inline images to be
3540 displayed at startup by configuring the variable
3541 @code{org-startup-with-inline-images}@footnote{with corresponding
3542 @code{#+STARTUP} keywords @code{inlineimages} and @code{inlineimages}}.
3543 @orgcmd{C-c %,org-mark-ring-push}
3544 @cindex mark ring
3545 Push the current position onto the mark ring, to be able to return
3546 easily.  Commands following an internal link do this automatically.
3548 @orgcmd{C-c &,org-mark-ring-goto}
3549 @cindex links, returning to
3550 Jump back to a recorded position.  A position is recorded by the
3551 commands following internal links, and by @kbd{C-c %}.  Using this
3552 command several times in direct succession moves through a ring of
3553 previously recorded positions.
3555 @orgcmdkkcc{C-c C-x C-n,C-c C-x C-p,org-next-link,org-previous-link}
3556 @cindex links, finding next/previous
3557 Move forward/backward to the next link in the buffer.  At the limit of
3558 the buffer, the search fails once, and then wraps around.  The key
3559 bindings for this are really too long; you might want to bind this also
3560 to @kbd{C-n} and @kbd{C-p}
3561 @lisp
3562 (add-hook 'org-load-hook
3563   (lambda ()
3564     (define-key org-mode-map "\C-n" 'org-next-link)
3565     (define-key org-mode-map "\C-p" 'org-previous-link)))
3566 @end lisp
3567 @end table
3569 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
3570 @section Using links outside Org
3572 You can insert and follow links that have Org syntax not only in
3573 Org, but in any Emacs buffer.  For this, you should create two
3574 global commands, like this (please select suitable global keys
3575 yourself):
3577 @lisp
3578 (global-set-key "\C-c L" 'org-insert-link-global)
3579 (global-set-key "\C-c o" 'org-open-at-point-global)
3580 @end lisp
3582 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
3583 @section Link abbreviations
3584 @cindex link abbreviations
3585 @cindex abbreviation, links
3587 Long URLs can be cumbersome to type, and often many similar links are
3588 needed in a document.  For this you can use link abbreviations.  An
3589 abbreviated link looks like this
3591 @example
3592 [[linkword:tag][description]]
3593 @end example
3595 @noindent
3596 @vindex org-link-abbrev-alist
3597 where the tag is optional.
3598 The @i{linkword} must be a word, starting with a letter, followed by
3599 letters, numbers, @samp{-}, and @samp{_}.  Abbreviations are resolved
3600 according to the information in the variable @code{org-link-abbrev-alist}
3601 that relates the linkwords to replacement text.  Here is an example:
3603 @smalllisp
3604 @group
3605 (setq org-link-abbrev-alist
3606   '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3607     ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
3608     ("google"    . "http://www.google.com/search?q=")
3609     ("gmap"      . "http://maps.google.com/maps?q=%s")
3610     ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
3611     ("ads"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
3612 @end group
3613 @end smalllisp
3615 If the replacement text contains the string @samp{%s}, it will be
3616 replaced with the tag.  Using @samp{%h} instead of @samp{%s} will
3617 url-encode the tag (see the example above, where we need to encode
3618 the URL parameter.)  Using @samp{%(my-function)} will pass the tag
3619 to a custom function, and replace it by the resulting string.
3621 If the replacement text don't contain any specifier, it will simply
3622 be appended to the string in order to create the link.
3624 Instead of a string, you may also specify a function that will be
3625 called with the tag as the only argument to create the link.
3627 With the above setting, you could link to a specific bug with
3628 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
3629 @code{[[google:OrgMode]]}, show the map location of the Free Software
3630 Foundation @code{[[gmap:51 Franklin Street, Boston]]} or of Carsten office
3631 @code{[[omap:Science Park 904, Amsterdam, The Netherlands]]} and find out
3632 what the Org author is doing besides Emacs hacking with
3633 @code{[[ads:Dominik,C]]}.
3635 If you need special abbreviations just for a single Org buffer, you
3636 can define them in the file with
3638 @cindex #+LINK
3639 @example
3640 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3641 #+LINK: google    http://www.google.com/search?q=%s
3642 @end example
3644 @noindent
3645 In-buffer completion (@pxref{Completion}) can be used after @samp{[} to
3646 complete link abbreviations.  You may also define a function
3647 @code{org-PREFIX-complete-link} that implements special (e.g., completion)
3648 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
3649 not accept any arguments, and return the full link with prefix.
3651 @node Search options, Custom searches, Link abbreviations, Hyperlinks
3652 @section Search options in file links
3653 @cindex search option in file links
3654 @cindex file links, searching
3656 File links can contain additional information to make Emacs jump to a
3657 particular location in the file when following a link.  This can be a
3658 line number or a search option after a double@footnote{For backward
3659 compatibility, line numbers can also follow a single colon.} colon.  For
3660 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
3661 links}) to a file, it encodes the words in the current line as a search
3662 string that can be used to find this line back later when following the
3663 link with @kbd{C-c C-o}.
3665 Here is the syntax of the different ways to attach a search to a file
3666 link, together with an explanation:
3668 @example
3669 [[file:~/code/main.c::255]]
3670 [[file:~/xx.org::My Target]]
3671 [[file:~/xx.org::*My Target]]
3672 [[file:~/xx.org::#my-custom-id]]
3673 [[file:~/xx.org::/regexp/]]
3674 @end example
3676 @table @code
3677 @item 255
3678 Jump to line 255.
3679 @item My Target
3680 Search for a link target @samp{<<My Target>>}, or do a text search for
3681 @samp{my target}, similar to the search in internal links, see
3682 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3683 link will become a HTML reference to the corresponding named anchor in
3684 the linked file.
3685 @item *My Target
3686 In an Org file, restrict search to headlines.
3687 @item #my-custom-id
3688 Link to a heading with a @code{CUSTOM_ID} property
3689 @item /regexp/
3690 Do a regular expression search for @code{regexp}.  This uses the Emacs
3691 command @code{occur} to list all matches in a separate window.  If the
3692 target file is in Org mode, @code{org-occur} is used to create a
3693 sparse tree with the matches.
3694 @c If the target file is a directory,
3695 @c @code{grep} will be used to search all files in the directory.
3696 @end table
3698 As a degenerate case, a file link with an empty file name can be used
3699 to search the current file.  For example, @code{[[file:::find me]]} does
3700 a search for @samp{find me} in the current file, just as
3701 @samp{[[find me]]} would.
3703 @node Custom searches,  , Search options, Hyperlinks
3704 @section Custom Searches
3705 @cindex custom search strings
3706 @cindex search strings, custom
3708 The default mechanism for creating search strings and for doing the
3709 actual search related to a file link may not work correctly in all
3710 cases.  For example, Bib@TeX{} database files have many entries like
3711 @samp{year="1993"} which would not result in good search strings,
3712 because the only unique identification for a Bib@TeX{} entry is the
3713 citation key.
3715 @vindex org-create-file-search-functions
3716 @vindex org-execute-file-search-functions
3717 If you come across such a problem, you can write custom functions to set
3718 the right search string for a particular file type, and to do the search
3719 for the string in the file.  Using @code{add-hook}, these functions need
3720 to be added to the hook variables
3721 @code{org-create-file-search-functions} and
3722 @code{org-execute-file-search-functions}.  See the docstring for these
3723 variables for more information.  Org actually uses this mechanism
3724 for Bib@TeX{} database files, and you can use the corresponding code as
3725 an implementation example.  See the file @file{org-bibtex.el}.
3727 @node TODO Items, Tags, Hyperlinks, Top
3728 @chapter TODO items
3729 @cindex TODO items
3731 Org mode does not maintain TODO lists as separate documents@footnote{Of
3732 course, you can make a document that contains only long lists of TODO items,
3733 but this is not required.}.  Instead, TODO items are an integral part of the
3734 notes file, because TODO items usually come up while taking notes!  With Org
3735 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3736 information is not duplicated, and the entire context from which the TODO
3737 item emerged is always present.
3739 Of course, this technique for managing TODO items scatters them
3740 throughout your notes file.  Org mode compensates for this by providing
3741 methods to give you an overview of all the things that you have to do.
3743 @menu
3744 * TODO basics::                 Marking and displaying TODO entries
3745 * TODO extensions::             Workflow and assignments
3746 * Progress logging::            Dates and notes for progress
3747 * Priorities::                  Some things are more important than others
3748 * Breaking down tasks::         Splitting a task into manageable pieces
3749 * Checkboxes::                  Tick-off lists
3750 @end menu
3752 @node TODO basics, TODO extensions, TODO Items, TODO Items
3753 @section Basic TODO functionality
3755 Any headline becomes a TODO item when it starts with the word
3756 @samp{TODO}, for example:
3758 @example
3759 *** TODO Write letter to Sam Fortune
3760 @end example
3762 @noindent
3763 The most important commands to work with TODO entries are:
3765 @table @kbd
3766 @orgcmd{C-c C-t,org-todo}
3767 @cindex cycling, of TODO states
3768 @vindex org-use-fast-todo-selection
3770 Rotate the TODO state of the current item among
3772 @example
3773 ,-> (unmarked) -> TODO -> DONE --.
3774 '--------------------------------'
3775 @end example
3777 If TODO keywords have fast access keys (see @ref{Fast access to TODO
3778 states}), you will be prompted for a TODO keyword through the fast selection
3779 interface; this is the default behavior when
3780 @var{org-use-fast-todo-selection} is @code{non-nil}.
3782 The same rotation can also be done ``remotely'' from the timeline and agenda
3783 buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3785 @orgkey{C-u C-c C-t}
3786 When TODO keywords have no selection keys, select a specific keyword using
3787 completion; otherwise force cycling through TODO states with no prompt.  When
3788 @var{org-use-fast-todo-selection} is set to @code{prefix}, use the fast
3789 selection interface.
3791 @kindex S-@key{right}
3792 @kindex S-@key{left}
3793 @item S-@key{right} @ @r{/} @ S-@key{left}
3794 @vindex org-treat-S-cursor-todo-selection-as-state-change
3795 Select the following/preceding TODO state, similar to cycling.  Useful
3796 mostly if more than two TODO states are possible (@pxref{TODO
3797 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
3798 with @code{shift-selection-mode}.  See also the variable
3799 @code{org-treat-S-cursor-todo-selection-as-state-change}.
3800 @orgcmd{C-c / t,org-show-todo-tree}
3801 @cindex sparse tree, for TODO
3802 @vindex org-todo-keywords
3803 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3804 entire buffer, but shows all TODO items (with not-DONE state) and the
3805 headings hierarchy above them.  With a prefix argument (or by using @kbd{C-c
3806 / T}), search for a specific TODO@.  You will be prompted for the keyword, and
3807 you can also give a list of keywords like @code{KWD1|KWD2|...} to list
3808 entries that match any one of these keywords.  With a numeric prefix argument
3809 N, show the tree for the Nth keyword in the variable
3810 @code{org-todo-keywords}.  With two prefix arguments, find all TODO states,
3811 both un-done and done.
3812 @orgcmd{C-c a t,org-todo-list}
3813 Show the global TODO list.  Collects the TODO items (with not-DONE states)
3814 from all agenda files (@pxref{Agenda Views}) into a single buffer.  The new
3815 buffer will be in @code{agenda-mode}, which provides commands to examine and
3816 manipulate the TODO entries from the new buffer (@pxref{Agenda commands}).
3817 @xref{Global TODO list}, for more information.
3818 @orgcmd{S-M-@key{RET},org-insert-todo-heading}
3819 Insert a new TODO entry below the current one.
3820 @end table
3822 @noindent
3823 @vindex org-todo-state-tags-triggers
3824 Changing a TODO state can also trigger tag changes.  See the docstring of the
3825 option @code{org-todo-state-tags-triggers} for details.
3827 @node TODO extensions, Progress logging, TODO basics, TODO Items
3828 @section Extended use of TODO keywords
3829 @cindex extended TODO keywords
3831 @vindex org-todo-keywords
3832 By default, marked TODO entries have one of only two states: TODO and
3833 DONE@.  Org mode allows you to classify TODO items in more complex ways
3834 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3835 special setup, the TODO keyword system can work differently in different
3836 files.
3838 Note that @i{tags} are another way to classify headlines in general and
3839 TODO items in particular (@pxref{Tags}).
3841 @menu
3842 * Workflow states::             From TODO to DONE in steps
3843 * TODO types::                  I do this, Fred does the rest
3844 * Multiple sets in one file::   Mixing it all, and still finding your way
3845 * Fast access to TODO states::  Single letter selection of a state
3846 * Per-file keywords::           Different files, different requirements
3847 * Faces for TODO keywords::     Highlighting states
3848 * TODO dependencies::           When one task needs to wait for others
3849 @end menu
3851 @node Workflow states, TODO types, TODO extensions, TODO extensions
3852 @subsection TODO keywords as workflow states
3853 @cindex TODO workflow
3854 @cindex workflow states as TODO keywords
3856 You can use TODO keywords to indicate different @emph{sequential} states
3857 in the process of working on an item, for example@footnote{Changing
3858 this variable only becomes effective after restarting Org mode in a
3859 buffer.}:
3861 @lisp
3862 (setq org-todo-keywords
3863   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3864 @end lisp
3866 The vertical bar separates the TODO keywords (states that @emph{need
3867 action}) from the DONE states (which need @emph{no further action}).  If
3868 you don't provide the separator bar, the last state is used as the DONE
3869 state.
3870 @cindex completion, of TODO keywords
3871 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3872 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED@.  You may
3873 also use a numeric prefix argument to quickly select a specific state.  For
3874 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY@.
3875 Or you can use @kbd{S-@key{left}} to go backward through the sequence.  If you
3876 define many keywords, you can use in-buffer completion
3877 (@pxref{Completion}) or even a special one-key selection scheme
3878 (@pxref{Fast access to TODO states}) to insert these words into the
3879 buffer.  Changing a TODO state can be logged with a timestamp, see
3880 @ref{Tracking TODO state changes}, for more information.
3882 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3883 @subsection TODO keywords as types
3884 @cindex TODO types
3885 @cindex names as TODO keywords
3886 @cindex types as TODO keywords
3888 The second possibility is to use TODO keywords to indicate different
3889 @emph{types} of action items.  For example, you might want to indicate
3890 that items are for ``work'' or ``home''.  Or, when you work with several
3891 people on a single project, you might want to assign action items
3892 directly to persons, by using their names as TODO keywords.  This would
3893 be set up like this:
3895 @lisp
3896 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3897 @end lisp
3899 In this case, different keywords do not indicate a sequence, but rather
3900 different types.  So the normal work flow would be to assign a task to a
3901 person, and later to mark it DONE@.  Org mode supports this style by adapting
3902 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3903 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3904 times in succession, it will still cycle through all names, in order to first
3905 select the right type for a task.  But when you return to the item after some
3906 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3907 to DONE@.  Use prefix arguments or completion to quickly select a specific
3908 name.  You can also review the items of a specific TODO type in a sparse tree
3909 by using a numeric prefix to @kbd{C-c / t}.  For example, to see all things
3910 Lucy has to do, you would use @kbd{C-3 C-c / t}.  To collect Lucy's items
3911 from all agenda files into a single buffer, you would use the numeric prefix
3912 argument as well when creating the global TODO list: @kbd{C-3 C-c a t}.
3914 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3915 @subsection Multiple keyword sets in one file
3916 @cindex TODO keyword sets
3918 Sometimes you may want to use different sets of TODO keywords in
3919 parallel.  For example, you may want to have the basic
3920 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
3921 separate state indicating that an item has been canceled (so it is not
3922 DONE, but also does not require action).  Your setup would then look
3923 like this:
3925 @lisp
3926 (setq org-todo-keywords
3927       '((sequence "TODO" "|" "DONE")
3928         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3929         (sequence "|" "CANCELED")))
3930 @end lisp
3932 The keywords should all be different, this helps Org mode to keep track
3933 of which subsequence should be used for a given entry.  In this setup,
3934 @kbd{C-c C-t} only operates within a subsequence, so it switches from
3935 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
3936 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
3937 select the correct sequence.  Besides the obvious ways like typing a
3938 keyword or using completion, you may also apply the following commands:
3940 @table @kbd
3941 @kindex C-S-@key{right}
3942 @kindex C-S-@key{left}
3943 @kindex C-u C-u C-c C-t
3944 @item C-u C-u C-c C-t
3945 @itemx C-S-@key{right}
3946 @itemx C-S-@key{left}
3947 These keys jump from one TODO subset to the next.  In the above example,
3948 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
3949 @code{DONE} to @code{REPORT}, and any of the words in the second row to
3950 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
3951 @code{shift-selection-mode} (@pxref{Conflicts}).
3952 @kindex S-@key{right}
3953 @kindex S-@key{left}
3954 @item S-@key{right}
3955 @itemx S-@key{left}
3956 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
3957 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
3958 from @code{DONE} to @code{REPORT} in the example above.  See also
3959 @ref{Conflicts}, for a discussion of the interaction with
3960 @code{shift-selection-mode}.
3961 @end table
3963 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
3964 @subsection Fast access to TODO states
3966 If you would like to quickly change an entry to an arbitrary TODO state
3967 instead of cycling through the states, you can set up keys for single-letter
3968 access to the states.  This is done by adding the selection character after
3969 each keyword, in parentheses@footnote{All characters are allowed except
3970 @code{@@^!}, which have a special meaning here.}.  For example:
3972 @lisp
3973 (setq org-todo-keywords
3974       '((sequence "TODO(t)" "|" "DONE(d)")
3975         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3976         (sequence "|" "CANCELED(c)")))
3977 @end lisp
3979 @vindex org-fast-tag-selection-include-todo
3980 If you then press @kbd{C-c C-t} followed by the selection key, the entry
3981 will be switched to this state.  @kbd{SPC} can be used to remove any TODO
3982 keyword from an entry.@footnote{Check also the variable
3983 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
3984 state through the tags interface (@pxref{Setting tags}), in case you like to
3985 mingle the two concepts.  Note that this means you need to come up with
3986 unique keys across both sets of keywords.}
3988 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
3989 @subsection Setting up keywords for individual files
3990 @cindex keyword options
3991 @cindex per-file keywords
3992 @cindex #+TODO
3993 @cindex #+TYP_TODO
3994 @cindex #+SEQ_TODO
3996 It can be very useful to use different aspects of the TODO mechanism in
3997 different files.  For file-local settings, you need to add special lines
3998 to the file which set the keywords and interpretation for that file
3999 only.  For example, to set one of the two examples discussed above, you
4000 need one of the following lines, starting in column zero anywhere in the
4001 file:
4003 @example
4004 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
4005 @end example
4006 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
4007 interpretation, but it means the same as @code{#+TODO}), or
4008 @example
4009 #+TYP_TODO: Fred Sara Lucy Mike | DONE
4010 @end example
4012 A setup for using several sets in parallel would be:
4014 @example
4015 #+TODO: TODO | DONE
4016 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
4017 #+TODO: | CANCELED
4018 @end example
4020 @cindex completion, of option keywords
4021 @kindex M-@key{TAB}
4022 @noindent To make sure you are using the correct keyword, type
4023 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
4025 @cindex DONE, final TODO keyword
4026 Remember that the keywords after the vertical bar (or the last keyword
4027 if no bar is there) must always mean that the item is DONE (although you
4028 may use a different word).  After changing one of these lines, use
4029 @kbd{C-c C-c} with the cursor still in the line to make the changes
4030 known to Org mode@footnote{Org mode parses these lines only when
4031 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
4032 cursor in a line starting with @samp{#+} is simply restarting Org mode
4033 for the current buffer.}.
4035 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
4036 @subsection Faces for TODO keywords
4037 @cindex faces, for TODO keywords
4039 @vindex org-todo @r{(face)}
4040 @vindex org-done @r{(face)}
4041 @vindex org-todo-keyword-faces
4042 Org mode highlights TODO keywords with special faces: @code{org-todo}
4043 for keywords indicating that an item still has to be acted upon, and
4044 @code{org-done} for keywords indicating that an item is finished.  If
4045 you are using more than 2 different states, you might want to use
4046 special faces for some of them.  This can be done using the variable
4047 @code{org-todo-keyword-faces}.  For example:
4049 @lisp
4050 @group
4051 (setq org-todo-keyword-faces
4052       '(("TODO" . org-warning) ("STARTED" . "yellow")
4053         ("CANCELED" . (:foreground "blue" :weight bold))))
4054 @end group
4055 @end lisp
4057 While using a list with face properties as shown for CANCELED @emph{should}
4058 work, this does not always seem to be the case.  If necessary, define a
4059 special face and use that.  A string is interpreted as a color.  The variable
4060 @code{org-faces-easy-properties} determines if that color is interpreted as a
4061 foreground or a background color.
4063 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
4064 @subsection TODO dependencies
4065 @cindex TODO dependencies
4066 @cindex dependencies, of TODO states
4068 @vindex org-enforce-todo-dependencies
4069 @cindex property, ORDERED
4070 The structure of Org files (hierarchy and lists) makes it easy to define TODO
4071 dependencies.  Usually, a parent TODO task should not be marked DONE until
4072 all subtasks (defined as children tasks) are marked as DONE@.  And sometimes
4073 there is a logical sequence to a number of (sub)tasks, so that one task
4074 cannot be acted upon before all siblings above it are done.  If you customize
4075 the variable @code{org-enforce-todo-dependencies}, Org will block entries
4076 from changing state to DONE while they have children that are not DONE@.
4077 Furthermore, if an entry has a property @code{ORDERED}, each of its children
4078 will be blocked until all earlier siblings are marked DONE@.  Here is an
4079 example:
4081 @example
4082 * TODO Blocked until (two) is done
4083 ** DONE one
4084 ** TODO two
4086 * Parent
4087   :PROPERTIES:
4088   :ORDERED: t
4089   :END:
4090 ** TODO a
4091 ** TODO b, needs to wait for (a)
4092 ** TODO c, needs to wait for (a) and (b)
4093 @end example
4095 @table @kbd
4096 @orgcmd{C-c C-x o,org-toggle-ordered-property}
4097 @vindex org-track-ordered-property-with-tag
4098 @cindex property, ORDERED
4099 Toggle the @code{ORDERED} property of the current entry.  A property is used
4100 for this behavior because this should be local to the current entry, not
4101 inherited like a tag.  However, if you would like to @i{track} the value of
4102 this property with a tag for better visibility, customize the variable
4103 @code{org-track-ordered-property-with-tag}.
4104 @orgkey{C-u C-u C-u C-c C-t}
4105 Change TODO state, circumventing any state blocking.
4106 @end table
4108 @vindex org-agenda-dim-blocked-tasks
4109 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
4110 that cannot be closed because of such dependencies will be shown in a dimmed
4111 font or even made invisible in agenda views (@pxref{Agenda Views}).
4113 @cindex checkboxes and TODO dependencies
4114 @vindex org-enforce-todo-dependencies
4115 You can also block changes of TODO states by looking at checkboxes
4116 (@pxref{Checkboxes}).  If you set the variable
4117 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
4118 checkboxes will be blocked from switching to DONE.
4120 If you need more complex dependency structures, for example dependencies
4121 between entries in different trees or files, check out the contributed
4122 module @file{org-depend.el}.
4124 @page
4125 @node Progress logging, Priorities, TODO extensions, TODO Items
4126 @section Progress logging
4127 @cindex progress logging
4128 @cindex logging, of progress
4130 Org mode can automatically record a timestamp and possibly a note when
4131 you mark a TODO item as DONE, or even each time you change the state of
4132 a TODO item.  This system is highly configurable; settings can be on a
4133 per-keyword basis and can be localized to a file or even a subtree.  For
4134 information on how to clock working time for a task, see @ref{Clocking
4135 work time}.
4137 @menu
4138 * Closing items::               When was this entry marked DONE?
4139 * Tracking TODO state changes::  When did the status change?
4140 * Tracking your habits::        How consistent have you been?
4141 @end menu
4143 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
4144 @subsection Closing items
4146 The most basic logging is to keep track of @emph{when} a certain TODO
4147 item was finished.  This is achieved with@footnote{The corresponding
4148 in-buffer setting is: @code{#+STARTUP: logdone}}
4150 @lisp
4151 (setq org-log-done 'time)
4152 @end lisp
4154 @noindent
4155 Then each time you turn an entry from a TODO (not-done) state into any
4156 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
4157 just after the headline.  If you turn the entry back into a TODO item
4158 through further state cycling, that line will be removed again.  If you
4159 want to record a note along with the timestamp, use@footnote{The
4160 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
4162 @lisp
4163 (setq org-log-done 'note)
4164 @end lisp
4166 @noindent
4167 You will then be prompted for a note, and that note will be stored below
4168 the entry with a @samp{Closing Note} heading.
4170 In the timeline (@pxref{Timeline}) and in the agenda
4171 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
4172 display the TODO items with a @samp{CLOSED} timestamp on each day,
4173 giving you an overview of what has been done.
4175 @node Tracking TODO state changes, Tracking your habits, Closing items, Progress logging
4176 @subsection Tracking TODO state changes
4177 @cindex drawer, for state change recording
4179 @vindex org-log-states-order-reversed
4180 @vindex org-log-into-drawer
4181 @cindex property, LOG_INTO_DRAWER
4182 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
4183 might want to keep track of when a state change occurred and maybe take a
4184 note about this change.  You can either record just a timestamp, or a
4185 time-stamped note for a change.  These records will be inserted after the
4186 headline as an itemized list, newest first@footnote{See the variable
4187 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
4188 want to get the notes out of the way into a drawer (@pxref{Drawers}).
4189 Customize the variable @code{org-log-into-drawer} to get this behavior---the
4190 recommended drawer for this is called @code{LOGBOOK}@footnote{Note that the
4191 @code{LOGBOOK} drawer is unfolded when pressing @key{SPC} in the agenda to
4192 show an entry---use @key{C-u SPC} to keep it folded here}.  You can also
4193 overrule the setting of this variable for a subtree by setting a
4194 @code{LOG_INTO_DRAWER} property.
4196 Since it is normally too much to record a note for every state, Org mode
4197 expects configuration on a per-keyword basis for this.  This is achieved by
4198 adding special markers @samp{!} (for a timestamp) or @samp{@@} (for a note
4199 with timestamp) in parentheses after each keyword.  For example, with the
4200 setting
4202 @lisp
4203 (setq org-todo-keywords
4204   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
4205 @end lisp
4207 To record a timestamp without a note for TODO keywords configured with
4208 @samp{@@}, just type @kbd{C-c C-c} to enter a blank note when prompted.
4210 @noindent
4211 @vindex org-log-done
4212 you not only define global TODO keywords and fast access keys, but also
4213 request that a time is recorded when the entry is set to
4214 DONE@footnote{It is possible that Org mode will record two timestamps
4215 when you are using both @code{org-log-done} and state change logging.
4216 However, it will never prompt for two notes---if you have configured
4217 both, the state change recording note will take precedence and cancel
4218 the @samp{Closing Note}.}, and that a note is recorded when switching to
4219 WAIT or CANCELED@.  The setting for WAIT is even more special: the
4220 @samp{!} after the slash means that in addition to the note taken when
4221 entering the state, a timestamp should be recorded when @i{leaving} the
4222 WAIT state, if and only if the @i{target} state does not configure
4223 logging for entering it.  So it has no effect when switching from WAIT
4224 to DONE, because DONE is configured to record a timestamp only.  But
4225 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
4226 setting now triggers a timestamp even though TODO has no logging
4227 configured.
4229 You can use the exact same syntax for setting logging preferences local
4230 to a buffer:
4231 @example
4232 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
4233 @end example
4235 @cindex property, LOGGING
4236 In order to define logging settings that are local to a subtree or a
4237 single item, define a LOGGING property in this entry.  Any non-empty
4238 LOGGING property resets all logging settings to nil.  You may then turn
4239 on logging for this specific tree using STARTUP keywords like
4240 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
4241 settings like @code{TODO(!)}.  For example
4243 @example
4244 * TODO Log each state with only a time
4245   :PROPERTIES:
4246   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4247   :END:
4248 * TODO Only log when switching to WAIT, and when repeating
4249   :PROPERTIES:
4250   :LOGGING: WAIT(@@) logrepeat
4251   :END:
4252 * TODO No logging at all
4253   :PROPERTIES:
4254   :LOGGING: nil
4255   :END:
4256 @end example
4258 @node Tracking your habits,  , Tracking TODO state changes, Progress logging
4259 @subsection Tracking your habits
4260 @cindex habits
4262 Org has the ability to track the consistency of a special category of TODOs,
4263 called ``habits''.  A habit has the following properties:
4265 @enumerate
4266 @item
4267 You have enabled the @code{habits} module by customizing the variable
4268 @code{org-modules}.
4269 @item
4270 The habit is a TODO item, with a TODO keyword representing an open state.
4271 @item
4272 The property @code{STYLE} is set to the value @code{habit}.
4273 @item
4274 The TODO has a scheduled date, usually with a @code{.+} style repeat
4275 interval.  A @code{++} style may be appropriate for habits with time
4276 constraints, e.g., must be done on weekends, or a @code{+} style for an
4277 unusual habit that can have a backlog, e.g., weekly reports.
4278 @item
4279 The TODO may also have minimum and maximum ranges specified by using the
4280 syntax @samp{.+2d/3d}, which says that you want to do the task at least every
4281 three days, but at most every two days.
4282 @item
4283 You must also have state logging for the @code{DONE} state enabled
4284 (@pxref{Tracking TODO state changes}), in order for historical data to be
4285 represented in the consistency graph.  If it is not enabled it is not an
4286 error, but the consistency graphs will be largely meaningless.
4287 @end enumerate
4289 To give you an idea of what the above rules look like in action, here's an
4290 actual habit with some history:
4292 @example
4293 ** TODO Shave
4294    SCHEDULED: <2009-10-17 Sat .+2d/4d>
4295    - State "DONE"       from "TODO"       [2009-10-15 Thu]
4296    - State "DONE"       from "TODO"       [2009-10-12 Mon]
4297    - State "DONE"       from "TODO"       [2009-10-10 Sat]
4298    - State "DONE"       from "TODO"       [2009-10-04 Sun]
4299    - State "DONE"       from "TODO"       [2009-10-02 Fri]
4300    - State "DONE"       from "TODO"       [2009-09-29 Tue]
4301    - State "DONE"       from "TODO"       [2009-09-25 Fri]
4302    - State "DONE"       from "TODO"       [2009-09-19 Sat]
4303    - State "DONE"       from "TODO"       [2009-09-16 Wed]
4304    - State "DONE"       from "TODO"       [2009-09-12 Sat]
4305    :PROPERTIES:
4306    :STYLE:    habit
4307    :LAST_REPEAT: [2009-10-19 Mon 00:36]
4308    :END:
4309 @end example
4311 What this habit says is: I want to shave at most every 2 days (given by the
4312 @code{SCHEDULED} date and repeat interval) and at least every 4 days.  If
4313 today is the 15th, then the habit first appears in the agenda on Oct 17,
4314 after the minimum of 2 days has elapsed, and will appear overdue on Oct 19,
4315 after four days have elapsed.
4317 What's really useful about habits is that they are displayed along with a
4318 consistency graph, to show how consistent you've been at getting that task
4319 done in the past.  This graph shows every day that the task was done over the
4320 past three weeks, with colors for each day.  The colors used are:
4322 @table @code
4323 @item Blue
4324 If the task wasn't to be done yet on that day.
4325 @item Green
4326 If the task could have been done on that day.
4327 @item Yellow
4328 If the task was going to be overdue the next day.
4329 @item Red
4330 If the task was overdue on that day.
4331 @end table
4333 In addition to coloring each day, the day is also marked with an asterisk if
4334 the task was actually done that day, and an exclamation mark to show where
4335 the current day falls in the graph.
4337 There are several configuration variables that can be used to change the way
4338 habits are displayed in the agenda.
4340 @table @code
4341 @item org-habit-graph-column
4342 The buffer column at which the consistency graph should be drawn.  This will
4343 overwrite any text in that column, so it is a good idea to keep your habits'
4344 titles brief and to the point.
4345 @item org-habit-preceding-days
4346 The amount of history, in days before today, to appear in consistency graphs.
4347 @item org-habit-following-days
4348 The number of days after today that will appear in consistency graphs.
4349 @item org-habit-show-habits-only-for-today
4350 If non-nil, only show habits in today's agenda view.  This is set to true by
4351 default.
4352 @end table
4354 Lastly, pressing @kbd{K} in the agenda buffer will cause habits to
4355 temporarily be disabled and they won't appear at all.  Press @kbd{K} again to
4356 bring them back.  They are also subject to tag filtering, if you have habits
4357 which should only be done in certain contexts, for example.
4359 @node Priorities, Breaking down tasks, Progress logging, TODO Items
4360 @section Priorities
4361 @cindex priorities
4363 If you use Org mode extensively, you may end up with enough TODO items that
4364 it starts to make sense to prioritize them.  Prioritizing can be done by
4365 placing a @emph{priority cookie} into the headline of a TODO item, like this
4367 @example
4368 *** TODO [#A] Write letter to Sam Fortune
4369 @end example
4371 @noindent
4372 @vindex org-priority-faces
4373 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
4374 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie is
4375 treated just like priority @samp{B}.  Priorities make a difference only for
4376 sorting in the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they
4377 have no inherent meaning to Org mode.  The cookies can be highlighted with
4378 special faces by customizing the variable @code{org-priority-faces}.
4380 Priorities can be attached to any outline node; they do not need to be TODO
4381 items.
4383 @table @kbd
4384 @item @kbd{C-c ,}
4385 @kindex @kbd{C-c ,}
4386 @findex org-priority
4387 Set the priority of the current headline (@command{org-priority}).  The
4388 command prompts for a priority character @samp{A}, @samp{B} or @samp{C}.
4389 When you press @key{SPC} instead, the priority cookie is removed from the
4390 headline.  The priorities can also be changed ``remotely'' from the timeline
4391 and agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
4393 @orgcmdkkcc{S-@key{up},S-@key{down},org-priority-up,org-priority-down}
4394 @vindex org-priority-start-cycle-with-default
4395 Increase/decrease priority of current headline@footnote{See also the option
4396 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
4397 also used to modify timestamps (@pxref{Creating timestamps}).  See also
4398 @ref{Conflicts}, for a discussion of the interaction with
4399 @code{shift-selection-mode}.
4400 @end table
4402 @vindex org-highest-priority
4403 @vindex org-lowest-priority
4404 @vindex org-default-priority
4405 You can change the range of allowed priorities by setting the variables
4406 @code{org-highest-priority}, @code{org-lowest-priority}, and
4407 @code{org-default-priority}.  For an individual buffer, you may set
4408 these values (highest, lowest, default) like this (please make sure that
4409 the highest priority is earlier in the alphabet than the lowest
4410 priority):
4412 @cindex #+PRIORITIES
4413 @example
4414 #+PRIORITIES: A C B
4415 @end example
4417 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
4418 @section Breaking tasks down into subtasks
4419 @cindex tasks, breaking down
4420 @cindex statistics, for TODO items
4422 @vindex org-agenda-todo-list-sublevels
4423 It is often advisable to break down large tasks into smaller, manageable
4424 subtasks.  You can do this by creating an outline tree below a TODO item,
4425 with detailed subtasks on the tree@footnote{To keep subtasks out of the
4426 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
4427 the overview over the fraction of subtasks that are already completed, insert
4428 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
4429 be updated each time the TODO status of a child changes, or when pressing
4430 @kbd{C-c C-c} on the cookie.  For example:
4432 @example
4433 * Organize Party [33%]
4434 ** TODO Call people [1/2]
4435 *** TODO Peter
4436 *** DONE Sarah
4437 ** TODO Buy food
4438 ** DONE Talk to neighbor
4439 @end example
4441 @cindex property, COOKIE_DATA
4442 If a heading has both checkboxes and TODO children below it, the meaning of
4443 the statistics cookie become ambiguous.  Set the property
4444 @code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
4445 this issue.
4447 @vindex org-hierarchical-todo-statistics
4448 If you would like to have the statistics cookie count any TODO entries in the
4449 subtree (not just direct children), configure the variable
4450 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
4451 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
4452 property.
4454 @example
4455 * Parent capturing statistics [2/20]
4456   :PROPERTIES:
4457   :COOKIE_DATA: todo recursive
4458   :END:
4459 @end example
4461 If you would like a TODO entry to automatically change to DONE
4462 when all children are done, you can use the following setup:
4464 @example
4465 (defun org-summary-todo (n-done n-not-done)
4466   "Switch entry to DONE when all subentries are done, to TODO otherwise."
4467   (let (org-log-done org-log-states)   ; turn off logging
4468     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4470 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4471 @end example
4474 Another possibility is the use of checkboxes to identify (a hierarchy of) a
4475 large number of subtasks (@pxref{Checkboxes}).
4478 @node Checkboxes,  , Breaking down tasks, TODO Items
4479 @section Checkboxes
4480 @cindex checkboxes
4482 @vindex org-list-automatic-rules
4483 Every item in a plain list@footnote{With the exception of description
4484 lists.  But you can allow it by modifying @code{org-list-automatic-rules}
4485 accordingly.} (@pxref{Plain lists}) can be made into a checkbox by starting
4486 it with the string @samp{[ ]}.  This feature is similar to TODO items
4487 (@pxref{TODO Items}), but is more lightweight.  Checkboxes are not included
4488 in the global TODO list, so they are often great to split a task into a
4489 number of simple steps.  Or you can use them in a shopping list.  To toggle a
4490 checkbox, use @kbd{C-c C-c}, or use the mouse (thanks to Piotr Zielinski's
4491 @file{org-mouse.el}).
4493 Here is an example of a checkbox list.
4495 @example
4496 * TODO Organize party [2/4]
4497   - [-] call people [1/3]
4498     - [ ] Peter
4499     - [X] Sarah
4500     - [ ] Sam
4501   - [X] order food
4502   - [ ] think about what music to play
4503   - [X] talk to the neighbors
4504 @end example
4506 Checkboxes work hierarchically, so if a checkbox item has children that
4507 are checkboxes, toggling one of the children checkboxes will make the
4508 parent checkbox reflect if none, some, or all of the children are
4509 checked.
4511 @cindex statistics, for checkboxes
4512 @cindex checkbox statistics
4513 @cindex property, COOKIE_DATA
4514 @vindex org-hierarchical-checkbox-statistics
4515 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
4516 indicating how many checkboxes present in this entry have been checked off,
4517 and the total number of checkboxes present.  This can give you an idea on how
4518 many checkboxes remain, even without opening a folded entry.  The cookies can
4519 be placed into a headline or into (the first line of) a plain list item.
4520 Each cookie covers checkboxes of direct children structurally below the
4521 headline/item on which the cookie appears@footnote{Set the variable
4522 @code{org-hierarchical-checkbox-statistics} if you want such cookies to
4523 count all checkboxes below the cookie, not just those belonging to direct
4524 children.}.  You have to insert the cookie yourself by typing either
4525 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
4526 result, as in the examples above.  With @samp{[%]} you get information about
4527 the percentage of checkboxes checked (in the above example, this would be
4528 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
4529 count either checkboxes below the heading or TODO states of children, and it
4530 will display whatever was changed last.  Set the property @code{COOKIE_DATA}
4531 to either @samp{checkbox} or @samp{todo} to resolve this issue.
4533 @cindex blocking, of checkboxes
4534 @cindex checkbox blocking
4535 @cindex property, ORDERED
4536 If the current outline node has an @code{ORDERED} property, checkboxes must
4537 be checked off in sequence, and an error will be thrown if you try to check
4538 off a box while there are unchecked boxes above it.
4540 @noindent The following commands work with checkboxes:
4542 @table @kbd
4543 @orgcmd{C-c C-c,org-toggle-checkbox}
4544 Toggle checkbox status or (with prefix arg) checkbox presence at point.
4545 With a single prefix argument, add an empty checkbox or remove the current
4546 one@footnote{@kbd{C-u C-c C-c} on the @emph{first} item of a list with no checkbox
4547 will add checkboxes to the rest of the list.}.  With a double prefix argument, set it to @samp{[-]}, which is
4548 considered to be an intermediate state.
4549 @orgcmd{C-c C-x C-b,org-toggle-checkbox}
4550 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
4551 double prefix argument, set it to @samp{[-]}, which is considered to be an
4552 intermediate state.
4553 @itemize @minus
4554 @item
4555 If there is an active region, toggle the first checkbox in the region
4556 and set all remaining boxes to the same status as the first.  With a prefix
4557 arg, add or remove the checkbox for all items in the region.
4558 @item
4559 If the cursor is in a headline, toggle checkboxes in the region between
4560 this headline and the next (so @emph{not} the entire subtree).
4561 @item
4562 If there is no active region, just toggle the checkbox at point.
4563 @end itemize
4564 @orgcmd{M-S-@key{RET},org-insert-todo-heading}
4565 Insert a new item with a checkbox.  This works only if the cursor is already
4566 in a plain list item (@pxref{Plain lists}).
4567 @orgcmd{C-c C-x o,org-toggle-ordered-property}
4568 @vindex org-track-ordered-property-with-tag
4569 @cindex property, ORDERED
4570 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
4571 be checked off in sequence.  A property is used for this behavior because
4572 this should be local to the current entry, not inherited like a tag.
4573 However, if you would like to @i{track} the value of this property with a tag
4574 for better visibility, customize the variable
4575 @code{org-track-ordered-property-with-tag}.
4576 @orgcmd{C-c #,org-update-statistics-cookies}
4577 Update the statistics cookie in the current outline entry.  When called with
4578 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
4579 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
4580 new ones with @kbd{M-S-@key{RET}}.  TODO statistics cookies update when
4581 changing TODO states.  If you delete boxes/entries or add/change them by
4582 hand, use this command to get things back into sync.
4583 @end table
4585 @node Tags, Properties and Columns, TODO Items, Top
4586 @chapter Tags
4587 @cindex tags
4588 @cindex headline tagging
4589 @cindex matching, tags
4590 @cindex sparse tree, tag based
4592 An excellent way to implement labels and contexts for cross-correlating
4593 information is to assign @i{tags} to headlines.  Org mode has extensive
4594 support for tags.
4596 @vindex org-tag-faces
4597 Every headline can contain a list of tags; they occur at the end of the
4598 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
4599 @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
4600 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
4601 Tags will by default be in bold face with the same color as the headline.
4602 You may specify special faces for specific tags using the variable
4603 @code{org-tag-faces}, in much the same way as you can for TODO keywords
4604 (@pxref{Faces for TODO keywords}).
4606 @menu
4607 * Tag inheritance::             Tags use the tree structure of the outline
4608 * Setting tags::                How to assign tags to a headline
4609 * Tag searches::                Searching for combinations of tags
4610 @end menu
4612 @node Tag inheritance, Setting tags, Tags, Tags
4613 @section Tag inheritance
4614 @cindex tag inheritance
4615 @cindex inheritance, of tags
4616 @cindex sublevels, inclusion into tags match
4618 @i{Tags} make use of the hierarchical structure of outline trees.  If a
4619 heading has a certain tag, all subheadings will inherit the tag as
4620 well.  For example, in the list
4622 @example
4623 * Meeting with the French group      :work:
4624 ** Summary by Frank                  :boss:notes:
4625 *** TODO Prepare slides for him      :action:
4626 @end example
4628 @noindent
4629 the final heading will have the tags @samp{:work:}, @samp{:boss:},
4630 @samp{:notes:}, and @samp{:action:} even though the final heading is not
4631 explicitly marked with those tags.  You can also set tags that all entries in
4632 a file should inherit just as if these tags were defined in a hypothetical
4633 level zero that surrounds the entire file.  Use a line like this@footnote{As
4634 with all these in-buffer settings, pressing @kbd{C-c C-c} activates any
4635 changes in the line.}:
4637 @cindex #+FILETAGS
4638 @example
4639 #+FILETAGS: :Peter:Boss:Secret:
4640 @end example
4642 @noindent
4643 @vindex org-use-tag-inheritance
4644 @vindex org-tags-exclude-from-inheritance
4645 To limit tag inheritance to specific tags, use @code{org-tags-exclude-from-inheritance}.
4646 To turn it off entirely, use @code{org-use-tag-inheritance}.
4648 @vindex org-tags-match-list-sublevels
4649 When a headline matches during a tags search while tag inheritance is turned
4650 on, all the sublevels in the same tree will (for a simple match form) match
4651 as well@footnote{This is only true if the search does not involve more
4652 complex tests including properties (@pxref{Property searches}).}.  The list
4653 of matches may then become very long.  If you only want to see the first tags
4654 match in a subtree, configure the variable
4655 @code{org-tags-match-list-sublevels} (not recommended).
4657 @vindex org-agenda-use-tag-inheritance
4658 Tag inheritance is relevant when the agenda search tries to match a tag,
4659 either in the @code{tags} or @code{tags-todo} agenda types.  In other agenda
4660 types, @code{org-use-tag-inheritance} has no effect.  Still, you may want to
4661 have your tags correctly set in the agenda, so that tag filtering works fine,
4662 with inherited tags.  Set @code{org-agenda-use-tag-inheritance} to control
4663 this: the default value includes all agenda types, but setting this to nil
4664 can really speed up agenda generation.
4666 @node Setting tags, Tag searches, Tag inheritance, Tags
4667 @section Setting tags
4668 @cindex setting tags
4669 @cindex tags, setting
4671 @kindex M-@key{TAB}
4672 Tags can simply be typed into the buffer at the end of a headline.
4673 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
4674 also a special command for inserting tags:
4676 @table @kbd
4677 @orgcmd{C-c C-q,org-set-tags-command}
4678 @cindex completion, of tags
4679 @vindex org-tags-column
4680 Enter new tags for the current headline.  Org mode will either offer
4681 completion or a special single-key interface for setting tags, see
4682 below.  After pressing @key{RET}, the tags will be inserted and aligned
4683 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
4684 tags in the current buffer will be aligned to that column, just to make
4685 things look nice.  TAGS are automatically realigned after promotion,
4686 demotion, and TODO state changes (@pxref{TODO basics}).
4687 @orgcmd{C-c C-c,org-set-tags-command}
4688 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
4689 @end table
4691 @vindex org-tag-alist
4692 Org supports tag insertion based on a @emph{list of tags}.  By
4693 default this list is constructed dynamically, containing all tags
4694 currently used in the buffer.  You may also globally specify a hard list
4695 of tags with the variable @code{org-tag-alist}.  Finally you can set
4696 the default tags for a given file with lines like
4698 @cindex #+TAGS
4699 @example
4700 #+TAGS: @@work @@home @@tennisclub
4701 #+TAGS: laptop car pc sailboat
4702 @end example
4704 If you have globally defined your preferred set of tags using the
4705 variable @code{org-tag-alist}, but would like to use a dynamic tag list
4706 in a specific file, add an empty TAGS option line to that file:
4708 @example
4709 #+TAGS:
4710 @end example
4712 @vindex org-tag-persistent-alist
4713 If you have a preferred set of tags that you would like to use in every file,
4714 in addition to those defined on a per-file basis by TAGS option lines, then
4715 you may specify a list of tags with the variable
4716 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
4717 by adding a STARTUP option line to that file:
4719 @example
4720 #+STARTUP: noptag
4721 @end example
4723 By default Org mode uses the standard minibuffer completion facilities for
4724 entering tags.  However, it also implements another, quicker, tag selection
4725 method called @emph{fast tag selection}.  This allows you to select and
4726 deselect tags with just a single key press.  For this to work well you should
4727 assign unique letters to most of your commonly used tags.  You can do this
4728 globally by configuring the variable @code{org-tag-alist} in your
4729 @file{.emacs} file.  For example, you may find the need to tag many items in
4730 different files with @samp{:@@home:}.  In this case you can set something
4731 like:
4733 @lisp
4734 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
4735 @end lisp
4737 @noindent If the tag is only relevant to the file you are working on, then you
4738 can instead set the TAGS option line as:
4740 @example
4741 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
4742 @end example
4744 @noindent The tags interface will show the available tags in a splash
4745 window.  If you want to start a new line after a specific tag, insert
4746 @samp{\n} into the tag list
4748 @example
4749 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
4750 @end example
4752 @noindent or write them in two lines:
4754 @example
4755 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
4756 #+TAGS: laptop(l)  pc(p)
4757 @end example
4759 @noindent
4760 You can also group together tags that are mutually exclusive by using
4761 braces, as in:
4763 @example
4764 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
4765 @end example
4767 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
4768 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
4770 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
4771 these lines to activate any changes.
4773 @noindent
4774 To set these mutually exclusive groups in the variable @code{org-tags-alist},
4775 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
4776 of the braces.  Similarly, you can use @code{:newline} to indicate a line
4777 break.  The previous example would be set globally by the following
4778 configuration:
4780 @lisp
4781 (setq org-tag-alist '((:startgroup . nil)
4782                       ("@@work" . ?w) ("@@home" . ?h)
4783                       ("@@tennisclub" . ?t)
4784                       (:endgroup . nil)
4785                       ("laptop" . ?l) ("pc" . ?p)))
4786 @end lisp
4788 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
4789 automatically present you with a special interface, listing inherited tags,
4790 the tags of the current headline, and a list of all valid tags with
4791 corresponding keys@footnote{Keys will automatically be assigned to tags which
4792 have no configured keys.}.  In this interface, you can use the following
4793 keys:
4795 @table @kbd
4796 @item a-z...
4797 Pressing keys assigned to tags will add or remove them from the list of
4798 tags in the current line.  Selecting a tag in a group of mutually
4799 exclusive tags will turn off any other tags from that group.
4800 @kindex @key{TAB}
4801 @item @key{TAB}
4802 Enter a tag in the minibuffer, even if the tag is not in the predefined
4803 list.  You will be able to complete on all tags present in the buffer.
4804 You can also add several tags: just separate them with a comma.
4806 @kindex @key{SPC}
4807 @item @key{SPC}
4808 Clear all tags for this line.
4809 @kindex @key{RET}
4810 @item @key{RET}
4811 Accept the modified set.
4812 @item C-g
4813 Abort without installing changes.
4814 @item q
4815 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
4816 @item !
4817 Turn off groups of mutually exclusive tags.  Use this to (as an
4818 exception) assign several tags from such a group.
4819 @item C-c
4820 Toggle auto-exit after the next change (see below).
4821 If you are using expert mode, the first @kbd{C-c} will display the
4822 selection window.
4823 @end table
4825 @noindent
4826 This method lets you assign tags to a headline with very few keys.  With
4827 the above setup, you could clear the current tags and set @samp{@@home},
4828 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
4829 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
4830 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
4831 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
4832 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
4833 @key{RET} @key{RET}}.
4835 @vindex org-fast-tag-selection-single-key
4836 If you find that most of the time you need only a single key press to
4837 modify your list of tags, set the variable
4838 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
4839 press @key{RET} to exit fast tag selection---it will immediately exit
4840 after the first change.  If you then occasionally need more keys, press
4841 @kbd{C-c} to turn off auto-exit for the current tag selection process
4842 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
4843 C-c}).  If you set the variable to the value @code{expert}, the special
4844 window is not even shown for single-key tag selection, it comes up only
4845 when you press an extra @kbd{C-c}.
4847 @node Tag searches,  , Setting tags, Tags
4848 @section Tag searches
4849 @cindex tag searches
4850 @cindex searching for tags
4852 Once a system of tags has been set up, it can be used to collect related
4853 information into special lists.
4855 @table @kbd
4856 @orgcmdkkc{C-c / m,C-c \\,org-match-sparse-tree}
4857 Create a sparse tree with all headlines matching a tags search.  With a
4858 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4859 @orgcmd{C-c a m,org-tags-view}
4860 Create a global list of tag matches from all agenda files.
4861 @xref{Matching tags and properties}.
4862 @orgcmd{C-c a M,org-tags-view}
4863 @vindex org-tags-match-list-sublevels
4864 Create a global list of tag matches from all agenda files, but check
4865 only TODO items and force checking subitems (see variable
4866 @code{org-tags-match-list-sublevels}).
4867 @end table
4869 These commands all prompt for a match string which allows basic Boolean logic
4870 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
4871 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
4872 which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of the search
4873 string is rich and allows also matching against TODO keywords, entry levels
4874 and properties.  For a complete description with many examples, see
4875 @ref{Matching tags and properties}.
4878 @node Properties and Columns, Dates and Times, Tags, Top
4879 @chapter Properties and columns
4880 @cindex properties
4882 A property is a key-value pair associated with an entry.  Properties can be
4883 set so they are associated with a single entry, with every entry in a tree,
4884 or with every entry in an Org mode file.
4886 There are two main applications for properties in Org mode.  First,
4887 properties are like tags, but with a value.  Imagine maintaining a file where
4888 you document bugs and plan releases for a piece of software.  Instead of
4889 using tags like @code{:release_1:}, @code{:release_2:}, you can use a
4890 property, say @code{:Release:}, that in different subtrees has different
4891 values, such as @code{1.0} or @code{2.0}.  Second, you can use properties to
4892 implement (very basic) database capabilities in an Org buffer.  Imagine
4893 keeping track of your music CDs, where properties could be things such as the
4894 album, artist, date of release, number of tracks, and so on.
4896 Properties can be conveniently edited and viewed in column view
4897 (@pxref{Column view}).
4899 @menu
4900 * Property syntax::             How properties are spelled out
4901 * Special properties::          Access to other Org mode features
4902 * Property searches::           Matching property values
4903 * Property inheritance::        Passing values down the tree
4904 * Column view::                 Tabular viewing and editing
4905 * Property API::                Properties for Lisp programmers
4906 @end menu
4908 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
4909 @section Property syntax
4910 @cindex property syntax
4911 @cindex drawer, for properties
4913 Properties are key-value pairs.  When they are associated with a single entry
4914 or with a tree they need to be inserted into a special
4915 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
4916 is specified on a single line, with the key (surrounded by colons)
4917 first, and the value after it.  Here is an example:
4919 @example
4920 * CD collection
4921 ** Classic
4922 *** Goldberg Variations
4923     :PROPERTIES:
4924     :Title:     Goldberg Variations
4925     :Composer:  J.S. Bach
4926     :Artist:    Glen Gould
4927     :Publisher: Deutsche Grammophon
4928     :NDisks:    1
4929     :END:
4930 @end example
4932 Depending on the value of @code{org-use-property-inheritance}, a property set
4933 this way will either be associated with a single entry, or the sub-tree
4934 defined by the entry, see @ref{Property inheritance}.
4936 You may define the allowed values for a particular property @samp{:Xyz:}
4937 by setting a property @samp{:Xyz_ALL:}.  This special property is
4938 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
4939 the entire tree.  When allowed values are defined, setting the
4940 corresponding property becomes easier and is less prone to typing
4941 errors.  For the example with the CD collection, we can predefine
4942 publishers and the number of disks in a box like this:
4944 @example
4945 * CD collection
4946   :PROPERTIES:
4947   :NDisks_ALL:  1 2 3 4
4948   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
4949   :END:
4950 @end example
4952 If you want to set properties that can be inherited by any entry in a
4953 file, use a line like
4954 @cindex property, _ALL
4955 @cindex #+PROPERTY
4956 @example
4957 #+PROPERTY: NDisks_ALL 1 2 3 4
4958 @end example
4960 Contrary to properties set from a special drawer, you have to refresh the
4961 buffer with @kbd{C-c C-c} to activate this changes.
4963 If you want to add to the value of an existing property, append a @code{+} to
4964 the property name.  The following results in the property @code{var} having
4965 the value ``foo=1 bar=2''.
4966 @cindex property, +
4967 @example
4968 #+PROPERTY: var  foo=1
4969 #+PROPERTY: var+ bar=2
4970 @end example
4972 It is also possible to add to the values of inherited properties.  The
4973 following results in the @code{genres} property having the value ``Classic
4974 Baroque'' under the @code{Goldberg Variations} subtree.
4975 @cindex property, +
4976 @example
4977 * CD collection
4978 ** Classic
4979     :PROPERTIES:
4980     :GENRES: Classic
4981     :END:
4982 *** Goldberg Variations
4983     :PROPERTIES:
4984     :Title:     Goldberg Variations
4985     :Composer:  J.S. Bach
4986     :Artist:    Glen Gould
4987     :Publisher: Deutsche Grammophon
4988     :NDisks:    1
4989     :GENRES+:   Baroque
4990     :END:
4991 @end example
4992 Note that a property can only have one entry per Drawer.
4994 @vindex org-global-properties
4995 Property values set with the global variable
4996 @code{org-global-properties} can be inherited by all entries in all
4997 Org files.
4999 @noindent
5000 The following commands help to work with properties:
5002 @table @kbd
5003 @orgcmd{M-@key{TAB},pcomplete}
5004 After an initial colon in a line, complete property keys.  All keys used
5005 in the current file will be offered as possible completions.
5006 @orgcmd{C-c C-x p,org-set-property}
5007 Set a property.  This prompts for a property name and a value.  If
5008 necessary, the property drawer is created as well.
5009 @item C-u M-x org-insert-drawer
5010 @cindex org-insert-drawer
5011 Insert a property drawer into the current entry.  The drawer will be
5012 inserted early in the entry, but after the lines with planning
5013 information like deadlines.
5014 @orgcmd{C-c C-c,org-property-action}
5015 With the cursor in a property drawer, this executes property commands.
5016 @orgcmd{C-c C-c s,org-set-property}
5017 Set a property in the current entry.  Both the property and the value
5018 can be inserted using completion.
5019 @orgcmdkkcc{S-@key{right},S-@key{left},org-property-next-allowed-value,org-property-previous-allowed-value}
5020 Switch property at point to the next/previous allowed value.
5021 @orgcmd{C-c C-c d,org-delete-property}
5022 Remove a property from the current entry.
5023 @orgcmd{C-c C-c D,org-delete-property-globally}
5024 Globally remove a property, from all entries in the current file.
5025 @orgcmd{C-c C-c c,org-compute-property-at-point}
5026 Compute the property at point, using the operator and scope from the
5027 nearest column format definition.
5028 @end table
5030 @node Special properties, Property searches, Property syntax, Properties and Columns
5031 @section Special properties
5032 @cindex properties, special
5034 Special properties provide an alternative access method to Org mode features,
5035 like the TODO state or the priority of an entry, discussed in the previous
5036 chapters.  This interface exists so that you can include these states in a
5037 column view (@pxref{Column view}), or to use them in queries.  The following
5038 property names are special and (except for @code{:CATEGORY:}) should not be
5039 used as keys in the properties drawer:
5041 @cindex property, special, ID
5042 @cindex property, special, TODO
5043 @cindex property, special, TAGS
5044 @cindex property, special, ALLTAGS
5045 @cindex property, special, CATEGORY
5046 @cindex property, special, PRIORITY
5047 @cindex property, special, DEADLINE
5048 @cindex property, special, SCHEDULED
5049 @cindex property, special, CLOSED
5050 @cindex property, special, TIMESTAMP
5051 @cindex property, special, TIMESTAMP_IA
5052 @cindex property, special, CLOCKSUM
5053 @cindex property, special, CLOCKSUM_T
5054 @cindex property, special, BLOCKED
5055 @c guessing that ITEM is needed in this area; also, should this list be sorted?
5056 @cindex property, special, ITEM
5057 @cindex property, special, FILE
5058 @example
5059 ID           @r{A globally unique ID used for synchronization during}
5060              @r{iCalendar or MobileOrg export.}
5061 TODO         @r{The TODO keyword of the entry.}
5062 TAGS         @r{The tags defined directly in the headline.}
5063 ALLTAGS      @r{All tags, including inherited ones.}
5064 CATEGORY     @r{The category of an entry.}
5065 PRIORITY     @r{The priority of the entry, a string with a single letter.}
5066 DEADLINE     @r{The deadline time string, without the angular brackets.}
5067 SCHEDULED    @r{The scheduling timestamp, without the angular brackets.}
5068 CLOSED       @r{When was this entry closed?}
5069 TIMESTAMP    @r{The first keyword-less timestamp in the entry.}
5070 TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
5071 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
5072              @r{must be run first to compute the values in the current buffer.}
5073 CLOCKSUM_T   @r{The sum of CLOCK intervals in the subtree for today.}
5074              @r{@code{org-clock-sum-today} must be run first to compute the}
5075              @r{values in the current buffer.}
5076 BLOCKED      @r{"t" if task is currently blocked by children or siblings}
5077 ITEM         @r{The headline of the entry.}
5078 FILE         @r{The filename the entry is located in.}
5079 @end example
5081 @node Property searches, Property inheritance, Special properties, Properties and Columns
5082 @section Property searches
5083 @cindex properties, searching
5084 @cindex searching, of properties
5086 To create sparse trees and special lists with selection based on properties,
5087 the same commands are used as for tag searches (@pxref{Tag searches}).
5088 @table @kbd
5089 @orgcmdkkc{C-c / m,C-c \\,org-match-sparse-tree}
5090 Create a sparse tree with all matching entries.  With a
5091 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
5092 @orgcmd{C-c a m,org-tags-view}
5093 Create a global list of tag/property  matches from all agenda files.
5094 @xref{Matching tags and properties}.
5095 @orgcmd{C-c a M,org-tags-view}
5096 @vindex org-tags-match-list-sublevels
5097 Create a global list of tag matches from all agenda files, but check
5098 only TODO items and force checking of subitems (see variable
5099 @code{org-tags-match-list-sublevels}).
5100 @end table
5102 The syntax for the search string is described in @ref{Matching tags and
5103 properties}.
5105 There is also a special command for creating sparse trees based on a
5106 single property:
5108 @table @kbd
5109 @orgkey{C-c / p}
5110 Create a sparse tree based on the value of a property.  This first
5111 prompts for the name of a property, and then for a value.  A sparse tree
5112 is created with all entries that define this property with the given
5113 value.  If you enclose the value in curly braces, it is interpreted as
5114 a regular expression and matched against the property values.
5115 @end table
5117 @node Property inheritance, Column view, Property searches, Properties and Columns
5118 @section Property Inheritance
5119 @cindex properties, inheritance
5120 @cindex inheritance, of properties
5122 @vindex org-use-property-inheritance
5123 The outline structure of Org mode documents lends itself to an
5124 inheritance model of properties: if the parent in a tree has a certain
5125 property, the children can inherit this property.  Org mode does not
5126 turn this on by default, because it can slow down property searches
5127 significantly and is often not needed.  However, if you find inheritance
5128 useful, you can turn it on by setting the variable
5129 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
5130 all properties inherited from the parent, to a list of properties
5131 that should be inherited, or to a regular expression that matches
5132 inherited properties.  If a property has the value @samp{nil}, this is
5133 interpreted as an explicit undefine of the property, so that inheritance
5134 search will stop at this value and return @code{nil}.
5136 Org mode has a few properties for which inheritance is hard-coded, at
5137 least for the special applications for which they are used:
5139 @cindex property, COLUMNS
5140 @table @code
5141 @item COLUMNS
5142 The @code{:COLUMNS:} property defines the format of column view
5143 (@pxref{Column view}).  It is inherited in the sense that the level
5144 where a @code{:COLUMNS:} property is defined is used as the starting
5145 point for a column view table, independently of the location in the
5146 subtree from where columns view is turned on.
5147 @item CATEGORY
5148 @cindex property, CATEGORY
5149 For agenda view, a category set through a @code{:CATEGORY:} property
5150 applies to the entire subtree.
5151 @item ARCHIVE
5152 @cindex property, ARCHIVE
5153 For archiving, the @code{:ARCHIVE:} property may define the archive
5154 location for the entire subtree (@pxref{Moving subtrees}).
5155 @item LOGGING
5156 @cindex property, LOGGING
5157 The LOGGING property may define logging settings for an entry or a
5158 subtree (@pxref{Tracking TODO state changes}).
5159 @end table
5161 @node Column view, Property API, Property inheritance, Properties and Columns
5162 @section Column view
5164 A great way to view and edit properties in an outline tree is
5165 @emph{column view}.  In column view, each outline node is turned into a
5166 table row.  Columns in this table provide access to properties of the
5167 entries.  Org mode implements columns by overlaying a tabular structure
5168 over the headline of each item.  While the headlines have been turned
5169 into a table row, you can still change the visibility of the outline
5170 tree.  For example, you get a compact table by switching to CONTENTS
5171 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
5172 is active), but you can still open, read, and edit the entry below each
5173 headline.  Or, you can switch to column view after executing a sparse
5174 tree command and in this way get a table only for the selected items.
5175 Column view also works in agenda buffers (@pxref{Agenda Views}) where
5176 queries have collected selected items, possibly from a number of files.
5178 @menu
5179 * Defining columns::            The COLUMNS format property
5180 * Using column view::           How to create and use column view
5181 * Capturing column view::       A dynamic block for column view
5182 @end menu
5184 @node Defining columns, Using column view, Column view, Column view
5185 @subsection Defining columns
5186 @cindex column view, for properties
5187 @cindex properties, column view
5189 Setting up a column view first requires defining the columns.  This is
5190 done by defining a column format line.
5192 @menu
5193 * Scope of column definitions::  Where defined, where valid?
5194 * Column attributes::           Appearance and content of a column
5195 @end menu
5197 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
5198 @subsubsection Scope of column definitions
5200 To define a column format for an entire file, use a line like
5202 @cindex #+COLUMNS
5203 @example
5204 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5205 @end example
5207 To specify a format that only applies to a specific tree, add a
5208 @code{:COLUMNS:} property to the top node of that tree, for example:
5210 @example
5211 ** Top node for columns view
5212    :PROPERTIES:
5213    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5214    :END:
5215 @end example
5217 If a @code{:COLUMNS:} property is present in an entry, it defines columns
5218 for the entry itself, and for the entire subtree below it.  Since the
5219 column definition is part of the hierarchical structure of the document,
5220 you can define columns on level 1 that are general enough for all
5221 sublevels, and more specific columns further down, when you edit a
5222 deeper part of the tree.
5224 @node Column attributes,  , Scope of column definitions, Defining columns
5225 @subsubsection Column attributes
5226 A column definition sets the attributes of a column.  The general
5227 definition looks like this:
5229 @example
5230  %[@var{width}]@var{property}[(@var{title})][@{@var{summary-type}@}]
5231 @end example
5233 @noindent
5234 Except for the percent sign and the property name, all items are
5235 optional.  The individual parts have the following meaning:
5237 @example
5238 @var{width}           @r{An integer specifying the width of the column in characters.}
5239                 @r{If omitted, the width will be determined automatically.}
5240 @var{property}        @r{The property that should be edited in this column.}
5241                 @r{Special properties representing meta data are allowed here}
5242                 @r{as well (@pxref{Special properties})}
5243 @var{title}           @r{The header text for the column.  If omitted, the property}
5244                 @r{name is used.}
5245 @{@var{summary-type}@}  @r{The summary type.  If specified, the column values for}
5246                 @r{parent nodes are computed from the children.}
5247                 @r{Supported summary types are:}
5248                 @{+@}       @r{Sum numbers in this column.}
5249                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
5250                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
5251                 @{:@}       @r{Sum times, HH:MM, plain numbers are hours.}
5252                 @{X@}       @r{Checkbox status, @samp{[X]} if all children are @samp{[X]}.}
5253                 @{X/@}      @r{Checkbox status, @samp{[n/m]}.}
5254                 @{X%@}      @r{Checkbox status, @samp{[n%]}.}
5255                 @{min@}     @r{Smallest number in column.}
5256                 @{max@}     @r{Largest number.}
5257                 @{mean@}    @r{Arithmetic mean of numbers.}
5258                 @{:min@}    @r{Smallest time value in column.}
5259                 @{:max@}    @r{Largest time value.}
5260                 @{:mean@}   @r{Arithmetic mean of time values.}
5261                 @{@@min@}    @r{Minimum age (in days/hours/mins/seconds).}
5262                 @{@@max@}    @r{Maximum age (in days/hours/mins/seconds).}
5263                 @{@@mean@}   @r{Arithmetic mean of ages (in days/hours/mins/seconds).}
5264                 @{est+@}    @r{Add low-high estimates.}
5265 @end example
5267 @noindent
5268 Be aware that you can only have one summary type for any property you
5269 include.  Subsequent columns referencing the same property will all display the
5270 same summary information.
5272 The @code{est+} summary type requires further explanation.  It is used for
5273 combining estimates, expressed as low-high ranges.  For example, instead
5274 of estimating a particular task will take 5 days, you might estimate it as
5275 5--6 days if you're fairly confident you know how much work is required, or
5276 1--10 days if you don't really know what needs to be done.  Both ranges
5277 average at 5.5 days, but the first represents a more predictable delivery.
5279 When combining a set of such estimates, simply adding the lows and highs
5280 produces an unrealistically wide result.  Instead, @code{est+} adds the
5281 statistical mean and variance of the sub-tasks, generating a final estimate
5282 from the sum.  For example, suppose you had ten tasks, each of which was
5283 estimated at 0.5 to 2 days of work.  Straight addition produces an estimate
5284 of 5 to 20 days, representing what to expect if everything goes either
5285 extremely well or extremely poorly.  In contrast, @code{est+} estimates the
5286 full job more realistically, at 10--15 days.
5288 Here is an example for a complete columns definition, along with allowed
5289 values.
5291 @example
5292 :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.}
5293                    %10Time_Estimate@{:@} %CLOCKSUM %CLOCKSUM_T
5294 :Owner_ALL:    Tammy Mark Karl Lisa Don
5295 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
5296 :Approved_ALL: "[ ]" "[X]"
5297 @end example
5299 @noindent
5300 The first column, @samp{%25ITEM}, means the first 25 characters of the
5301 item itself, i.e., of the headline.  You probably always should start the
5302 column definition with the @samp{ITEM} specifier.  The other specifiers
5303 create columns @samp{Owner} with a list of names as allowed values, for
5304 @samp{Status} with four different possible values, and for a checkbox
5305 field @samp{Approved}.  When no width is given after the @samp{%}
5306 character, the column will be exactly as wide as it needs to be in order
5307 to fully display all values.  The @samp{Approved} column does have a
5308 modified title (@samp{Approved?}, with a question mark).  Summaries will
5309 be created for the @samp{Time_Estimate} column by adding time duration
5310 expressions like HH:MM, and for the @samp{Approved} column, by providing
5311 an @samp{[X]} status if all children have been checked.  The
5312 @samp{CLOCKSUM} and @samp{CLOCKSUM_T} columns are special, they lists the
5313 sums of CLOCK intervals in the subtree, either for all clocks or just for
5314 today.
5316 @node Using column view, Capturing column view, Defining columns, Column view
5317 @subsection Using column view
5319 @table @kbd
5320 @tsubheading{Turning column view on and off}
5321 @orgcmd{C-c C-x C-c,org-columns}
5322 @vindex org-columns-default-format
5323 Turn on column view.  If the cursor is before the first headline in the file,
5324 column view is turned on for the entire file, using the @code{#+COLUMNS}
5325 definition.  If the cursor is somewhere inside the outline, this command
5326 searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
5327 defines a format.  When one is found, the column view table is established
5328 for the tree starting at the entry that contains the @code{:COLUMNS:}
5329 property.  If no such property is found, the format is taken from the
5330 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
5331 and column view is established for the current entry and its subtree.
5332 @orgcmd{r,org-columns-redo}
5333 Recreate the column view, to include recent changes made in the buffer.
5334 @orgcmd{g,org-columns-redo}
5335 Same as @kbd{r}.
5336 @orgcmd{q,org-columns-quit}
5337 Exit column view.
5338 @tsubheading{Editing values}
5339 @item @key{left} @key{right} @key{up} @key{down}
5340 Move through the column view from field to field.
5341 @kindex S-@key{left}
5342 @kindex S-@key{right}
5343 @item  S-@key{left}/@key{right}
5344 Switch to the next/previous allowed value of the field.  For this, you
5345 have to have specified allowed values for a property.
5346 @item 1..9,0
5347 Directly select the Nth allowed value, @kbd{0} selects the 10th value.
5348 @orgcmdkkcc{n,p,org-columns-next-allowed-value,org-columns-previous-allowed-value}
5349 Same as @kbd{S-@key{left}/@key{right}}
5350 @orgcmd{e,org-columns-edit-value}
5351 Edit the property at point.  For the special properties, this will
5352 invoke the same interface that you normally use to change that
5353 property.  For example, when editing a TAGS property, the tag completion
5354 or fast selection interface will pop up.
5355 @orgcmd{C-c C-c,org-columns-set-tags-or-toggle}
5356 When there is a checkbox at point, toggle it.
5357 @orgcmd{v,org-columns-show-value}
5358 View the full value of this property.  This is useful if the width of
5359 the column is smaller than that of the value.
5360 @orgcmd{a,org-columns-edit-allowed}
5361 Edit the list of allowed values for this property.  If the list is found
5362 in the hierarchy, the modified values is stored there.  If no list is
5363 found, the new value is stored in the first entry that is part of the
5364 current column view.
5365 @tsubheading{Modifying the table structure}
5366 @orgcmdkkcc{<,>,org-columns-narrow,org-columns-widen}
5367 Make the column narrower/wider by one character.
5368 @orgcmd{S-M-@key{right},org-columns-new}
5369 Insert a new column, to the left of the current column.
5370 @orgcmd{S-M-@key{left},org-columns-delete}
5371 Delete the current column.
5372 @end table
5374 @node Capturing column view,  , Using column view, Column view
5375 @subsection Capturing column view
5377 Since column view is just an overlay over a buffer, it cannot be
5378 exported or printed directly.  If you want to capture a column view, use
5379 a @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
5380 of this block looks like this:
5382 @cindex #+BEGIN, columnview
5383 @example
5384 * The column view
5385 #+BEGIN: columnview :hlines 1 :id "label"
5387 #+END:
5388 @end example
5390 @noindent This dynamic block has the following parameters:
5392 @table @code
5393 @item :id
5394 This is the most important parameter.  Column view is a feature that is
5395 often localized to a certain (sub)tree, and the capture block might be
5396 at a different location in the file.  To identify the tree whose view to
5397 capture, you can use 4 values:
5398 @cindex property, ID
5399 @example
5400 local     @r{use the tree in which the capture block is located}
5401 global    @r{make a global view, including all headings in the file}
5402 "file:@var{path-to-file}"
5403           @r{run column view at the top of this file}
5404 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
5405           @r{property with the value @i{label}.  You can use}
5406           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
5407           @r{the current entry and copy it to the kill-ring.}
5408 @end example
5409 @item :hlines
5410 When @code{t}, insert an hline after every line.  When a number @var{N}, insert
5411 an hline before each headline with level @code{<= @var{N}}.
5412 @item :vlines
5413 When set to @code{t}, force column groups to get vertical lines.
5414 @item :maxlevel
5415 When set to a number, don't capture entries below this level.
5416 @item :skip-empty-rows
5417 When set to @code{t}, skip rows where the only non-empty specifier of the
5418 column view is @code{ITEM}.
5420 @end table
5422 @noindent
5423 The following commands insert or update the dynamic block:
5425 @table @kbd
5426 @orgcmd{C-c C-x i,org-insert-columns-dblock}
5427 Insert a dynamic block capturing a column view.  You will be prompted
5428 for the scope or ID of the view.
5429 @orgcmdkkc{C-c C-c,C-c C-x C-u,org-dblock-update}
5430 Update dynamic block at point.  The cursor needs to be in the
5431 @code{#+BEGIN} line of the dynamic block.
5432 @orgcmd{C-u C-c C-x C-u,org-update-all-dblocks}
5433 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5434 you have several clock table blocks, column-capturing blocks or other dynamic
5435 blocks in a buffer.
5436 @end table
5438 You can add formulas to the column view table and you may add plotting
5439 instructions in front of the table---these will survive an update of the
5440 block.  If there is a @code{#+TBLFM:} after the table, the table will
5441 actually be recalculated automatically after an update.
5443 An alternative way to capture and process property values into a table is
5444 provided by Eric Schulte's @file{org-collector.el} which is a contributed
5445 package@footnote{Contributed packages are not part of Emacs, but are
5446 distributed with the main distribution of Org (visit
5447 @uref{http://orgmode.org}).}.  It provides a general API to collect
5448 properties from entries in a certain scope, and arbitrary Lisp expressions to
5449 process these values before inserting them into a table or a dynamic block.
5451 @node Property API,  , Column view, Properties and Columns
5452 @section The Property API
5453 @cindex properties, API
5454 @cindex API, for properties
5456 There is a full API for accessing and changing properties.  This API can
5457 be used by Emacs Lisp programs to work with properties and to implement
5458 features based on them.  For more information see @ref{Using the
5459 property API}.
5461 @node Dates and Times, Capture - Refile - Archive, Properties and Columns, Top
5462 @chapter Dates and times
5463 @cindex dates
5464 @cindex times
5465 @cindex timestamp
5466 @cindex date stamp
5468 To assist project planning, TODO items can be labeled with a date and/or
5469 a time.  The specially formatted string carrying the date and time
5470 information is called a @emph{timestamp} in Org mode.  This may be a
5471 little confusing because timestamp is often used as indicating when
5472 something was created or last changed.  However, in Org mode this term
5473 is used in a much wider sense.
5475 @menu
5476 * Timestamps::                  Assigning a time to a tree entry
5477 * Creating timestamps::         Commands which insert timestamps
5478 * Deadlines and scheduling::    Planning your work
5479 * Clocking work time::          Tracking how long you spend on a task
5480 * Effort estimates::            Planning work effort in advance
5481 * Relative timer::              Notes with a running timer
5482 * Countdown timer::             Starting a countdown timer for a task
5483 @end menu
5486 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
5487 @section Timestamps, deadlines, and scheduling
5488 @cindex timestamps
5489 @cindex ranges, time
5490 @cindex date stamps
5491 @cindex deadlines
5492 @cindex scheduling
5494 A timestamp is a specification of a date (possibly with a time or a range of
5495 times) in a special format, either @samp{<2003-09-16 Tue>}@footnote{In this
5496 simplest form, the day name is optional when you type the date yourself.
5497 However, any dates inserted or modified by Org will add that day name, for
5498 reading convenience.} or @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16
5499 Tue 12:00-12:30>}@footnote{This is inspired by the standard ISO 8601
5500 date/time format.  To use an alternative format, see @ref{Custom time
5501 format}.}.  A timestamp can appear anywhere in the headline or body of an Org
5502 tree entry.  Its presence causes entries to be shown on specific dates in the
5503 agenda (@pxref{Weekly/daily agenda}).  We distinguish:
5505 @table @var
5506 @item Plain timestamp; Event; Appointment
5507 @cindex timestamp
5508 @cindex appointment
5509 A simple timestamp just assigns a date/time to an item.  This is just
5510 like writing down an appointment or event in a paper agenda.  In the
5511 timeline and agenda displays, the headline of an entry associated with a
5512 plain timestamp will be shown exactly on that date.
5514 @example
5515 * Meet Peter at the movies
5516   <2006-11-01 Wed 19:15>
5517 * Discussion on climate change
5518   <2006-11-02 Thu 20:00-22:00>
5519 @end example
5521 @item Timestamp with repeater interval
5522 @cindex timestamp, with repeater interval
5523 A timestamp may contain a @emph{repeater interval}, indicating that it
5524 applies not only on the given date, but again and again after a certain
5525 interval of N days (d), weeks (w), months (m), or years (y).  The
5526 following will show up in the agenda every Wednesday:
5528 @example
5529 * Pick up Sam at school
5530   <2007-05-16 Wed 12:30 +1w>
5531 @end example
5533 @item Diary-style sexp entries
5534 For more complex date specifications, Org mode supports using the special
5535 sexp diary entries implemented in the Emacs calendar/diary
5536 package@footnote{When working with the standard diary sexp functions, you
5537 need to be very careful with the order of the arguments.  That order depend
5538 evilly on the variable @code{calendar-date-style} (or, for older Emacs
5539 versions, @code{european-calendar-style}).  For example, to specify a date
5540 December 12, 2005, the call might look like @code{(diary-date 12 1 2005)} or
5541 @code{(diary-date 1 12 2005)} or @code{(diary-date 2005 12 1)}, depending on
5542 the settings.  This has been the source of much confusion.  Org mode users
5543 can resort to special versions of these functions like @code{org-date} or
5544 @code{org-anniversary}.  These work just like the corresponding @code{diary-}
5545 functions, but with stable ISO order of arguments (year, month, day) wherever
5546 applicable, independent of the value of @code{calendar-date-style}.}.  For
5547 example with optional time
5549 @example
5550 * 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
5551   <%%(diary-float t 4 2)>
5552 @end example
5554 @item Time/Date range
5555 @cindex timerange
5556 @cindex date range
5557 Two timestamps connected by @samp{--} denote a range.  The headline
5558 will be shown on the first and last day of the range, and on any dates
5559 that are displayed and fall in the range.  Here is an example:
5561 @example
5562 ** Meeting in Amsterdam
5563    <2004-08-23 Mon>--<2004-08-26 Thu>
5564 @end example
5566 @item Inactive timestamp
5567 @cindex timestamp, inactive
5568 @cindex inactive timestamp
5569 Just like a plain timestamp, but with square brackets instead of
5570 angular ones.  These timestamps are inactive in the sense that they do
5571 @emph{not} trigger an entry to show up in the agenda.
5573 @example
5574 * Gillian comes late for the fifth time
5575   [2006-11-01 Wed]
5576 @end example
5578 @end table
5580 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
5581 @section Creating timestamps
5582 @cindex creating timestamps
5583 @cindex timestamps, creating
5585 For Org mode to recognize timestamps, they need to be in the specific
5586 format.  All commands listed below produce timestamps in the correct
5587 format.
5589 @table @kbd
5590 @orgcmd{C-c .,org-time-stamp}
5591 Prompt for a date and insert a corresponding timestamp.  When the cursor is
5592 at an existing timestamp in the buffer, the command is used to modify this
5593 timestamp instead of inserting a new one.  When this command is used twice in
5594 succession, a time range is inserted.
5596 @orgcmd{C-c !,org-time-stamp-inactive}
5597 Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
5598 an agenda entry.
5600 @kindex C-u C-c .
5601 @kindex C-u C-c !
5602 @item C-u C-c .
5603 @itemx C-u C-c !
5604 @vindex org-time-stamp-rounding-minutes
5605 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
5606 contains date and time.  The default time can be rounded to multiples of 5
5607 minutes, see the option @code{org-time-stamp-rounding-minutes}.
5609 @orgkey{C-c C-c}
5610 Normalize timestamp, insert/fix day name if missing or wrong.
5612 @orgcmd{C-c <,org-date-from-calendar}
5613 Insert a timestamp corresponding to the cursor date in the Calendar.
5615 @orgcmd{C-c >,org-goto-calendar}
5616 Access the Emacs calendar for the current date.  If there is a
5617 timestamp in the current line, go to the corresponding date
5618 instead.
5620 @orgcmd{C-c C-o,org-open-at-point}
5621 Access the agenda for the date given by the timestamp or -range at
5622 point (@pxref{Weekly/daily agenda}).
5624 @orgcmdkkcc{S-@key{left},S-@key{right},org-timestamp-down-day,org-timestamp-up-day}
5625 Change date at cursor by one day.  These key bindings conflict with
5626 shift-selection and related modes (@pxref{Conflicts}).
5628 @orgcmdkkcc{S-@key{up},S-@key{down},org-timestamp-up,org-timestamp-down-down}
5629 Change the item under the cursor in a timestamp.  The cursor can be on a
5630 year, month, day, hour or minute.  When the timestamp contains a time range
5631 like @samp{15:30-16:30}, modifying the first time will also shift the second,
5632 shifting the time block with constant length.  To change the length, modify
5633 the second time.  Note that if the cursor is in a headline and not at a
5634 timestamp, these same keys modify the priority of an item.
5635 (@pxref{Priorities}).  The key bindings also conflict with shift-selection and
5636 related modes (@pxref{Conflicts}).
5638 @orgcmd{C-c C-y,org-evaluate-time-range}
5639 @cindex evaluate time range
5640 Evaluate a time range by computing the difference between start and end.
5641 With a prefix argument, insert result after the time range (in a table: into
5642 the following column).
5643 @end table
5646 @menu
5647 * The date/time prompt::        How Org mode helps you entering date and time
5648 * Custom time format::          Making dates look different
5649 @end menu
5651 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
5652 @subsection The date/time prompt
5653 @cindex date, reading in minibuffer
5654 @cindex time, reading in minibuffer
5656 @vindex org-read-date-prefer-future
5657 When Org mode prompts for a date/time, the default is shown in default
5658 date/time format, and the prompt therefore seems to ask for a specific
5659 format.  But it will in fact accept date/time information in a variety of
5660 formats.  Generally, the information should start at the beginning of the
5661 string.  Org mode will find whatever information is in
5662 there and derive anything you have not specified from the @emph{default date
5663 and time}.  The default is usually the current date and time, but when
5664 modifying an existing timestamp, or when entering the second stamp of a
5665 range, it is taken from the stamp in the buffer.  When filling in
5666 information, Org mode assumes that most of the time you will want to enter a
5667 date in the future: if you omit the month/year and the given day/month is
5668 @i{before} today, it will assume that you mean a future date@footnote{See the
5669 variable @code{org-read-date-prefer-future}.  You may set that variable to
5670 the symbol @code{time} to even make a time before now shift the date to
5671 tomorrow.}.  If the date has been automatically shifted into the future, the
5672 time prompt will show this with @samp{(=>F).}
5674 For example, let's assume that today is @b{June 13, 2006}.  Here is how
5675 various inputs will be interpreted, the items filled in by Org mode are
5676 in @b{bold}.
5678 @example
5679 3-2-5         @result{} 2003-02-05
5680 2/5/3         @result{} 2003-02-05
5681 14            @result{} @b{2006}-@b{06}-14
5682 12            @result{} @b{2006}-@b{07}-12
5683 2/5           @result{} @b{2007}-02-05
5684 Fri           @result{} nearest Friday (default date or later)
5685 sep 15        @result{} @b{2006}-09-15
5686 feb 15        @result{} @b{2007}-02-15
5687 sep 12 9      @result{} 2009-09-12
5688 12:45         @result{} @b{2006}-@b{06}-@b{13} 12:45
5689 22 sept 0:34  @result{} @b{2006}-09-22 0:34
5690 w4            @result{} ISO week for of the current year @b{2006}
5691 2012 w4 fri   @result{} Friday of ISO week 4 in 2012
5692 2012-w04-5    @result{} Same as above
5693 @end example
5695 Furthermore you can specify a relative date by giving, as the
5696 @emph{first} thing in the input: a plus/minus sign, a number and a
5697 letter ([dwmy]) to indicate change in days, weeks, months, or years.  With a
5698 single plus or minus, the date is always relative to today.  With a
5699 double plus or minus, it is relative to the default date.  If instead of
5700 a single letter, you use the abbreviation of day name, the date will be
5701 the Nth such day, e.g.:
5703 @example
5704 +0            @result{} today
5705 .             @result{} today
5706 +4d           @result{} four days from today
5707 +4            @result{} same as above
5708 +2w           @result{} two weeks from today
5709 ++5           @result{} five days from default date
5710 +2tue         @result{} second Tuesday from now.
5711 @end example
5713 @vindex parse-time-months
5714 @vindex parse-time-weekdays
5715 The function understands English month and weekday abbreviations.  If
5716 you want to use unabbreviated names and/or other languages, configure
5717 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
5719 @vindex org-read-date-force-compatible-dates
5720 Not all dates can be represented in a given Emacs implementation.  By default
5721 Org mode forces dates into the compatibility range 1970--2037 which works on
5722 all Emacs implementations.  If you want to use dates outside of this range,
5723 read the docstring of the variable
5724 @code{org-read-date-force-compatible-dates}.
5726 You can specify a time range by giving start and end times or by giving a
5727 start time and a duration (in HH:MM format).  Use one or two dash(es) as the
5728 separator in the former case and use '+' as the separator in the latter
5729 case, e.g.:
5731 @example
5732 11am-1:15pm    @result{} 11:00-13:15
5733 11am--1:15pm   @result{} same as above
5734 11am+2:15      @result{} same as above
5735 @end example
5737 @cindex calendar, for selecting date
5738 @vindex org-popup-calendar-for-date-prompt
5739 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
5740 you don't need/want the calendar, configure the variable
5741 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
5742 prompt, either by clicking on a date in the calendar, or by pressing
5743 @key{RET}, the date selected in the calendar will be combined with the
5744 information entered at the prompt.  You can control the calendar fully
5745 from the minibuffer:
5747 @kindex <
5748 @kindex >
5749 @kindex M-v
5750 @kindex C-v
5751 @kindex mouse-1
5752 @kindex S-@key{right}
5753 @kindex S-@key{left}
5754 @kindex S-@key{down}
5755 @kindex S-@key{up}
5756 @kindex M-S-@key{right}
5757 @kindex M-S-@key{left}
5758 @kindex @key{RET}
5759 @example
5760 @key{RET}           @r{Choose date at cursor in calendar.}
5761 mouse-1        @r{Select date by clicking on it.}
5762 S-@key{right}/@key{left}     @r{One day forward/backward.}
5763 S-@key{down}/@key{up}     @r{One week forward/backward.}
5764 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
5765 > / <          @r{Scroll calendar forward/backward by one month.}
5766 M-v / C-v      @r{Scroll calendar forward/backward by 3 months.}
5767 @end example
5769 @vindex org-read-date-display-live
5770 The actions of the date/time prompt may seem complex, but I assure you they
5771 will grow on you, and you will start getting annoyed by pretty much any other
5772 way of entering a date/time out there.  To help you understand what is going
5773 on, the current interpretation of your input will be displayed live in the
5774 minibuffer@footnote{If you find this distracting, turn the display of with
5775 @code{org-read-date-display-live}.}.
5777 @node Custom time format,  , The date/time prompt, Creating timestamps
5778 @subsection Custom time format
5779 @cindex custom date/time format
5780 @cindex time format, custom
5781 @cindex date format, custom
5783 @vindex org-display-custom-times
5784 @vindex org-time-stamp-custom-formats
5785 Org mode uses the standard ISO notation for dates and times as it is
5786 defined in ISO 8601.  If you cannot get used to this and require another
5787 representation of date and time to keep you happy, you can get it by
5788 customizing the variables @code{org-display-custom-times} and
5789 @code{org-time-stamp-custom-formats}.
5791 @table @kbd
5792 @orgcmd{C-c C-x C-t,org-toggle-time-stamp-overlays}
5793 Toggle the display of custom formats for dates and times.
5794 @end table
5796 @noindent
5797 Org mode needs the default format for scanning, so the custom date/time
5798 format does not @emph{replace} the default format---instead it is put
5799 @emph{over} the default format using text properties.  This has the
5800 following consequences:
5801 @itemize @bullet
5802 @item
5803 You cannot place the cursor onto a timestamp anymore, only before or
5804 after.
5805 @item
5806 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
5807 each component of a timestamp.  If the cursor is at the beginning of
5808 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
5809 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
5810 time will be changed by one minute.
5811 @item
5812 If the timestamp contains a range of clock times or a repeater, these
5813 will not be overlaid, but remain in the buffer as they were.
5814 @item
5815 When you delete a timestamp character-by-character, it will only
5816 disappear from the buffer after @emph{all} (invisible) characters
5817 belonging to the ISO timestamp have been removed.
5818 @item
5819 If the custom timestamp format is longer than the default and you are
5820 using dates in tables, table alignment will be messed up.  If the custom
5821 format is shorter, things do work as expected.
5822 @end itemize
5825 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
5826 @section Deadlines and scheduling
5828 A timestamp may be preceded by special keywords to facilitate planning:
5830 @table @var
5831 @item DEADLINE
5832 @cindex DEADLINE keyword
5834 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
5835 to be finished on that date.
5837 @vindex org-deadline-warning-days
5838 @vindex org-agenda-skip-deadline-prewarning-if-scheduled
5839 On the deadline date, the task will be listed in the agenda.  In
5840 addition, the agenda for @emph{today} will carry a warning about the
5841 approaching or missed deadline, starting
5842 @code{org-deadline-warning-days} before the due date, and continuing
5843 until the entry is marked DONE@.  An example:
5845 @example
5846 *** TODO write article about the Earth for the Guide
5847     DEADLINE: <2004-02-29 Sun>
5848     The editor in charge is [[bbdb:Ford Prefect]]
5849 @end example
5851 You can specify a different lead time for warnings for a specific
5852 deadlines using the following syntax.  Here is an example with a warning
5853 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.  This warning is
5854 deactivated if the task get scheduled and you set
5855 @code{org-agenda-skip-deadline-prewarning-if-scheduled} to @code{t}.
5857 @item SCHEDULED
5858 @cindex SCHEDULED keyword
5860 Meaning: you are planning to start working on that task on the given
5861 date.
5863 @vindex org-agenda-skip-scheduled-if-done
5864 The headline will be listed under the given date@footnote{It will still
5865 be listed on that date after it has been marked DONE@.  If you don't like
5866 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
5867 addition, a reminder that the scheduled date has passed will be present
5868 in the compilation for @emph{today}, until the entry is marked DONE, i.e.,
5869 the task will automatically be forwarded until completed.
5871 @example
5872 *** TODO Call Trillian for a date on New Years Eve.
5873     SCHEDULED: <2004-12-25 Sat>
5874 @end example
5876 @vindex org-scheduled-delay-days
5877 @vindex org-agenda-skip-scheduled-delay-if-deadline
5878 If you want to @emph{delay} the display of this task in the agenda, use
5879 @code{SCHEDULED: <2004-12-25 Sat -2d>}: the task is still scheduled on the
5880 25th but will appear two days later.  In case the task contains a repeater,
5881 the delay is considered to affect all occurrences; if you want it to affect
5882 only the first scheduled occurrence of the task, use @code{--2d} instead.
5883 See @code{org-scheduled-delay-days} and
5884 @code{org-agenda-skip-scheduled-delay-if-deadline} for details on how to
5885 control this globally or per agenda.
5887 @noindent
5888 @b{Important:} Scheduling an item in Org mode should @i{not} be
5889 understood in the same way that we understand @i{scheduling a meeting}.
5890 Setting a date for a meeting is just a simple appointment, you should
5891 mark this entry with a simple plain timestamp, to get this item shown
5892 on the date where it applies.  This is a frequent misunderstanding by
5893 Org users.  In Org mode, @i{scheduling} means setting a date when you
5894 want to start working on an action item.
5895 @end table
5897 You may use timestamps with repeaters in scheduling and deadline
5898 entries.  Org mode will issue early and late warnings based on the
5899 assumption that the timestamp represents the @i{nearest instance} of
5900 the repeater.  However, the use of diary sexp entries like
5902 @code{<%%(diary-float t 42)>}
5904 in scheduling and deadline timestamps is limited.  Org mode does not
5905 know enough about the internals of each sexp function to issue early and
5906 late warnings.  However, it will show the item on each day where the
5907 sexp entry matches.
5909 @menu
5910 * Inserting deadline/schedule::  Planning items
5911 * Repeated tasks::              Items that show up again and again
5912 @end menu
5914 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
5915 @subsection Inserting deadlines or schedules
5917 The following commands allow you to quickly insert@footnote{The @samp{SCHEDULED} and
5918 @samp{DEADLINE} dates are inserted on the line right below the headline.  Don't put
5919 any text between this line and the headline.} a deadline or to schedule
5920 an item:
5922 @table @kbd
5924 @orgcmd{C-c C-d,org-deadline}
5925 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will happen
5926 in the line directly following the headline.  Any CLOSED timestamp will be
5927 removed.  When called with a prefix arg, an existing deadline will be removed
5928 from the entry.  Depending on the variable @code{org-log-redeadline}@footnote{with corresponding
5929 @code{#+STARTUP} keywords @code{logredeadline}, @code{lognoteredeadline},
5930 and @code{nologredeadline}}, a note will be taken when changing an existing
5931 deadline.
5933 @orgcmd{C-c C-s,org-schedule}
5934 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
5935 happen in the line directly following the headline.  Any CLOSED timestamp
5936 will be removed.  When called with a prefix argument, remove the scheduling
5937 date from the entry.  Depending on the variable
5938 @code{org-log-reschedule}@footnote{with corresponding @code{#+STARTUP}
5939 keywords @code{logreschedule}, @code{lognotereschedule}, and
5940 @code{nologreschedule}}, a note will be taken when changing an existing
5941 scheduling time.
5943 @orgcmd{C-c C-x C-k,org-mark-entry-for-agenda-action}
5944 @kindex k a
5945 @kindex k s
5946 Mark the current entry for agenda action.  After you have marked the entry
5947 like this, you can open the agenda or the calendar to find an appropriate
5948 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
5949 schedule the marked item.
5951 @orgcmd{C-c / d,org-check-deadlines}
5952 @cindex sparse tree, for deadlines
5953 @vindex org-deadline-warning-days
5954 Create a sparse tree with all deadlines that are either past-due, or
5955 which will become due within @code{org-deadline-warning-days}.
5956 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
5957 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
5958 all deadlines due tomorrow.
5960 @orgcmd{C-c / b,org-check-before-date}
5961 Sparse tree for deadlines and scheduled items before a given date.
5963 @orgcmd{C-c / a,org-check-after-date}
5964 Sparse tree for deadlines and scheduled items after a given date.
5965 @end table
5967 Note that @code{org-schedule} and @code{org-deadline} supports
5968 setting the date by indicating a relative time: e.g., +1d will set
5969 the date to the next day after today, and --1w will set the date
5970 to the previous week before any current timestamp.
5972 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
5973 @subsection Repeated tasks
5974 @cindex tasks, repeated
5975 @cindex repeated tasks
5977 Some tasks need to be repeated again and again.  Org mode helps to
5978 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
5979 or plain timestamp.  In the following example
5980 @example
5981 ** TODO Pay the rent
5982    DEADLINE: <2005-10-01 Sat +1m>
5983 @end example
5984 @noindent
5985 the @code{+1m} is a repeater; the intended interpretation is that the task
5986 has a deadline on <2005-10-01> and repeats itself every (one) month starting
5987 from that time.  You can use yearly, monthly, weekly, daily and hourly repeat
5988 cookies by using the @code{y/w/m/d/h} letters.  If you need both a repeater
5989 and a special warning period in a deadline entry, the repeater should come
5990 first and the warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
5992 @vindex org-todo-repeat-to-state
5993 Deadlines and scheduled items produce entries in the agenda when they are
5994 over-due, so it is important to be able to mark such an entry as completed
5995 once you have done so.  When you mark a DEADLINE or a SCHEDULE with the TODO
5996 keyword DONE, it will no longer produce entries in the agenda.  The problem
5997 with this is, however, that then also the @emph{next} instance of the
5998 repeated entry will not be active.  Org mode deals with this in the following
5999 way: When you try to mark such an entry DONE (using @kbd{C-c C-t}), it will
6000 shift the base date of the repeating timestamp by the repeater interval, and
6001 immediately set the entry state back to TODO@footnote{In fact, the target
6002 state is taken from, in this sequence, the @code{REPEAT_TO_STATE} property or
6003 the variable @code{org-todo-repeat-to-state}.  If neither of these is
6004 specified, the target state defaults to the first state of the TODO state
6005 sequence.}.  In the example above, setting the state to DONE would actually
6006 switch the date like this:
6008 @example
6009 ** TODO Pay the rent
6010    DEADLINE: <2005-11-01 Tue +1m>
6011 @end example
6013 @vindex org-log-repeat
6014 A timestamp@footnote{You can change this using the option
6015 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
6016 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
6017 will also be prompted for a note.} will be added under the deadline, to keep
6018 a record that you actually acted on the previous instance of this deadline.
6020 As a consequence of shifting the base date, this entry will no longer be
6021 visible in the agenda when checking past dates, but all future instances
6022 will be visible.
6024 With the @samp{+1m} cookie, the date shift will always be exactly one
6025 month.  So if you have not paid the rent for three months, marking this
6026 entry DONE will still keep it as an overdue deadline.  Depending on the
6027 task, this may not be the best way to handle it.  For example, if you
6028 forgot to call your father for 3 weeks, it does not make sense to call
6029 him 3 times in a single day to make up for it.  Finally, there are tasks
6030 like changing batteries which should always repeat a certain time
6031 @i{after} the last time you did it.  For these tasks, Org mode has
6032 special repeaters  @samp{++} and @samp{.+}.  For example:
6034 @example
6035 ** TODO Call Father
6036    DEADLINE: <2008-02-10 Sun ++1w>
6037    Marking this DONE will shift the date by at least one week,
6038    but also by as many weeks as it takes to get this date into
6039    the future.  However, it stays on a Sunday, even if you called
6040    and marked it done on Saturday.
6041 ** TODO Check the batteries in the smoke detectors
6042    DEADLINE: <2005-11-01 Tue .+1m>
6043    Marking this DONE will shift the date to one month after
6044    today.
6045 @end example
6047 You may have both scheduling and deadline information for a specific
6048 task---just make sure that the repeater intervals on both are the same.
6050 An alternative to using a repeater is to create a number of copies of a task
6051 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
6052 created for this purpose, it is described in @ref{Structure editing}.
6055 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
6056 @section Clocking work time
6057 @cindex clocking time
6058 @cindex time clocking
6060 Org mode allows you to clock the time you spend on specific tasks in a
6061 project.  When you start working on an item, you can start the clock.  When
6062 you stop working on that task, or when you mark the task done, the clock is
6063 stopped and the corresponding time interval is recorded.  It also computes
6064 the total time spent on each subtree@footnote{Clocking only works if all
6065 headings are indented with less than 30 stars.  This is a hardcoded
6066 limitation of `lmax' in `org-clock-sum'.} of a project.  And it remembers a
6067 history or tasks recently clocked, to that you can jump quickly between a
6068 number of tasks absorbing your time.
6070 To save the clock history across Emacs sessions, use
6071 @lisp
6072 (setq org-clock-persist 'history)
6073 (org-clock-persistence-insinuate)
6074 @end lisp
6075 When you clock into a new task after resuming Emacs, the incomplete
6076 clock@footnote{To resume the clock under the assumption that you have worked
6077 on this task while outside Emacs, use @code{(setq org-clock-persist t)}.}
6078 will be found (@pxref{Resolving idle time}) and you will be prompted about
6079 what to do with it.
6081 @menu
6082 * Clocking commands::           Starting and stopping a clock
6083 * The clock table::             Detailed reports
6084 * Resolving idle time::         Resolving time when you've been idle
6085 @end menu
6087 @node Clocking commands, The clock table, Clocking work time, Clocking work time
6088 @subsection Clocking commands
6090 @table @kbd
6091 @orgcmd{C-c C-x C-i,org-clock-in}
6092 @vindex org-clock-into-drawer
6093 @vindex org-clock-continuously
6094 @cindex property, LOG_INTO_DRAWER
6095 Start the clock on the current item (clock-in).  This inserts the CLOCK
6096 keyword together with a timestamp.  If this is not the first clocking of
6097 this item, the multiple CLOCK lines will be wrapped into a
6098 @code{:LOGBOOK:} drawer (see also the variable
6099 @code{org-clock-into-drawer}).  You can also overrule
6100 the setting of this variable for a subtree by setting a
6101 @code{CLOCK_INTO_DRAWER} or @code{LOG_INTO_DRAWER} property.
6102 When called with a @kbd{C-u} prefix argument,
6103 select the task from a list of recently clocked tasks.  With two @kbd{C-u
6104 C-u} prefixes, clock into the task at point and mark it as the default task;
6105 the default task will then always be available with letter @kbd{d} when
6106 selecting a clocking task.  With three @kbd{C-u C-u C-u} prefixes, force
6107 continuous clocking by starting the clock when the last clock stopped.@*
6108 @cindex property: CLOCK_MODELINE_TOTAL
6109 @cindex property: LAST_REPEAT
6110 @vindex org-clock-modeline-total
6111 While the clock is running, the current clocking time is shown in the mode
6112 line, along with the title of the task.  The clock time shown will be all
6113 time ever clocked for this task and its children.  If the task has an effort
6114 estimate (@pxref{Effort estimates}), the mode line displays the current
6115 clocking time against it@footnote{To add an effort estimate ``on the fly'',
6116 hook a function doing this to @code{org-clock-in-prepare-hook}.}  If the task
6117 is a repeating one (@pxref{Repeated tasks}), only the time since the last
6118 reset of the task @footnote{as recorded by the @code{LAST_REPEAT} property}
6119 will be shown.  More control over what time is shown can be exercised with
6120 the @code{CLOCK_MODELINE_TOTAL} property.  It may have the values
6121 @code{current} to show only the current clocking instance, @code{today} to
6122 show all time clocked on this tasks today (see also the variable
6123 @code{org-extend-today-until}), @code{all} to include all time, or
6124 @code{auto} which is the default@footnote{See also the variable
6125 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
6126 mode line entry will pop up a menu with clocking options.
6128 @orgcmd{C-c C-x C-o,org-clock-out}
6129 @vindex org-log-note-clock-out
6130 Stop the clock (clock-out).  This inserts another timestamp at the same
6131 location where the clock was last started.  It also directly computes
6132 the resulting time in inserts it after the time range as @samp{=>
6133 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
6134 possibility to record an additional note together with the clock-out
6135 timestamp@footnote{The corresponding in-buffer setting is:
6136 @code{#+STARTUP: lognoteclock-out}}.
6137 @orgcmd{C-c C-x C-x,org-clock-in-last}
6138 @vindex org-clock-continuously
6139 Reclock the last clocked task.  With one @kbd{C-u} prefix argument,
6140 select the task from the clock history.  With two @kbd{C-u} prefixes,
6141 force continuous clocking by starting the clock when the last clock
6142 stopped.
6143 @orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
6144 Update the effort estimate for the current clock task.
6145 @kindex C-c C-y
6146 @kindex C-c C-c
6147 @orgcmdkkc{C-c C-c,C-c C-y,org-evaluate-time-range}
6148 Recompute the time interval after changing one of the timestamps.  This
6149 is only necessary if you edit the timestamps directly.  If you change
6150 them with @kbd{S-@key{cursor}} keys, the update is automatic.
6151 @orgcmd{C-S-@key{up/down},org-clock-timestamps-up/down}
6152 On @code{CLOCK} log lines, increase/decrease both timestamps so that the
6153 clock duration keeps the same.
6154 @orgcmd{S-M-@key{up/down},org-timestamp-up/down}
6155 On @code{CLOCK} log lines, increase/decrease the timestamp at point and
6156 the one of the previous (or the next clock) timestamp by the same duration.
6157 For example, if you hit @kbd{S-M-@key{up}} to increase a clocked-out timestamp
6158 by five minutes, then the clocked-in timestamp of the next clock will be
6159 increased by five minutes.
6160 @orgcmd{C-c C-t,org-todo}
6161 Changing the TODO state of an item to DONE automatically stops the clock
6162 if it is running in this same item.
6163 @orgcmd{C-c C-x C-q,org-clock-cancel}
6164 Cancel the current clock.  This is useful if a clock was started by
6165 mistake, or if you ended up working on something else.
6166 @orgcmd{C-c C-x C-j,org-clock-goto}
6167 Jump to the headline of the currently clocked in task.  With a @kbd{C-u}
6168 prefix arg, select the target task from a list of recently clocked tasks.
6169 @orgcmd{C-c C-x C-d,org-clock-display}
6170 @vindex org-remove-highlights-with-change
6171 Display time summaries for each subtree in the current buffer.  This puts
6172 overlays at the end of each headline, showing the total time recorded under
6173 that heading, including the time of any subheadings.  You can use visibility
6174 cycling to study the tree, but the overlays disappear when you change the
6175 buffer (see variable @code{org-remove-highlights-with-change}) or press
6176 @kbd{C-c C-c}.
6177 @end table
6179 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
6180 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
6181 worked on or closed during a day.
6183 @strong{Important:} note that both @code{org-clock-out} and
6184 @code{org-clock-in-last} can have a global keybinding and will not
6185 modify the window disposition.
6187 @node The clock table, Resolving idle time, Clocking commands, Clocking work time
6188 @subsection The clock table
6189 @cindex clocktable, dynamic block
6190 @cindex report, of clocked time
6192 Org mode can produce quite complex reports based on the time clocking
6193 information.  Such a report is called a @emph{clock table}, because it is
6194 formatted as one or several Org tables.
6196 @table @kbd
6197 @orgcmd{C-c C-x C-r,org-clock-report}
6198 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
6199 report as an Org mode table into the current file.  When the cursor is
6200 at an existing clock table, just update it.  When called with a prefix
6201 argument, jump to the first clock report in the current document and
6202 update it.  The clock table always includes also trees with
6203 @code{:ARCHIVE:} tag.
6204 @orgcmdkkc{C-c C-c,C-c C-x C-u,org-dblock-update}
6205 Update dynamic block at point.  The cursor needs to be in the
6206 @code{#+BEGIN} line of the dynamic block.
6207 @orgkey{C-u C-c C-x C-u}
6208 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
6209 you have several clock table blocks in a buffer.
6210 @orgcmdkxkc{S-@key{left},S-@key{right},org-clocktable-try-shift}
6211 Shift the current @code{:block} interval and update the table.  The cursor
6212 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
6213 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
6214 @end table
6217 Here is an example of the frame for a clock table as it is inserted into the
6218 buffer with the @kbd{C-c C-x C-r} command:
6220 @cindex #+BEGIN, clocktable
6221 @example
6222 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
6223 #+END: clocktable
6224 @end example
6225 @noindent
6226 @vindex org-clocktable-defaults
6227 The @samp{BEGIN} line and specify a number of options to define the scope,
6228 structure, and formatting of the report.  Defaults for all these options can
6229 be configured in the variable @code{org-clocktable-defaults}.
6231 @noindent First there are options that determine which clock entries are to
6232 be selected:
6233 @example
6234 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
6235              @r{Clocks at deeper levels will be summed into the upper level.}
6236 :scope       @r{The scope to consider.  This can be any of the following:}
6237              nil        @r{the current buffer or narrowed region}
6238              file       @r{the full current buffer}
6239              subtree    @r{the subtree where the clocktable is located}
6240              tree@var{N}      @r{the surrounding level @var{N} tree, for example @code{tree3}}
6241              tree       @r{the surrounding level 1 tree}
6242              agenda     @r{all agenda files}
6243              ("file"..) @r{scan these files}
6244              file-with-archives    @r{current file and its archives}
6245              agenda-with-archives  @r{all agenda files, including archives}
6246 :block       @r{The time block to consider.  This block is specified either}
6247              @r{absolute, or relative to the current time and may be any of}
6248              @r{these formats:}
6249              2007-12-31    @r{New year eve 2007}
6250              2007-12       @r{December 2007}
6251              2007-W50      @r{ISO-week 50 in 2007}
6252              2007-Q2       @r{2nd quarter in 2007}
6253              2007          @r{the year 2007}
6254              today, yesterday, today-@var{N}          @r{a relative day}
6255              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
6256              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
6257              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
6258              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
6259 :tstart      @r{A time string specifying when to start considering times.}
6260              @r{Relative times like @code{"<-2w>"} can also be used.  See}
6261              @r{@ref{Matching tags and properties} for relative time syntax.}
6262 :tend        @r{A time string specifying when to stop considering times.}
6263              @r{Relative times like @code{"<now>"} can also be used.  See}
6264              @r{@ref{Matching tags and properties} for relative time syntax.}
6265 :wstart      @r{The starting day of the week.  The default is 1 for monday.}
6266 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
6267              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
6268 :stepskip0   @r{Do not show steps that have zero time.}
6269 :fileskip0   @r{Do not show table sections from files which did not contribute.}
6270 :tags        @r{A tags match to select entries that should contribute.  See}
6271              @r{@ref{Matching tags and properties} for the match syntax.}
6272 @end example
6274 Then there are options which determine the formatting of the table.  There
6275 options are interpreted by the function @code{org-clocktable-write-default},
6276 but you can specify your own function using the @code{:formatter} parameter.
6277 @example
6278 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
6279 :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".}
6280 :link        @r{Link the item headlines in the table to their origins.}
6281 :narrow      @r{An integer to limit the width of the headline column in}
6282              @r{the org table.  If you write it like @samp{50!}, then the}
6283              @r{headline will also be shortened in export.}
6284 :indent      @r{Indent each headline field according to its level.}
6285 :tcolumns    @r{Number of columns to be used for times.  If this is smaller}
6286              @r{than @code{:maxlevel}, lower levels will be lumped into one column.}
6287 :level       @r{Should a level number column be included?}
6288 :compact     @r{Abbreviation for @code{:level nil :indent t :narrow 40! :tcolumns 1}}
6289              @r{All are overwritten except if there is an explicit @code{:narrow}}
6290 :timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
6291              @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
6292 :properties  @r{List of properties that should be shown in the table.  Each}
6293              @r{property will get its own column.}
6294 :inherit-props @r{When this flag is @code{t}, the values for @code{:properties} will be inherited.}
6295 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
6296              @r{As a special case, @samp{:formula %} adds a column with % time.}
6297              @r{If you do not specify a formula here, any existing formula}
6298              @r{below the clock table will survive updates and be evaluated.}
6299 :formatter   @r{A function to format clock data and insert it into the buffer.}
6300 @end example
6301 To get a clock summary of the current level 1 tree, for the current
6302 day, you could write
6303 @example
6304 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
6305 #+END: clocktable
6306 @end example
6307 @noindent
6308 and to use a specific time range you could write@footnote{Note that all
6309 parameters must be specified in a single line---the line is broken here
6310 only to fit it into the manual.}
6311 @example
6312 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
6313                     :tend "<2006-08-10 Thu 12:00>"
6314 #+END: clocktable
6315 @end example
6316 A range starting a week ago and ending right now could be written as
6317 @example
6318 #+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
6319 #+END: clocktable
6320 @end example
6321 A summary of the current subtree with % times would be
6322 @example
6323 #+BEGIN: clocktable :scope subtree :link t :formula %
6324 #+END: clocktable
6325 @end example
6326 A horizontally compact representation of everything clocked during last week
6327 would be
6328 @example
6329 #+BEGIN: clocktable :scope agenda :block lastweek :compact t
6330 #+END: clocktable
6331 @end example
6333 @node Resolving idle time,  , The clock table, Clocking work time
6334 @subsection Resolving idle time and continuous clocking
6336 @subsubheading Resolving idle time
6337 @cindex resolve idle time
6338 @vindex org-clock-x11idle-program-name
6340 @cindex idle, resolve, dangling
6341 If you clock in on a work item, and then walk away from your
6342 computer---perhaps to take a phone call---you often need to ``resolve'' the
6343 time you were away by either subtracting it from the current clock, or
6344 applying it to another one.
6346 @vindex org-clock-idle-time
6347 By customizing the variable @code{org-clock-idle-time} to some integer, such
6348 as 10 or 15, Emacs can alert you when you get back to your computer after
6349 being idle for that many minutes@footnote{On computers using Mac OS X,
6350 idleness is based on actual user idleness, not just Emacs' idle time.  For
6351 X11, you can install a utility program @file{x11idle.c}, available in the
6352 @code{contrib/scripts} directory of the Org git distribution, or install the
6353 @file{xprintidle} package and set it to the variable
6354 @code{org-clock-x11idle-program-name} if you are running Debian, to get the
6355 same general treatment of idleness.  On other systems, idle time refers to
6356 Emacs idle time only.}, and ask what you want to do with the idle time.
6357 There will be a question waiting for you when you get back, indicating how
6358 much idle time has passed (constantly updated with the current amount), as
6359 well as a set of choices to correct the discrepancy:
6361 @table @kbd
6362 @item k
6363 To keep some or all of the minutes and stay clocked in, press @kbd{k}.  Org
6364 will ask how many of the minutes to keep.  Press @key{RET} to keep them all,
6365 effectively changing nothing, or enter a number to keep that many minutes.
6366 @item K
6367 If you use the shift key and press @kbd{K}, it will keep however many minutes
6368 you request and then immediately clock out of that task.  If you keep all of
6369 the minutes, this is the same as just clocking out of the current task.
6370 @item s
6371 To keep none of the minutes, use @kbd{s} to subtract all the away time from
6372 the clock, and then check back in from the moment you returned.
6373 @item S
6374 To keep none of the minutes and just clock out at the start of the away time,
6375 use the shift key and press @kbd{S}.  Remember that using shift will always
6376 leave you clocked out, no matter which option you choose.
6377 @item C
6378 To cancel the clock altogether, use @kbd{C}.  Note that if instead of
6379 canceling you subtract the away time, and the resulting clock amount is less
6380 than a minute, the clock will still be canceled rather than clutter up the
6381 log with an empty entry.
6382 @end table
6384 What if you subtracted those away minutes from the current clock, and now
6385 want to apply them to a new clock?  Simply clock in to any task immediately
6386 after the subtraction.  Org will notice that you have subtracted time ``on
6387 the books'', so to speak, and will ask if you want to apply those minutes to
6388 the next task you clock in on.
6390 There is one other instance when this clock resolution magic occurs.  Say you
6391 were clocked in and hacking away, and suddenly your cat chased a mouse who
6392 scared a hamster that crashed into your UPS's power button!  You suddenly
6393 lose all your buffers, but thanks to auto-save you still have your recent Org
6394 mode changes, including your last clock in.
6396 If you restart Emacs and clock into any task, Org will notice that you have a
6397 dangling clock which was never clocked out from your last session.  Using
6398 that clock's starting time as the beginning of the unaccounted-for period,
6399 Org will ask how you want to resolve that time.  The logic and behavior is
6400 identical to dealing with away time due to idleness; it is just happening due
6401 to a recovery event rather than a set amount of idle time.
6403 You can also check all the files visited by your Org agenda for dangling
6404 clocks at any time using @kbd{M-x org-resolve-clocks RET} (or @kbd{C-c C-x C-z}).
6406 @subsubheading Continuous clocking
6407 @cindex continuous clocking
6408 @vindex org-clock-continuously
6410 You may want to start clocking from the time when you clocked out the
6411 previous task.  To enable this systematically, set @code{org-clock-continuously}
6412 to @code{t}.  Each time you clock in, Org retrieves the clock-out time of the
6413 last clocked entry for this session, and start the new clock from there.
6415 If you only want this from time to time, use three universal prefix arguments
6416 with @code{org-clock-in} and two @kbd{C-u C-u} with @code{org-clock-in-last}.
6418 @node Effort estimates, Relative timer, Clocking work time, Dates and Times
6419 @section Effort estimates
6420 @cindex effort estimates
6422 @cindex property, Effort
6423 @vindex org-effort-property
6424 If you want to plan your work in a very detailed way, or if you need to
6425 produce offers with quotations of the estimated work effort, you may want to
6426 assign effort estimates to entries.  If you are also clocking your work, you
6427 may later want to compare the planned effort with the actual working time, a
6428 great way to improve planning estimates.  Effort estimates are stored in a
6429 special property @samp{Effort}@footnote{You may change the property being
6430 used with the variable @code{org-effort-property}.}.  You can set the effort
6431 for an entry with the following commands:
6433 @table @kbd
6434 @orgcmd{C-c C-x e,org-set-effort}
6435 Set the effort estimate for the current entry.  With a numeric prefix
6436 argument, set it to the Nth allowed value (see below).  This command is also
6437 accessible from the agenda with the @kbd{e} key.
6438 @orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
6439 Modify the effort estimate of the item currently being clocked.
6440 @end table
6442 Clearly the best way to work with effort estimates is through column view
6443 (@pxref{Column view}).  You should start by setting up discrete values for
6444 effort estimates, and a @code{COLUMNS} format that displays these values
6445 together with clock sums (if you want to clock your time).  For a specific
6446 buffer you can use
6448 @example
6449 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
6450 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
6451 @end example
6453 @noindent
6454 @vindex org-global-properties
6455 @vindex org-columns-default-format
6456 or, even better, you can set up these values globally by customizing the
6457 variables @code{org-global-properties} and @code{org-columns-default-format}.
6458 In particular if you want to use this setup also in the agenda, a global
6459 setup may be advised.
6461 The way to assign estimates to individual items is then to switch to column
6462 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
6463 value.  The values you enter will immediately be summed up in the hierarchy.
6464 In the column next to it, any clocked time will be displayed.
6466 @vindex org-agenda-columns-add-appointments-to-effort-sum
6467 If you switch to column view in the daily/weekly agenda, the effort column
6468 will summarize the estimated work effort for each day@footnote{Please note
6469 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
6470 column view}).}, and you can use this to find space in your schedule.  To get
6471 an overview of the entire part of the day that is committed, you can set the
6472 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
6473 appointments on a day that take place over a specified time interval will
6474 then also be added to the load estimate of the day.
6476 Effort estimates can be used in secondary agenda filtering that is triggered
6477 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
6478 these estimates defined consistently, two or three key presses will narrow
6479 down the list to stuff that fits into an available time slot.
6481 @node Relative timer, Countdown timer, Effort estimates, Dates and Times
6482 @section Taking notes with a relative timer
6483 @cindex relative timer
6485 When taking notes during, for example, a meeting or a video viewing, it can
6486 be useful to have access to times relative to a starting time.  Org provides
6487 such a relative timer and make it easy to create timed notes.
6489 @table @kbd
6490 @orgcmd{C-c C-x .,org-timer}
6491 Insert a relative time into the buffer.  The first time you use this, the
6492 timer will be started.  When called with a prefix argument, the timer is
6493 restarted.
6494 @orgcmd{C-c C-x -,org-timer-item}
6495 Insert a description list item with the current relative time.  With a prefix
6496 argument, first reset the timer to 0.
6497 @orgcmd{M-@key{RET},org-insert-heading}
6498 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
6499 new timer items.
6500 @c for key sequences with a comma, command name macros fail :(
6501 @kindex C-c C-x ,
6502 @item C-c C-x ,
6503 Pause the timer, or continue it if it is already paused
6504 (@command{org-timer-pause-or-continue}).
6505 @c removed the sentence because it is redundant to the following item
6506 @kindex C-u C-c C-x ,
6507 @item C-u C-c C-x ,
6508 Stop the timer.  After this, you can only start a new timer, not continue the
6509 old one.  This command also removes the timer from the mode line.
6510 @orgcmd{C-c C-x 0,org-timer-start}
6511 Reset the timer without inserting anything into the buffer.  By default, the
6512 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
6513 specific starting offset.  The user is prompted for the offset, with a
6514 default taken from a timer string at point, if any, So this can be used to
6515 restart taking notes after a break in the process.  When called with a double
6516 prefix argument @kbd{C-u C-u}, change all timer strings in the active region
6517 by a certain amount.  This can be used to fix timer strings if the timer was
6518 not started at exactly the right moment.
6519 @end table
6521 @node Countdown timer,  , Relative timer, Dates and Times
6522 @section Countdown timer
6523 @cindex Countdown timer
6524 @kindex C-c C-x ;
6525 @kindex ;
6527 Calling @code{org-timer-set-timer} from an Org mode buffer runs a countdown
6528 timer.  Use @kbd{;} from agenda buffers, @key{C-c C-x ;} everywhere else.
6530 @code{org-timer-set-timer} prompts the user for a duration and displays a
6531 countdown timer in the modeline.  @code{org-timer-default-timer} sets the
6532 default countdown value.  Giving a prefix numeric argument overrides this
6533 default value.
6535 @node Capture - Refile - Archive, Agenda Views, Dates and Times, Top
6536 @chapter Capture - Refile - Archive
6537 @cindex capture
6539 An important part of any organization system is the ability to quickly
6540 capture new ideas and tasks, and to associate reference material with them.
6541 Org does this using a process called @i{capture}.  It also can store files
6542 related to a task (@i{attachments}) in a special directory.  Once in the
6543 system, tasks and projects need to be moved around.  Moving completed project
6544 trees to an archive file keeps the system compact and fast.
6546 @menu
6547 * Capture::                     Capturing new stuff
6548 * Attachments::                 Add files to tasks
6549 * RSS Feeds::                   Getting input from RSS feeds
6550 * Protocols::                   External (e.g., Browser) access to Emacs and Org
6551 * Refile and copy::             Moving/copying a tree from one place to another
6552 * Archiving::                   What to do with finished projects
6553 @end menu
6555 @node Capture, Attachments, Capture - Refile - Archive, Capture - Refile - Archive
6556 @section Capture
6557 @cindex capture
6559 Capture lets you quickly store notes with little interruption of your work
6560 flow.  Org's method for capturing new items is heavily inspired by John
6561 Wiegley excellent @code{remember.el} package.  Up to version 6.36, Org
6562 used a special setup for @file{remember.el}, then replaced it with
6563 @file{org-remember.el}.  As of version 8.0, @file{org-remember.el} has
6564 been completely replaced by @file{org-capture.el}.
6566 If your configuration depends on @fite{org-remember.el}, you need to update
6567 it and use the setup described below.  To convert your
6568 @code{org-remember-templates}, run the command
6569 @example
6570 @kbd{M-x org-capture-import-remember-templates @key{RET}}
6571 @end example
6572 @noindent and then customize the new variable with @kbd{M-x
6573 customize-variable org-capture-templates}, check the result, and save the
6574 customization.
6576 @menu
6577 * Setting up capture::          Where notes will be stored
6578 * Using capture::               Commands to invoke and terminate capture
6579 * Capture templates::           Define the outline of different note types
6580 @end menu
6582 @node Setting up capture, Using capture, Capture, Capture
6583 @subsection Setting up capture
6585 The following customization sets a default target file for notes, and defines
6586 a global key@footnote{Please select your own key, @kbd{C-c c} is only a
6587 suggestion.}  for capturing new material.
6589 @vindex org-default-notes-file
6590 @example
6591 (setq org-default-notes-file (concat org-directory "/notes.org"))
6592 (define-key global-map "\C-cc" 'org-capture)
6593 @end example
6595 @node Using capture, Capture templates, Setting up capture, Capture
6596 @subsection Using capture
6598 @table @kbd
6599 @orgcmd{C-c c,org-capture}
6600 Call the command @code{org-capture}.  Note that this keybinding is global and
6601 not active by default: you need to install it.  If you have templates
6602 @cindex date tree
6603 defined @pxref{Capture templates}, it will offer these templates for
6604 selection or use a new Org outline node as the default template.  It will
6605 insert the template into the target file and switch to an indirect buffer
6606 narrowed to this new node.  You may then insert the information you want.
6608 @orgcmd{C-c C-c,org-capture-finalize}
6609 Once you have finished entering information into the capture buffer, @kbd{C-c
6610 C-c} will return you to the window configuration before the capture process,
6611 so that you can resume your work without further distraction.  When called
6612 with a prefix arg, finalize and then jump to the captured item.
6614 @orgcmd{C-c C-w,org-capture-refile}
6615 Finalize the capture process by refiling (@pxref{Refile and copy}) the note to
6616 a different place.  Please realize that this is a normal refiling command
6617 that will be executed---so the cursor position at the moment you run this
6618 command is important.  If you have inserted a tree with a parent and
6619 children, first move the cursor back to the parent.  Any prefix argument
6620 given to this command will be passed on to the @code{org-refile} command.
6622 @orgcmd{C-c C-k,org-capture-kill}
6623 Abort the capture process and return to the previous state.
6625 @end table
6627 You can also call @code{org-capture} in a special way from the agenda, using
6628 the @kbd{k c} key combination.  With this access, any timestamps inserted by
6629 the selected capture template will default to the cursor date in the agenda,
6630 rather than to the current date.
6632 To find the locations of the last stored capture, use @code{org-capture} with
6633 prefix commands:
6635 @table @kbd
6636 @orgkey{C-u C-c c}
6637 Visit the target location of a capture template.  You get to select the
6638 template in the usual way.
6639 @orgkey{C-u C-u C-c c}
6640 Visit the last stored capture item in its buffer.
6641 @end table
6643 @vindex org-capture-bookmark
6644 @cindex org-capture-last-stored
6645 You can also jump to the bookmark @code{org-capture-last-stored}, which will
6646 automatically be created unless you set @code{org-capture-bookmark} to
6647 @code{nil}.
6649 To insert the capture at point in an Org buffer, call @code{org-capture} with
6650 a @code{C-0} prefix argument.
6652 @node Capture templates,  , Using capture, Capture
6653 @subsection Capture templates
6654 @cindex templates, for Capture
6656 You can use templates for different types of capture items, and
6657 for different target locations.  The easiest way to create such templates is
6658 through the customize interface.
6660 @table @kbd
6661 @orgkey{C-c c C}
6662 Customize the variable @code{org-capture-templates}.
6663 @end table
6665 Before we give the formal description of template definitions, let's look at
6666 an example.  Say you would like to use one template to create general TODO
6667 entries, and you want to put these entries under the heading @samp{Tasks} in
6668 your file @file{~/org/gtd.org}.  Also, a date tree in the file
6669 @file{journal.org} should capture journal entries.  A possible configuration
6670 would look like:
6672 @example
6673 (setq org-capture-templates
6674  '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
6675         "* TODO %?\n  %i\n  %a")
6676    ("j" "Journal" entry (file+datetree "~/org/journal.org")
6677         "* %?\nEntered on %U\n  %i\n  %a")))
6678 @end example
6680 @noindent If you then press @kbd{C-c c t}, Org will prepare the template
6681 for you like this:
6682 @example
6683 * TODO
6684   [[file:@var{link to where you initiated capture}]]
6685 @end example
6687 @noindent
6688 During expansion of the template, @code{%a} has been replaced by a link to
6689 the location from where you called the capture command.  This can be
6690 extremely useful for deriving tasks from emails, for example.  You fill in
6691 the task definition, press @code{C-c C-c} and Org returns you to the same
6692 place where you started the capture process.
6694 To define special keys to capture to a particular template without going
6695 through the interactive template selection, you can create your key binding
6696 like this:
6698 @lisp
6699 (define-key global-map "\C-cx"
6700    (lambda () (interactive) (org-capture nil "x")))
6701 @end lisp
6703 @menu
6704 * Template elements::           What is needed for a complete template entry
6705 * Template expansion::          Filling in information about time and context
6706 * Templates in contexts::       Only show a template in a specific context
6707 @end menu
6709 @node Template elements, Template expansion, Capture templates, Capture templates
6710 @subsubsection Template elements
6712 Now lets look at the elements of a template definition.  Each entry in
6713 @code{org-capture-templates} is a list with the following items:
6715 @table @var
6716 @item keys
6717 The keys that will select the template, as a string, characters
6718 only, for example @code{"a"} for a template to be selected with a
6719 single key, or @code{"bt"} for selection with two keys.  When using
6720 several keys, keys using the same prefix key must be sequential
6721 in the list and preceded by a 2-element entry explaining the
6722 prefix key, for example
6723 @example
6724          ("b" "Templates for marking stuff to buy")
6725 @end example
6726 @noindent If you do not define a template for the @kbd{C} key, this key will
6727 be used to open the customize buffer for this complex variable.
6729 @item description
6730 A short string describing the template, which will be shown during
6731 selection.
6733 @item type
6734 The type of entry, a symbol.  Valid values are:
6735 @table @code
6736 @item entry
6737 An Org mode node, with a headline.  Will be filed as the child of the target
6738 entry or as a top-level entry.  The target file should be an Org mode file.
6739 @item item
6740 A plain list item, placed in the first plain  list at the target
6741 location.  Again the target file should be an Org file.
6742 @item checkitem
6743 A checkbox item.  This only differs from the plain list item by the
6744 default template.
6745 @item table-line
6746 a new line in the first table at the target location.  Where exactly the
6747 line will be inserted depends on the properties @code{:prepend} and
6748 @code{:table-line-pos} (see below).
6749 @item plain
6750 Text to be inserted as it is.
6751 @end table
6753 @item target
6754 @vindex org-default-notes-file
6755 Specification of where the captured item should be placed.  In Org mode
6756 files, targets usually define a node.  Entries will become children of this
6757 node.  Other types will be added to the table or list in the body of this
6758 node.  Most target specifications contain a file name.  If that file name is
6759 the empty string, it defaults to @code{org-default-notes-file}.  A file can
6760 also be given as a variable, function, or Emacs Lisp form.
6762 Valid values are:
6763 @table @code
6764 @item (file "path/to/file")
6765 Text will be placed at the beginning or end of that file.
6767 @item (id "id of existing org entry")
6768 Filing as child of this entry, or in the body of the entry.
6770 @item (file+headline "path/to/file" "node headline")
6771 Fast configuration if the target heading is unique in the file.
6773 @item (file+olp "path/to/file" "Level 1 heading" "Level 2" ...)
6774 For non-unique headings, the full path is safer.
6776 @item (file+regexp  "path/to/file" "regexp to find location")
6777 Use a regular expression to position the cursor.
6779 @item (file+datetree "path/to/file")
6780 Will create a heading in a date tree for today's date.
6782 @item (file+datetree+prompt "path/to/file")
6783 Will create a heading in a date tree, but will prompt for the date.
6785 @item (file+function "path/to/file" function-finding-location)
6786 A function to find the right location in the file.
6788 @item (clock)
6789 File to the entry that is currently being clocked.
6791 @item (function function-finding-location)
6792 Most general way, write your own function to find both
6793 file and location.
6794 @end table
6796 @item template
6797 The template for creating the capture item.  If you leave this empty, an
6798 appropriate default template will be used.  Otherwise this is a string with
6799 escape codes, which will be replaced depending on time and context of the
6800 capture call.  The string with escapes may be loaded from a template file,
6801 using the special syntax @code{(file "path/to/template")}.  See below for
6802 more details.
6804 @item properties
6805 The rest of the entry is a property list of additional options.
6806 Recognized properties are:
6807 @table @code
6808 @item :prepend
6809 Normally new captured information will be appended at
6810 the target location (last child, last table line, last list item...).
6811 Setting this property will change that.
6813 @item :immediate-finish
6814 When set, do not offer to edit the information, just
6815 file it away immediately.  This makes sense if the template only needs
6816 information that can be added automatically.
6818 @item :empty-lines
6819 Set this to the number of lines to insert
6820 before and after the new item.  Default 0, only common other value is 1.
6822 @item :clock-in
6823 Start the clock in this item.
6825 @item :clock-keep
6826 Keep the clock running when filing the captured entry.
6828 @item :clock-resume
6829 If starting the capture interrupted a clock, restart that clock when finished
6830 with the capture.  Note that @code{:clock-keep} has precedence over
6831 @code{:clock-resume}.  When setting both to @code{t}, the current clock will
6832 run and the previous one will not be resumed.
6834 @item :unnarrowed
6835 Do not narrow the target buffer, simply show the full buffer.  Default is to
6836 narrow it so that you only see the new material.
6838 @item :table-line-pos
6839 Specification of the location in the table where the new line should be
6840 inserted.  It should be a string like @code{"II-3"} meaning that the new
6841 line should become the third line before the second horizontal separator
6842 line.
6844 @item :kill-buffer
6845 If the target file was not yet visited when capture was invoked, kill the
6846 buffer again after capture is completed.
6847 @end table
6848 @end table
6850 @node Template expansion, Templates in contexts, Template elements, Capture templates
6851 @subsubsection Template expansion
6853 In the template itself, special @kbd{%}-escapes@footnote{If you need one of
6854 these sequences literally, escape the @kbd{%} with a backslash.} allow
6855 dynamic insertion of content.  The templates are expanded in the order given here:
6857 @smallexample
6858 %[@var{file}]     @r{Insert the contents of the file given by @var{file}.}
6859 %(@var{sexp})     @r{Evaluate Elisp @var{sexp} and replace with the result.}
6860                   @r{For convenience, %:keyword (see below) placeholders}
6861                   @r{within the expression will be expanded prior to this.}
6862                   @r{The sexp must return a string.}
6863 %<...>      @r{The result of format-time-string on the ... format specification.}
6864 %t          @r{Timestamp, date only.}
6865 %T          @r{Timestamp, with date and time.}
6866 %u, %U      @r{Like the above, but inactive timestamps.}
6867 %i          @r{Initial content, the region when capture is called while the}
6868             @r{region is active.}
6869             @r{The entire text will be indented like @code{%i} itself.}
6870 %a          @r{Annotation, normally the link created with @code{org-store-link}.}
6871 %A          @r{Like @code{%a}, but prompt for the description part.}
6872 %l          @r{Like %a, but only insert the literal link.}
6873 %c          @r{Current kill ring head.}
6874 %x          @r{Content of the X clipboard.}
6875 %k          @r{Title of the currently clocked task.}
6876 %K          @r{Link to the currently clocked task.}
6877 %n          @r{User name (taken from @code{user-full-name}).}
6878 %f          @r{File visited by current buffer when org-capture was called.}
6879 %F          @r{Full path of the file or directory visited by current buffer.}
6880 %:keyword   @r{Specific information for certain link types, see below.}
6881 %^g         @r{Prompt for tags, with completion on tags in target file.}
6882 %^G         @r{Prompt for tags, with completion all tags in all agenda files.}
6883 %^t         @r{Like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}.}
6884             @r{You may define a prompt like @code{%^@{Birthday@}t}.}
6885 %^C         @r{Interactive selection of which kill or clip to use.}
6886 %^L         @r{Like @code{%^C}, but insert as link.}
6887 %^@{@var{prop}@}p   @r{Prompt the user for a value for property @var{prop}.}
6888 %^@{@var{prompt}@}  @r{prompt the user for a string and replace this sequence with it.}
6889             @r{You may specify a default value and a completion table with}
6890             @r{%^@{prompt|default|completion2|completion3...@}.}
6891             @r{The arrow keys access a prompt-specific history.}
6892 %\n         @r{Insert the text entered at the nth %^@{@var{prompt}@}, where @code{n} is}
6893             @r{a number, starting from 1.}
6894 %?          @r{After completing the template, position cursor here.}
6895 @end smallexample
6897 @noindent
6898 For specific link types, the following keywords will be
6899 defined@footnote{If you define your own link types (@pxref{Adding
6900 hyperlink types}), any property you store with
6901 @code{org-store-link-props} can be accessed in capture templates in a
6902 similar way.}:
6904 @vindex org-from-is-user-regexp
6905 @smallexample
6906 Link type                        |  Available keywords
6907 ---------------------------------+----------------------------------------------
6908 bbdb                             |  %:name %:company
6909 irc                              |  %:server %:port %:nick
6910 vm, vm-imap, wl, mh, mew, rmail  |  %:type %:subject %:message-id
6911                                  |  %:from %:fromname %:fromaddress
6912                                  |  %:to   %:toname   %:toaddress
6913                                  |  %:date @r{(message date header field)}
6914                                  |  %:date-timestamp @r{(date as active timestamp)}
6915                                  |  %:date-timestamp-inactive @r{(date as inactive timestamp)}
6916                                  |  %: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}.}}
6917 gnus                             |  %:group, @r{for messages also all email fields}
6918 w3, w3m                          |  %:url
6919 info                             |  %:file %:node
6920 calendar                         |  %:date
6921 @end smallexample
6923 @noindent
6924 To place the cursor after template expansion use:
6926 @smallexample
6927 %?          @r{After completing the template, position cursor here.}
6928 @end smallexample
6930 @node Templates in contexts,  , Template expansion, Capture templates
6931 @subsubsection Templates in contexts
6933 @vindex org-capture-templates-contexts
6934 To control whether a capture template should be accessible from a specific
6935 context, you can customize @var{org-capture-templates-contexts}.  Let's say
6936 for example that you have a capture template @code{"p"} for storing Gnus
6937 emails containing patches.  Then you would configure this option like this:
6939 @example
6940 (setq org-capture-templates-contexts
6941       '(("p" (in-mode . "message-mode"))))
6942 @end example
6944 You can also tell that the command key @code{"p"} should refer to another
6945 template.  In that case, add this command key like this:
6947 @example
6948 (setq org-capture-templates-contexts
6949       '(("p" "q" (in-mode . "message-mode"))))
6950 @end example
6952 See the docstring of the variable for more information.
6954 @node Attachments, RSS Feeds, Capture, Capture - Refile - Archive
6955 @section Attachments
6956 @cindex attachments
6958 @vindex org-attach-directory
6959 It is often useful to associate reference material with an outline node/task.
6960 Small chunks of plain text can simply be stored in the subtree of a project.
6961 Hyperlinks (@pxref{Hyperlinks}) can establish associations with
6962 files that live elsewhere on your computer or in the cloud, like emails or
6963 source code files belonging to a project.  Another method is @i{attachments},
6964 which are files located in a directory belonging to an outline node.  Org
6965 uses directories named by the unique ID of each entry.  These directories are
6966 located in the @file{data} directory which lives in the same directory where
6967 your Org file lives@footnote{If you move entries or Org files from one
6968 directory to another, you may want to configure @code{org-attach-directory}
6969 to contain an absolute path.}.  If you initialize this directory with
6970 @code{git init}, Org will automatically commit changes when it sees them.
6971 The attachment system has been contributed to Org by John Wiegley.
6973 In cases where it seems better to do so, you can also attach a directory of your
6974 choice to an entry.  You can also make children inherit the attachment
6975 directory from a parent, so that an entire subtree uses the same attached
6976 directory.
6978 @noindent The following commands deal with attachments:
6980 @table @kbd
6982 @orgcmd{C-c C-a,org-attach}
6983 The dispatcher for commands related to the attachment system.  After these
6984 keys, a list of commands is displayed and you must press an additional key
6985 to select a command:
6987 @table @kbd
6988 @orgcmdtkc{a,C-c C-a a,org-attach-attach}
6989 @vindex org-attach-method
6990 Select a file and move it into the task's attachment directory.  The file
6991 will be copied, moved, or linked, depending on @code{org-attach-method}.
6992 Note that hard links are not supported on all systems.
6994 @kindex C-c C-a c
6995 @kindex C-c C-a m
6996 @kindex C-c C-a l
6997 @item c/m/l
6998 Attach a file using the copy/move/link method.
6999 Note that hard links are not supported on all systems.
7001 @orgcmdtkc{n,C-c C-a n,org-attach-new}
7002 Create a new attachment as an Emacs buffer.
7004 @orgcmdtkc{z,C-c C-a z,org-attach-sync}
7005 Synchronize the current task with its attachment directory, in case you added
7006 attachments yourself.
7008 @orgcmdtkc{o,C-c C-a o,org-attach-open}
7009 @vindex org-file-apps
7010 Open current task's attachment.  If there is more than one, prompt for a
7011 file name first.  Opening will follow the rules set by @code{org-file-apps}.
7012 For more details, see the information on following hyperlinks
7013 (@pxref{Handling links}).
7015 @orgcmdtkc{O,C-c C-a O,org-attach-open-in-emacs}
7016 Also open the attachment, but force opening the file in Emacs.
7018 @orgcmdtkc{f,C-c C-a f,org-attach-reveal}
7019 Open the current task's attachment directory.
7021 @orgcmdtkc{F,C-c C-a F,org-attach-reveal-in-emacs}
7022 Also open the directory, but force using @command{dired} in Emacs.
7024 @orgcmdtkc{d,C-c C-a d,org-attach-delete-one}
7025 Select and delete a single attachment.
7027 @orgcmdtkc{D,C-c C-a D,org-attach-delete-all}
7028 Delete all of a task's attachments.  A safer way is to open the directory in
7029 @command{dired} and delete from there.
7031 @orgcmdtkc{s,C-c C-a s,org-attach-set-directory}
7032 @cindex property, ATTACH_DIR
7033 Set a specific directory as the entry's attachment directory.  This works by
7034 putting the directory path into the @code{ATTACH_DIR} property.
7036 @orgcmdtkc{i,C-c C-a i,org-attach-set-inherit}
7037 @cindex property, ATTACH_DIR_INHERIT
7038 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
7039 same directory for attachments as the parent does.
7040 @end table
7041 @end table
7043 @node RSS Feeds, Protocols, Attachments, Capture - Refile - Archive
7044 @section RSS feeds
7045 @cindex RSS feeds
7046 @cindex Atom feeds
7048 Org can add and change entries based on information found in RSS feeds and
7049 Atom feeds.  You could use this to make a task out of each new podcast in a
7050 podcast feed.  Or you could use a phone-based note-creating service on the
7051 web to import tasks into Org.  To access feeds, configure the variable
7052 @code{org-feed-alist}.  The docstring of this variable has detailed
7053 information.  Here is just an example:
7055 @example
7056 (setq org-feed-alist
7057      '(("Slashdot"
7058          "http://rss.slashdot.org/Slashdot/slashdot"
7059          "~/txt/org/feeds.org" "Slashdot Entries")))
7060 @end example
7062 @noindent
7063 will configure that new items from the feed provided by
7064 @code{rss.slashdot.org} will result in new entries in the file
7065 @file{~/org/feeds.org} under the heading @samp{Slashdot Entries}, whenever
7066 the following command is used:
7068 @table @kbd
7069 @orgcmd{C-c C-x g,org-feed-update-all}
7070 @item C-c C-x g
7071 Collect items from the feeds configured in @code{org-feed-alist} and act upon
7072 them.
7073 @orgcmd{C-c C-x G,org-feed-goto-inbox}
7074 Prompt for a feed name and go to the inbox configured for this feed.
7075 @end table
7077 Under the same headline, Org will create a drawer @samp{FEEDSTATUS} in which
7078 it will store information about the status of items in the feed, to avoid
7079 adding the same item several times.  You should add @samp{FEEDSTATUS} to the
7080 list of drawers in that file:
7082 @example
7083 #+DRAWERS: LOGBOOK PROPERTIES FEEDSTATUS
7084 @end example
7086 For more information, including how to read atom feeds, see
7087 @file{org-feed.el} and the docstring of @code{org-feed-alist}.
7089 @node Protocols, Refile and copy, RSS Feeds, Capture - Refile - Archive
7090 @section Protocols for external access
7091 @cindex protocols, for external access
7092 @cindex emacsserver
7094 You can set up Org for handling protocol calls from outside applications that
7095 are passed to Emacs through the @file{emacsserver}.  For example, you can
7096 configure bookmarks in your web browser to send a link to the current page to
7097 Org and create a note from it using capture (@pxref{Capture}).  Or you
7098 could create a bookmark that will tell Emacs to open the local source file of
7099 a remote website you are looking at with the browser.  See
7100 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
7101 documentation and setup instructions.
7103 @node Refile and copy, Archiving, Protocols, Capture - Refile - Archive
7104 @section Refile and copy
7105 @cindex refiling notes
7106 @cindex copying notes
7108 When reviewing the captured data, you may want to refile or to copy some of
7109 the entries into a different list, for example into a project.  Cutting,
7110 finding the right location, and then pasting the note is cumbersome.  To
7111 simplify this process, you can use the following special command:
7113 @table @kbd
7114 @orgcmd{C-c M-w,org-copy}
7115 @findex org-copy
7116 Copying works like refiling, except that the original note is not deleted.
7117 @orgcmd{C-c C-w,org-refile}
7118 @findex org-refile
7119 @vindex org-reverse-note-order
7120 @vindex org-refile-targets
7121 @vindex org-refile-use-outline-path
7122 @vindex org-outline-path-complete-in-steps
7123 @vindex org-refile-allow-creating-parent-nodes
7124 @vindex org-log-refile
7125 @vindex org-refile-use-cache
7126 Refile the entry or region at point.  This command offers possible locations
7127 for refiling the entry and lets you select one with completion.  The item (or
7128 all items in the region) is filed below the target heading as a subitem.
7129 Depending on @code{org-reverse-note-order}, it will be either the first or
7130 last subitem.@*
7131 By default, all level 1 headlines in the current buffer are considered to be
7132 targets, but you can have more complex definitions across a number of files.
7133 See the variable @code{org-refile-targets} for details.  If you would like to
7134 select a location via a file-path-like completion along the outline path, see
7135 the variables @code{org-refile-use-outline-path} and
7136 @code{org-outline-path-complete-in-steps}.  If you would like to be able to
7137 create new nodes as new parents for refiling on the fly, check the
7138 variable @code{org-refile-allow-creating-parent-nodes}.
7139 When the variable @code{org-log-refile}@footnote{with corresponding
7140 @code{#+STARTUP} keywords @code{logrefile}, @code{lognoterefile},
7141 and @code{nologrefile}} is set, a timestamp or a note will be
7142 recorded when an entry has been refiled.
7143 @orgkey{C-u C-c C-w}
7144 Use the refile interface to jump to a heading.
7145 @orgcmd{C-u C-u C-c C-w,org-refile-goto-last-stored}
7146 Jump to the location where @code{org-refile} last moved a tree to.
7147 @item C-2 C-c C-w
7148 Refile as the child of the item currently being clocked.
7149 @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}
7150 Clear the target cache.  Caching of refile targets can be turned on by
7151 setting @code{org-refile-use-cache}.  To make the command see new possible
7152 targets, you have to clear the cache with this command.
7153 @end table
7155 @node Archiving,  , Refile and copy, Capture - Refile - Archive
7156 @section Archiving
7157 @cindex archiving
7159 When a project represented by a (sub)tree is finished, you may want
7160 to move the tree out of the way and to stop it from contributing to the
7161 agenda.  Archiving is important to keep your working files compact and global
7162 searches like the construction of agenda views fast.
7164 @table @kbd
7165 @orgcmd{C-c C-x C-a,org-archive-subtree-default}
7166 @vindex org-archive-default-command
7167 Archive the current entry using the command specified in the variable
7168 @code{org-archive-default-command}.
7169 @end table
7171 @menu
7172 * Moving subtrees::             Moving a tree to an archive file
7173 * Internal archiving::          Switch off a tree but keep it in the file
7174 @end menu
7176 @node Moving subtrees, Internal archiving, Archiving, Archiving
7177 @subsection Moving a tree to the archive file
7178 @cindex external archiving
7180 The most common archiving action is to move a project tree to another file,
7181 the archive file.
7183 @table @kbd
7184 @orgcmdkskc{C-c C-x C-s,C-c $,org-archive-subtree}
7185 @vindex org-archive-location
7186 Archive the subtree starting at the cursor position to the location
7187 given by @code{org-archive-location}.
7188 @orgkey{C-u C-c C-x C-s}
7189 Check if any direct children of the current headline could be moved to
7190 the archive.  To do this, each subtree is checked for open TODO entries.
7191 If none are found, the command offers to move it to the archive
7192 location.  If the cursor is @emph{not} on a headline when this command
7193 is invoked, the level 1 trees will be checked.
7194 @end table
7196 @cindex archive locations
7197 The default archive location is a file in the same directory as the
7198 current file, with the name derived by appending @file{_archive} to the
7199 current file name.  You can also choose what heading to file archived
7200 items under, with the possibility to add them to a datetree in a file.
7201 For information and examples on how to specify the file and the heading,
7202 see the documentation string of the variable
7203 @code{org-archive-location}.
7205 There is also an in-buffer option for setting this variable, for
7206 example@footnote{For backward compatibility, the following also works:
7207 If there are several such lines in a file, each specifies the archive
7208 location for the text below it.  The first such line also applies to any
7209 text before its definition.  However, using this method is
7210 @emph{strongly} deprecated as it is incompatible with the outline
7211 structure of the document.  The correct method for setting multiple
7212 archive locations in a buffer is using properties.}:
7214 @cindex #+ARCHIVE
7215 @example
7216 #+ARCHIVE: %s_done::
7217 @end example
7219 @cindex property, ARCHIVE
7220 @noindent
7221 If you would like to have a special ARCHIVE location for a single entry
7222 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
7223 location as the value (@pxref{Properties and Columns}).
7225 @vindex org-archive-save-context-info
7226 When a subtree is moved, it receives a number of special properties that
7227 record context information like the file from where the entry came, its
7228 outline path the archiving time etc.  Configure the variable
7229 @code{org-archive-save-context-info} to adjust the amount of information
7230 added.
7233 @node Internal archiving,  , Moving subtrees, Archiving
7234 @subsection Internal archiving
7236 If you want to just switch off (for agenda views) certain subtrees without
7237 moving them to a different file, you can use the @code{ARCHIVE tag}.
7239 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
7240 its location in the outline tree, but behaves in the following way:
7241 @itemize @minus
7242 @item
7243 @vindex org-cycle-open-archived-trees
7244 It does not open when you attempt to do so with a visibility cycling
7245 command (@pxref{Visibility cycling}).  You can force cycling archived
7246 subtrees with @kbd{C-@key{TAB}}, or by setting the option
7247 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
7248 @code{show-all} will open archived subtrees.
7249 @item
7250 @vindex org-sparse-tree-open-archived-trees
7251 During sparse tree construction (@pxref{Sparse trees}), matches in
7252 archived subtrees are not exposed, unless you configure the option
7253 @code{org-sparse-tree-open-archived-trees}.
7254 @item
7255 @vindex org-agenda-skip-archived-trees
7256 During agenda view construction (@pxref{Agenda Views}), the content of
7257 archived trees is ignored unless you configure the option
7258 @code{org-agenda-skip-archived-trees}, in which case these trees will always
7259 be included.  In the agenda you can press @kbd{v a} to get archives
7260 temporarily included.
7261 @item
7262 @vindex org-export-with-archived-trees
7263 Archived trees are not exported (@pxref{Exporting}), only the headline
7264 is.  Configure the details using the variable
7265 @code{org-export-with-archived-trees}.
7266 @item
7267 @vindex org-columns-skip-archived-trees
7268 Archived trees are excluded from column view unless the variable
7269 @code{org-columns-skip-archived-trees} is configured to @code{nil}.
7270 @end itemize
7272 The following commands help manage the ARCHIVE tag:
7274 @table @kbd
7275 @orgcmd{C-c C-x a,org-toggle-archive-tag}
7276 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
7277 the headline changes to a shadowed face, and the subtree below it is
7278 hidden.
7279 @orgkey{C-u C-c C-x a}
7280 Check if any direct children of the current headline should be archived.
7281 To do this, each subtree is checked for open TODO entries.  If none are
7282 found, the command offers to set the ARCHIVE tag for the child.  If the
7283 cursor is @emph{not} on a headline when this command is invoked, the
7284 level 1 trees will be checked.
7285 @orgcmd{C-@kbd{TAB},org-force-cycle-archived}
7286 Cycle a tree even if it is tagged with ARCHIVE.
7287 @orgcmd{C-c C-x A,org-archive-to-archive-sibling}
7288 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
7289 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}.  The
7290 entry becomes a child of that sibling and in this way retains a lot of its
7291 original context, including inherited tags and approximate position in the
7292 outline.
7293 @end table
7296 @node Agenda Views, Markup, Capture - Refile - Archive, Top
7297 @chapter Agenda views
7298 @cindex agenda views
7300 Due to the way Org works, TODO items, time-stamped items, and
7301 tagged headlines can be scattered throughout a file or even a number of
7302 files.  To get an overview of open action items, or of events that are
7303 important for a particular date, this information must be collected,
7304 sorted and displayed in an organized way.
7306 Org can select items based on various criteria and display them
7307 in a separate buffer.  Seven different view types are provided:
7309 @itemize @bullet
7310 @item
7311 an @emph{agenda} that is like a calendar and shows information
7312 for specific dates,
7313 @item
7314 a @emph{TODO list} that covers all unfinished
7315 action items,
7316 @item
7317 a @emph{match view}, showings headlines based on the tags, properties, and
7318 TODO state associated with them,
7319 @item
7320 a @emph{timeline view} that shows all events in a single Org file,
7321 in time-sorted view,
7322 @item
7323 a @emph{text search view} that shows all entries from multiple files
7324 that contain specified keywords,
7325 @item
7326 a @emph{stuck projects view} showing projects that currently don't move
7327 along, and
7328 @item
7329 @emph{custom views} that are special searches and combinations of different
7330 views.
7331 @end itemize
7333 @noindent
7334 The extracted information is displayed in a special @emph{agenda
7335 buffer}.  This buffer is read-only, but provides commands to visit the
7336 corresponding locations in the original Org files, and even to
7337 edit these files remotely.
7339 @vindex org-agenda-window-setup
7340 @vindex org-agenda-restore-windows-after-quit
7341 Two variables control how the agenda buffer is displayed and whether the
7342 window configuration is restored when the agenda exits:
7343 @code{org-agenda-window-setup} and
7344 @code{org-agenda-restore-windows-after-quit}.
7346 @menu
7347 * Agenda files::                Files being searched for agenda information
7348 * Agenda dispatcher::           Keyboard access to agenda views
7349 * Built-in agenda views::       What is available out of the box?
7350 * Presentation and sorting::    How agenda items are prepared for display
7351 * Agenda commands::             Remote editing of Org trees
7352 * Custom agenda views::         Defining special searches and views
7353 * Exporting Agenda Views::      Writing a view to a file
7354 * Agenda column view::          Using column view for collected entries
7355 @end menu
7357 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
7358 @section Agenda files
7359 @cindex agenda files
7360 @cindex files for agenda
7362 @vindex org-agenda-files
7363 The information to be shown is normally collected from all @emph{agenda
7364 files}, the files listed in the variable
7365 @code{org-agenda-files}@footnote{If the value of that variable is not a
7366 list, but a single file name, then the list of agenda files will be
7367 maintained in that external file.}.  If a directory is part of this list,
7368 all files with the extension @file{.org} in this directory will be part
7369 of the list.
7371 Thus, even if you only work with a single Org file, that file should
7372 be put into the list@footnote{When using the dispatcher, pressing
7373 @kbd{<} before selecting a command will actually limit the command to
7374 the current file, and ignore @code{org-agenda-files} until the next
7375 dispatcher command.}.  You can customize @code{org-agenda-files}, but
7376 the easiest way to maintain it is through the following commands
7378 @cindex files, adding to agenda list
7379 @table @kbd
7380 @orgcmd{C-c [,org-agenda-file-to-front}
7381 Add current file to the list of agenda files.  The file is added to
7382 the front of the list.  If it was already in the list, it is moved to
7383 the front.  With a prefix argument, file is added/moved to the end.
7384 @orgcmd{C-c ],org-remove-file}
7385 Remove current file from the list of agenda files.
7386 @kindex C-,
7387 @cindex cycling, of agenda files
7388 @orgcmd{C-',org-cycle-agenda-files}
7389 @itemx C-,
7390 Cycle through agenda file list, visiting one file after the other.
7391 @kindex M-x org-iswitchb
7392 @item M-x org-iswitchb
7393 Command to use an @code{iswitchb}-like interface to switch to and between Org
7394 buffers.
7395 @end table
7397 @noindent
7398 The Org menu contains the current list of files and can be used
7399 to visit any of them.
7401 If you would like to focus the agenda temporarily on a file not in
7402 this list, or on just one file in the list, or even on only a subtree in a
7403 file, then this can be done in different ways.  For a single agenda command,
7404 you may press @kbd{<} once or several times in the dispatcher
7405 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
7406 extended period, use the following commands:
7408 @table @kbd
7409 @orgcmd{C-c C-x <,org-agenda-set-restriction-lock}
7410 Permanently restrict the agenda to the current subtree.  When with a
7411 prefix argument, or with the cursor before the first headline in a file,
7412 the agenda scope is set to the entire file.  This restriction remains in
7413 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
7414 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
7415 agenda view, the new restriction takes effect immediately.
7416 @orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
7417 Remove the permanent restriction created by @kbd{C-c C-x <}.
7418 @end table
7420 @noindent
7421 When working with @file{speedbar.el}, you can use the following commands in
7422 the Speedbar frame:
7423 @table @kbd
7424 @orgcmdtkc{< @r{in the speedbar frame},<,org-speedbar-set-agenda-restriction}
7425 Permanently restrict the agenda to the item---either an Org file or a subtree
7426 in such a file---at the cursor in the Speedbar frame.
7427 If there is a window displaying an agenda view, the new restriction takes
7428 effect immediately.
7429 @orgcmdtkc{> @r{in the speedbar frame},>,org-agenda-remove-restriction-lock}
7430 Lift the restriction.
7431 @end table
7433 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
7434 @section The agenda dispatcher
7435 @cindex agenda dispatcher
7436 @cindex dispatching agenda commands
7437 The views are created through a dispatcher, which should be bound to a
7438 global key---for example @kbd{C-c a} (@pxref{Activation}).  In the
7439 following we will assume that @kbd{C-c a} is indeed how the dispatcher
7440 is accessed and list keyboard access to commands accordingly.  After
7441 pressing @kbd{C-c a}, an additional letter is required to execute a
7442 command.  The dispatcher offers the following default commands:
7443 @table @kbd
7444 @item a
7445 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
7446 @item t @r{/} T
7447 Create a list of all TODO items (@pxref{Global TODO list}).
7448 @item m @r{/} M
7449 Create a list of headlines matching a TAGS expression (@pxref{Matching
7450 tags and properties}).
7451 @item L
7452 Create the timeline view for the current buffer (@pxref{Timeline}).
7453 @item s
7454 Create a list of entries selected by a boolean expression of keywords
7455 and/or regular expressions that must or must not occur in the entry.
7456 @item /
7457 @vindex org-agenda-text-search-extra-files
7458 Search for a regular expression in all agenda files and additionally in
7459 the files listed in @code{org-agenda-text-search-extra-files}.  This
7460 uses the Emacs command @code{multi-occur}.  A prefix argument can be
7461 used to specify the number of context lines for each match, default is
7463 @item # @r{/} !
7464 Create a list of stuck projects (@pxref{Stuck projects}).
7465 @item <
7466 Restrict an agenda command to the current buffer@footnote{For backward
7467 compatibility, you can also press @kbd{1} to restrict to the current
7468 buffer.}.  After pressing @kbd{<}, you still need to press the character
7469 selecting the command.
7470 @item < <
7471 If there is an active region, restrict the following agenda command to
7472 the region.  Otherwise, restrict it to the current subtree@footnote{For
7473 backward compatibility, you can also press @kbd{0} to restrict to the
7474 current region/subtree.}.  After pressing @kbd{< <}, you still need to press the
7475 character selecting the command.
7477 @item *
7478 @vindex org-agenda-sticky
7479 Toggle sticky agenda views.  By default, Org maintains only a single agenda
7480 buffer and rebuilds it each time you change the view, to make sure everything
7481 is always up to date.  If you switch between views often and the build time
7482 bothers you, you can turn on sticky agenda buffers (make this the default by
7483 customizing the variable @code{org-agenda-sticky}).  With sticky agendas, the
7484 dispatcher only switches to the selected view, you need to update it by hand
7485 with @kbd{r} or @kbd{g}.  You can toggle sticky agenda view any time with
7486 @code{org-toggle-sticky-agenda}.
7487 @end table
7489 You can also define custom commands that will be accessible through the
7490 dispatcher, just like the default commands.  This includes the
7491 possibility to create extended agenda buffers that contain several
7492 blocks together, for example the weekly agenda, the global TODO list and
7493 a number of special tags matches.  @xref{Custom agenda views}.
7495 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
7496 @section The built-in agenda views
7498 In this section we describe the built-in views.
7500 @menu
7501 * Weekly/daily agenda::         The calendar page with current tasks
7502 * Global TODO list::            All unfinished action items
7503 * Matching tags and properties::  Structured information with fine-tuned search
7504 * Timeline::                    Time-sorted view for single file
7505 * Search view::                 Find entries by searching for text
7506 * Stuck projects::              Find projects you need to review
7507 @end menu
7509 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
7510 @subsection The weekly/daily agenda
7511 @cindex agenda
7512 @cindex weekly agenda
7513 @cindex daily agenda
7515 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
7516 paper agenda, showing all the tasks for the current week or day.
7518 @table @kbd
7519 @cindex org-agenda, command
7520 @orgcmd{C-c a a,org-agenda-list}
7521 Compile an agenda for the current week from a list of Org files.  The agenda
7522 shows the entries for each day.  With a numeric prefix@footnote{For backward
7523 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
7524 listed before the agenda.  This feature is deprecated, use the dedicated TODO
7525 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
7526 C-c a a}) you may set the number of days to be displayed.
7527 @end table
7529 @vindex org-agenda-span
7530 @vindex org-agenda-ndays
7531 The default number of days displayed in the agenda is set by the variable
7532 @code{org-agenda-span} (or the obsolete @code{org-agenda-ndays}).  This
7533 variable can be set to any number of days you want to see by default in the
7534 agenda, or to a span name, such a @code{day}, @code{week}, @code{month} or
7535 @code{year}.
7537 Remote editing from the agenda buffer means, for example, that you can
7538 change the dates of deadlines and appointments from the agenda buffer.
7539 The commands available in the Agenda buffer are listed in @ref{Agenda
7540 commands}.
7542 @subsubheading Calendar/Diary integration
7543 @cindex calendar integration
7544 @cindex diary integration
7546 Emacs contains the calendar and diary by Edward M. Reingold.  The
7547 calendar displays a three-month calendar with holidays from different
7548 countries and cultures.  The diary allows you to keep track of
7549 anniversaries, lunar phases, sunrise/set, recurrent appointments
7550 (weekly, monthly) and more.  In this way, it is quite complementary to
7551 Org.  It can be very useful to combine output from Org with
7552 the diary.
7554 In order to include entries from the Emacs diary into Org mode's
7555 agenda, you only need to customize the variable
7557 @lisp
7558 (setq org-agenda-include-diary t)
7559 @end lisp
7561 @noindent After that, everything will happen automatically.  All diary
7562 entries including holidays, anniversaries, etc., will be included in the
7563 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
7564 @key{RET} can be used from the agenda buffer to jump to the diary
7565 file in order to edit existing diary entries.  The @kbd{i} command to
7566 insert new entries for the current date works in the agenda buffer, as
7567 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
7568 Sunrise/Sunset times, show lunar phases and to convert to other
7569 calendars, respectively.  @kbd{c} can be used to switch back and forth
7570 between calendar and agenda.
7572 If you are using the diary only for sexp entries and holidays, it is
7573 faster to not use the above setting, but instead to copy or even move
7574 the entries into an Org file.  Org mode evaluates diary-style sexp
7575 entries, and does it faster because there is no overhead for first
7576 creating the diary display.  Note that the sexp entries must start at
7577 the left margin, no whitespace is allowed before them.  For example,
7578 the following segment of an Org file will be processed and entries
7579 will be made in the agenda:
7581 @example
7582 * Birthdays and similar stuff
7583 #+CATEGORY: Holiday
7584 %%(org-calendar-holiday)   ; special function for holiday names
7585 #+CATEGORY: Ann
7586 %%(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
7587 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
7588 @end example
7590 @subsubheading Anniversaries from BBDB
7591 @cindex BBDB, anniversaries
7592 @cindex anniversaries, from BBDB
7594 If you are using the Big Brothers Database to store your contacts, you will
7595 very likely prefer to store anniversaries in BBDB rather than in a
7596 separate Org or diary file.  Org supports this and will show BBDB
7597 anniversaries as part of the agenda.  All you need to do is to add the
7598 following to one of your agenda files:
7600 @example
7601 * Anniversaries
7602   :PROPERTIES:
7603   :CATEGORY: Anniv
7604   :END:
7605 %%(org-bbdb-anniversaries)
7606 @end example
7608 You can then go ahead and define anniversaries for a BBDB record.  Basically,
7609 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
7610 record and then add the date in the format @code{YYYY-MM-DD} or @code{MM-DD},
7611 followed by a space and the class of the anniversary (@samp{birthday} or
7612 @samp{wedding}, or a format string).  If you omit the class, it will default to
7613 @samp{birthday}.  Here are a few examples, the header for the file
7614 @file{org-bbdb.el} contains more detailed information.
7616 @example
7617 1973-06-22
7618 06-22
7619 1955-08-02 wedding
7620 2008-04-14 %s released version 6.01 of org mode, %d years ago
7621 @end example
7623 After a change to BBDB, or for the first agenda display during an Emacs
7624 session, the agenda display will suffer a short delay as Org updates its
7625 hash with anniversaries.  However, from then on things will be very fast---much
7626 faster in fact than a long list of @samp{%%(diary-anniversary)} entries
7627 in an Org or Diary file.
7629 @subsubheading Appointment reminders
7630 @cindex @file{appt.el}
7631 @cindex appointment reminders
7632 @cindex appointment
7633 @cindex reminders
7635 Org can interact with Emacs appointments notification facility.  To add the
7636 appointments of your agenda files, use the command @code{org-agenda-to-appt}.
7637 This command lets you filter through the list of your appointments and add
7638 only those belonging to a specific category or matching a regular expression.
7639 It also reads a @code{APPT_WARNTIME} property which will then override the
7640 value of @code{appt-message-warning-time} for this appointment.  See the
7641 docstring for details.
7643 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
7644 @subsection The global TODO list
7645 @cindex global TODO list
7646 @cindex TODO list, global
7648 The global TODO list contains all unfinished TODO items formatted and
7649 collected into a single place.
7651 @table @kbd
7652 @orgcmd{C-c a t,org-todo-list}
7653 Show the global TODO list.  This collects the TODO items from all agenda
7654 files (@pxref{Agenda Views}) into a single buffer.  By default, this lists
7655 items with a state the is not a DONE state.  The buffer is in
7656 @code{agenda-mode}, so there are commands to examine and manipulate the TODO
7657 entries directly from that buffer (@pxref{Agenda commands}).
7658 @orgcmd{C-c a T,org-todo-list}
7659 @cindex TODO keyword matching
7660 @vindex org-todo-keywords
7661 Like the above, but allows selection of a specific TODO keyword.  You can
7662 also do this by specifying a prefix argument to @kbd{C-c a t}.  You are
7663 prompted for a keyword, and you may also specify several keywords by
7664 separating them with @samp{|} as the boolean OR operator.  With a numeric
7665 prefix, the Nth keyword in @code{org-todo-keywords} is selected.
7666 @kindex r
7667 The @kbd{r} key in the agenda buffer regenerates it, and you can give
7668 a prefix argument to this command to change the selected TODO keyword,
7669 for example @kbd{3 r}.  If you often need a search for a specific
7670 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
7671 Matching specific TODO keywords can also be done as part of a tags
7672 search (@pxref{Tag searches}).
7673 @end table
7675 Remote editing of TODO items means that you can change the state of a
7676 TODO entry with a single key press.  The commands available in the
7677 TODO list are described in @ref{Agenda commands}.
7679 @cindex sublevels, inclusion into TODO list
7680 Normally the global TODO list simply shows all headlines with TODO
7681 keywords.  This list can become very long.  There are two ways to keep
7682 it more compact:
7683 @itemize @minus
7684 @item
7685 @vindex org-agenda-todo-ignore-scheduled
7686 @vindex org-agenda-todo-ignore-deadlines
7687 @vindex org-agenda-todo-ignore-timestamp
7688 @vindex org-agenda-todo-ignore-with-date
7689 Some people view a TODO item that has been @emph{scheduled} for execution or
7690 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
7691 Configure the variables @code{org-agenda-todo-ignore-scheduled},
7692 @code{org-agenda-todo-ignore-deadlines},
7693 @code{org-agenda-todo-ignore-timestamp} and/or
7694 @code{org-agenda-todo-ignore-with-date} to exclude such items from the global
7695 TODO list.
7696 @item
7697 @vindex org-agenda-todo-list-sublevels
7698 TODO items may have sublevels to break up the task into subtasks.  In
7699 such cases it may be enough to list only the highest level TODO headline
7700 and omit the sublevels from the global list.  Configure the variable
7701 @code{org-agenda-todo-list-sublevels} to get this behavior.
7702 @end itemize
7704 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
7705 @subsection Matching tags and properties
7706 @cindex matching, of tags
7707 @cindex matching, of properties
7708 @cindex tags view
7709 @cindex match view
7711 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
7712 or have properties (@pxref{Properties and Columns}), you can select headlines
7713 based on this metadata and collect them into an agenda buffer.  The match
7714 syntax described here also applies when creating sparse trees with @kbd{C-c /
7717 @table @kbd
7718 @orgcmd{C-c a m,org-tags-view}
7719 Produce a list of all headlines that match a given set of tags.  The
7720 command prompts for a selection criterion, which is a boolean logic
7721 expression with tags, like @samp{+work+urgent-withboss} or
7722 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
7723 define a custom command for it (@pxref{Agenda dispatcher}).
7724 @orgcmd{C-c a M,org-tags-view}
7725 @vindex org-tags-match-list-sublevels
7726 @vindex org-agenda-tags-todo-honor-ignore-options
7727 Like @kbd{C-c a m}, but only select headlines that are also TODO items in a
7728 not-DONE state and force checking subitems (see variable
7729 @code{org-tags-match-list-sublevels}).  To exclude scheduled/deadline items,
7730 see the variable @code{org-agenda-tags-todo-honor-ignore-options}.  Matching
7731 specific TODO keywords together with a tags match is also possible, see
7732 @ref{Tag searches}.
7733 @end table
7735 The commands available in the tags list are described in @ref{Agenda
7736 commands}.
7738 @subsubheading Match syntax
7740 @cindex Boolean logic, for tag/property searches
7741 A search string can use Boolean operators @samp{&} for AND and @samp{|} for
7742 OR@.  @samp{&} binds more strongly than @samp{|}.  Parentheses are currently
7743 not implemented.  Each element in the search is either a tag, a regular
7744 expression matching tags, or an expression like @code{PROPERTY OPERATOR
7745 VALUE} with a comparison operator, accessing a property value.  Each element
7746 may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
7747 sugar for positive selection.  The AND operator @samp{&} is optional when
7748 @samp{+} or @samp{-} is present.  Here are some examples, using only tags.
7750 @table @samp
7751 @item +work-boss
7752 Select headlines tagged @samp{:work:}, but discard those also tagged
7753 @samp{:boss:}.
7754 @item work|laptop
7755 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
7756 @item work|laptop+night
7757 Like before, but require the @samp{:laptop:} lines to be tagged also
7758 @samp{:night:}.
7759 @end table
7761 @cindex regular expressions, with tags search
7762 Instead of a tag, you may also specify a regular expression enclosed in curly
7763 braces.  For example,
7764 @samp{work+@{^boss.*@}} matches headlines that contain the tag
7765 @samp{:work:} and any tag @i{starting} with @samp{boss}.
7767 @cindex TODO keyword matching, with tags search
7768 @cindex level, require for tags/property match
7769 @cindex category, require for tags/property match
7770 @vindex org-odd-levels-only
7771 You may also test for properties (@pxref{Properties and Columns}) at the same
7772 time as matching tags.  The properties may be real properties, or special
7773 properties that represent other metadata (@pxref{Special properties}).  For
7774 example, the ``property'' @code{TODO} represents the TODO keyword of the
7775 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
7776 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
7777 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
7778 DONE@.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
7779 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
7780 The ITEM special property cannot currently be used in tags/property
7781 searches@footnote{But @pxref{x-agenda-skip-entry-regexp,
7782 ,skipping entries based on regexp}.}.
7784 Here are more examples:
7785 @table @samp
7786 @item work+TODO="WAITING"
7787 Select @samp{:work:}-tagged TODO lines with the specific TODO
7788 keyword @samp{WAITING}.
7789 @item work+TODO="WAITING"|home+TODO="WAITING"
7790 Waiting tasks both at work and at home.
7791 @end table
7793 When matching properties, a number of different operators can be used to test
7794 the value of a property.  Here is a complex example:
7796 @example
7797 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
7798          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
7799 @end example
7801 @noindent
7802 The type of comparison will depend on how the comparison value is written:
7803 @itemize @minus
7804 @item
7805 If the comparison value is a plain number, a numerical comparison is done,
7806 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
7807 @samp{>=}, and @samp{<>}.
7808 @item
7809 If the comparison value is enclosed in double-quotes,
7810 a string comparison is done, and the same operators are allowed.
7811 @item
7812 If the comparison value is enclosed in double-quotes @emph{and} angular
7813 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
7814 assumed to be date/time specifications in the standard Org way, and the
7815 comparison will be done accordingly.  Special values that will be recognized
7816 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
7817 @code{"<tomorrow>"} for these days at 0:00 hours, i.e., without a time
7818 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
7819 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
7820 respectively, can be used.
7821 @item
7822 If the comparison value is enclosed
7823 in curly braces, a regexp match is performed, with @samp{=} meaning that the
7824 regexp matches the property value, and @samp{<>} meaning that it does not
7825 match.
7826 @end itemize
7828 So the search string in the example finds entries tagged @samp{:work:} but
7829 not @samp{:boss:}, which also have a priority value @samp{A}, a
7830 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
7831 property that is numerically smaller than 2, a @samp{:With:} property that is
7832 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
7833 on or after October 11, 2008.
7835 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
7836 other properties will slow down the search.  However, once you have paid the
7837 price by accessing one property, testing additional properties is cheap
7838 again.
7840 You can configure Org mode to use property inheritance during a search, but
7841 beware that this can slow down searches considerably.  See @ref{Property
7842 inheritance}, for details.
7844 For backward compatibility, and also for typing speed, there is also a
7845 different way to test TODO states in a search.  For this, terminate the
7846 tags/property part of the search string (which may include several terms
7847 connected with @samp{|}) with a @samp{/} and then specify a Boolean
7848 expression just for TODO keywords.  The syntax is then similar to that for
7849 tags, but should be applied with care: for example, a positive selection on
7850 several TODO keywords cannot meaningfully be combined with boolean AND@.
7851 However, @emph{negative selection} combined with AND can be meaningful.  To
7852 make sure that only lines are checked that actually have any TODO keyword
7853 (resulting in a speed-up), use @kbd{C-c a M}, or equivalently start the TODO
7854 part after the slash with @samp{!}.  Using @kbd{C-c a M} or @samp{/!} will
7855 not match TODO keywords in a DONE state.  Examples:
7857 @table @samp
7858 @item work/WAITING
7859 Same as @samp{work+TODO="WAITING"}
7860 @item work/!-WAITING-NEXT
7861 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
7862 nor @samp{NEXT}
7863 @item work/!+WAITING|+NEXT
7864 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
7865 @samp{NEXT}.
7866 @end table
7868 @node Timeline, Search view, Matching tags and properties, Built-in agenda views
7869 @subsection Timeline for a single file
7870 @cindex timeline, single file
7871 @cindex time-sorted view
7873 The timeline summarizes all time-stamped items from a single Org mode
7874 file in a @emph{time-sorted view}.  The main purpose of this command is
7875 to give an overview over events in a project.
7877 @table @kbd
7878 @orgcmd{C-c a L,org-timeline}
7879 Show a time-sorted view of the Org file, with all time-stamped items.
7880 When called with a @kbd{C-u} prefix, all unfinished TODO entries
7881 (scheduled or not) are also listed under the current date.
7882 @end table
7884 @noindent
7885 The commands available in the timeline buffer are listed in
7886 @ref{Agenda commands}.
7888 @node Search view, Stuck projects, Timeline, Built-in agenda views
7889 @subsection Search view
7890 @cindex search view
7891 @cindex text search
7892 @cindex searching, for text
7894 This agenda view is a general text search facility for Org mode entries.
7895 It is particularly useful to find notes.
7897 @table @kbd
7898 @orgcmd{C-c a s,org-search-view}
7899 This is a special search that lets you select entries by matching a substring
7900 or specific words using a boolean logic.
7901 @end table
7902 For example, the search string @samp{computer equipment} will find entries
7903 that contain @samp{computer equipment} as a substring.  If the two words are
7904 separated by more space or a line break, the search will still match.
7905 Search view can also search for specific keywords in the entry, using Boolean
7906 logic.  The search string @samp{+computer +wifi -ethernet -@{8\.11[bg]@}}
7907 will search for note entries that contain the keywords @code{computer}
7908 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
7909 not matched by the regular expression @code{8\.11[bg]}, meaning to
7910 exclude both 8.11b and 8.11g.  The first @samp{+} is necessary to turn on
7911 word search, other @samp{+} characters are optional.  For more details, see
7912 the docstring of the command @code{org-search-view}.
7914 @vindex org-agenda-text-search-extra-files
7915 Note that in addition to the agenda files, this command will also search
7916 the files listed in @code{org-agenda-text-search-extra-files}.
7918 @node Stuck projects,  , Search view, Built-in agenda views
7919 @subsection Stuck projects
7920 @pindex GTD, Getting Things Done
7922 If you are following a system like David Allen's GTD to organize your
7923 work, one of the ``duties'' you have is a regular review to make sure
7924 that all projects move along.  A @emph{stuck} project is a project that
7925 has no defined next actions, so it will never show up in the TODO lists
7926 Org mode produces.  During the review, you need to identify such
7927 projects and define next actions for them.
7929 @table @kbd
7930 @orgcmd{C-c a #,org-agenda-list-stuck-projects}
7931 List projects that are stuck.
7932 @kindex C-c a !
7933 @item C-c a !
7934 @vindex org-stuck-projects
7935 Customize the variable @code{org-stuck-projects} to define what a stuck
7936 project is and how to find it.
7937 @end table
7939 You almost certainly will have to configure this view before it will
7940 work for you.  The built-in default assumes that all your projects are
7941 level-2 headlines, and that a project is not stuck if it has at least
7942 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
7944 Let's assume that you, in your own way of using Org mode, identify
7945 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
7946 indicate a project that should not be considered yet.  Let's further
7947 assume that the TODO keyword DONE marks finished projects, and that NEXT
7948 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
7949 is a next action even without the NEXT tag.  Finally, if the project
7950 contains the special word IGNORE anywhere, it should not be listed
7951 either.  In this case you would start by identifying eligible projects
7952 with a tags/todo match@footnote{@xref{Tag searches}.}
7953 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
7954 IGNORE in the subtree to identify projects that are not stuck.  The
7955 correct customization for this is
7957 @lisp
7958 (setq org-stuck-projects
7959       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
7960                                "\\<IGNORE\\>"))
7961 @end lisp
7963 Note that if a project is identified as non-stuck, the subtree of this entry
7964 will still be searched for stuck projects.
7966 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
7967 @section Presentation and sorting
7968 @cindex presentation, of agenda items
7970 @vindex org-agenda-prefix-format
7971 @vindex org-agenda-tags-column
7972 Before displaying items in an agenda view, Org mode visually prepares the
7973 items and sorts them.  Each item occupies a single line.  The line starts
7974 with a @emph{prefix} that contains the @emph{category} (@pxref{Categories})
7975 of the item and other important information.  You can customize in which
7976 column tags will be displayed through @code{org-agenda-tags-column}.  You can
7977 also customize the prefix using the option @code{org-agenda-prefix-format}.
7978 This prefix is followed by a cleaned-up version of the outline headline
7979 associated with the item.
7981 @menu
7982 * Categories::                  Not all tasks are equal
7983 * Time-of-day specifications::  How the agenda knows the time
7984 * Sorting of agenda items::     The order of things
7985 @end menu
7987 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
7988 @subsection Categories
7990 @cindex category
7991 @cindex #+CATEGORY
7992 The category is a broad label assigned to each agenda item.  By default,
7993 the category is simply derived from the file name, but you can also
7994 specify it with a special line in the buffer, like this@footnote{For
7995 backward compatibility, the following also works: if there are several
7996 such lines in a file, each specifies the category for the text below it.
7997 The first category also applies to any text before the first CATEGORY
7998 line.  However, using this method is @emph{strongly} deprecated as it is
7999 incompatible with the outline structure of the document.  The correct
8000 method for setting multiple categories in a buffer is using a
8001 property.}:
8003 @example
8004 #+CATEGORY: Thesis
8005 @end example
8007 @noindent
8008 @cindex property, CATEGORY
8009 If you would like to have a special CATEGORY for a single entry or a
8010 (sub)tree, give the entry a @code{:CATEGORY:} property with the
8011 special category you want to apply as the value.
8013 @noindent
8014 The display in the agenda buffer looks best if the category is not
8015 longer than 10 characters.
8017 @noindent
8018 You can set up icons for category by customizing the
8019 @code{org-agenda-category-icon-alist} variable.
8021 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
8022 @subsection Time-of-day specifications
8023 @cindex time-of-day specification
8025 Org mode checks each agenda item for a time-of-day specification.  The
8026 time can be part of the timestamp that triggered inclusion into the
8027 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
8028 ranges can be specified with two timestamps, like
8030 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
8032 In the headline of the entry itself, a time(range) may also appear as
8033 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
8034 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
8035 specifications in diary entries are recognized as well.
8037 For agenda display, Org mode extracts the time and displays it in a
8038 standard 24 hour format as part of the prefix.  The example times in
8039 the previous paragraphs would end up in the agenda like this:
8041 @example
8042     8:30-13:00 Arthur Dent lies in front of the bulldozer
8043    12:45...... Ford Prefect arrives and takes Arthur to the pub
8044    19:00...... The Vogon reads his poem
8045    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8046 @end example
8048 @cindex time grid
8049 If the agenda is in single-day mode, or for the display of today, the
8050 timed entries are embedded in a time grid, like
8052 @example
8053     8:00...... ------------------
8054     8:30-13:00 Arthur Dent lies in front of the bulldozer
8055    10:00...... ------------------
8056    12:00...... ------------------
8057    12:45...... Ford Prefect arrives and takes Arthur to the pub
8058    14:00...... ------------------
8059    16:00...... ------------------
8060    18:00...... ------------------
8061    19:00...... The Vogon reads his poem
8062    20:00...... ------------------
8063    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
8064 @end example
8066 @vindex org-agenda-use-time-grid
8067 @vindex org-agenda-time-grid
8068 The time grid can be turned on and off with the variable
8069 @code{org-agenda-use-time-grid}, and can be configured with
8070 @code{org-agenda-time-grid}.
8072 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
8073 @subsection Sorting of agenda items
8074 @cindex sorting, of agenda items
8075 @cindex priorities, of agenda items
8076 Before being inserted into a view, the items are sorted.  How this is
8077 done depends on the type of view.
8078 @itemize @bullet
8079 @item
8080 @vindex org-agenda-files
8081 For the daily/weekly agenda, the items for each day are sorted.  The
8082 default order is to first collect all items containing an explicit
8083 time-of-day specification.  These entries will be shown at the beginning
8084 of the list, as a @emph{schedule} for the day.  After that, items remain
8085 grouped in categories, in the sequence given by @code{org-agenda-files}.
8086 Within each category, items are sorted by priority (@pxref{Priorities}),
8087 which is composed of the base priority (2000 for priority @samp{A}, 1000
8088 for @samp{B}, and 0 for @samp{C}), plus additional increments for
8089 overdue scheduled or deadline items.
8090 @item
8091 For the TODO list, items remain in the order of categories, but within
8092 each category, sorting takes place according to priority
8093 (@pxref{Priorities}).  The priority used for sorting derives from the
8094 priority cookie, with additions depending on how close an item is to its due
8095 or scheduled date.
8096 @item
8097 For tags matches, items are not sorted at all, but just appear in the
8098 sequence in which they are found in the agenda files.
8099 @end itemize
8101 @vindex org-agenda-sorting-strategy
8102 Sorting can be customized using the variable
8103 @code{org-agenda-sorting-strategy}, and may also include criteria based on
8104 the estimated effort of an entry (@pxref{Effort estimates}).
8106 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
8107 @section Commands in the agenda buffer
8108 @cindex commands, in agenda buffer
8110 Entries in the agenda buffer are linked back to the Org file or diary
8111 file where they originate.  You are not allowed to edit the agenda
8112 buffer itself, but commands are provided to show and jump to the
8113 original entry location, and to edit the Org files ``remotely'' from
8114 the agenda buffer.  In this way, all information is stored only once,
8115 removing the risk that your agenda and note files may diverge.
8117 Some commands can be executed with mouse clicks on agenda lines.  For
8118 the other commands, the cursor needs to be in the desired line.
8120 @table @kbd
8121 @tsubheading{Motion}
8122 @cindex motion commands in agenda
8123 @orgcmd{n,org-agenda-next-line}
8124 Next line (same as @key{down} and @kbd{C-n}).
8125 @orgcmd{p,org-agenda-previous-line}
8126 Previous line (same as @key{up} and @kbd{C-p}).
8127 @tsubheading{View/Go to Org file}
8128 @orgcmdkkc{@key{SPC},mouse-3,org-agenda-show-and-scroll-up}
8129 Display the original location of the item in another window.
8130 With prefix arg, make sure that the entire entry is made visible in the
8131 outline, not only the heading.
8133 @orgcmd{L,org-agenda-recenter}
8134 Display original location and recenter that window.
8136 @orgcmdkkc{@key{TAB},mouse-2,org-agenda-goto}
8137 Go to the original location of the item in another window.
8139 @orgcmd{@key{RET},org-agenda-switch-to}
8140 Go to the original location of the item and delete other windows.
8142 @orgcmd{F,org-agenda-follow-mode}
8143 @vindex org-agenda-start-with-follow-mode
8144 Toggle Follow mode.  In Follow mode, as you move the cursor through
8145 the agenda buffer, the other window always shows the corresponding
8146 location in the Org file.  The initial setting for this mode in new
8147 agenda buffers can be set with the variable
8148 @code{org-agenda-start-with-follow-mode}.
8150 @orgcmd{C-c C-x b,org-agenda-tree-to-indirect-buffer}
8151 Display the entire subtree of the current item in an indirect buffer.  With a
8152 numeric prefix argument N, go up to level N and then take that tree.  If N is
8153 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
8154 previously used indirect buffer.
8156 @orgcmd{C-c C-o,org-agenda-open-link}
8157 Follow a link in the entry.  This will offer a selection of any links in the
8158 text belonging to the referenced Org node.  If there is only one link, it
8159 will be followed without a selection prompt.
8161 @tsubheading{Change display}
8162 @cindex display changing, in agenda
8163 @kindex A
8164 @item A
8165 Interactively select another agenda view and append it to the current view.
8167 @kindex o
8168 @item o
8169 Delete other windows.
8171 @orgcmdkskc{v d,d,org-agenda-day-view}
8172 @xorgcmdkskc{v w,w,org-agenda-week-view}
8173 @xorgcmd{v m,org-agenda-month-view}
8174 @xorgcmd{v y,org-agenda-year-view}
8175 @xorgcmd{v SPC,org-agenda-reset-view}
8176 @vindex org-agenda-span
8177 Switch to day/week/month/year view.  When switching to day or week view, this
8178 setting becomes the default for subsequent agenda refreshes.  Since month and
8179 year views are slow to create, they do not become the default.  A numeric
8180 prefix argument may be used to jump directly to a specific day of the year,
8181 ISO week, month, or year, respectively.  For example, @kbd{32 d} jumps to
8182 February 1st, @kbd{9 w} to ISO week number 9.  When setting day, week, or
8183 month view, a year may be encoded in the prefix argument as well.  For
8184 example, @kbd{200712 w} will jump to week 12 in 2007.  If such a year
8185 specification has only one or two digits, it will be mapped to the interval
8186 1938--2037.  @kbd{v @key{SPC}} will reset to what is set in
8187 @code{org-agenda-span}.
8189 @orgcmd{f,org-agenda-later}
8190 Go forward in time to display the following @code{org-agenda-current-span} days.
8191 For example, if the display covers a week, switch to the following week.
8192 With prefix arg, go forward that many times @code{org-agenda-current-span} days.
8194 @orgcmd{b,org-agenda-earlier}
8195 Go backward in time to display earlier dates.
8197 @orgcmd{.,org-agenda-goto-today}
8198 Go to today.
8200 @orgcmd{j,org-agenda-goto-date}
8201 Prompt for a date and go there.
8203 @orgcmd{J,org-agenda-clock-goto}
8204 Go to the currently clocked-in task @i{in the agenda buffer}.
8206 @orgcmd{D,org-agenda-toggle-diary}
8207 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
8209 @orgcmdkskc{v l,l,org-agenda-log-mode}
8210 @kindex v L
8211 @vindex org-log-done
8212 @vindex org-agenda-log-mode-items
8213 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
8214 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
8215 entries that have been clocked on that day.  You can configure the entry
8216 types that should be included in log mode using the variable
8217 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
8218 all possible logbook entries, including state changes.  When called with two
8219 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
8220 @kbd{v L} is equivalent to @kbd{C-u v l}.
8222 @orgcmdkskc{v [,[,org-agenda-manipulate-query-add}
8223 Include inactive timestamps into the current view.  Only for weekly/daily
8224 agenda and timeline views.
8226 @orgcmd{v a,org-agenda-archives-mode}
8227 @xorgcmd{v A,org-agenda-archives-mode 'files}
8228 Toggle Archives mode.  In Archives mode, trees that are marked
8229 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
8230 capital @kbd{A}, even all archive files are included.  To exit archives mode,
8231 press @kbd{v a} again.
8233 @orgcmdkskc{v R,R,org-agenda-clockreport-mode}
8234 @vindex org-agenda-start-with-clockreport-mode
8235 @vindex org-clock-report-include-clocking-task
8236 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
8237 always show a table with the clocked times for the timespan and file scope
8238 covered by the current agenda view.  The initial setting for this mode in new
8239 agenda buffers can be set with the variable
8240 @code{org-agenda-start-with-clockreport-mode}.  By using a prefix argument
8241 when toggling this mode (i.e., @kbd{C-u R}), the clock table will not show
8242 contributions from entries that are hidden by agenda filtering@footnote{Only
8243 tags filtering will be respected here, effort filtering is ignored.}.  See
8244 also the variable @code{org-clock-report-include-clocking-task}.
8246 @orgkey{v c}
8247 @vindex org-agenda-clock-consistency-checks
8248 Show overlapping clock entries, clocking gaps, and other clocking problems in
8249 the current agenda range.  You can then visit clocking lines and fix them
8250 manually.  See the variable @code{org-agenda-clock-consistency-checks} for
8251 information on how to customize the definition of what constituted a clocking
8252 problem.  To return to normal agenda display, press @kbd{l} to exit Logbook
8253 mode.
8255 @orgcmdkskc{v E,E,org-agenda-entry-text-mode}
8256 @vindex org-agenda-start-with-entry-text-mode
8257 @vindex org-agenda-entry-text-maxlines
8258 Toggle entry text mode.  In entry text mode, a number of lines from the Org
8259 outline node referenced by an agenda line will be displayed below the line.
8260 The maximum number of lines is given by the variable
8261 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
8262 prefix argument will temporarily modify that number to the prefix value.
8264 @orgcmd{G,org-agenda-toggle-time-grid}
8265 @vindex org-agenda-use-time-grid
8266 @vindex org-agenda-time-grid
8267 Toggle the time grid on and off.  See also the variables
8268 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
8270 @orgcmd{r,org-agenda-redo}
8271 Recreate the agenda buffer, for example to reflect the changes after
8272 modification of the timestamps of items with @kbd{S-@key{left}} and
8273 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
8274 argument is interpreted to create a selective list for a specific TODO
8275 keyword.
8276 @orgcmd{g,org-agenda-redo}
8277 Same as @kbd{r}.
8279 @orgcmdkskc{C-x C-s,s,org-save-all-org-buffers}
8280 Save all Org buffers in the current Emacs session, and also the locations of
8281 IDs.
8283 @orgcmd{C-c C-x C-c,org-agenda-columns}
8284 @vindex org-columns-default-format
8285 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
8286 view format is taken from the entry at point, or (if there is no entry at
8287 point), from the first entry in the agenda view.  So whatever the format for
8288 that entry would be in the original buffer (taken from a property, from a
8289 @code{#+COLUMNS} line, or from the default variable
8290 @code{org-columns-default-format}), will be used in the agenda.
8292 @orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
8293 Remove the restriction lock on the agenda, if it is currently restricted to a
8294 file or subtree (@pxref{Agenda files}).
8296 @tsubheading{Secondary filtering and query editing}
8297 @cindex filtering, by tag category and effort, in agenda
8298 @cindex tag filtering, in agenda
8299 @cindex category filtering, in agenda
8300 @cindex effort filtering, in agenda
8301 @cindex query editing, in agenda
8303 @orgcmd{<,org-agenda-filter-by-category}
8304 @vindex org-agenda-category-filter-preset
8306 Filter the current agenda view with respect to the category of the item at
8307 point.  Pressing @code{<} another time will remove this filter.  You can add
8308 a filter preset through the option @code{org-agenda-category-filter-preset}
8309 (see below.)
8311 @orgcmd{/,org-agenda-filter-by-tag}
8312 @vindex org-agenda-tag-filter-preset
8313 Filter the current agenda view with respect to a tag and/or effort estimates.
8314 The difference between this and a custom agenda command is that filtering is
8315 very fast, so that you can switch quickly between different filters without
8316 having to recreate the agenda.@footnote{Custom commands can preset a filter by
8317 binding the variable @code{org-agenda-tag-filter-preset} as an option.  This
8318 filter will then be applied to the view and persist as a basic filter through
8319 refreshes and more secondary filtering.  The filter is a global property of
8320 the entire agenda view---in a block agenda, you should only set this in the
8321 global options section, not in the section of an individual block.}
8323 You will be prompted for a tag selection letter; @key{SPC} will mean any tag at
8324 all.  Pressing @key{TAB} at that prompt will offer use completion to select a
8325 tag (including any tags that do not have a selection character).  The command
8326 then hides all entries that do not contain or inherit this tag.  When called
8327 with prefix arg, remove the entries that @emph{do} have the tag.  A second
8328 @kbd{/} at the prompt will turn off the filter and unhide any hidden entries.
8329 If the first key you press is either @kbd{+} or @kbd{-}, the previous filter
8330 will be narrowed by requiring or forbidding the selected additional tag.
8331 Instead of pressing @kbd{+} or @kbd{-} after @kbd{/}, you can also
8332 immediately use the @kbd{\} command.
8334 @vindex org-sort-agenda-noeffort-is-high
8335 In order to filter for effort estimates, you should set up allowed
8336 efforts globally, for example
8337 @lisp
8338 (setq org-global-properties
8339     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
8340 @end lisp
8341 You can then filter for an effort by first typing an operator, one of
8342 @kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
8343 estimate in your array of allowed values, where @kbd{0} means the 10th value.
8344 The filter will then restrict to entries with effort smaller-or-equal, equal,
8345 or larger-or-equal than the selected value.  If the digits 0--9 are not used
8346 as fast access keys to tags, you can also simply press the index digit
8347 directly without an operator.  In this case, @kbd{<} will be assumed.  For
8348 application of the operator, entries without a defined effort will be treated
8349 according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
8350 for tasks without effort definition, press @kbd{?} as the operator.
8352 Org also supports automatic, context-aware tag filtering.  If the variable
8353 @code{org-agenda-auto-exclude-function} is set to a user-defined function,
8354 that function can decide which tags should be excluded from the agenda
8355 automatically.  Once this is set, the @kbd{/} command then accepts @kbd{RET}
8356 as a sub-option key and runs the auto exclusion logic.  For example, let's
8357 say you use a @code{Net} tag to identify tasks which need network access, an
8358 @code{Errand} tag for errands in town, and a @code{Call} tag for making phone
8359 calls.  You could auto-exclude these tags based on the availability of the
8360 Internet, and outside of business hours, with something like this:
8362 @lisp
8363 @group
8364 (defun org-my-auto-exclude-function (tag)
8365   (and (cond
8366         ((string= tag "Net")
8367          (/= 0 (call-process "/sbin/ping" nil nil nil
8368                              "-c1" "-q" "-t1" "mail.gnu.org")))
8369         ((or (string= tag "Errand") (string= tag "Call"))
8370          (let ((hour (nth 2 (decode-time))))
8371            (or (< hour 8) (> hour 21)))))
8372        (concat "-" tag)))
8374 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
8375 @end group
8376 @end lisp
8378 @orgcmd{\\,org-agenda-filter-by-tag-refine}
8379 Narrow the current agenda filter by an additional condition.  When called with
8380 prefix arg, remove the entries that @emph{do} have the tag, or that do match
8381 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
8382 @kbd{-} as the first key after the @kbd{/} command.
8385 @kindex [
8386 @kindex ]
8387 @kindex @{
8388 @kindex @}
8389 @item [ ] @{ @}
8390 @table @i
8391 @item @r{in} search view
8392 add new search words (@kbd{[} and @kbd{]}) or new regular expressions
8393 (@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
8394 add a positive search term prefixed by @samp{+}, indicating that this search
8395 term @i{must} occur/match in the entry.  The closing bracket/brace will add a
8396 negative search term which @i{must not} occur/match in the entry for it to be
8397 selected.
8398 @end table
8400 @tsubheading{Remote editing}
8401 @cindex remote editing, from agenda
8403 @item 0--9
8404 Digit argument.
8406 @cindex undoing remote-editing events
8407 @cindex remote editing, undo
8408 @orgcmd{C-_,org-agenda-undo}
8409 Undo a change due to a remote editing command.  The change is undone
8410 both in the agenda buffer and in the remote buffer.
8412 @orgcmd{t,org-agenda-todo}
8413 Change the TODO state of the item, both in the agenda and in the
8414 original org file.
8416 @orgcmd{C-S-@key{right},org-agenda-todo-nextset}
8417 @orgcmd{C-S-@key{left},org-agenda-todo-previousset}
8418 Switch to the next/previous set of TODO keywords.
8420 @orgcmd{C-k,org-agenda-kill}
8421 @vindex org-agenda-confirm-kill
8422 Delete the current agenda item along with the entire subtree belonging
8423 to it in the original Org file.  If the text to be deleted remotely
8424 is longer than one line, the kill needs to be confirmed by the user.  See
8425 variable @code{org-agenda-confirm-kill}.
8427 @orgcmd{C-c C-w,org-agenda-refile}
8428 Refile the entry at point.
8430 @orgcmdkskc{C-c C-x C-a,a,org-agenda-archive-default-with-confirmation}
8431 @vindex org-archive-default-command
8432 Archive the subtree corresponding to the entry at point using the default
8433 archiving command set in @code{org-archive-default-command}.  When using the
8434 @code{a} key, confirmation will be required.
8436 @orgcmd{C-c C-x a,org-agenda-toggle-archive-tag}
8437 Toggle the ARCHIVE tag for the current headline.
8439 @orgcmd{C-c C-x A,org-agenda-archive-to-archive-sibling}
8440 Move the subtree corresponding to the current entry to its @emph{archive
8441 sibling}.
8443 @orgcmdkskc{C-c C-x C-s,$,org-agenda-archive}
8444 Archive the subtree corresponding to the current headline.  This means the
8445 entry will be moved to the configured archive location, most likely a
8446 different file.
8448 @orgcmd{T,org-agenda-show-tags}
8449 @vindex org-agenda-show-inherited-tags
8450 Show all tags associated with the current item.  This is useful if you have
8451 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
8452 tags of a headline occasionally.
8454 @orgcmd{:,org-agenda-set-tags}
8455 Set tags for the current headline.  If there is an active region in the
8456 agenda, change a tag for all headings in the region.
8458 @kindex ,
8459 @item ,
8460 Set the priority for the current item (@command{org-agenda-priority}).
8461 Org mode prompts for the priority character.  If you reply with @key{SPC},
8462 the priority cookie is removed from the entry.
8464 @orgcmd{P,org-agenda-show-priority}
8465 Display weighted priority of current item.
8467 @orgcmdkkc{+,S-@key{up},org-agenda-priority-up}
8468 Increase the priority of the current item.  The priority is changed in
8469 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
8470 key for this.
8472 @orgcmdkkc{-,S-@key{down},org-agenda-priority-down}
8473 Decrease the priority of the current item.
8475 @orgcmdkkc{z,C-c C-z,org-agenda-add-note}
8476 @vindex org-log-into-drawer
8477 Add a note to the entry.  This note will be recorded, and then filed to the
8478 same location where state change notes are put.  Depending on
8479 @code{org-log-into-drawer}, this may be inside a drawer.
8481 @orgcmd{C-c C-a,org-attach}
8482 Dispatcher for all command related to attachments.
8484 @orgcmd{C-c C-s,org-agenda-schedule}
8485 Schedule this item.  With prefix arg remove the scheduling timestamp
8487 @orgcmd{C-c C-d,org-agenda-deadline}
8488 Set a deadline for this item.  With prefix arg remove the deadline.
8490 @orgcmd{S-@key{right},org-agenda-do-date-later}
8491 Change the timestamp associated with the current line by one day into the
8492 future.  If the date is in the past, the first call to this command will move
8493 it to today.@*
8494 With a numeric prefix argument, change it by that many days.  For example,
8495 @kbd{3 6 5 S-@key{right}} will change it by a year.  With a @kbd{C-u} prefix,
8496 change the time by one hour.  If you immediately repeat the command, it will
8497 continue to change hours even without the prefix arg.  With a double @kbd{C-u
8498 C-u} prefix, do the same for changing minutes.@*
8499 The stamp is changed in the original Org file, but the change is not directly
8500 reflected in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
8502 @orgcmd{S-@key{left},org-agenda-do-date-earlier}
8503 Change the timestamp associated with the current line by one day
8504 into the past.
8506 @orgcmd{>,org-agenda-date-prompt}
8507 Change the timestamp associated with the current line.  The key @kbd{>} has
8508 been chosen, because it is the same as @kbd{S-.}  on my keyboard.
8510 @orgcmd{I,org-agenda-clock-in}
8511 Start the clock on the current item.  If a clock is running already, it
8512 is stopped first.
8514 @orgcmd{O,org-agenda-clock-out}
8515 Stop the previously started clock.
8517 @orgcmd{X,org-agenda-clock-cancel}
8518 Cancel the currently running clock.
8520 @orgcmd{J,org-agenda-clock-goto}
8521 Jump to the running clock in another window.
8523 @orgcmd{k,org-agenda-capture}
8524 Like @code{org-capture}, but use the date at point as the default date for
8525 the capture template.  See @var{org-capture-use-agenda-date} to make this
8526 the default behavior of @code{org-capture}.
8527 @cindex capturing, from agenda
8528 @vindex org-capture-use-agenda-date
8530 @tsubheading{Bulk remote editing selected entries}
8531 @cindex remote editing, bulk, from agenda
8532 @vindex org-agenda-bulk-persistent-marks
8533 @vindex org-agenda-bulk-custom-functions
8535 @orgcmd{m,org-agenda-bulk-mark}
8536 Mark the entry at point for bulk action.  With prefix arg, mark that many
8537 successive entries.
8539 @orgcmd{%,org-agenda-bulk-mark-regexp}
8540 Mark entries matching a regular expression for bulk action.
8542 @orgcmd{u,org-agenda-bulk-unmark}
8543 Unmark entry for bulk action.
8545 @orgcmd{U,org-agenda-bulk-remove-all-marks}
8546 Unmark all marked entries for bulk action.
8548 @orgcmd{B,org-agenda-bulk-action}
8549 Bulk action: act on all marked entries in the agenda.  This will prompt for
8550 another key to select the action to be applied.  The prefix arg to @kbd{B}
8551 will be passed through to the @kbd{s} and @kbd{d} commands, to bulk-remove
8552 these special timestamps.  By default, marks are removed after the bulk.  If
8553 you want them to persist, set @code{org-agenda-bulk-persistent-marks} to
8554 @code{t} or hit @kbd{p} at the prompt.
8556 @example
8557 *  @r{Toggle persistent marks.}
8558 $  @r{Archive all selected entries.}
8559 A  @r{Archive entries by moving them to their respective archive siblings.}
8560 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
8561    @r{changes the state of all selected entries, bypassing blocking and}
8562    @r{suppressing logging notes (but not timestamps).}
8563 +  @r{Add a tag to all selected entries.}
8564 -  @r{Remove a tag from all selected entries.}
8565 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
8566    @r{by a fixed number of days, use something starting with double plus}
8567    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
8568 d  @r{Set deadline to a specific date.}
8569 r  @r{Prompt for a single refile target and move all entries.  The entries}
8570    @r{will no longer be in the agenda; refresh (@kbd{g}) to bring them back.}
8571 S  @r{Reschedule randomly into the coming N days.  N will be prompted for.}
8572    @r{With prefix arg (@kbd{C-u B S}), scatter only across weekdays.}
8573 f  @r{Apply a function@footnote{You can also create persistent custom functions through@code{org-agenda-bulk-custom-functions}.} to marked entries.}
8574    @r{For example, the function below sets the CATEGORY property of the}
8575    @r{entries to web.}
8576    @r{(defun set-category ()}
8577    @r{  (interactive "P")}
8578    @r{  (let* ((marker (or (org-get-at-bol 'org-hd-marker)}
8579    @r{                     (org-agenda-error)))}
8580    @r{            (buffer (marker-buffer marker)))}
8581    @r{       (with-current-buffer buffer}
8582    @r{         (save-excursion}
8583    @r{           (save-restriction}
8584    @r{             (widen)}
8585    @r{             (goto-char marker)}
8586    @r{             (org-back-to-heading t)}
8587    @r{             (org-set-property "CATEGORY" "web"))))))}
8588 @end example
8591 @tsubheading{Calendar commands}
8592 @cindex calendar commands, from agenda
8594 @orgcmd{c,org-agenda-goto-calendar}
8595 Open the Emacs calendar and move to the date at the agenda cursor.
8597 @orgcmd{c,org-calendar-goto-agenda}
8598 When in the calendar, compute and show the Org mode agenda for the
8599 date at the cursor.
8601 @cindex diary entries, creating from agenda
8602 @orgcmd{i,org-agenda-diary-entry}
8603 @vindex org-agenda-diary-file
8604 Insert a new entry into the diary, using the date at the cursor and (for
8605 block entries) the date at the mark.  This will add to the Emacs diary
8606 file@footnote{This file is parsed for the agenda when
8607 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
8608 command in the calendar.  The diary file will pop up in another window, where
8609 you can add the entry.
8611 If you configure @code{org-agenda-diary-file} to point to an Org mode file,
8612 Org will create entries (in Org mode syntax) in that file instead.  Most
8613 entries will be stored in a date-based outline tree that will later make it
8614 easy to archive appointments from previous months/years.  The tree will be
8615 built under an entry with a @code{DATE_TREE} property, or else with years as
8616 top-level entries.  Emacs will prompt you for the entry text---if you specify
8617 it, the entry will be created in @code{org-agenda-diary-file} without further
8618 interaction.  If you directly press @key{RET} at the prompt without typing
8619 text, the target file will be shown in another window for you to finish the
8620 entry there.  See also the @kbd{k r} command.
8622 @orgcmd{M,org-agenda-phases-of-moon}
8623 Show the phases of the moon for the three months around current date.
8625 @orgcmd{S,org-agenda-sunrise-sunset}
8626 Show sunrise and sunset times.  The geographical location must be set
8627 with calendar variables, see the documentation for the Emacs calendar.
8629 @orgcmd{C,org-agenda-convert-date}
8630 Convert the date at cursor into many other cultural and historic
8631 calendars.
8633 @orgcmd{H,org-agenda-holidays}
8634 Show holidays for three months around the cursor date.
8636 @item M-x org-export-icalendar-combine-agenda-files
8637 Export a single iCalendar file containing entries from all agenda files.
8638 This is a globally available command, and also available in the agenda menu.
8640 @tsubheading{Exporting to a file}
8641 @orgcmd{C-x C-w,org-agenda-write}
8642 @cindex exporting agenda views
8643 @cindex agenda views, exporting
8644 @vindex org-agenda-exporter-settings
8645 Write the agenda view to a file.  Depending on the extension of the selected
8646 file name, the view will be exported as HTML (extension @file{.html} or
8647 @file{.htm}), Postscript (extension @file{.ps}), PDF (extension @file{.pdf}),
8648 and plain text (any other extension).  When called with a @kbd{C-u} prefix
8649 argument, immediately open the newly created file.  Use the variable
8650 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
8651 for @file{htmlize} to be used during export.
8653 @tsubheading{Quit and Exit}
8654 @orgcmd{q,org-agenda-quit}
8655 Quit agenda, remove the agenda buffer.
8657 @cindex agenda files, removing buffers
8658 @orgcmd{x,org-agenda-exit}
8659 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
8660 for the compilation of the agenda.  Buffers created by the user to
8661 visit Org files will not be removed.
8662 @end table
8665 @node Custom agenda views, Exporting Agenda Views, Agenda commands, Agenda Views
8666 @section Custom agenda views
8667 @cindex custom agenda views
8668 @cindex agenda views, custom
8670 Custom agenda commands serve two purposes: to store and quickly access
8671 frequently used TODO and tags searches, and to create special composite
8672 agenda buffers.  Custom agenda commands will be accessible through the
8673 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
8675 @menu
8676 * Storing searches::            Type once, use often
8677 * Block agenda::                All the stuff you need in a single buffer
8678 * Setting Options::             Changing the rules
8679 @end menu
8681 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
8682 @subsection Storing searches
8684 The first application of custom searches is the definition of keyboard
8685 shortcuts for frequently used searches, either creating an agenda
8686 buffer, or a sparse tree (the latter covering of course only the current
8687 buffer).
8688 @kindex C-c a C
8689 @vindex org-agenda-custom-commands
8690 @cindex agenda views, main example
8691 @cindex tags, as an agenda view
8692 @cindex todo, as an agenda view
8693 @cindex tags-todo
8694 @cindex todo-tree
8695 @cindex occur-tree
8696 @cindex tags-tree
8698 Custom commands are configured in the variable
8699 @code{org-agenda-custom-commands}.  You can customize this variable, for
8700 example by pressing @kbd{C-c a C}.  You can also directly set it with Emacs
8701 Lisp in @file{.emacs}.  The following example contains all valid search
8702 types:
8704 @lisp
8705 @group
8706 (setq org-agenda-custom-commands
8707       '(("w" todo "WAITING")
8708         ("W" todo-tree "WAITING")
8709         ("u" tags "+boss-urgent")
8710         ("v" tags-todo "+boss-urgent")
8711         ("U" tags-tree "+boss-urgent")
8712         ("f" occur-tree "\\<FIXME\\>")
8713         ("h" . "HOME+Name tags searches") ; description for "h" prefix
8714         ("hl" tags "+home+Lisa")
8715         ("hp" tags "+home+Peter")
8716         ("hk" tags "+home+Kim")))
8717 @end group
8718 @end lisp
8720 @noindent
8721 The initial string in each entry defines the keys you have to press
8722 after the dispatcher command @kbd{C-c a} in order to access the command.
8723 Usually this will be just a single character, but if you have many
8724 similar commands, you can also define two-letter combinations where the
8725 first character is the same in several combinations and serves as a
8726 prefix key@footnote{You can provide a description for a prefix key by
8727 inserting a cons cell with the prefix and the description.}.  The second
8728 parameter is the search type, followed by the string or regular
8729 expression to be used for the matching.  The example above will
8730 therefore define:
8732 @table @kbd
8733 @item C-c a w
8734 as a global search for TODO entries with @samp{WAITING} as the TODO
8735 keyword
8736 @item C-c a W
8737 as the same search, but only in the current buffer and displaying the
8738 results as a sparse tree
8739 @item C-c a u
8740 as a global tags search for headlines marked @samp{:boss:} but not
8741 @samp{:urgent:}
8742 @item C-c a v
8743 as the same search as @kbd{C-c a u}, but limiting the search to
8744 headlines that are also TODO items
8745 @item C-c a U
8746 as the same search as @kbd{C-c a u}, but only in the current buffer and
8747 displaying the result as a sparse tree
8748 @item C-c a f
8749 to create a sparse tree (again: current buffer only) with all entries
8750 containing the word @samp{FIXME}
8751 @item C-c a h
8752 as a prefix command for a HOME tags search where you have to press an
8753 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
8754 Peter, or Kim) as additional tag to match.
8755 @end table
8757 Note that the @code{*-tree} agenda views need to be called from an
8758 Org buffer as they operate on the current buffer only.
8760 @node Block agenda, Setting Options, Storing searches, Custom agenda views
8761 @subsection Block agenda
8762 @cindex block agenda
8763 @cindex agenda, with block views
8765 Another possibility is the construction of agenda views that comprise
8766 the results of @emph{several} commands, each of which creates a block in
8767 the agenda buffer.  The available commands include @code{agenda} for the
8768 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
8769 for the global TODO list (as constructed with @kbd{C-c a t}), and the
8770 matching commands discussed above: @code{todo}, @code{tags}, and
8771 @code{tags-todo}.  Here are two examples:
8773 @lisp
8774 @group
8775 (setq org-agenda-custom-commands
8776       '(("h" "Agenda and Home-related tasks"
8777          ((agenda "")
8778           (tags-todo "home")
8779           (tags "garden")))
8780         ("o" "Agenda and Office-related tasks"
8781          ((agenda "")
8782           (tags-todo "work")
8783           (tags "office")))))
8784 @end group
8785 @end lisp
8787 @noindent
8788 This will define @kbd{C-c a h} to create a multi-block view for stuff
8789 you need to attend to at home.  The resulting agenda buffer will contain
8790 your agenda for the current week, all TODO items that carry the tag
8791 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
8792 command @kbd{C-c a o} provides a similar view for office tasks.
8794 @node Setting Options,  , Block agenda, Custom agenda views
8795 @subsection Setting options for custom commands
8796 @cindex options, for custom agenda views
8798 @vindex org-agenda-custom-commands
8799 Org mode contains a number of variables regulating agenda construction
8800 and display.  The global variables define the behavior for all agenda
8801 commands, including the custom commands.  However, if you want to change
8802 some settings just for a single custom view, you can do so.  Setting
8803 options requires inserting a list of variable names and values at the
8804 right spot in @code{org-agenda-custom-commands}.  For example:
8806 @lisp
8807 @group
8808 (setq org-agenda-custom-commands
8809       '(("w" todo "WAITING"
8810          ((org-agenda-sorting-strategy '(priority-down))
8811           (org-agenda-prefix-format "  Mixed: ")))
8812         ("U" tags-tree "+boss-urgent"
8813          ((org-show-following-heading nil)
8814           (org-show-hierarchy-above nil)))
8815         ("N" search ""
8816          ((org-agenda-files '("~org/notes.org"))
8817           (org-agenda-text-search-extra-files nil)))))
8818 @end group
8819 @end lisp
8821 @noindent
8822 Now the @kbd{C-c a w} command will sort the collected entries only by
8823 priority, and the prefix format is modified to just say @samp{  Mixed: }
8824 instead of giving the category of the entry.  The sparse tags tree of
8825 @kbd{C-c a U} will now turn out ultra-compact, because neither the
8826 headline hierarchy above the match, nor the headline following the match
8827 will be shown.  The command @kbd{C-c a N} will do a text search limited
8828 to only a single file.
8830 @vindex org-agenda-custom-commands
8831 For command sets creating a block agenda,
8832 @code{org-agenda-custom-commands} has two separate spots for setting
8833 options.  You can add options that should be valid for just a single
8834 command in the set, and options that should be valid for all commands in
8835 the set.  The former are just added to the command entry; the latter
8836 must come after the list of command entries.  Going back to the block
8837 agenda example (@pxref{Block agenda}), let's change the sorting strategy
8838 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
8839 the results for GARDEN tags query in the opposite order,
8840 @code{priority-up}.  This would look like this:
8842 @lisp
8843 @group
8844 (setq org-agenda-custom-commands
8845       '(("h" "Agenda and Home-related tasks"
8846          ((agenda)
8847           (tags-todo "home")
8848           (tags "garden"
8849                 ((org-agenda-sorting-strategy '(priority-up)))))
8850          ((org-agenda-sorting-strategy '(priority-down))))
8851         ("o" "Agenda and Office-related tasks"
8852          ((agenda)
8853           (tags-todo "work")
8854           (tags "office")))))
8855 @end group
8856 @end lisp
8858 As you see, the values and parentheses setting is a little complex.
8859 When in doubt, use the customize interface to set this variable---it
8860 fully supports its structure.  Just one caveat: when setting options in
8861 this interface, the @emph{values} are just Lisp expressions.  So if the
8862 value is a string, you need to add the double-quotes around the value
8863 yourself.
8865 @vindex org-agenda-custom-commands-contexts
8866 To control whether an agenda command should be accessible from a specific
8867 context, you can customize @var{org-agenda-custom-commands-contexts}.  Let's
8868 say for example that you have an agenda commands @code{"o"} displaying a view
8869 that you only need when reading emails.  Then you would configure this option
8870 like this:
8872 @example
8873 (setq org-agenda-custom-commands-contexts
8874       '(("o" (in-mode . "message-mode"))))
8875 @end example
8877 You can also tell that the command key @code{"o"} should refer to another
8878 command key @code{"r"}.  In that case, add this command key like this:
8880 @example
8881 (setq org-agenda-custom-commands-contexts
8882       '(("o" "r" (in-mode . "message-mode"))))
8883 @end example
8885 See the docstring of the variable for more information.
8887 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
8888 @section Exporting Agenda Views
8889 @cindex agenda views, exporting
8891 If you are away from your computer, it can be very useful to have a printed
8892 version of some agenda views to carry around.  Org mode can export custom
8893 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
8894 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
8895 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
8896 a PDF file will also create the postscript file.}, and iCalendar files.  If
8897 you want to do this only occasionally, use the command
8899 @table @kbd
8900 @orgcmd{C-x C-w,org-agenda-write}
8901 @cindex exporting agenda views
8902 @cindex agenda views, exporting
8903 @vindex org-agenda-exporter-settings
8904 Write the agenda view to a file.  Depending on the extension of the selected
8905 file name, the view will be exported as HTML (extension @file{.html} or
8906 @file{.htm}), Postscript (extension @file{.ps}), iCalendar (extension
8907 @file{.ics}), or plain text (any other extension).  Use the variable
8908 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
8909 for @file{htmlize} to be used during export, for example
8911 @vindex org-agenda-add-entry-text-maxlines
8912 @vindex htmlize-output-type
8913 @vindex ps-number-of-columns
8914 @vindex ps-landscape-mode
8915 @lisp
8916 (setq org-agenda-exporter-settings
8917       '((ps-number-of-columns 2)
8918         (ps-landscape-mode t)
8919         (org-agenda-add-entry-text-maxlines 5)
8920         (htmlize-output-type 'css)))
8921 @end lisp
8922 @end table
8924 If you need to export certain agenda views frequently, you can associate
8925 any custom agenda command with a list of output file names
8926 @footnote{If you want to store standard views like the weekly agenda
8927 or the global TODO list as well, you need to define custom commands for
8928 them in order to be able to specify file names.}.  Here is an example
8929 that first defines custom commands for the agenda and the global
8930 TODO list, together with a number of files to which to export them.
8931 Then we define two block agenda commands and specify file names for them
8932 as well.  File names can be relative to the current working directory,
8933 or absolute.
8935 @lisp
8936 @group
8937 (setq org-agenda-custom-commands
8938       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
8939         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
8940         ("h" "Agenda and Home-related tasks"
8941          ((agenda "")
8942           (tags-todo "home")
8943           (tags "garden"))
8944          nil
8945          ("~/views/home.html"))
8946         ("o" "Agenda and Office-related tasks"
8947          ((agenda)
8948           (tags-todo "work")
8949           (tags "office"))
8950          nil
8951          ("~/views/office.ps" "~/calendars/office.ics"))))
8952 @end group
8953 @end lisp
8955 The extension of the file name determines the type of export.  If it is
8956 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
8957 the buffer to HTML and save it to this file name.  If the extension is
8958 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
8959 Postscript output.  If the extension is @file{.ics}, iCalendar export is
8960 run export over all files that were used to construct the agenda, and
8961 limit the export to entries listed in the agenda.  Any other
8962 extension produces a plain ASCII file.
8964 The export files are @emph{not} created when you use one of those
8965 commands interactively because this might use too much overhead.
8966 Instead, there is a special command to produce @emph{all} specified
8967 files in one step:
8969 @table @kbd
8970 @orgcmd{C-c a e,org-store-agenda-views}
8971 Export all agenda views that have export file names associated with
8972 them.
8973 @end table
8975 You can use the options section of the custom agenda commands to also
8976 set options for the export commands.  For example:
8978 @lisp
8979 (setq org-agenda-custom-commands
8980       '(("X" agenda ""
8981          ((ps-number-of-columns 2)
8982           (ps-landscape-mode t)
8983           (org-agenda-prefix-format " [ ] ")
8984           (org-agenda-with-colors nil)
8985           (org-agenda-remove-tags t))
8986          ("theagenda.ps"))))
8987 @end lisp
8989 @noindent
8990 This command sets two options for the Postscript exporter, to make it
8991 print in two columns in landscape format---the resulting page can be cut
8992 in two and then used in a paper agenda.  The remaining settings modify
8993 the agenda prefix to omit category and scheduling information, and
8994 instead include a checkbox to check off items.  We also remove the tags
8995 to make the lines compact, and we don't want to use colors for the
8996 black-and-white printer.  Settings specified in
8997 @code{org-agenda-exporter-settings} will also apply, but the settings
8998 in @code{org-agenda-custom-commands} take precedence.
9000 @noindent
9001 From the command line you may also use
9002 @example
9003 emacs -eval (org-batch-store-agenda-views) -kill
9004 @end example
9005 @noindent
9006 or, if you need to modify some parameters@footnote{Quoting depends on the
9007 system you use, please check the FAQ for examples.}
9008 @example
9009 emacs -eval '(org-batch-store-agenda-views                      \
9010               org-agenda-span (quote month)                     \
9011               org-agenda-start-day "2007-11-01"                 \
9012               org-agenda-include-diary nil                      \
9013               org-agenda-files (quote ("~/org/project.org")))'  \
9014       -kill
9015 @end example
9016 @noindent
9017 which will create the agenda views restricted to the file
9018 @file{~/org/project.org}, without diary entries and with a 30-day
9019 extent.
9021 You can also extract agenda information in a way that allows further
9022 processing by other programs.  See @ref{Extracting agenda information}, for
9023 more information.
9026 @node Agenda column view,  , Exporting Agenda Views, Agenda Views
9027 @section Using column view in the agenda
9028 @cindex column view, in agenda
9029 @cindex agenda, column view
9031 Column view (@pxref{Column view}) is normally used to view and edit
9032 properties embedded in the hierarchical structure of an Org file.  It can be
9033 quite useful to use column view also from the agenda, where entries are
9034 collected by certain criteria.
9036 @table @kbd
9037 @orgcmd{C-c C-x C-c,org-agenda-columns}
9038 Turn on column view in the agenda.
9039 @end table
9041 To understand how to use this properly, it is important to realize that the
9042 entries in the agenda are no longer in their proper outline environment.
9043 This causes the following issues:
9045 @enumerate
9046 @item
9047 @vindex org-columns-default-format
9048 @vindex org-overriding-columns-format
9049 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
9050 entries in the agenda are collected from different files, and different files
9051 may have different @code{COLUMNS} formats, this is a non-trivial problem.
9052 Org first checks if the variable @code{org-agenda-overriding-columns-format} is
9053 currently set, and if so, takes the format from there.  Otherwise it takes
9054 the format associated with the first item in the agenda, or, if that item
9055 does not have a specific format (defined in a property, or in its file), it
9056 uses @code{org-columns-default-format}.
9057 @item
9058 @cindex property, special, CLOCKSUM
9059 If any of the columns has a summary type defined (@pxref{Column attributes}),
9060 turning on column view in the agenda will visit all relevant agenda files and
9061 make sure that the computations of this property are up to date.  This is
9062 also true for the special @code{CLOCKSUM} property.  Org will then sum the
9063 values displayed in the agenda.  In the daily/weekly agenda, the sums will
9064 cover a single day; in all other views they cover the entire block.  It is
9065 vital to realize that the agenda may show the same entry @emph{twice} (for
9066 example as scheduled and as a deadline), and it may show two entries from the
9067 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
9068 cases, the summation in the agenda will lead to incorrect results because
9069 some values will count double.
9070 @item
9071 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
9072 the entire clocked time for this item.  So even in the daily/weekly agenda,
9073 the clocksum listed in column view may originate from times outside the
9074 current view.  This has the advantage that you can compare these values with
9075 a column listing the planned total effort for a task---one of the major
9076 applications for column view in the agenda.  If you want information about
9077 clocked time in the displayed period use clock table mode (press @kbd{R} in
9078 the agenda).
9080 @item
9081 @cindex property, special, CLOCKSUM_T
9082 When the column view in the agenda shows the @code{CLOCKSUM_T}, that is
9083 always today's clocked time for this item.  So even in the weekly agenda,
9084 the clocksum listed in column view only originates from today.  This lets
9085 you compare the time you spent on a task for today, with the time already
9086 spent (via @code{CLOCKSUM}) and with the planned total effort for it.
9087 @end enumerate
9090 @node Markup, Exporting, Agenda Views, Top
9091 @chapter Markup for rich export
9093 When exporting Org mode documents, the exporter tries to reflect the
9094 structure of the document as accurately as possible in the backend.  Since
9095 export targets like HTML, @LaTeX{} allow much richer formatting, Org mode has
9096 rules on how to prepare text for rich export.  This section summarizes the
9097 markup rules used in an Org mode buffer.
9099 @menu
9100 * Structural markup elements::  The basic structure as seen by the exporter
9101 * Images and tables::           Tables and Images will be included
9102 * Literal examples::            Source code examples with special formatting
9103 * Include files::               Include additional files into a document
9104 * Index entries::               Making an index
9105 * Macro replacement::           Use macros to create complex output
9106 * Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
9107 @end menu
9109 @node Structural markup elements, Images and tables, Markup, Markup
9110 @section Structural markup elements
9112 @menu
9113 * Document title::              Where the title is taken from
9114 * Headings and sections::       The document structure as seen by the exporter
9115 * Table of contents::           The if and where of the table of contents
9116 * Initial text::                Text before the first heading?
9117 * Lists::                       Lists
9118 * Paragraphs::                  Paragraphs
9119 * Footnote markup::             Footnotes
9120 * Emphasis and monospace::      Bold, italic, etc.
9121 * Horizontal rules::            Make a line
9122 * Comment lines::               What will *not* be exported
9123 @end menu
9125 @node Document title, Headings and sections, Structural markup elements, Structural markup elements
9126 @subheading Document title
9127 @cindex document title, markup rules
9129 @noindent
9130 The title of the exported document is taken from the special line
9132 @cindex #+TITLE
9133 @example
9134 #+TITLE: This is the title of the document
9135 @end example
9137 @noindent
9138 If this line does not exist, the title is derived from the first non-empty,
9139 non-comment line in the buffer.  If no such line exists, or if you have
9140 turned off exporting of the text before the first headline (see below), the
9141 title will be the file name without extension.
9143 @cindex property, EXPORT_TITLE
9144 If you are exporting only a subtree by marking is as the region, the heading
9145 of the subtree will become the title of the document.  If the subtree has a
9146 property @code{EXPORT_TITLE}, that will take precedence.
9148 @node Headings and sections, Table of contents, Document title, Structural markup elements
9149 @subheading Headings and sections
9150 @cindex headings and sections, markup rules
9152 @vindex org-export-headline-levels
9153 The outline structure of the document as described in @ref{Document
9154 Structure}, forms the basis for defining sections of the exported document.
9155 However, since the outline structure is also used for (for example) lists of
9156 tasks, only the first three outline levels will be used as headings.  Deeper
9157 levels will become itemized lists.  You can change the location of this
9158 switch globally by setting the variable @code{org-export-headline-levels}, or on a
9159 per-file basis with a line
9161 @cindex #+OPTIONS
9162 @example
9163 #+OPTIONS: H:4
9164 @end example
9166 @node Table of contents, Initial text, Headings and sections, Structural markup elements
9167 @subheading Table of contents
9168 @cindex table of contents, markup rules
9170 @vindex org-export-with-toc
9171 The table of contents is normally inserted directly before the first headline
9172 of the file.  If you would like to get it to a different location, insert the
9173 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
9174 location.  The depth of the table of contents is by default the same as the
9175 number of headline levels, but you can choose a smaller number, or turn off
9176 the table of contents entirely, by configuring the variable
9177 @code{org-export-with-toc}, or on a per-file basis with a line like
9179 @example
9180 #+OPTIONS: toc:2          (only to two levels in TOC)
9181 #+OPTIONS: toc:nil        (no TOC at all)
9182 @end example
9184 @node Initial text, Lists, Table of contents, Structural markup elements
9185 @subheading Text before the first headline
9186 @cindex text before first headline, markup rules
9187 @cindex #+TEXT
9189 Org mode normally exports the text before the first headline, and even uses
9190 the first line as the document title.  The text will be fully marked up.  If
9191 you need to include literal HTML or @LaTeX{} code, use the special constructs
9192 described below in the sections for the individual exporters.
9194 @vindex org-export-skip-text-before-1st-heading
9195 Some people like to use the space before the first headline for setup and
9196 internal links and therefore would like to control the exported text before
9197 the first headline in a different way.  You can do so by setting the variable
9198 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
9199 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
9201 @noindent
9202 If you still want to have some text before the first headline, use the
9203 @code{#+TEXT} construct:
9205 @example
9206 #+OPTIONS: skip:t
9207 #+TEXT: This text will go before the *first* headline.
9208 #+TEXT: [TABLE-OF-CONTENTS]
9209 #+TEXT: This goes between the table of contents and the *first* headline
9210 @end example
9212 @node Lists, Paragraphs, Initial text, Structural markup elements
9213 @subheading Lists
9214 @cindex lists, markup rules
9216 Plain lists as described in @ref{Plain lists}, are translated to the backend's
9217 syntax for such lists.  Most backends support unordered, ordered, and
9218 description lists.
9220 @node Paragraphs, Footnote markup, Lists, Structural markup elements
9221 @subheading Paragraphs, line breaks, and quoting
9222 @cindex paragraphs, markup rules
9224 Paragraphs are separated by at least one empty line.  If you need to enforce
9225 a line break within a paragraph, use @samp{\\} at the end of a line.
9227 To keep the line breaks in a region, but otherwise use normal formatting, you
9228 can use this construct, which can also be used to format poetry.
9230 @cindex #+BEGIN_VERSE
9231 @example
9232 #+BEGIN_VERSE
9233  Great clouds overhead
9234  Tiny black birds rise and fall
9235  Snow covers Emacs
9237      -- AlexSchroeder
9238 #+END_VERSE
9239 @end example
9241 When quoting a passage from another document, it is customary to format this
9242 as a paragraph that is indented on both the left and the right margin.  You
9243 can include quotations in Org mode documents like this:
9245 @cindex #+BEGIN_QUOTE
9246 @example
9247 #+BEGIN_QUOTE
9248 Everything should be made as simple as possible,
9249 but not any simpler -- Albert Einstein
9250 #+END_QUOTE
9251 @end example
9253 If you would like to center some text, do it like this:
9254 @cindex #+BEGIN_CENTER
9255 @example
9256 #+BEGIN_CENTER
9257 Everything should be made as simple as possible, \\
9258 but not any simpler
9259 #+END_CENTER
9260 @end example
9263 @node Footnote markup, Emphasis and monospace, Paragraphs, Structural markup elements
9264 @subheading Footnote markup
9265 @cindex footnotes, markup rules
9266 @cindex @file{footnote.el}
9268 Footnotes defined in the way described in @ref{Footnotes}, will be exported
9269 by all backends.  Org allows multiple references to the same note, and
9270 multiple footnotes side by side.
9272 @node Emphasis and monospace, Horizontal rules, Footnote markup, Structural markup elements
9273 @subheading Emphasis and monospace
9275 @cindex underlined text, markup rules
9276 @cindex bold text, markup rules
9277 @cindex italic text, markup rules
9278 @cindex verbatim text, markup rules
9279 @cindex code text, markup rules
9280 @cindex strike-through text, markup rules
9281 @vindex org-fontify-emphasized-text
9282 @vindex org-emphasis-regexp-components
9283 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
9284 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
9285 in the code and verbatim string is not processed for Org mode specific
9286 syntax; it is exported verbatim.
9288 To turn off fontification for marked up text, you can set
9289 @code{org-fontify-emphasized-text} to @code{nil}.  To fine tune what
9290 characters are allowed before and after the special characters, see
9291 @code{org-emphasis-regexp-components}.
9293 @node Horizontal rules, Comment lines, Emphasis and monospace, Structural markup elements
9294 @subheading  Horizontal rules
9295 @cindex horizontal rules, markup rules
9296 A line consisting of only dashes, and at least 5 of them, will be exported as
9297 a horizontal line (@samp{<hr/>} in HTML and @code{\hrule} in @LaTeX{}).
9299 @node Comment lines,  , Horizontal rules, Structural markup elements
9300 @subheading Comment lines
9301 @cindex comment lines
9302 @cindex exporting, not
9303 @cindex #+BEGIN_COMMENT
9305 Lines starting with zero or more whitespace characters followed by one
9306 @samp{#} and a whitespace are treated as comments and will never be exported.
9307 Also entire subtrees starting with the word @samp{COMMENT} will never be
9308 exported.  Finally, regions surrounded by @samp{#+BEGIN_COMMENT}
9309 ... @samp{#+END_COMMENT} will not be exported.
9311 @table @kbd
9312 @kindex C-c ;
9313 @item C-c ;
9314 Toggle the COMMENT keyword at the beginning of an entry.
9315 @end table
9318 @node Images and tables, Literal examples, Structural markup elements, Markup
9319 @section Images and Tables
9321 @cindex tables, markup rules
9322 @cindex #+CAPTION
9323 @cindex #+LABEL
9324 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
9325 the @file{table.el} package will be exported properly.  For Org mode tables,
9326 the lines before the first horizontal separator line will become table header
9327 lines.  You can use the following lines somewhere before the table to assign
9328 a caption and a label for cross references, and in the text you can refer to
9329 the object with @code{\ref@{tab:basic-data@}}:
9331 @example
9332 #+CAPTION: This is the caption for the next table (or link)
9333 #+LABEL:   tab:basic-data
9334    | ... | ...|
9335    |-----|----|
9336 @end example
9338 Optionally, the caption can take the form:
9339 @example
9340 #+CAPTION: [Caption for list of figures]@{Caption for table (or link).@}
9341 @end example
9343 @cindex inlined images, markup rules
9344 Some backends (HTML and @LaTeX{}) allow you to directly include images into
9345 the exported document.  Org does this, if a link to an image files does not
9346 have a description part, for example @code{[[./img/a.jpg]]}.  If you wish to
9347 define a caption for the image and maybe a label for internal cross
9348 references, make sure that the link is on a line by itself and precede it
9349 with @code{#+CAPTION} and @code{#+LABEL} as follows:
9351 @example
9352 #+CAPTION: This is the caption for the next figure link (or table)
9353 #+LABEL:   fig:SED-HR4049
9354 [[./img/a.jpg]]
9355 @end example
9357 You may also define additional attributes for the figure.  As this is
9358 backend-specific, see the sections about the individual backends for more
9359 information.
9361 @xref{Handling links,the discussion of image links}.
9363 @node Literal examples, Include files, Images and tables, Markup
9364 @section Literal examples
9365 @cindex literal examples, markup rules
9366 @cindex code line references, markup rules
9368 You can include literal examples that should not be subjected to
9369 markup.  Such examples will be typeset in monospace, so this is well suited
9370 for source code and similar examples.
9371 @cindex #+BEGIN_EXAMPLE
9373 @example
9374 #+BEGIN_EXAMPLE
9375 Some example from a text file.
9376 #+END_EXAMPLE
9377 @end example
9379 Note that such blocks may be @i{indented} in order to align nicely with
9380 indented text and in particular with plain list structure (@pxref{Plain
9381 lists}).  For simplicity when using small examples, you can also start the
9382 example lines with a colon followed by a space.  There may also be additional
9383 whitespace before the colon:
9385 @example
9386 Here is an example
9387    : Some example from a text file.
9388 @end example
9390 @cindex formatting source code, markup rules
9391 If the example is source code from a programming language, or any other text
9392 that can be marked up by font-lock in Emacs, you can ask for the example to
9393 look like the fontified Emacs buffer@footnote{This works automatically for
9394 the HTML backend (it requires version 1.34 of the @file{htmlize.el} package,
9395 which is distributed with Org).  Fontified code chunks in @LaTeX{} can be
9396 achieved using either the listings or the
9397 @url{http://code.google.com/p/minted, minted,} package.  Refer to
9398 @code{org-latex-listings} documentation for details.}.  This is done
9399 with the @samp{src} block, where you also need to specify the name of the
9400 major mode that should be used to fontify the example@footnote{Code in
9401 @samp{src} blocks may also be evaluated either interactively or on export.
9402 See @pxref{Working With Source Code} for more information on evaluating code
9403 blocks.}, see @ref{Easy Templates} for shortcuts to easily insert code
9404 blocks.
9405 @cindex #+BEGIN_SRC
9407 @example
9408 #+BEGIN_SRC emacs-lisp
9409   (defun org-xor (a b)
9410      "Exclusive or."
9411      (if a (not b) b))
9412 #+END_SRC
9413 @end example
9415 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
9416 switch to the end of the @code{BEGIN} line, to get the lines of the example
9417 numbered.  If you use a @code{+n} switch, the numbering from the previous
9418 numbered snippet will be continued in the current one.  In literal examples,
9419 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
9420 targets for special hyperlinks like @code{[[(name)]]} (i.e., the reference name
9421 enclosed in single parenthesis).  In HTML, hovering the mouse over such a
9422 link will remote-highlight the corresponding code line, which is kind of
9423 cool.
9425 You can also add a @code{-r} switch which @i{removes} the labels from the
9426 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
9427 labels in the source code while using line numbers for the links, which might
9428 be useful to explain those in an Org mode example code.}.  With the @code{-n}
9429 switch, links to these references will be labeled by the line numbers from
9430 the code listing, otherwise links will use the labels with no parentheses.
9431 Here is an example:
9433 @example
9434 #+BEGIN_SRC emacs-lisp -n -r
9435 (save-excursion                  (ref:sc)
9436    (goto-char (point-min))       (ref:jump)
9437 #+END_SRC
9438 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
9439 jumps to point-min.
9440 @end example
9442 @vindex org-coderef-label-format
9443 If the syntax for the label format conflicts with the language syntax, use a
9444 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
9445 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
9447 HTML export also allows examples to be published as text areas (@pxref{Text
9448 areas in HTML export}).
9450 Because the @code{#+BEGIN_...} and @code{#+END_...} patterns need to be added
9451 so often, shortcuts are provided using the Easy Templates facility
9452 (@pxref{Easy Templates}).
9454 @table @kbd
9455 @kindex C-c '
9456 @item C-c '
9457 Edit the source code example at point in its native mode.  This works by
9458 switching to a temporary buffer with the source code.  You need to exit by
9459 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*},
9460 @samp{,*}, @samp{#+} and @samp{,#+} will get a comma prepended, to keep them
9461 from being interpreted by Org as outline nodes or special syntax.  These
9462 commas will be stripped for editing with @kbd{C-c '}, and also for export.}.
9463 The edited version will then replace the old version in the Org buffer.
9464 Fixed-width regions (where each line starts with a colon followed by a space)
9465 will be edited using @code{artist-mode}@footnote{You may select
9466 a different-mode with the variable @code{org-edit-fixed-width-region-mode}.}
9467 to allow creating ASCII drawings easily.  Using this command in an empty line
9468 will create a new fixed-width region.
9469 @kindex C-c l
9470 @item C-c l
9471 Calling @code{org-store-link} while editing a source code example in a
9472 temporary buffer created with @kbd{C-c '} will prompt for a label.  Make sure
9473 that it is unique in the current buffer, and insert it with the proper
9474 formatting like @samp{(ref:label)} at the end of the current line.  Then the
9475 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
9476 @end table
9479 @node Include files, Index entries, Literal examples, Markup
9480 @section Include files
9481 @cindex include files, markup rules
9483 During export, you can include the content of another file.  For example, to
9484 include your @file{.emacs} file, you could use:
9485 @cindex #+INCLUDE
9487 @example
9488 #+INCLUDE: "~/.emacs" src emacs-lisp
9489 @end example
9491 @noindent
9492 The optional second and third parameter are the markup (e.g., @samp{quote},
9493 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
9494 language for formatting the contents.  The markup is optional; if it is not
9495 given, the text will be assumed to be in Org mode format and will be
9496 processed normally.  The include line will also allow additional keyword
9497 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
9498 first line and for each following line, @code{:minlevel} in order to get
9499 Org mode content demoted to a specified level, as well as any options
9500 accepted by the selected markup.  For example, to include a file as an item,
9503 @example
9504 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
9505 @end example
9507 You can also include a portion of a file by specifying a lines range using
9508 the @code{:lines} parameter.  The line at the upper end of the range will not
9509 be included.  The start and/or the end of the range may be omitted to use the
9510 obvious defaults.
9512 @example
9513 #+INCLUDE: "~/.emacs" :lines "5-10"   @r{Include lines 5 to 10, 10 excluded}
9514 #+INCLUDE: "~/.emacs" :lines "-10"    @r{Include lines 1 to 10, 10 excluded}
9515 #+INCLUDE: "~/.emacs" :lines "10-"    @r{Include lines from 10 to EOF}
9516 @end example
9518 @table @kbd
9519 @kindex C-c '
9520 @item C-c '
9521 Visit the include file at point.
9522 @end table
9524 @node Index entries, Macro replacement, Include files, Markup
9525 @section Index entries
9526 @cindex index entries, for publishing
9528 You can specify entries that will be used for generating an index during
9529 publishing.  This is done by lines starting with @code{#+INDEX}.  An entry
9530 the contains an exclamation mark will create a sub item.  See @ref{Generating
9531 an index} for more information.
9533 @example
9534 * Curriculum Vitae
9535 #+INDEX: CV
9536 #+INDEX: Application!CV
9537 @end example
9542 @node Macro replacement, Embedded @LaTeX{}, Index entries, Markup
9543 @section Macro replacement
9544 @cindex macro replacement, during export
9545 @cindex #+MACRO
9547 You can define text snippets with
9549 @example
9550 #+MACRO: name   replacement text $1, $2 are arguments
9551 @end example
9553 @noindent which can be referenced anywhere in the document (even in
9554 code examples) with @code{@{@{@{name(arg1,arg2)@}@}@}}.  In addition to
9555 defined macros, @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc.,
9556 will reference information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and
9557 similar lines.  Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
9558 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
9559 and to the modification time of the file being exported, respectively.
9560 @var{FORMAT} should be a format string understood by
9561 @code{format-time-string}.
9563 Macro expansion takes place during export, and some people use it to
9564 construct complex HTML code.
9567 @node Embedded @LaTeX{},  , Macro replacement, Markup
9568 @section Embedded @LaTeX{}
9569 @cindex @TeX{} interpretation
9570 @cindex @LaTeX{} interpretation
9572 Plain ASCII is normally sufficient for almost all note taking.  Exceptions
9573 include scientific notes, which often require mathematical symbols and the
9574 occasional formula.  @LaTeX{}@footnote{@LaTeX{} is a macro system based on
9575 Donald E. Knuth's @TeX{} system.  Many of the features described here as
9576 ``@LaTeX{}'' are really from @TeX{}, but for simplicity I am blurring this
9577 distinction.}  is widely used to typeset scientific documents.  Org mode
9578 supports embedding @LaTeX{} code into its files, because many academics are
9579 used to writing and reading @LaTeX{} source code, and because it can be
9580 readily processed to produce pretty output for a number of export backends.
9582 @menu
9583 * Special symbols::             Greek letters and other symbols
9584 * Subscripts and superscripts::  Simple syntax for raising/lowering text
9585 * @LaTeX{} fragments::          Complex formulas made easy
9586 * Previewing @LaTeX{} fragments::  What will this snippet look like?
9587 * CDLaTeX mode::                Speed up entering of formulas
9588 @end menu
9590 @node Special symbols, Subscripts and superscripts, Embedded @LaTeX{}, Embedded @LaTeX{}
9591 @subsection Special symbols
9592 @cindex math symbols
9593 @cindex special symbols
9594 @cindex @TeX{} macros
9595 @cindex @LaTeX{} fragments, markup rules
9596 @cindex HTML entities
9597 @cindex @LaTeX{} entities
9599 You can use @LaTeX{} macros to insert special symbols like @samp{\alpha} to
9600 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
9601 for these macros is available, just type @samp{\} and maybe a few letters,
9602 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike @LaTeX{}
9603 code, Org mode allows these macros to be present without surrounding math
9604 delimiters, for example:
9606 @example
9607 Angles are written as Greek letters \alpha, \beta and \gamma.
9608 @end example
9610 @vindex org-entities
9611 During export, these symbols will be transformed into the native format of
9612 the exporter backend.  Strings like @code{\alpha} will be exported as
9613 @code{&alpha;} in the HTML output, and as @code{$\alpha$} in the @LaTeX{}
9614 output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in HTML and
9615 @code{~} in @LaTeX{}.  If you need such a symbol inside a word, terminate it
9616 like this: @samp{\Aacute@{@}stor}.
9618 A large number of entities is provided, with names taken from both HTML and
9619 @LaTeX{}; see the variable @code{org-entities} for the complete list.
9620 @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
9621 @samp{...} are all converted into special commands creating hyphens of
9622 different lengths or a compact set of dots.
9624 If you would like to see entities displayed as UTF8 characters, use the
9625 following command@footnote{You can turn this on by default by setting the
9626 variable @code{org-pretty-entities}, or on a per-file base with the
9627 @code{#+STARTUP} option @code{entitiespretty}.}:
9629 @table @kbd
9630 @kindex C-c C-x \
9631 @item C-c C-x \
9632 Toggle display of entities as UTF-8 characters.  This does not change the
9633 buffer content which remains plain ASCII, but it overlays the UTF-8 character
9634 for display purposes only.
9635 @end table
9637 @node Subscripts and superscripts, @LaTeX{} fragments, Special symbols, Embedded @LaTeX{}
9638 @subsection Subscripts and superscripts
9639 @cindex subscript
9640 @cindex superscript
9642 Just like in @LaTeX{}, @samp{^} and @samp{_} are used to indicate super-
9643 and subscripts.  Again, these can be used without embedding them in
9644 math-mode delimiters.  To increase the readability of ASCII text, it is
9645 not necessary (but OK) to surround multi-character sub- and superscripts
9646 with curly braces.  For example
9648 @example
9649 The mass of the sun is M_sun = 1.989 x 10^30 kg.  The radius of
9650 the sun is R_@{sun@} = 6.96 x 10^8 m.
9651 @end example
9653 @vindex org-export-with-sub-superscripts
9654 To avoid interpretation as raised or lowered text, you can quote @samp{^} and
9655 @samp{_} with a backslash: @samp{\^} and @samp{\_}.  If you write a text
9656 where the underscore is often used in a different context, Org's convention
9657 to always interpret these as subscripts can get in your way.  Configure the
9658 variable @code{org-export-with-sub-superscripts} to globally change this
9659 convention, or use, on a per-file basis:
9661 @example
9662 #+OPTIONS: ^:@{@}
9663 @end example
9665 @noindent With this setting, @samp{a_b} will not be interpreted as a
9666 subscript, but @samp{a_@{b@}} will.
9668 @table @kbd
9669 @kindex C-c C-x \
9670 @item C-c C-x \
9671 In addition to showing entities as UTF-8 characters, this command will also
9672 format sub- and superscripts in a WYSIWYM way.
9673 @end table
9675 @node @LaTeX{} fragments, Previewing @LaTeX{} fragments, Subscripts and superscripts, Embedded @LaTeX{}
9676 @subsection @LaTeX{} fragments
9677 @cindex @LaTeX{} fragments
9679 @vindex org-format-latex-header
9680 Going beyond symbols and sub- and superscripts, a full formula language is
9681 needed.  Org mode can contain @LaTeX{} math fragments, and it supports ways
9682 to process these for several export backends.  When exporting to @LaTeX{},
9683 the code is obviously left as it is.  When exporting to HTML, Org invokes the
9684 @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in
9685 HTML export}) to process and display the math@footnote{If you plan to use
9686 this regularly or on pages with significant page views, you should install
9687 @file{MathJax} on your own
9688 server in order to limit the load of our server.}.  Finally, it can also
9689 process the mathematical expressions into images@footnote{For this to work
9690 you need to be on a system with a working @LaTeX{} installation.  You also
9691 need the @file{dvipng} program or the @file{convert}, respectively available
9692 at @url{http://sourceforge.net/projects/dvipng/} and from the
9693 @file{imagemagick} suite.  The @LaTeX{} header that will be used when
9694 processing a fragment can be configured with the variable
9695 @code{org-format-latex-header}.} that can be displayed in a browser.
9697 @LaTeX{} fragments don't need any special marking at all.  The following
9698 snippets will be identified as @LaTeX{} source code:
9699 @itemize @bullet
9700 @item
9701 Environments of any kind@footnote{When @file{MathJax} is used, only the
9702 environment recognized by @file{MathJax} will be processed.  When
9703 @file{dvipng} is used to create images, any @LaTeX{} environments will be
9704 handled.}.  The only requirement is that the @code{\begin} statement appears
9705 on a new line, preceded by only whitespace.
9706 @item
9707 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
9708 currency specifications, single @samp{$} characters are only recognized as
9709 math delimiters if the enclosed text contains at most two line breaks, is
9710 directly attached to the @samp{$} characters with no whitespace in between,
9711 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
9712 For the other delimiters, there is no such restriction, so when in doubt, use
9713 @samp{\(...\)} as inline math delimiters.
9714 @end itemize
9716 @noindent For example:
9718 @example
9719 \begin@{equation@}                          % arbitrary environments,
9720 x=\sqrt@{b@}                                % even tables, figures
9721 \end@{equation@}                            % etc
9723 If $a^2=b$ and \( b=2 \), then the solution must be
9724 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
9725 @end example
9727 @noindent
9728 @vindex org-format-latex-options
9729 If you need any of the delimiter ASCII sequences for other purposes, you
9730 can configure the option @code{org-format-latex-options} to deselect the
9731 ones you do not wish to have interpreted by the @LaTeX{} converter.
9733 @vindex org-export-with-LaTeX-fragments
9734 @LaTeX{} processing can be configured with the variable
9735 @code{org-export-with-LaTeX-fragments}.  The default setting is @code{t}
9736 which means @file{MathJax} for HTML, and no processing for ASCII and @LaTeX{}
9737 backends.  You can also set this variable on a per-file basis using one of
9738 these lines:
9740 @example
9741 #+OPTIONS: LaTeX:t          @r{Do the right thing automatically (MathJax)}
9742 #+OPTIONS: LaTeX:dvipng     @r{Force using dvipng images}
9743 #+OPTIONS: LaTeX:nil        @r{Do not process @LaTeX{} fragments at all}
9744 #+OPTIONS: LaTeX:verbatim   @r{Verbatim export, for jsMath or so}
9745 @end example
9747 @node Previewing @LaTeX{} fragments, CDLaTeX mode, @LaTeX{} fragments, Embedded @LaTeX{}
9748 @subsection Previewing @LaTeX{} fragments
9749 @cindex @LaTeX{} fragments, preview
9751 If you have @file{dvipng} installed, @LaTeX{} fragments can be processed to
9752 produce preview images of the typeset expressions:
9754 @table @kbd
9755 @kindex C-c C-x C-l
9756 @item C-c C-x C-l
9757 Produce a preview image of the @LaTeX{} fragment at point and overlay it
9758 over the source code.  If there is no fragment at point, process all
9759 fragments in the current entry (between two headlines).  When called
9760 with a prefix argument, process the entire subtree.  When called with
9761 two prefix arguments, or when the cursor is before the first headline,
9762 process the entire buffer.
9763 @kindex C-c C-c
9764 @item C-c C-c
9765 Remove the overlay preview images.
9766 @end table
9768 @vindex org-format-latex-options
9769 You can customize the variable @code{org-format-latex-options} to influence
9770 some aspects of the preview.  In particular, the @code{:scale} (and for HTML
9771 export, @code{:html-scale}) property can be used to adjust the size of the
9772 preview images.
9774 @vindex org-startup-with-latex-preview
9775 You can turn on the previewing of all @LaTeX{} fragments in a file with
9777 @example
9778 #+STARTUP: latexpreview
9779 @end example
9781 To disable it, simply use
9783 @example
9784 #+STARTUP: nolatexpreview
9785 @end example
9787 @node CDLaTeX mode,  , Previewing @LaTeX{} fragments, Embedded @LaTeX{}
9788 @subsection Using CD@LaTeX{} to enter math
9789 @cindex CD@LaTeX{}
9791 CD@LaTeX{} mode is a minor mode that is normally used in combination with a
9792 major @LaTeX{} mode like AUC@TeX{} in order to speed-up insertion of
9793 environments and math templates.  Inside Org mode, you can make use of
9794 some of the features of CD@LaTeX{} mode.  You need to install
9795 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
9796 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
9797 Don't use CD@LaTeX{} mode itself under Org mode, but use the light
9798 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
9799 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
9800 Org files with
9802 @lisp
9803 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
9804 @end lisp
9806 When this mode is enabled, the following features are present (for more
9807 details see the documentation of CD@LaTeX{} mode):
9808 @itemize @bullet
9809 @kindex C-c @{
9810 @item
9811 Environment templates can be inserted with @kbd{C-c @{}.
9812 @item
9813 @kindex @key{TAB}
9814 The @key{TAB} key will do template expansion if the cursor is inside a
9815 @LaTeX{} fragment@footnote{Org mode has a method to test if the cursor is
9816 inside such a fragment, see the documentation of the function
9817 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
9818 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
9819 correctly inside the first brace.  Another @key{TAB} will get you into
9820 the second brace.  Even outside fragments, @key{TAB} will expand
9821 environment abbreviations at the beginning of a line.  For example, if
9822 you write @samp{equ} at the beginning of a line and press @key{TAB},
9823 this abbreviation will be expanded to an @code{equation} environment.
9824 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
9825 @item
9826 @kindex _
9827 @kindex ^
9828 @vindex cdlatex-simplify-sub-super-scripts
9829 Pressing @kbd{_} and @kbd{^} inside a @LaTeX{} fragment will insert these
9830 characters together with a pair of braces.  If you use @key{TAB} to move
9831 out of the braces, and if the braces surround only a single character or
9832 macro, they are removed again (depending on the variable
9833 @code{cdlatex-simplify-sub-super-scripts}).
9834 @item
9835 @kindex `
9836 Pressing the backquote @kbd{`} followed by a character inserts math
9837 macros, also outside @LaTeX{} fragments.  If you wait more than 1.5 seconds
9838 after the backquote, a help window will pop up.
9839 @item
9840 @kindex '
9841 Pressing the single-quote @kbd{'} followed by another character modifies
9842 the symbol before point with an accent or a font.  If you wait more than
9843 1.5 seconds after the single-quote, a help window will pop up.  Character
9844 modification will work only inside @LaTeX{} fragments; outside the quote
9845 is normal.
9846 @end itemize
9848 @node Exporting, Publishing, Markup, Top
9849 @chapter Exporting
9850 @cindex exporting
9852 Org mode documents can be exported into a variety of other formats.  For
9853 printing and sharing of notes, ASCII export produces a readable and simple
9854 version of an Org file.  HTML export allows you to publish a notes file on
9855 the web.  @LaTeX{} export lets you use Org mode and its structured editing
9856 functions to easily create @LaTeX{} files.  OpenDocument Text (ODT) export
9857 allows seamless collaboration across organizational boundaries.  To
9858 incorporate entries with associated times like deadlines or appointments into
9859 a desktop calendar program like iCal, Org mode can also produce extracts in
9860 the iCalendar format.  Currently, Org mode only supports export, not import
9861 of these different formats.
9863 Org supports export of selected regions when @code{transient-mark-mode} is
9864 enabled (default in Emacs 23).
9866 @menu
9867 * Selective export::            Using tags to select and exclude trees
9868 * Export options::              Per-file export settings
9869 * The export dispatcher::       How to access exporter commands
9870 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
9871 * HTML export::                 Exporting to HTML
9872 * @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
9873 * OpenDocument Text export::    Exporting to OpenDocument Text
9874 * Freemind export::             Exporting to Freemind mind maps
9875 * iCalendar export::            Exporting in iCalendar format
9876 @end menu
9878 @node Selective export, Export options, Exporting, Exporting
9879 @section Selective export
9880 @cindex export, selective by tags or TODO keyword
9882 @vindex org-export-select-tags
9883 @vindex org-export-exclude-tags
9884 @cindex org-export-with-tasks
9885 You may use tags to select the parts of a document that should be exported,
9886 or to exclude parts from export.  This behavior is governed by two variables:
9887 @code{org-export-select-tags} and @code{org-export-exclude-tags},
9888 respectively defaulting to @code{'(:export:)} and @code{'(:noexport:)}.
9890 @enumerate
9891 @item
9892 Org first checks if any of the @emph{select} tags is present in the
9893 buffer.  If yes, all trees that do not carry one of these tags will be
9894 excluded.  If a selected tree is a subtree, the heading hierarchy above it
9895 will also be selected for export, but not the text below those headings.
9897 @item
9898 If none of the select tags is found, the whole buffer will be selected for
9899 export.
9901 @item
9902 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
9903 be removed from the export buffer.
9904 @end enumerate
9906 The variable @code{org-export-with-tasks} can be configured to select which
9907 kind of tasks should be included for export.  See the docstring of the
9908 variable for more information.
9910 @node Export options, The export dispatcher, Selective export, Exporting
9911 @section Export options
9912 @cindex options, for export
9914 @cindex completion, of option keywords
9915 The exporter recognizes special lines in the buffer which provide
9916 additional information.  These lines may be put anywhere in the file.
9917 The whole set of lines can be inserted into the buffer with @kbd{C-c
9918 C-e t}.  For individual lines, a good way to make sure the keyword is
9919 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
9920 (@pxref{Completion}).   For a summary of other in-buffer settings not
9921 specifically related to export, see @ref{In-buffer settings}.
9922 In particular, note that you can place commonly-used (export) options in
9923 a separate file which can be included using @code{#+SETUPFILE}.
9925 @table @kbd
9926 @orgcmd{C-c C-e t,org-insert-export-options-template}
9927 Insert template with export options, see example below.
9928 @end table
9930 @cindex #+TITLE
9931 @cindex #+AUTHOR
9932 @cindex #+DATE
9933 @cindex #+EMAIL
9934 @cindex #+DESCRIPTION
9935 @cindex #+KEYWORDS
9936 @cindex #+LANGUAGE
9937 @cindex #+TEXT
9938 @cindex #+OPTIONS
9939 @cindex #+BIND
9940 @cindex #+HTML_LINK_UP
9941 @cindex #+HTML_LINK_HOME
9942 @cindex #+SELECT_TAGS
9943 @cindex #+EXCLUDE_TAGS
9944 @cindex #+LaTeX_HEADER
9945 @vindex user-full-name
9946 @vindex user-mail-address
9947 @vindex org-export-default-language
9948 @vindex org-export-date-timestamp-format
9949 @example
9950 #+TITLE:       the title to be shown (default is the buffer name)
9951 #+AUTHOR:      the author (default taken from @code{user-full-name})
9952 #+DATE:        a date, an Org timestamp@footnote{@code{org-export-date-timestamp-format} defines how this timestamp will be exported.}, or a format string for @code{format-time-string}
9953 #+EMAIL:       his/her email address (default from @code{user-mail-address})
9954 #+DESCRIPTION: the page description, e.g., for the XHTML meta tag
9955 #+KEYWORDS:    the page keywords, e.g., for the XHTML meta tag
9956 #+LANGUAGE:    language for HTML, e.g., @samp{en} (@code{org-export-default-language})
9957 #+TEXT:        Some descriptive text to be inserted at the beginning.
9958 #+TEXT:        Several lines may be given.
9959 #+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
9960 #+BIND:        lisp-var lisp-val, e.g., @code{org-latex-image-default-option width=.7\\linewidth}
9961                @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
9962 #+HTML_LINK_UP:     the ``up'' link of an exported page
9963 #+HTML_LINK_HOME:   the ``home'' link of an exported page
9964 #+LaTeX_HEADER: extra line(s) for the @LaTeX{} header, like \usepackage@{xyz@}
9965 #+SELECT_TAGS:   Tags that select a tree for export
9966 #+EXCLUDE_TAGS:  Tags that exclude a tree from export
9967 @end example
9969 @noindent
9970 The @code{#+OPTIONS} line is a compact@footnote{If you want to configure many options
9971 this way, you can use several @code{#+OPTIONS} lines.} form to specify export
9972 settings.  Here you can:
9973 @cindex headline levels
9974 @cindex section-numbers
9975 @cindex table of contents
9976 @cindex line-break preservation
9977 @cindex quoted HTML tags
9978 @cindex fixed-width sections
9979 @cindex tables
9980 @cindex @TeX{}-like syntax for sub- and superscripts
9981 @cindex footnotes
9982 @cindex special strings
9983 @cindex emphasized text
9984 @cindex @TeX{} macros
9985 @cindex @LaTeX{} fragments
9986 @cindex author info, in export
9987 @cindex time info, in export
9988 @vindex org-export-plist-vars
9989 @vindex org-export-author-info
9990 @vindex org-export-creator-info
9991 @vindex org-export-email-info
9992 @vindex org-export-time-stamp-file
9993 @example
9994 H:         @r{set the number of headline levels for export}
9995 num:       @r{turn on/off section-numbers}
9996 toc:       @r{turn on/off table of contents, or set level limit (integer)}
9997 \n:        @r{turn on/off line-break-preservation (DOES NOT WORK)}
9998 @@:         @r{turn on/off quoted HTML tags}
9999 ::         @r{turn on/off fixed-width sections}
10000 |:         @r{turn on/off tables}
10001 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
10002            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
10003            @r{the simple @code{a_b} will be left as it is.}
10004 -:         @r{turn on/off conversion of special strings.}
10005 f:         @r{turn on/off footnotes like this[1].}
10006 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
10007 tasks:     @r{turn on/off inclusion of tasks (TODO items), can be nil to remove}
10008            @r{all tasks, @code{todo} to remove DONE tasks, or list of kwds to keep}
10009 pri:       @r{turn on/off priority cookies}
10010 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
10011 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
10012 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
10013 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
10014 LaTeX:     @r{configure export of @LaTeX{} fragments.  Default @code{auto}}
10015 skip:      @r{turn on/off skipping the text before the first heading}
10016 author:    @r{turn on/off inclusion of author name/email into exported file}
10017 email:     @r{turn on/off inclusion of author email into exported file}
10018 creator:   @r{turn on/off inclusion of creator info into exported file}
10019 timestamp: @r{turn on/off inclusion creation time into exported file}
10020 d:         @r{turn on/off inclusion of drawers, or list drawers to include}
10021 @end example
10022 @noindent
10023 These options take effect in both the HTML and @LaTeX{} export, except for
10024 @code{TeX} and @code{LaTeX} options, which are respectively @code{t} and
10025 @code{nil} for the @LaTeX{} export.
10027 The default values for these and many other options are given by a set of
10028 variables.  For a list of such variables, the corresponding OPTIONS keys and
10029 also the publishing keys (@pxref{Project alist}), see the constant
10030 @code{org-export-plist-vars}.
10032 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
10033 calling an export command, the subtree can overrule some of the file's export
10034 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
10035 @code{EXPORT_TEXT}, @code{EXPORT_AUTHOR}, @code{EXPORT_DATE}, and
10036 @code{EXPORT_OPTIONS}.
10038 @node The export dispatcher, ASCII/Latin-1/UTF-8 export, Export options, Exporting
10039 @section The export dispatcher
10040 @cindex dispatcher, for export commands
10042 All export commands can be reached using the export dispatcher, which is a
10043 prefix key that prompts for an additional key specifying the command.
10044 Normally the entire file is exported, but if there is an active region that
10045 contains one outline tree, the first heading is used as document title and
10046 the subtrees are exported.
10048 @table @kbd
10049 @orgcmd{C-c C-e,org-export}
10050 @vindex org-export-run-in-background
10051 Dispatcher for export and publishing commands.  Displays a help-window
10052 listing the additional key(s) needed to launch an export or publishing
10053 command.  The prefix arg is passed through to the exporter.  A double prefix
10054 @kbd{C-u C-u} causes most commands to be executed in the background, in a
10055 separate Emacs process@footnote{To make this behavior the default, customize
10056 the variable @code{org-export-run-in-background}.}.
10057 @orgcmd{C-c C-e v,org-export-visible}
10058 Like @kbd{C-c C-e}, but only export the text that is currently visible
10059 (i.e., not hidden by outline visibility).
10060 @orgcmd{C-u C-u C-c C-e,org-export}
10061 @vindex org-export-run-in-background
10062 Call the exporter, but reverse the setting of
10063 @code{org-export-run-in-background}, i.e., request background processing if
10064 not set, or force processing in the current Emacs process if set.
10065 @end table
10067 @node ASCII/Latin-1/UTF-8 export, HTML export, The export dispatcher, Exporting
10068 @section ASCII/Latin-1/UTF-8 export
10069 @cindex ASCII export
10070 @cindex Latin-1 export
10071 @cindex UTF-8 export
10073 ASCII export produces a simple and very readable version of an Org mode
10074 file, containing only plain ASCII@.  Latin-1 and UTF-8 export augment the file
10075 with special characters and symbols available in these encodings.
10077 @cindex region, active
10078 @cindex active region
10079 @cindex transient-mark-mode
10080 @table @kbd
10081 @orgcmd{C-c C-e a,org-export-as-ascii}
10082 @cindex property, EXPORT_FILE_NAME
10083 Export as an ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
10084 will be @file{myfile.txt}.  The file will be overwritten without
10085 warning.  If there is an active region@footnote{This requires
10086 @code{transient-mark-mode} be turned on.}, only the region will be
10087 exported.  If the selected region is a single tree@footnote{To select the
10088 current subtree, use @kbd{C-c @@}.}, the tree head will
10089 become the document title.  If the tree head entry has or inherits an
10090 @code{EXPORT_FILE_NAME} property, that name will be used for the
10091 export.
10092 @orgcmd{C-c C-e A,org-export-as-ascii-to-buffer}
10093 Export to a temporary buffer.  Do not create a file.
10094 @orgcmd{C-c C-e n,org-export-as-latin1}
10095 @xorgcmd{C-c C-e N,org-export-as-latin1-to-buffer}
10096 Like the above commands, but use Latin-1 encoding.
10097 @orgcmd{C-c C-e u,org-export-as-utf8}
10098 @xorgcmd{C-c C-e U,org-export-as-utf8-to-buffer}
10099 Like the above commands, but use UTF-8 encoding.
10100 @item C-c C-e v a/n/u
10101 Export only the visible part of the document.
10102 @end table
10104 @cindex headline levels, for exporting
10105 In the exported version, the first 3 outline levels will become
10106 headlines, defining a general document structure.  Additional levels
10107 will be exported as itemized lists.  If you want that transition to occur
10108 at a different level, specify it with a prefix argument.  For example,
10110 @example
10111 @kbd{C-1 C-c C-e a}
10112 @end example
10114 @noindent
10115 creates only top level headlines and exports the rest as items.  When
10116 headlines are converted to items, the indentation of the text following
10117 the headline is changed to fit nicely under the item.  This is done with
10118 the assumption that the first body line indicates the base indentation of
10119 the body text.  Any indentation larger than this is adjusted to preserve
10120 the layout relative to the first line.  Should there be lines with less
10121 indentation than the first one, these are left alone.
10123 @vindex org-export-ascii-links-to-notes
10124 Links will be exported in a footnote-like style, with the descriptive part in
10125 the text and the link in a note before the next heading.  See the variable
10126 @code{org-export-ascii-links-to-notes} for details and other options.
10128 @node HTML export, @LaTeX{} and PDF export, ASCII/Latin-1/UTF-8 export, Exporting
10129 @section HTML export
10130 @cindex HTML export
10132 Org mode contains a HTML (XHTML 1.0 strict) exporter with extensive
10133 HTML formatting, in ways similar to John Gruber's @emph{markdown}
10134 language, but with additional support for tables.
10136 @menu
10137 * HTML Export commands::        How to invoke HTML export
10138 * HTML preamble and postamble::  How to insert a preamble and a postamble
10139 * Quoting HTML tags::           Using direct HTML in Org mode
10140 * Links in HTML export::        How links will be interpreted and formatted
10141 * Tables in HTML export::       How to modify the formatting of tables
10142 * Images in HTML export::       How to insert figures into HTML output
10143 * Math formatting in HTML export::  Beautiful math also on the web
10144 * Text areas in HTML export::   An alternative way to show an example
10145 * CSS support::                 Changing the appearance of the output
10146 * JavaScript support::          Info and Folding in a web browser
10147 @end menu
10149 @node HTML Export commands, HTML preamble and postamble, HTML export, HTML export
10150 @subsection HTML export commands
10152 @cindex region, active
10153 @cindex active region
10154 @cindex transient-mark-mode
10155 @table @kbd
10156 @orgcmd{C-c C-e h,org-export-as-html}
10157 @cindex property, EXPORT_FILE_NAME
10158 Export as a HTML file.  For an Org file @file{myfile.org},
10159 the HTML file will be @file{myfile.html}.  The file will be overwritten
10160 without warning.  If there is an active region@footnote{This requires
10161 @code{transient-mark-mode} be turned on.}, only the region will be
10162 exported.  If the selected region is a single tree@footnote{To select the
10163 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
10164 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
10165 property, that name will be used for the export.
10166 @orgcmd{C-c C-e b,org-export-as-html-and-open}
10167 Export as a HTML file and immediately open it with a browser.
10168 @orgcmd{C-c C-e H,org-export-as-html-to-buffer}
10169 Export to a temporary buffer.  Do not create a file.
10170 @orgcmd{C-c C-e R,org-export-region-as-html}
10171 Export the active region to a temporary buffer.  With a prefix argument, do
10172 not produce the file header and footer, but just the plain HTML section for
10173 the region.  This is good for cut-and-paste operations.
10174 @item C-c C-e v h/b/H/R
10175 Export only the visible part of the document.
10176 @item M-x org-export-region-as-html
10177 Convert the region to HTML under the assumption that it was in Org mode
10178 syntax before.  This is a global command that can be invoked in any
10179 buffer.
10180 @item M-x org-replace-region-by-HTML
10181 Replace the active region (assumed to be in Org mode syntax) by HTML
10182 code.
10183 @end table
10185 @cindex headline levels, for exporting
10186 In the exported version, the first 3 outline levels will become headlines,
10187 defining a general document structure.  Additional levels will be exported as
10188 itemized lists.  If you want that transition to occur at a different level,
10189 specify it with a numeric prefix argument.  For example,
10191 @example
10192 @kbd{C-2 C-c C-e b}
10193 @end example
10195 @noindent
10196 creates two levels of headings and does the rest as items.
10199 @node HTML preamble and postamble, Quoting HTML tags, HTML Export commands, HTML export
10200 @subsection HTML preamble and postamble
10201 @vindex org-html-preamble
10202 @vindex org-html-postamble
10203 @vindex org-html-preamble-format
10204 @vindex org-html-postamble-format
10205 @vindex org-html-validation-link
10206 @vindex org-export-author-info
10207 @vindex org-export-email-info
10208 @vindex org-export-creator-info
10209 @vindex org-export-time-stamp-file
10211 The HTML exporter lets you define a preamble and a postamble.
10213 The default value for @code{org-html-preamble} is @code{t}, which means
10214 that the preamble is inserted depending on the relevant format string in
10215 @code{org-html-preamble-format}.
10217 Setting @code{org-html-preamble} to a string will override the default
10218 format string.  Setting it to a function, will insert the output of the
10219 function, which must be a string; such a function takes no argument but you
10220 can check against the value of @code{opt-plist}, which contains the list of
10221 publishing properties for the current file.  Setting to @code{nil} will not
10222 insert any preamble.
10224 The default value for @code{org-html-postamble} is @code{'auto}, which
10225 means that the HTML exporter will look for the value of
10226 @code{org-export-author-info}, @code{org-export-email-info},
10227 @code{org-export-creator-info} and @code{org-export-time-stamp-file},
10228 @code{org-html-validation-link} and build the postamble from these
10229 values.  Setting @code{org-html-postamble} to @code{t} will insert the
10230 postamble from the relevant format string found in
10231 @code{org-html-postamble-format}.  Setting it to @code{nil} will not
10232 insert any postamble.
10234 @node Quoting HTML tags, Links in HTML export, HTML preamble and postamble, HTML export
10235 @subsection Quoting HTML tags
10237 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
10238 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
10239 which should be interpreted as such, mark them with @samp{@@} as in
10240 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
10241 simple tags.  For more extensive HTML that should be copied verbatim to
10242 the exported file use either
10244 @cindex #+HTML
10245 @cindex #+BEGIN_HTML
10246 @example
10247 #+HTML: Literal HTML code for export
10248 @end example
10250 @noindent or
10251 @cindex #+BEGIN_HTML
10253 @example
10254 #+BEGIN_HTML
10255 All lines between these markers are exported literally
10256 #+END_HTML
10257 @end example
10260 @node Links in HTML export, Tables in HTML export, Quoting HTML tags, HTML export
10261 @subsection Links in HTML export
10263 @cindex links, in HTML export
10264 @cindex internal links, in HTML export
10265 @cindex external links, in HTML export
10266 Internal links (@pxref{Internal links}) will continue to work in HTML@.  This
10267 includes automatic links created by radio targets (@pxref{Radio
10268 targets}).  Links to external files will still work if the target file is on
10269 the same @i{relative} path as the published Org file.  Links to other
10270 @file{.org} files will be translated into HTML links under the assumption
10271 that a HTML version also exists of the linked file, at the same relative
10272 path.  @samp{id:} links can then be used to jump to specific entries across
10273 files.  For information related to linking files while publishing them to a
10274 publishing directory see @ref{Publishing links}.
10276 If you want to specify attributes for links, you can do so using a special
10277 @code{#+ATTR_HTML} line to define attributes that will be added to the
10278 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
10279 and @code{style} attributes for a link:
10281 @cindex #+ATTR_HTML
10282 @example
10283 #+ATTR_HTML: title="The Org mode homepage" style="color:red;"
10284 [[http://orgmode.org]]
10285 @end example
10287 @node Tables in HTML export, Images in HTML export, Links in HTML export, HTML export
10288 @subsection Tables
10289 @cindex tables, in HTML
10290 @vindex org-html-table-tag
10292 Org mode tables are exported to HTML using the table tag defined in
10293 @code{org-html-table-tag}.  The default setting makes tables without
10294 cell borders and frame.  If you would like to change this for individual
10295 tables, place something like the following before the table:
10297 @cindex #+CAPTION
10298 @cindex #+ATTR_HTML
10299 @example
10300 #+CAPTION: This is a table with lines around and between cells
10301 #+ATTR_HTML: border="2" rules="all" frame="border"
10302 @end example
10304 @node Images in HTML export, Math formatting in HTML export, Tables in HTML export, HTML export
10305 @subsection Images in HTML export
10307 @cindex images, inline in HTML
10308 @cindex inlining images in HTML
10309 @vindex org-html-inline-images
10310 HTML export can inline images given as links in the Org file, and
10311 it can make an image the clickable part of a link.  By
10312 default@footnote{But see the variable
10313 @code{org-html-inline-images}.}, images are inlined if a link does
10314 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
10315 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
10316 @samp{the image} that points to the image.  If the description part
10317 itself is a @code{file:} link or a @code{http:} URL pointing to an
10318 image, this image will be inlined and activated so that clicking on the
10319 image will activate the link.  For example, to include a thumbnail that
10320 will link to a high resolution version of the image, you could use:
10322 @example
10323 [[file:highres.jpg][file:thumb.jpg]]
10324 @end example
10326 If you need to add attributes to an inlined image, use a @code{#+ATTR_HTML}.
10327 In the example below we specify the @code{alt} and @code{title} attributes to
10328 support text viewers and accessibility, and align it to the right.
10330 @cindex #+CAPTION
10331 @cindex #+ATTR_HTML
10332 @example
10333 #+CAPTION: A black cat stalking a spider
10334 #+ATTR_HTML: alt="cat/spider image" title="Action!" align="right"
10335 [[./img/a.jpg]]
10336 @end example
10338 @noindent
10339 You could use @code{http} addresses just as well.
10341 @node Math formatting in HTML export, Text areas in HTML export, Images in HTML export, HTML export
10342 @subsection Math formatting in HTML export
10343 @cindex MathJax
10344 @cindex dvipng
10346 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
10347 different ways on HTML pages.  The default is to use the
10348 @uref{http://www.mathjax.org, MathJax system} which should work out of the
10349 box with Org mode installation because @code{http://orgmode.org} serves
10350 @file{MathJax} for Org mode users for small applications and for testing
10351 purposes.  @b{If you plan to use this regularly or on pages with significant
10352 page views, you should install@footnote{Installation instructions can be
10353 found on the MathJax website, see
10354 @uref{http://www.mathjax.org/resources/docs/?installation.html}.} MathJax on
10355 your own server in order to limit the load of our server.}  To configure
10356 @file{MathJax}, use the variable @code{org-html-mathjax-options} or
10357 insert something like the following into the buffer:
10359 @example
10360 #+HTML_MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js"
10361 @end example
10363 @noindent See the docstring of the variable
10364 @code{org-html-mathjax-options} for the meaning of the parameters in
10365 this line.
10367 If you prefer, you can also request that @LaTeX{} fragments are processed
10368 into small images that will be inserted into the browser page.  Before the
10369 availability of MathJax, this was the default method for Org files.  This
10370 method requires that the @file{dvipng} program is available on your system.
10371 You can still get this processing with
10373 @example
10374 #+OPTIONS: LaTeX:dvipng
10375 @end example
10377 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
10378 @subsection Text areas in HTML export
10380 @cindex text areas, in HTML
10381 An alternative way to publish literal code examples in HTML is to use text
10382 areas, where the example can even be edited before pasting it into an
10383 application.  It is triggered by a @code{-t} switch at an @code{example} or
10384 @code{src} block.  Using this switch disables any options for syntax and
10385 label highlighting, and line numbering, which may be present.  You may also
10386 use @code{-h} and @code{-w} switches to specify the height and width of the
10387 text area, which default to the number of lines in the example, and 80,
10388 respectively.  For example
10390 @example
10391 #+BEGIN_EXAMPLE -t -w 40
10392   (defun org-xor (a b)
10393      "Exclusive or."
10394      (if a (not b) b))
10395 #+END_EXAMPLE
10396 @end example
10399 @node CSS support, JavaScript support, Text areas in HTML export, HTML export
10400 @subsection CSS support
10401 @cindex CSS, for HTML export
10402 @cindex HTML export, CSS
10404 @vindex org-html-todo-kwd-class-prefix
10405 @vindex org-html-tag-class-prefix
10406 You can also give style information for the exported file.  The HTML exporter
10407 assigns the following special CSS classes@footnote{If the classes on TODO
10408 keywords and tags lead to conflicts, use the variables
10409 @code{org-html-todo-kwd-class-prefix} and
10410 @code{org-html-tag-class-prefix} to make them unique.} to appropriate
10411 parts of the document---your style specifications may change these, in
10412 addition to any of the standard classes like for headlines, tables, etc.
10413 @example
10414 p.author            @r{author information, including email}
10415 p.date              @r{publishing date}
10416 p.creator           @r{creator info, about org mode version}
10417 .title              @r{document title}
10418 .todo               @r{TODO keywords, all not-done states}
10419 .done               @r{the DONE keywords, all states that count as done}
10420 .WAITING            @r{each TODO keyword also uses a class named after itself}
10421 .timestamp          @r{timestamp}
10422 .timestamp-kwd      @r{keyword associated with a timestamp, like SCHEDULED}
10423 .timestamp-wrapper  @r{span around keyword plus timestamp}
10424 .tag                @r{tag in a headline}
10425 ._HOME              @r{each tag uses itself as a class, "@@" replaced by "_"}
10426 .target             @r{target for links}
10427 .linenr             @r{the line number in a code example}
10428 .code-highlighted   @r{for highlighting referenced code lines}
10429 div.outline-N       @r{div for outline level N (headline plus text))}
10430 div.outline-text-N  @r{extra div for text at outline level N}
10431 .section-number-N   @r{section number in headlines, different for each level}
10432 div.figure          @r{how to format an inlined image}
10433 pre.src             @r{formatted source code}
10434 pre.example         @r{normal example}
10435 p.verse             @r{verse paragraph}
10436 div.footnotes       @r{footnote section headline}
10437 p.footnote          @r{footnote definition paragraph, containing a footnote}
10438 .footref            @r{a footnote reference number (always a <sup>)}
10439 .footnum            @r{footnote number in footnote definition (always <sup>)}
10440 @end example
10442 @vindex org-html-style-default
10443 @vindex org-html-style-include-default
10444 @vindex org-html-style
10445 @vindex org-html-style-default
10446 Each exported file contains a compact default style that defines these
10447 classes in a basic way@footnote{This style is defined in the constant
10448 @code{org-html-style-default}, which you should not modify.  To turn
10449 inclusion of these defaults off, customize
10450 @code{org-html-style-include-default}}.  You may overwrite these
10451 settings, or add to them by using the variables @code{org-html-style}
10452 (for Org-wide settings) and @code{org-html-style-extra} (for more
10453 fine-grained settings, like file-local settings).  To set the latter variable
10454 individually for each file, you can use
10456 @cindex #+HTML_STYLE
10457 @example
10458 #+HTML_STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
10459 @end example
10461 @noindent
10462 For longer style definitions, you can use several such lines.  You could also
10463 directly write a @code{<style>} @code{</style>} section in this way, without
10464 referring to an external file.
10466 In order to add styles to a subtree, use the @code{:HTML_CONTAINER_CLASS:}
10467 property to assign a class to the tree.  In order to specify CSS styles for a
10468 particular headline, you can use the id specified in a @code{:CUSTOM_ID:}
10469 property.
10471 @c FIXME: More about header and footer styles
10472 @c FIXME: Talk about links and targets.
10474 @node JavaScript support,  , CSS support, HTML export
10475 @subsection JavaScript supported display of web pages
10477 @cindex Rose, Sebastian
10478 Sebastian Rose has written a JavaScript program especially designed to
10479 enhance the web viewing experience of HTML files created with Org.  This
10480 program allows you to view large files in two different ways.  The first one
10481 is an @emph{Info}-like mode where each section is displayed separately and
10482 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
10483 as well, press @kbd{?} for an overview of the available keys).  The second
10484 view type is a @emph{folding} view much like Org provides inside Emacs.  The
10485 script is available at @url{http://orgmode.org/org-info.js} and you can find
10486 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
10487 We host the script at our site, but if you use it a lot, you might
10488 not want to be dependent on @url{orgmode.org} and prefer to install a local
10489 copy on your own web server.
10491 To use the script, you need to make sure that the @file{org-jsinfo.el} module
10492 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
10493 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
10494 this is indeed the case.  All it then takes to make use of the program is
10495 adding a single line to the Org file:
10497 @cindex #+INFOJS_OPT
10498 @example
10499 #+INFOJS_OPT: view:info toc:nil
10500 @end example
10502 @noindent
10503 If this line is found, the HTML header will automatically contain the code
10504 needed to invoke the script.  Using the line above, you can set the following
10505 viewing options:
10507 @example
10508 path:    @r{The path to the script.  The default is to grab the script from}
10509          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
10510          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
10511 view:    @r{Initial view when the website is first shown.  Possible values are:}
10512          info      @r{Info-like interface with one section per page.}
10513          overview  @r{Folding interface, initially showing only top-level.}
10514          content   @r{Folding interface, starting with all headlines visible.}
10515          showall   @r{Folding interface, all headlines and text visible.}
10516 sdepth:  @r{Maximum headline level that will still become an independent}
10517          @r{section for info and folding modes.  The default is taken from}
10518          @r{@code{org-export-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
10519          @r{If this is smaller than in @code{org-export-headline-levels}, each}
10520          @r{info/folding section can still contain child headlines.}
10521 toc:     @r{Should the table of contents @emph{initially} be visible?}
10522          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
10523 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
10524          @r{the variables @code{org-export-headline-levels} and @code{org-export-with-toc}.}
10525 ftoc:    @r{Does the CSS of the page specify a fixed position for the "toc"?}
10526          @r{If yes, the toc will never be displayed as a section.}
10527 ltoc:    @r{Should there be short contents (children) in each section?}
10528          @r{Make this @code{above} if the section should be above initial text.}
10529 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
10530          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
10531 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
10532          @r{default), only one such button will be present.}
10533 @end example
10534 @noindent
10535 @vindex org-infojs-options
10536 @vindex org-export-html-use-infojs
10537 You can choose default values for these options by customizing the variable
10538 @code{org-infojs-options}.  If you always want to apply the script to your
10539 pages, configure the variable @code{org-export-html-use-infojs}.
10541 @node @LaTeX{} and PDF export, OpenDocument Text export, HTML export, Exporting
10542 @section @LaTeX{} and PDF export
10543 @cindex @LaTeX{} export
10544 @cindex PDF export
10545 @cindex Guerry, Bastien
10547 Org mode contains a @LaTeX{} exporter.  With further processing@footnote{The
10548 default @LaTeX{} output is designed for processing with @code{pdftex} or
10549 @LaTeX{}.  It includes packages that are not compatible with @code{xetex} and
10550 possibly @code{luatex}.  See the variables
10551 @code{org-latex-default-packages-alist} and
10552 @code{org-latex-packages-alist}.}, this backend is also used to produce PDF
10553 output.  Since the @LaTeX{} output uses @file{hyperref} to implement links
10554 and cross references, the PDF output file will be fully linked.  Beware of
10555 the fact that your @code{org} file has to be properly structured in order to
10556 be correctly exported: respect the hierarchy of sections.
10558 @menu
10559 * @LaTeX{}/PDF export commands::
10560 * Header and sectioning::       Setting up the export file structure
10561 * Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
10562 * Tables in @LaTeX{} export::   Options for exporting tables to @LaTeX{}
10563 * Images in @LaTeX{} export::   How to insert figures into @LaTeX{} output
10564 * Beamer class export::         Turning the file into a presentation
10565 @end menu
10567 @node @LaTeX{}/PDF export commands, Header and sectioning, @LaTeX{} and PDF export, @LaTeX{} and PDF export
10568 @subsection @LaTeX{} export commands
10570 @cindex region, active
10571 @cindex active region
10572 @cindex transient-mark-mode
10573 @table @kbd
10574 @orgcmd{C-c C-e l,org-export-as-latex}
10575 @cindex property EXPORT_FILE_NAME
10576 Export as a @LaTeX{} file.  For an Org file
10577 @file{myfile.org}, the @LaTeX{} file will be @file{myfile.tex}.  The file will
10578 be overwritten without warning.  If there is an active region@footnote{This
10579 requires @code{transient-mark-mode} be turned on.}, only the region will be
10580 exported.  If the selected region is a single tree@footnote{To select the
10581 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
10582 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
10583 property, that name will be used for the export.
10584 @orgcmd{C-c C-e L,org-export-as-latex-to-buffer}
10585 Export to a temporary buffer.  Do not create a file.
10586 @item C-c C-e v l/L
10587 Export only the visible part of the document.
10588 @item M-x org-export-region-as-latex
10589 Convert the region to @LaTeX{} under the assumption that it was in Org mode
10590 syntax before.  This is a global command that can be invoked in any
10591 buffer.
10592 @item M-x org-replace-region-by-latex
10593 Replace the active region (assumed to be in Org mode syntax) by @LaTeX{}
10594 code.
10595 @orgcmd{C-c C-e p,org-export-as-pdf}
10596 Export as @LaTeX{} and then process to PDF.
10597 @orgcmd{C-c C-e d,org-export-as-pdf-and-open}
10598 Export as @LaTeX{} and then process to PDF, then open the resulting PDF file.
10599 @end table
10601 @cindex headline levels, for exporting
10602 @vindex org-latex-low-levels
10603 In the exported version, the first 3 outline levels will become
10604 headlines, defining a general document structure.  Additional levels
10605 will be exported as description lists.  The exporter can ignore them or
10606 convert them to a custom string depending on
10607 @code{org-latex-low-levels}.
10609 If you want that transition to occur at a different level, specify it
10610 with a numeric prefix argument.  For example,
10612 @example
10613 @kbd{C-2 C-c C-e l}
10614 @end example
10616 @noindent
10617 creates two levels of headings and does the rest as items.
10619 @node Header and sectioning, Quoting @LaTeX{} code, @LaTeX{}/PDF export commands, @LaTeX{} and PDF export
10620 @subsection Header and sectioning structure
10621 @cindex @LaTeX{} class
10622 @cindex @LaTeX{} sectioning structure
10623 @cindex @LaTeX{} header
10624 @cindex header, for @LaTeX{} files
10625 @cindex sectioning structure, for @LaTeX{} export
10627 By default, the @LaTeX{} output uses the class @code{article}.
10629 @vindex org-latex-default-class
10630 @vindex org-latex-classes
10631 @vindex org-latex-default-packages-alist
10632 @vindex org-latex-packages-alist
10633 @cindex #+LaTeX_HEADER
10634 @cindex #+LaTeX_CLASS
10635 @cindex #+LaTeX_CLASS_OPTIONS
10636 @cindex property, LaTeX_CLASS
10637 @cindex property, LaTeX_CLASS_OPTIONS
10638 You can change this globally by setting a different value for
10639 @code{org-latex-default-class} or locally by adding an option like
10640 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
10641 property that applies when exporting a region containing only this (sub)tree.
10642 The class must be listed in @code{org-latex-classes}.  This variable
10643 defines a header template for each class@footnote{Into which the values of
10644 @code{org-latex-default-packages-alist} and
10645 @code{org-latex-packages-alist} are spliced.}, and allows you to
10646 define the sectioning structure for each class.  You can also define your own
10647 classes there.  @code{#+LaTeX_CLASS_OPTIONS} or a @code{:LaTeX_CLASS_OPTIONS:}
10648 property can specify the options for the @code{\documentclass} macro.  The
10649 options to documentclass have to be provided, as expected by @LaTeX{}, within
10650 square brackets.  You can also use @code{#+LaTeX_HEADER: \usepackage@{xyz@}}
10651 to add lines to the header.  See the docstring of
10652 @code{org-latex-classes} for more information.  An example is shown
10653 below.
10655 @example
10656 #+LaTeX_CLASS: article
10657 #+LaTeX_CLASS_OPTIONS: [a4paper]
10658 #+LaTeX_HEADER: \usepackage@{xyz@}
10660 * Headline 1
10661   some text
10662 @end example
10664 @node Quoting @LaTeX{} code, Tables in @LaTeX{} export, Header and sectioning, @LaTeX{} and PDF export
10665 @subsection Quoting @LaTeX{} code
10667 Embedded @LaTeX{} as described in @ref{Embedded @LaTeX{}}, will be correctly
10668 inserted into the @LaTeX{} file.  This includes simple macros like
10669 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
10670 you can add special code that should only be present in @LaTeX{} export with
10671 the following constructs:
10673 @cindex #+LaTeX
10674 @cindex #+BEGIN_LaTeX
10675 @example
10676 #+LaTeX: Literal @LaTeX{} code for export
10677 @end example
10679 @noindent or
10680 @cindex #+BEGIN_LaTeX
10682 @example
10683 #+BEGIN_LaTeX
10684 All lines between these markers are exported literally
10685 #+END_LaTeX
10686 @end example
10689 @node Tables in @LaTeX{} export, Images in @LaTeX{} export, Quoting @LaTeX{} code, @LaTeX{} and PDF export
10690 @subsection Tables in @LaTeX{} export
10691 @cindex tables, in @LaTeX{} export
10693 For @LaTeX{} export of a table, you can specify a label, a caption and
10694 placement options (@pxref{Images and tables}).  You can also use the
10695 @code{ATTR_LaTeX} line to request a @code{longtable} environment for the
10696 table, so that it may span several pages, or to change the default table
10697 environment from @code{table} to @code{table*} or to change the default inner
10698 tabular environment to @code{tabularx} or @code{tabulary}.  Finally, you can
10699 set the alignment string, and (with @code{tabularx} or @code{tabulary}) the
10700 width:
10702 @cindex #+CAPTION
10703 @cindex #+LABEL
10704 @cindex #+ATTR_LaTeX
10705 @example
10706 #+CAPTION: A long table
10707 #+LABEL: tbl:long
10708 #+ATTR_LaTeX: longtable align=l|lp@{3cm@}r|l
10709 | ..... | ..... |
10710 | ..... | ..... |
10711 @end example
10713 or to specify a multicolumn table with @code{tabulary}
10715 @cindex #+CAPTION
10716 @cindex #+LABEL
10717 @cindex #+ATTR_LaTeX
10718 @example
10719 #+CAPTION: A wide table with tabulary
10720 #+LABEL: tbl:wide
10721 #+ATTR_LaTeX: table* tabulary width=\textwidth
10722 | ..... | ..... |
10723 | ..... | ..... |
10724 @end example
10726 @node Images in @LaTeX{} export, Beamer class export, Tables in @LaTeX{} export, @LaTeX{} and PDF export
10727 @subsection Images in @LaTeX{} export
10728 @cindex images, inline in @LaTeX{}
10729 @cindex inlining images in @LaTeX{}
10731 Images that are linked to without a description part in the link, like
10732 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
10733 output file resulting from @LaTeX{} processing.  Org will use an
10734 @code{\includegraphics} macro to insert the image.  If you have specified a
10735 caption and/or a label as described in @ref{Images and tables}, the figure
10736 will be wrapped into a @code{figure} environment and thus become a floating
10737 element.  You can use an @code{#+ATTR_LaTeX:} line to specify various other
10738 options.  You can ask org to export an image as a float without specifying
10739 a label or a caption by using the keyword @code{float} in this line.  Various
10740 optional arguments to the @code{\includegraphics} macro can also be specified
10741 in this fashion.  To modify the placement option of the floating environment,
10742 add something like @samp{placement=[h!]} to the attributes.  It is to be noted
10743 this option can be used with tables as well@footnote{One can also take
10744 advantage of this option to pass other, unrelated options into the figure or
10745 table environment.  For an example see the section ``Exporting org files'' in
10746 @url{http://orgmode.org/worg/org-hacks.html}}.
10748 If you would like to let text flow around the image, add the word @samp{wrap}
10749 to the @code{#+ATTR_LaTeX:} line, which will make the figure occupy the left
10750 half of the page.  To fine-tune, the @code{placement} field will be the set
10751 of additional arguments needed by the @code{wrapfigure} environment.  Note
10752 that if you change the size of the image, you need to use compatible settings
10753 for @code{\includegraphics} and @code{wrapfigure}.
10755 @cindex #+CAPTION
10756 @cindex #+LABEL
10757 @cindex #+ATTR_LaTeX
10758 @example
10759 #+CAPTION:    The black-body emission of the disk around HR 4049
10760 #+LABEL:      fig:SED-HR4049
10761 #+ATTR_LaTeX: width=5cm,angle=90
10762 [[./img/sed-hr4049.pdf]]
10764 #+ATTR_LaTeX: width=0.38\textwidth wrap placement=@{r@}@{0.4\textwidth@}
10765 [[./img/hst.png]]
10766 @end example
10768 If you wish to include an image which spans multiple columns in a page, you
10769 can use the keyword @code{multicolumn} in the @code{#+ATTR_LaTeX} line.  This
10770 will export the image wrapped in a @code{figure*} environment.
10772 If you need references to a label created in this way, write
10773 @samp{\ref@{fig:SED-HR4049@}} just like in @LaTeX{}.
10775 @node Beamer class export,  , Images in @LaTeX{} export, @LaTeX{} and PDF export
10776 @subsection Beamer class export
10778 The @LaTeX{} class @file{beamer} allows production of high quality presentations
10779 using @LaTeX{} and pdf processing.  Org mode has special support for turning an
10780 Org mode file or tree into a @file{beamer} presentation.
10782 When the @LaTeX{} class for the current buffer (as set with @code{#+LaTeX_CLASS:
10783 beamer}) or subtree (set with a @code{LaTeX_CLASS} property) is
10784 @code{beamer}, a special export mode will turn the file or tree into a beamer
10785 presentation.  Any tree with not-too-deep level nesting should in principle be
10786 exportable as a beamer presentation.  By default, the top-level entries (or
10787 the first level below the selected subtree heading) will be turned into
10788 frames, and the outline structure below this level will become itemize lists.
10789 You can also configure the variable @code{org-beamer-frame-level} to a
10790 different level---then the hierarchy above frames will produce the sectioning
10791 structure of the presentation.
10793 A template for useful in-buffer settings or properties can be inserted into
10794 the buffer with @kbd{M-x org-insert-beamer-options-template}.  Among other
10795 things, this will install a column view format which is very handy for
10796 editing special properties used by beamer.
10798 You can influence the structure of the presentation using the following
10799 properties:
10801 @table @code
10802 @item BEAMER_env
10803 The environment that should be used to format this entry.  Valid environments
10804 are defined in the constant @code{org-beamer-environments-default}, and you
10805 can define more in @code{org-beamer-environments-extra}.  If this property is
10806 set, the entry will also get a @code{:B_environment:} tag to make this
10807 visible.  This tag has no semantic meaning, it is only a visual aid.
10808 @item BEAMER_envargs
10809 The beamer-special arguments that should be used for the environment, like
10810 @code{[t]} or @code{[<+->]} of @code{<2-3>}.  If the @code{BEAMER_col}
10811 property is also set, something like @code{C[t]} can be added here as well to
10812 set an options argument for the implied @code{columns} environment.
10813 @code{c[t]} or @code{c<2->} will set an options for the implied @code{column}
10814 environment.
10815 @item BEAMER_col
10816 The width of a column that should start with this entry.  If this property is
10817 set, the entry will also get a @code{:BMCOL:} property to make this visible.
10818 Also this tag is only a visual aid.  When this is a plain number, it will be
10819 interpreted as a fraction of @code{\textwidth}.  Otherwise it will be assumed
10820 that you have specified the units, like @samp{3cm}.  The first such property
10821 in a frame will start a @code{columns} environment to surround the columns.
10822 This environment is closed when an entry has a @code{BEAMER_col} property
10823 with value 0 or 1, or automatically at the end of the frame.
10824 @item BEAMER_extra
10825 Additional commands that should be inserted after the environment has been
10826 opened.  For example, when creating a frame, this can be used to specify
10827 transitions.
10828 @end table
10830 Frames will automatically receive a @code{fragile} option if they contain
10831 source code that uses the verbatim environment.  Special @file{beamer}
10832 specific code can be inserted using @code{#+BEAMER:} and
10833 @code{#+BEGIN_BEAMER...#+END_BEAMER} constructs, similar to other export
10834 backends, but with the difference that @code{#+LaTeX:} stuff will be included
10835 in the presentation as well.
10837 Outline nodes with @code{BEAMER_env} property value @samp{note} or
10838 @samp{noteNH} will be formatted as beamer notes, i,e, they will be wrapped
10839 into @code{\note@{...@}}.  The former will include the heading as part of the
10840 note text, the latter will ignore the heading of that node.  To simplify note
10841 generation, it is actually enough to mark the note with a @emph{tag} (either
10842 @code{:B_note:} or @code{:B_noteNH:}) instead of creating the
10843 @code{BEAMER_env} property.
10845 You can turn on a special minor mode @code{org-beamer-mode} for editing
10846 support with
10848 @example
10849 #+STARTUP: beamer
10850 @end example
10852 @table @kbd
10853 @orgcmd{C-c C-b,org-beamer-select-environment}
10854 In @code{org-beamer-mode}, this key offers fast selection of a beamer
10855 environment or the @code{BEAMER_col} property.
10856 @end table
10858 Column view provides a great way to set the environment of a node and other
10859 important parameters.  Make sure you are using a COLUMN format that is geared
10860 toward this special purpose.  The command @kbd{M-x
10861 org-insert-beamer-options-template} defines such a format.
10863 Here is a simple example Org document that is intended for beamer export.
10865 @smallexample
10866 #+LaTeX_CLASS: beamer
10867 #+TITLE: Example Presentation
10868 #+AUTHOR: Carsten Dominik
10869 #+LaTeX_CLASS_OPTIONS: [presentation]
10870 #+BEAMER_FRAME_LEVEL: 2
10871 #+BEAMER_HEADER_EXTRA: \usetheme@{Madrid@}\usecolortheme@{default@}
10872 #+COLUMNS: %35ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Args) %4BEAMER_col(Col) %8BEAMER_extra(Ex)
10874 * This is the first structural section
10876 ** Frame 1 \\ with a subtitle
10877 *** Thanks to Eric Fraga                                      :BMCOL:B_block:
10878     :PROPERTIES:
10879     :BEAMER_env: block
10880     :BEAMER_envargs: C[t]
10881     :BEAMER_col: 0.5
10882     :END:
10883     for the first viable beamer setup in Org
10884 *** Thanks to everyone else                                   :BMCOL:B_block:
10885     :PROPERTIES:
10886     :BEAMER_col: 0.5
10887     :BEAMER_env: block
10888     :BEAMER_envargs: <2->
10889     :END:
10890     for contributing to the discussion
10891 **** This will be formatted as a beamer note                  :B_note:
10892 ** Frame 2 \\ where we will not use columns
10893 *** Request                                                   :B_block:
10894     Please test this stuff!
10895     :PROPERTIES:
10896     :BEAMER_env: block
10897     :END:
10898 @end smallexample
10900 For more information, see the documentation on Worg.
10902 @c begin opendocument
10904 @node OpenDocument Text export, Freemind export, @LaTeX{} and PDF export, Exporting
10905 @section OpenDocument Text export
10906 @cindex K, Jambunathan
10907 @cindex ODT
10908 @cindex OpenDocument
10909 @cindex export, OpenDocument
10910 @cindex LibreOffice
10911 @cindex org-odt.el
10912 @cindex org-modules
10914 Org Mode@footnote{Versions 7.8 or later} supports export to OpenDocument Text
10915 (ODT) format using the @file{org-odt.el} module.  Documents created
10916 by this exporter use the @cite{OpenDocument-v1.2
10917 specification}@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
10918 Open Document Format for Office Applications (OpenDocument) Version 1.2}} and
10919 are compatible with LibreOffice 3.4.
10921 @menu
10922 * Pre-requisites for ODT export::  What packages ODT exporter relies on
10923 * ODT export commands::         How to invoke ODT export
10924 * Extending ODT export::        How to produce @samp{doc}, @samp{pdf} files
10925 * Applying custom styles::      How to apply custom styles to the output
10926 * Links in ODT export::         How links will be interpreted and formatted
10927 * Tables in ODT export::        How Tables are exported
10928 * Images in ODT export::        How to insert images
10929 * Math formatting in ODT export::  How @LaTeX{} fragments are formatted
10930 * Labels and captions in ODT export::  How captions are rendered
10931 * Literal examples in ODT export::  How source and example blocks are formatted
10932 * Advanced topics in ODT export::  Read this if you are a power user
10933 @end menu
10935 @node Pre-requisites for ODT export, ODT export commands, OpenDocument Text export, OpenDocument Text export
10936 @subsection Pre-requisites for ODT export
10937 @cindex zip
10938 The ODT exporter relies on the @file{zip} program to create the final
10939 output.  Check the availability of this program before proceeding further.
10941 @node ODT export commands, Extending ODT export, Pre-requisites for ODT export, OpenDocument Text export
10942 @subsection ODT export commands
10944 @subsubheading Exporting to ODT
10945 @anchor{x-export-to-odt}
10947 @cindex region, active
10948 @cindex active region
10949 @cindex transient-mark-mode
10950 @table @kbd
10951 @orgcmd{C-c C-e o,org-export-as-odt}
10952 @cindex property EXPORT_FILE_NAME
10954 Export as OpenDocument Text file.
10956 @vindex org-export-odt-preferred-output-format
10957 If @code{org-export-odt-preferred-output-format} is specified, automatically
10958 convert the exported file to that format.  @xref{x-export-to-other-formats, ,
10959 Automatically exporting to other formats}.
10961 For an Org file @file{myfile.org}, the ODT file will be
10962 @file{myfile.odt}.  The file will be overwritten without warning.  If there
10963 is an active region,@footnote{This requires @code{transient-mark-mode} to be
10964 turned on} only the region will be exported.  If the selected region is a
10965 single tree,@footnote{To select the current subtree, use @kbd{C-c @@}} the
10966 tree head will become the document title.  If the tree head entry has, or
10967 inherits, an @code{EXPORT_FILE_NAME} property, that name will be used for the
10968 export.
10970 @orgcmd{C-c C-e O,org-export-as-odt-and-open}
10971 Export as an OpenDocument Text file and open the resulting file.
10973 @vindex org-export-odt-preferred-output-format
10974 If @code{org-export-odt-preferred-output-format} is specified, open the
10975 converted file instead.  @xref{x-export-to-other-formats, , Automatically
10976 exporting to other formats}.
10977 @end table
10979 @node Extending ODT export, Applying custom styles, ODT export commands, OpenDocument Text export
10980 @subsection Extending ODT export
10982 The ODT exporter can interface with a variety of document
10983 converters and supports popular converters out of the box.  As a result, you
10984 can use it to export to formats like @samp{doc} or convert a document from
10985 one format (say @samp{csv}) to another format (say @samp{ods} or @samp{xls}).
10987 @cindex @file{unoconv}
10988 @cindex LibreOffice
10989 If you have a working installation of LibreOffice, a document converter is
10990 pre-configured for you and you can use it right away.  If you would like to
10991 use @file{unoconv} as your preferred converter, customize the variable
10992 @code{org-export-odt-convert-process} to point to @code{unoconv}.  You can
10993 also use your own favorite converter or tweak the default settings of the
10994 @file{LibreOffice} and @samp{unoconv} converters.  @xref{Configuring a
10995 document converter}.
10997 @subsubsection Automatically exporting to other formats
10998 @anchor{x-export-to-other-formats}
11000 @vindex org-export-odt-preferred-output-format
11001 Very often, you will find yourself exporting to ODT format, only to
11002 immediately save the exported document to other formats like @samp{doc},
11003 @samp{docx}, @samp{rtf}, @samp{pdf} etc.  In such cases, you can specify your
11004 preferred output format by customizing the variable
11005 @code{org-export-odt-preferred-output-format}.  This way, the export commands
11006 (@pxref{x-export-to-odt,,Exporting to ODT}) can be extended to export to a
11007 format that is of immediate interest to you.
11009 @subsubsection Converting between document formats
11010 @anchor{x-convert-to-other-formats}
11012 There are many document converters in the wild which support conversion to
11013 and from various file formats, including, but not limited to the
11014 ODT format.  LibreOffice converter, mentioned above, is one such
11015 converter.  Once a converter is configured, you can interact with it using
11016 the following command.
11018 @vindex org-export-odt-convert
11019 @table @kbd
11021 @item M-x org-export-odt-convert
11022 Convert an existing document from one format to another.  With a prefix
11023 argument, also open the newly produced file.
11024 @end table
11026 @node Applying custom styles, Links in ODT export, Extending ODT export, OpenDocument Text export
11027 @subsection Applying custom styles
11028 @cindex styles, custom
11029 @cindex template, custom
11031 The ODT exporter ships with a set of OpenDocument styles
11032 (@pxref{Working with OpenDocument style files}) that ensure a well-formatted
11033 output.  These factory styles, however, may not cater to your specific
11034 tastes.  To customize the output, you can either modify the above styles
11035 files directly, or generate the required styles using an application like
11036 LibreOffice.  The latter method is suitable for expert and non-expert
11037 users alike, and is described here.
11039 @subsubsection Applying custom styles: the easy way
11041 @enumerate
11042 @item
11043 Create a sample @file{example.org} file with the below settings and export it
11044 to ODT format.
11046 @example
11047 #+OPTIONS: H:10 num:t
11048 @end example
11050 @item
11051 Open the above @file{example.odt} using LibreOffice.  Use the @file{Stylist}
11052 to locate the target styles---these typically have the @samp{Org} prefix---and
11053 modify those to your taste.  Save the modified file either as an
11054 OpenDocument Text (@file{.odt}) or OpenDocument Template (@file{.ott}) file.
11056 @item
11057 @cindex #+ODT_STYLES_FILE
11058 @vindex org-export-odt-styles-file
11059 Customize the variable @code{org-export-odt-styles-file} and point it to the
11060 newly created file.  For additional configuration options
11061 @pxref{x-overriding-factory-styles,,Overriding factory styles}.
11063 If you would like to choose a style on a per-file basis, you can use the
11064 @code{#+ODT_STYLES_FILE} option.  A typical setting will look like
11066 @example
11067 #+ODT_STYLES_FILE: "/path/to/example.ott"
11068 @end example
11072 @example
11073 #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
11074 @end example
11076 @end enumerate
11078 @subsubsection Using third-party styles and templates
11080 You can use third-party styles and templates for customizing your output.
11081 This will produce the desired output only if the template provides all
11082 style names that the @samp{ODT} exporter relies on.  Unless this condition is
11083 met, the output is going to be less than satisfactory.  So it is highly
11084 recommended that you only work with templates that are directly derived from
11085 the factory settings.
11087 @node Links in ODT export, Tables in ODT export, Applying custom styles, OpenDocument Text export
11088 @subsection Links in ODT export
11089 @cindex links, in ODT export
11091 ODT exporter creates native cross-references for internal links.  It creates
11092 Internet-style links for all other links.
11094 A link with no description and destined to a regular (un-itemized) outline
11095 heading is replaced with a cross-reference and section number of the heading.
11097 A @samp{\ref@{label@}}-style reference to an image, table etc. is replaced
11098 with a cross-reference and sequence number of the labeled entity.
11099 @xref{Labels and captions in ODT export}.
11101 @node Tables in ODT export, Images in ODT export, Links in ODT export, OpenDocument Text export
11102 @subsection Tables in ODT export
11103 @cindex tables, in ODT export
11105 Export of native Org mode tables (@pxref{Tables}) and simple @file{table.el}
11106 tables is supported.  However, export of complex @file{table.el} tables---tables
11107 that have column or row spans---is not supported.  Such tables are
11108 stripped from the exported document.
11110 By default, a table is exported with top and bottom frames and with rules
11111 separating row and column groups (@pxref{Column groups}).  Furthermore, all
11112 tables are typeset to occupy the same width.  If the table specifies
11113 alignment and relative width for its columns (@pxref{Column width and
11114 alignment}) then these are honored on export.@footnote{The column widths are
11115 interpreted as weighted ratios with the default weight being 1}
11117 @cindex #+ATTR_ODT
11118 You can control the width of the table by specifying @code{:rel-width}
11119 property using an @code{#+ATTR_ODT} line.
11121 For example, consider the following table which makes use of all the rules
11122 mentioned above.
11124 @example
11125 #+ATTR_ODT: :rel-width 50
11126 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
11127 |---------------+-------+-------+-------+-------|
11128 | /             |     < |       |       |     < |
11129 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
11130 | North America |     1 |    21 |   926 |   948 |
11131 | Middle East   |     6 |    75 |   844 |   925 |
11132 | Asia Pacific  |     9 |    27 |   790 |   826 |
11133 |---------------+-------+-------+-------+-------|
11134 | Sum           |    16 |   123 |  2560 |  2699 |
11135 @end example
11137 On export, the table will occupy 50% of text area.  The columns will be sized
11138 (roughly) in the ratio of 13:5:5:5:6.  The first column will be left-aligned
11139 and rest of the columns will be right-aligned.  There will be vertical rules
11140 after separating the header and last columns from other columns.  There will
11141 be horizontal rules separating the header and last rows from other rows.
11143 If you are not satisfied with the above formatting options, you can create
11144 custom table styles and associate them with a table using the
11145 @code{#+ATTR_ODT} line.  @xref{Customizing tables in ODT export}.
11147 @node Images in ODT export, Math formatting in ODT export, Tables in ODT export, OpenDocument Text export
11148 @subsection Images in ODT export
11149 @cindex images, embedding in ODT
11150 @cindex embedding images in ODT
11152 @subsubheading Embedding images
11153 You can embed images within the exported document by providing a link to the
11154 desired image file with no link description.  For example, to embed
11155 @samp{img.png} do either of the following:
11157 @example
11158 [[file:img.png]]
11159 @end example
11161 @example
11162 [[./img.png]]
11163 @end example
11165 @subsubheading Embedding clickable images
11166 You can create clickable images by providing a link whose description is a
11167 link to an image file.  For example, to embed a image
11168 @file{org-mode-unicorn.png} which when clicked jumps to
11169 @uref{http://Orgmode.org} website, do the following
11171 @example
11172 [[http://orgmode.org][./org-mode-unicorn.png]]
11173 @end example
11175 @subsubheading Sizing and scaling of embedded images
11177 @cindex #+ATTR_ODT
11178 You can control the size and scale of the embedded images using the
11179 @code{#+ATTR_ODT} attribute.
11181 @cindex identify, ImageMagick
11182 @vindex org-export-odt-pixels-per-inch
11183 The exporter specifies the desired size of the image in the final document in
11184 units of centimeters.  In order to scale the embedded images, the exporter
11185 queries for pixel dimensions of the images using one of a) ImageMagick's
11186 @file{identify} program or b) Emacs `create-image' and `image-size'
11187 APIs.@footnote{Use of @file{ImageMagick} is only desirable.  However, if you
11188 routinely produce documents that have large images or you export your Org
11189 files that has images using a Emacs batch script, then the use of
11190 @file{ImageMagick} is mandatory.} The pixel dimensions are subsequently
11191 converted in to units of centimeters using
11192 @code{org-export-odt-pixels-per-inch}.  The default value of this variable is
11193 set to @code{display-pixels-per-inch}.  You can tweak this variable to
11194 achieve the best results.
11196 The examples below illustrate the various possibilities.
11198 @table @asis
11199 @item Explicitly size the image
11200 To embed @file{img.png} as a 10 cm x 10 cm image, do the following:
11202 @example
11203 #+ATTR_ODT: :width 10 :height 10
11204 [[./img.png]]
11205 @end example
11207 @item Scale the image
11208 To embed @file{img.png} at half its size, do the following:
11210 @example
11211 #+ATTR_ODT: :scale 0.5
11212 [[./img.png]]
11213 @end example
11215 @item Scale the image to a specific width
11216 To embed @file{img.png} with a width of 10 cm while retaining the original
11217 height:width ratio, do the following:
11219 @example
11220 #+ATTR_ODT: :width 10
11221 [[./img.png]]
11222 @end example
11224 @item Scale the image to a specific height
11225 To embed @file{img.png} with a height of 10 cm while retaining the original
11226 height:width ratio, do the following
11228 @example
11229 #+ATTR_ODT: :height 10
11230 [[./img.png]]
11231 @end example
11232 @end table
11234 @subsubheading Anchoring of images
11236 @cindex #+ATTR_ODT
11237 You can control the manner in which an image is anchored by setting the
11238 @code{:anchor} property of it's @code{#+ATTR_ODT} line.  You can specify one
11239 of the the following three values for the @code{:anchor} property:
11240 @samp{"as-char"}, @samp{"paragraph"} and @samp{"page"}.
11242 To create an image that is anchored to a page, do the following:
11243 @example
11244 #+ATTR_ODT: :anchor "page"
11245 [[./img.png]]
11246 @end example
11248 @node Math formatting in ODT export, Labels and captions in ODT export, Images in ODT export, OpenDocument Text export
11249 @subsection Math formatting in ODT export
11251 The ODT exporter has special support for handling math.
11253 @menu
11254 * Working with @LaTeX{} math snippets::  How to embed @LaTeX{} math fragments
11255 * Working with MathML or OpenDocument formula files::  How to embed equations in native format
11256 @end menu
11258 @node Working with @LaTeX{} math snippets, Working with MathML or OpenDocument formula files, Math formatting in ODT export, Math formatting in ODT export
11259 @subsubsection Working with @LaTeX{} math snippets
11261 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be embedded in the ODT
11262 document in one of the following ways:
11264 @cindex MathML
11265 @enumerate
11266 @item MathML
11268 This option is activated on a per-file basis with
11270 @example
11271 #+OPTIONS: LaTeX:t
11272 @end example
11274 With this option, @LaTeX{} fragments are first converted into MathML
11275 fragments using an external @LaTeX{}-to-MathML converter program.  The
11276 resulting MathML fragments are then embedded as an OpenDocument Formula in
11277 the exported document.
11279 @vindex org-latex-to-mathml-convert-command
11280 @vindex org-latex-to-mathml-jar-file
11282 You can specify the @LaTeX{}-to-MathML converter by customizing the variables
11283 @code{org-latex-to-mathml-convert-command} and
11284 @code{org-latex-to-mathml-jar-file}.
11286 If you prefer to use @file{MathToWeb}@footnote{See
11287 @uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}} as your
11288 converter, you can configure the above variables as shown below.
11290 @lisp
11291 (setq org-latex-to-mathml-convert-command
11292       "java -jar %j -unicode -force -df %o %I"
11293       org-latex-to-mathml-jar-file
11294       "/path/to/mathtoweb.jar")
11295 @end lisp
11297 You can use the following commands to quickly verify the reliability of
11298 the @LaTeX{}-to-MathML converter.
11300 @table @kbd
11302 @item M-x org-export-as-odf
11303 Convert a @LaTeX{} math snippet to an OpenDocument formula (@file{.odf}) file.
11305 @item M-x org-export-as-odf-and-open
11306 Convert a @LaTeX{} math snippet to an OpenDocument formula (@file{.odf}) file
11307 and open the formula file with the system-registered application.
11308 @end table
11310 @cindex dvipng
11311 @item PNG images
11313 This option is activated on a per-file basis with
11315 @example
11316 #+OPTIONS: LaTeX:dvipng
11317 @end example
11319 With this option, @LaTeX{} fragments are processed into PNG images and the
11320 resulting images are embedded in the exported document.  This method requires
11321 that the @file{dvipng} program be available on your system.
11322 @end enumerate
11324 @node Working with MathML or OpenDocument formula files,  , Working with @LaTeX{} math snippets, Math formatting in ODT export
11325 @subsubsection Working with MathML or OpenDocument formula files
11327 For various reasons, you may find embedding @LaTeX{} math snippets in an
11328 ODT document less than reliable.  In that case, you can embed a
11329 math equation by linking to its MathML (@file{.mml}) source or its
11330 OpenDocument formula (@file{.odf}) file as shown below:
11332 @example
11333 [[./equation.mml]]
11334 @end example
11338 @example
11339 [[./equation.odf]]
11340 @end example
11342 @node Labels and captions in ODT export, Literal examples in ODT export, Math formatting in ODT export, OpenDocument Text export
11343 @subsection Labels and captions in ODT export
11345 You can label and caption various category of objects---an inline image, a
11346 table, a @LaTeX{} fragment or a Math formula---using @code{#+LABEL} and
11347 @code{#+CAPTION} lines.  @xref{Images and tables}.  ODT exporter enumerates
11348 each labeled or captioned object of a given category separately.  As a
11349 result, each such object is assigned a sequence number based on order of it's
11350 appearance in the Org file.
11352 In the exported document, a user-provided caption is augmented with the
11353 category and sequence number.  Consider the following inline image in an Org
11354 file.
11356 @example
11357 #+CAPTION: Bell curve
11358 #+LABEL:   fig:SED-HR4049
11359 [[./img/a.png]]
11360 @end example
11362 It could be rendered as shown below in the exported document.
11364 @example
11365 Figure 2: Bell curve
11366 @end example
11368 @vindex org-export-odt-category-strings
11369 You can modify the category component of the caption by customizing the
11370 variable @code{org-export-odt-category-strings}.  For example, to tag all
11371 embedded images with the string @samp{Illustration} (instead of the default
11372 @samp{Figure}) use the following setting.
11374 @lisp
11375 (setq org-export-odt-category-strings
11376       '(("en" "Table" "Illustration" "Equation" "Equation")))
11377 @end lisp
11379 With this, previous image will be captioned as below in the exported
11380 document.
11382 @example
11383 Illustration 2: Bell curve
11384 @end example
11386 @node Literal examples in ODT export, Advanced topics in ODT export, Labels and captions in ODT export, OpenDocument Text export
11387 @subsection Literal examples in ODT export
11389 Export of literal examples (@pxref{Literal examples}) with full fontification
11390 is supported.  Internally, the exporter relies on @file{htmlfontify.el} to
11391 generate all style definitions needed for a fancy listing.@footnote{Your
11392 @file{htmlfontify.el} library must at least be at Emacs 24.1 levels for
11393 fontification to be turned on.}  The auto-generated styles have @samp{OrgSrc}
11394 as prefix and inherit their color from the faces used by Emacs
11395 @code{font-lock} library for the source language.
11397 @vindex org-export-odt-fontify-srcblocks
11398 If you prefer to use your own custom styles for fontification, you can do so
11399 by customizing the variable
11400 @code{org-export-odt-create-custom-styles-for-srcblocks}.
11402 @vindex org-export-odt-create-custom-styles-for-srcblocks
11403 You can turn off fontification of literal examples by customizing the
11404 variable @code{org-export-odt-fontify-srcblocks}.
11406 @node Advanced topics in ODT export,  , Literal examples in ODT export, OpenDocument Text export
11407 @subsection Advanced topics in ODT export
11409 If you rely heavily on ODT export, you may want to exploit the full
11410 set of features that the exporter offers.  This section describes features
11411 that would be of interest to power users.
11413 @menu
11414 * Configuring a document converter::  How to register a document converter
11415 * Working with OpenDocument style files::  Explore the internals
11416 * Creating one-off styles::     How to produce custom highlighting etc
11417 * Customizing tables in ODT export::  How to define and use Table templates
11418 * Validating OpenDocument XML::  How to debug corrupt OpenDocument files
11419 @end menu
11421 @node Configuring a document converter, Working with OpenDocument style files, Advanced topics in ODT export, Advanced topics in ODT export
11422 @subsubsection Configuring a document converter
11423 @cindex convert
11424 @cindex doc, docx, rtf
11425 @cindex converter
11427 The ODT exporter can work with popular converters with little or no
11428 extra configuration from your side. @xref{Extending ODT export}.
11429 If you are using a converter that is not supported by default or if you would
11430 like to tweak the default converter settings, proceed as below.
11432 @enumerate
11433 @item Register the converter
11435 @vindex org-export-odt-convert-processes
11436 Name your converter and add it to the list of known converters by customizing
11437 the variable @code{org-export-odt-convert-processes}.  Also specify how the
11438 converter can be invoked via command-line to effect the conversion.
11440 @item Configure its capabilities
11442 @vindex org-export-odt-convert-capabilities
11443 @anchor{x-odt-converter-capabilities}
11444 Specify the set of formats the converter can handle by customizing the
11445 variable @code{org-export-odt-convert-capabilities}.  Use the default value
11446 for this variable as a guide for configuring your converter.  As suggested by
11447 the default setting, you can specify the full set of formats supported by the
11448 converter and not limit yourself to specifying formats that are related to
11449 just the OpenDocument Text format.
11451 @item Choose the converter
11453 @vindex org-export-odt-convert-process
11454 Select the newly added converter as the preferred one by customizing the
11455 variable @code{org-export-odt-convert-process}.
11456 @end enumerate
11458 @node Working with OpenDocument style files, Creating one-off styles, Configuring a document converter, Advanced topics in ODT export
11459 @subsubsection Working with OpenDocument style files
11460 @cindex styles, custom
11461 @cindex template, custom
11463 This section explores the internals of the ODT exporter and the
11464 means by which it produces styled documents.  Read this section if you are
11465 interested in exploring the automatic and custom OpenDocument styles used by
11466 the exporter.
11468 @anchor{x-factory-styles}
11469 @subsubheading Factory styles
11471 The ODT exporter relies on two files for generating its output.
11472 These files are bundled with the distribution under the directory pointed to
11473 by the variable @code{org-odt-styles-dir}.  The two files are:
11475 @itemize
11476 @anchor{x-orgodtstyles-xml}
11477 @item
11478 @file{OrgOdtStyles.xml}
11480 This file contributes to the @file{styles.xml} file of the final @samp{ODT}
11481 document.  This file gets modified for the following purposes:
11482 @enumerate
11484 @item
11485 To control outline numbering based on user settings.
11487 @item
11488 To add styles generated by @file{htmlfontify.el} for fontification of code
11489 blocks.
11490 @end enumerate
11492 @anchor{x-orgodtcontenttemplate-xml}
11493 @item
11494 @file{OrgOdtContentTemplate.xml}
11496 This file contributes to the @file{content.xml} file of the final @samp{ODT}
11497 document.  The contents of the Org outline are inserted between the
11498 @samp{<office:text>}@dots{}@samp{</office:text>} elements of this file.
11500 Apart from serving as a template file for the final @file{content.xml}, the
11501 file serves the following purposes:
11502 @enumerate
11504 @item
11505 It contains automatic styles for formatting of tables which are referenced by
11506 the exporter.
11508 @item
11509 It contains @samp{<text:sequence-decl>}@dots{}@samp{</text:sequence-decl>}
11510 elements that control how various entities---tables, images, equations,
11511 etc.---are numbered.
11512 @end enumerate
11513 @end itemize
11515 @anchor{x-overriding-factory-styles}
11516 @subsubheading Overriding factory styles
11517 The following two variables control the location from which the ODT
11518 exporter picks up the custom styles and content template files.  You can
11519 customize these variables to override the factory styles used by the
11520 exporter.
11522 @itemize
11523 @anchor{x-org-export-odt-styles-file}
11524 @item
11525 @code{org-export-odt-styles-file}
11527 Use this variable to specify the @file{styles.xml} that will be used in the
11528 final output.  You can specify one of the following values:
11530 @enumerate
11531 @item A @file{styles.xml} file
11533 Use this file instead of the default @file{styles.xml}
11535 @item A @file{.odt} or @file{.ott} file
11537 Use the @file{styles.xml} contained in the specified OpenDocument Text or
11538 Template file
11540 @item A @file{.odt} or @file{.ott} file and a subset of files contained within them
11542 Use the @file{styles.xml} contained in the specified OpenDocument Text or
11543 Template file.  Additionally extract the specified member files and embed
11544 those within the final @samp{ODT} document.
11546 Use this option if the @file{styles.xml} file references additional files
11547 like header and footer images.
11549 @item @code{nil}
11551 Use the default @file{styles.xml}
11552 @end enumerate
11554 @anchor{x-org-export-odt-content-template-file}
11555 @item
11556 @code{org-export-odt-content-template-file}
11558 Use this variable to specify the blank @file{content.xml} that will be used
11559 in the final output.
11560 @end itemize
11562 @node Creating one-off styles, Customizing tables in ODT export, Working with OpenDocument style files, Advanced topics in ODT export
11563 @subsubsection Creating one-off styles
11565 There are times when you would want one-off formatting in the exported
11566 document.  You can achieve this by embedding raw OpenDocument XML in the Org
11567 file.  The use of this feature is better illustrated with couple of examples.
11569 @enumerate
11570 @item Embedding ODT tags as part of regular text
11572 You can include simple OpenDocument tags by prefixing them with
11573 @samp{@@}.  For example, to highlight a region of text do the following:
11575 @example
11576 @@<text:span text:style-name="Highlight">This is a
11577 highlighted text@@</text:span>.  But this is a
11578 regular text.
11579 @end example
11581 @strong{Hint:} To see the above example in action, edit your
11582 @file{styles.xml} (@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
11583 custom @samp{Highlight} style as shown below.
11585 @example
11586 <style:style style:name="Highlight" style:family="text">
11587   <style:text-properties fo:background-color="#ff0000"/>
11588 </style:style>
11589 @end example
11591 @item Embedding a one-line OpenDocument XML
11593 You can add a simple OpenDocument one-liner using the @code{#+ODT:}
11594 directive.  For example, to force a page break do the following:
11596 @example
11597 #+ODT: <text:p text:style-name="PageBreak"/>
11598 @end example
11600 @strong{Hint:} To see the above example in action, edit your
11601 @file{styles.xml} (@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
11602 custom @samp{PageBreak} style as shown below.
11604 @example
11605 <style:style style:name="PageBreak" style:family="paragraph"
11606              style:parent-style-name="Text_20_body">
11607   <style:paragraph-properties fo:break-before="page"/>
11608 </style:style>
11609 @end example
11611 @item Embedding a block of OpenDocument XML
11613 You can add a large block of OpenDocument XML using the
11614 @code{#+BEGIN_ODT}@dots{}@code{#+END_ODT} construct.
11616 For example, to create a one-off paragraph that uses bold text, do the
11617 following:
11619 @example
11620 #+BEGIN_ODT
11621 <text:p text:style-name="Text_20_body_20_bold">
11622 This paragraph is specially formatted and uses bold text.
11623 </text:p>
11624 #+END_ODT
11625 @end example
11627 @end enumerate
11629 @node Customizing tables in ODT export, Validating OpenDocument XML, Creating one-off styles, Advanced topics in ODT export
11630 @subsubsection Customizing tables in ODT export
11631 @cindex tables, in ODT export
11633 @cindex #+ATTR_ODT
11634 You can override the default formatting of the table by specifying a custom
11635 table style with the @code{#+ATTR_ODT} line.  For a discussion on default
11636 formatting of tables @pxref{Tables in ODT export}.
11638 This feature closely mimics the way table templates are defined in the
11639 OpenDocument-v1.2
11640 specification.@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
11641 OpenDocument-v1.2 Specification}}
11645 @subsubheading Custom table styles: an illustration
11647 To have a quick preview of this feature, install the below setting and export
11648 the table that follows.
11650 @lisp
11651 (setq org-export-odt-table-styles
11652       (append org-export-odt-table-styles
11653               '(("TableWithHeaderRowAndColumn" "Custom"
11654                  ((use-first-row-styles . t)
11655                   (use-first-column-styles . t)))
11656                 ("TableWithFirstRowandLastRow" "Custom"
11657                  ((use-first-row-styles . t)
11658                   (use-last-row-styles . t))))))
11659 @end lisp
11661 @example
11662 #+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
11663 | Name  | Phone | Age |
11664 | Peter |  1234 |  17 |
11665 | Anna  |  4321 |  25 |
11666 @end example
11668 In the above example, you used a template named @samp{Custom} and installed
11669 two table styles with the names @samp{TableWithHeaderRowAndColumn} and
11670 @samp{TableWithFirstRowandLastRow}.  (@strong{Important:} The OpenDocument
11671 styles needed for producing the above template have been pre-defined for you.
11672 These styles are available under the section marked @samp{Custom Table
11673 Template} in @file{OrgOdtContentTemplate.xml}
11674 (@pxref{x-orgodtcontenttemplate-xml,,Factory styles}).  If you need
11675 additional templates you have to define these styles yourselves.
11677 @subsubheading Custom table styles: the nitty-gritty
11678 To use this feature proceed as follows:
11680 @enumerate
11681 @item
11682 Create a table template@footnote{See the @code{<table:table-template>}
11683 element of the OpenDocument-v1.2 specification}
11685 A table template is nothing but a set of @samp{table-cell} and
11686 @samp{paragraph} styles for each of the following table cell categories:
11688 @itemize @minus
11689 @item Body
11690 @item First column
11691 @item Last column
11692 @item First row
11693 @item Last row
11694 @item Even row
11695 @item Odd row
11696 @item Even column
11697 @item Odd Column
11698 @end itemize
11700 The names for the above styles must be chosen based on the name of the table
11701 template using a well-defined convention.
11703 The naming convention is better illustrated with an example.  For a table
11704 template with the name @samp{Custom}, the needed style names are listed in
11705 the following table.
11707 @multitable  {Table cell type} {CustomEvenColumnTableCell} {CustomEvenColumnTableParagraph}
11708 @headitem Table cell type
11709 @tab @code{table-cell} style
11710 @tab @code{paragraph} style
11711 @item
11712 @tab
11713 @tab
11714 @item Body
11715 @tab @samp{CustomTableCell}
11716 @tab @samp{CustomTableParagraph}
11717 @item First column
11718 @tab @samp{CustomFirstColumnTableCell}
11719 @tab @samp{CustomFirstColumnTableParagraph}
11720 @item Last column
11721 @tab @samp{CustomLastColumnTableCell}
11722 @tab @samp{CustomLastColumnTableParagraph}
11723 @item First row
11724 @tab @samp{CustomFirstRowTableCell}
11725 @tab @samp{CustomFirstRowTableParagraph}
11726 @item Last row
11727 @tab @samp{CustomLastRowTableCell}
11728 @tab @samp{CustomLastRowTableParagraph}
11729 @item Even row
11730 @tab @samp{CustomEvenRowTableCell}
11731 @tab @samp{CustomEvenRowTableParagraph}
11732 @item Odd row
11733 @tab @samp{CustomOddRowTableCell}
11734 @tab @samp{CustomOddRowTableParagraph}
11735 @item Even column
11736 @tab @samp{CustomEvenColumnTableCell}
11737 @tab @samp{CustomEvenColumnTableParagraph}
11738 @item Odd column
11739 @tab @samp{CustomOddColumnTableCell}
11740 @tab @samp{CustomOddColumnTableParagraph}
11741 @end multitable
11743 To create a table template with the name @samp{Custom}, define the above
11744 styles in the
11745 @code{<office:automatic-styles>}...@code{</office:automatic-styles>} element
11746 of the content template file (@pxref{x-orgodtcontenttemplate-xml,,Factory
11747 styles}).
11749 @item
11750 Define a table style@footnote{See the attributes @code{table:template-name},
11751 @code{table:use-first-row-styles}, @code{table:use-last-row-styles},
11752 @code{table:use-first-column-styles}, @code{table:use-last-column-styles},
11753 @code{table:use-banding-rows-styles}, and
11754 @code{table:use-banding-column-styles} of the @code{<table:table>} element in
11755 the OpenDocument-v1.2 specification}
11757 @vindex org-export-odt-table-styles
11758 To define a table style, create an entry for the style in the variable
11759 @code{org-export-odt-table-styles} and specify the following:
11761 @itemize @minus
11762 @item the name of the table template created in step (1)
11763 @item the set of cell styles in that template that are to be activated
11764 @end itemize
11766 For example, the entry below defines two different table styles
11767 @samp{TableWithHeaderRowAndColumn} and @samp{TableWithFirstRowandLastRow}
11768 based on the same template @samp{Custom}.  The styles achieve their intended
11769 effect by selectively activating the individual cell styles in that template.
11771 @lisp
11772 (setq org-export-odt-table-styles
11773       (append org-export-odt-table-styles
11774               '(("TableWithHeaderRowAndColumn" "Custom"
11775                  ((use-first-row-styles . t)
11776                   (use-first-column-styles . t)))
11777                 ("TableWithFirstRowandLastRow" "Custom"
11778                  ((use-first-row-styles . t)
11779                   (use-last-row-styles . t))))))
11780 @end lisp
11782 @item
11783 Associate a table with the table style
11785 To do this, specify the table style created in step (2) as part of
11786 the @code{ATTR_ODT} line as shown below.
11788 @example
11789 #+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
11790 | Name  | Phone | Age |
11791 | Peter |  1234 |  17 |
11792 | Anna  |  4321 |  25 |
11793 @end example
11794 @end enumerate
11796 @node Validating OpenDocument XML,  , Customizing tables in ODT export, Advanced topics in ODT export
11797 @subsubsection Validating OpenDocument XML
11799 Occasionally, you will discover that the document created by the
11800 ODT exporter cannot be opened by your favorite application.  One of
11801 the common reasons for this is that the @file{.odt} file is corrupt.  In such
11802 cases, you may want to validate the document against the OpenDocument RELAX
11803 NG Compact Syntax (RNC) schema.
11805 For de-compressing the @file{.odt} file@footnote{@file{.odt} files are
11806 nothing but @samp{zip} archives}: @inforef{File Archives,,emacs}.  For
11807 general help with validation (and schema-sensitive editing) of XML files:
11808 @inforef{Introduction,,nxml-mode}.
11810 @vindex org-export-odt-schema-dir
11811 If you have ready access to OpenDocument @file{.rnc} files and the needed
11812 schema-locating rules in a single folder, you can customize the variable
11813 @code{org-export-odt-schema-dir} to point to that directory.  The
11814 ODT exporter will take care of updating the
11815 @code{rng-schema-locating-files} for you.
11817 @c end opendocument
11819 @node Freemind export, iCalendar export, OpenDocument Text export, Exporting
11820 @section Freemind export
11821 @cindex Freemind export
11822 @cindex mind map
11824 The Freemind exporter was written by Lennart Borgman.
11826 @table @kbd
11827 @orgcmd{C-c C-e m,org-export-as-freemind}
11828 Export as a Freemind mind map.  For an Org file @file{myfile.org}, the Freemind
11829 file will be @file{myfile.mm}.
11830 @end table
11832 @node iCalendar export,  , Freemind export, Exporting
11833 @section iCalendar export
11834 @cindex iCalendar export
11836 @vindex org-icalendar-include-todo
11837 @vindex org-icalendar-use-deadline
11838 @vindex org-icalendar-use-scheduled
11839 @vindex org-icalendar-categories
11840 @vindex org-icalendar-alarm-time
11841 Some people use Org mode for keeping track of projects, but still prefer a
11842 standard calendar application for anniversaries and appointments.  In this
11843 case it can be useful to show deadlines and other time-stamped items in Org
11844 files in the calendar application.  Org mode can export calendar information
11845 in the standard iCalendar format.  If you also want to have TODO entries
11846 included in the export, configure the variable
11847 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
11848 and TODO items as VTODO@.  It will also create events from deadlines that are
11849 in non-TODO items.  Deadlines and scheduling dates in TODO items will be used
11850 to set the start and due dates for the TODO entry@footnote{See the variables
11851 @code{org-icalendar-use-deadline} and @code{org-icalendar-use-scheduled}.}.
11852 As categories, it will use the tags locally defined in the heading, and the
11853 file/tree category@footnote{To add inherited tags or the TODO state,
11854 configure the variable @code{org-icalendar-categories}.}.  See the variable
11855 @code{org-icalendar-alarm-time} for a way to assign alarms to entries with a
11856 time.
11858 @vindex org-icalendar-store-UID
11859 @cindex property, ID
11860 The iCalendar standard requires each entry to have a globally unique
11861 identifier (UID).  Org creates these identifiers during export.  If you set
11862 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
11863 @code{:ID:} property of the entry and re-used next time you report this
11864 entry.  Since a single entry can give rise to multiple iCalendar entries (as
11865 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
11866 prefixes to the UID, depending on what triggered the inclusion of the entry.
11867 In this way the UID remains unique, but a synchronization program can still
11868 figure out from which entry all the different instances originate.
11870 @table @kbd
11871 @orgcmd{C-c C-e i,org-export-icalendar-this-file}
11872 Create iCalendar entries for the current file and store them in the same
11873 directory, using a file extension @file{.ics}.
11874 @orgcmd{C-c C-e I, org-export-icalendar-all-agenda-files}
11875 @vindex org-agenda-files
11876 Like @kbd{C-c C-e i}, but do this for all files in
11877 @code{org-agenda-files}.  For each of these files, a separate iCalendar
11878 file will be written.
11879 @orgcmd{C-c C-e c,org-export-icalendar-combine-agenda-files}
11880 @vindex org-combined-agenda-icalendar-file
11881 Create a single large iCalendar file from all files in
11882 @code{org-agenda-files} and write it to the file given by
11883 @code{org-combined-agenda-icalendar-file}.
11884 @end table
11886 @vindex org-use-property-inheritance
11887 @vindex org-icalendar-include-body
11888 @cindex property, SUMMARY
11889 @cindex property, DESCRIPTION
11890 @cindex property, LOCATION
11891 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
11892 property can be inherited from higher in the hierarchy if you configure
11893 @code{org-use-property-inheritance} accordingly.} properties if the selected
11894 entries have them.  If not, the summary will be derived from the headline,
11895 and the description from the body (limited to
11896 @code{org-icalendar-include-body} characters).
11898 How this calendar is best read and updated, depends on the application
11899 you are using.  The FAQ covers this issue.
11901 @node Publishing, Working With Source Code, Exporting, Top
11902 @chapter Publishing
11903 @cindex publishing
11905 Org includes a publishing management system that allows you to configure
11906 automatic HTML conversion of @emph{projects} composed of interlinked org
11907 files.  You can also configure Org to automatically upload your exported HTML
11908 pages and related attachments, such as images and source code files, to a web
11909 server.
11911 You can also use Org to convert files into PDF, or even combine HTML and PDF
11912 conversion so that files are available in both formats on the server.
11914 Publishing has been contributed to Org by David O'Toole.
11916 @menu
11917 * Configuration::               Defining projects
11918 * Uploading files::             How to get files up on the server
11919 * Sample configuration::        Example projects
11920 * Triggering publication::      Publication commands
11921 @end menu
11923 @node Configuration, Uploading files, Publishing, Publishing
11924 @section Configuration
11926 Publishing needs significant configuration to specify files, destination
11927 and many other properties of a project.
11929 @menu
11930 * Project alist::               The central configuration variable
11931 * Sources and destinations::    From here to there
11932 * Selecting files::             What files are part of the project?
11933 * Publishing action::           Setting the function doing the publishing
11934 * Publishing options::          Tweaking HTML/@LaTeX{} export
11935 * Publishing links::            Which links keep working after publishing?
11936 * Sitemap::                     Generating a list of all pages
11937 * Generating an index::         An index that reaches across pages
11938 @end menu
11940 @node Project alist, Sources and destinations, Configuration, Configuration
11941 @subsection The variable @code{org-publish-project-alist}
11942 @cindex org-publish-project-alist
11943 @cindex projects, for publishing
11945 @vindex org-publish-project-alist
11946 Publishing is configured almost entirely through setting the value of one
11947 variable, called @code{org-publish-project-alist}.  Each element of the list
11948 configures one project, and may be in one of the two following forms:
11950 @lisp
11951    ("project-name" :property value :property value ...)
11952      @r{i.e., a well-formed property list with alternating keys and values}
11953 @r{or}
11954    ("project-name" :components ("project-name" "project-name" ...))
11956 @end lisp
11958 In both cases, projects are configured by specifying property values.  A
11959 project defines the set of files that will be published, as well as the
11960 publishing configuration to use when publishing those files.  When a project
11961 takes the second form listed above, the individual members of the
11962 @code{:components} property are taken to be sub-projects, which group
11963 together files requiring different publishing options.  When you publish such
11964 a ``meta-project'', all the components will also be published, in the
11965 sequence given.
11967 @node Sources and destinations, Selecting files, Project alist, Configuration
11968 @subsection Sources and destinations for files
11969 @cindex directories, for publishing
11971 Most properties are optional, but some should always be set.  In
11972 particular, Org needs to know where to look for source files,
11973 and where to put published files.
11975 @multitable @columnfractions 0.3 0.7
11976 @item @code{:base-directory}
11977 @tab Directory containing publishing source files
11978 @item @code{:publishing-directory}
11979 @tab Directory where output files will be published.  You can directly
11980 publish to a webserver using a file name syntax appropriate for
11981 the Emacs @file{tramp} package.  Or you can publish to a local directory and
11982 use external tools to upload your website (@pxref{Uploading files}).
11983 @item @code{:preparation-function}
11984 @tab Function or list of functions to be called before starting the
11985 publishing process, for example, to run @code{make} for updating files to be
11986 published.  The project property list is scoped into this call as the
11987 variable @code{project-plist}.
11988 @item @code{:completion-function}
11989 @tab Function or list of functions called after finishing the publishing
11990 process, for example, to change permissions of the resulting files.  The
11991 project property list is scoped into this call as the variable
11992 @code{project-plist}.
11993 @end multitable
11994 @noindent
11996 @node Selecting files, Publishing action, Sources and destinations, Configuration
11997 @subsection Selecting files
11998 @cindex files, selecting for publishing
12000 By default, all files with extension @file{.org} in the base directory
12001 are considered part of the project.  This can be modified by setting the
12002 properties
12003 @multitable @columnfractions 0.25 0.75
12004 @item @code{:base-extension}
12005 @tab Extension (without the dot!) of source files.  This actually is a
12006 regular expression.  Set this to the symbol @code{any} if you want to get all
12007 files in @code{:base-directory}, even without extension.
12009 @item @code{:exclude}
12010 @tab Regular expression to match file names that should not be
12011 published, even though they have been selected on the basis of their
12012 extension.
12014 @item @code{:include}
12015 @tab List of files to be included regardless of @code{:base-extension}
12016 and @code{:exclude}.
12018 @item @code{:recursive}
12019 @tab Non-nil means, check base-directory recursively for files to publish.
12020 @end multitable
12022 @node Publishing action, Publishing options, Selecting files, Configuration
12023 @subsection Publishing action
12024 @cindex action, for publishing
12026 Publishing means that a file is copied to the destination directory and
12027 possibly transformed in the process.  The default transformation is to export
12028 Org files as HTML files, and this is done by the function
12029 @code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
12030 export}).  But you also can publish your content as PDF files using
12031 @code{org-publish-org-to-pdf}, or as @code{ascii}, @code{latin1} or
12032 @code{utf8} encoded files using the corresponding functions.  If you want to
12033 publish the Org file itself, but with @i{archived}, @i{commented}, and
12034 @i{tag-excluded} trees removed, use @code{org-publish-org-to-org} and set the
12035 parameters @code{:plain-source} and/or @code{:htmlized-source}.  This will
12036 produce @file{file.org} and @file{file.org.html} in the publishing
12037 directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
12038 source and publishing directories are equal.  Note that with this kind of
12039 setup, you need to add @code{:exclude "-source\\.org"} to the project
12040 definition in @code{org-publish-project-alist} to prevent the published
12041 source files from being considered as new org files the next time the project
12042 is published.}.  Other files like images only need to be copied to the
12043 publishing destination; for this you may use @code{org-publish-attachment}.
12044 For non-Org files, you always need to specify the publishing function:
12046 @multitable @columnfractions 0.3 0.7
12047 @item @code{:publishing-function}
12048 @tab Function executing the publication of a file.  This may also be a
12049 list of functions, which will all be called in turn.
12050 @item @code{:plain-source}
12051 @tab Non-nil means, publish plain source.
12052 @item @code{:htmlized-source}
12053 @tab Non-nil means, publish htmlized source.
12054 @end multitable
12056 The function must accept three arguments: a property list containing at least
12057 a @code{:publishing-directory} property, the name of the file to be
12058 published, and the path to the publishing directory of the output file.  It
12059 should take the specified file, make the necessary transformation (if any)
12060 and place the result into the destination folder.
12062 @node Publishing options, Publishing links, Publishing action, Configuration
12063 @subsection Options for the HTML/@LaTeX{} exporters
12064 @cindex options, for publishing
12066 The property list can be used to set many export options for the HTML
12067 and @LaTeX{} exporters.  In most cases, these properties correspond to user
12068 variables in Org.  The table below lists these properties along
12069 with the variable they belong to.  See the documentation string for the
12070 respective variable for details.
12072 @vindex org-html-link-up
12073 @vindex org-html-link-home
12074 @vindex org-export-default-language
12075 @vindex org-display-custom-times
12076 @vindex org-export-headline-levels
12077 @vindex org-export-with-section-numbers
12078 @vindex org-export-section-number-format
12079 @vindex org-export-with-toc
12080 @vindex org-export-preserve-breaks
12081 @vindex org-export-with-archived-trees
12082 @vindex org-export-with-emphasize
12083 @vindex org-export-with-sub-superscripts
12084 @vindex org-export-with-special-strings
12085 @vindex org-export-with-footnotes
12086 @vindex org-export-with-drawers
12087 @vindex org-export-with-tags
12088 @vindex org-export-with-todo-keywords
12089 @vindex org-export-with-tasks
12090 @vindex org-export-with-done-tasks
12091 @vindex org-export-with-priority
12092 @vindex org-export-with-TeX-macros
12093 @vindex org-export-with-LaTeX-fragments
12094 @vindex org-export-skip-text-before-1st-heading
12095 @vindex org-export-with-fixed-width
12096 @vindex org-export-with-timestamps
12097 @vindex org-export-author-info
12098 @vindex org-export-email-info
12099 @vindex org-export-creator-info
12100 @vindex org-export-time-stamp-file
12101 @vindex org-export-with-tables
12102 @vindex org-export-highlight-first-table-line
12103 @vindex org-html-style-include-default
12104 @vindex org-html-style-include-scripts
12105 @vindex org-html-style
12106 @vindex org-html-style-extra
12107 @vindex org-html-link-org-files-as-html
12108 @vindex org-html-inline-images
12109 @vindex org-html-extension
12110 @vindex org-html-table-tag
12111 @vindex org-export-publishing-directory
12112 @vindex org-html-preamble
12113 @vindex org-html-postamble
12114 @vindex user-full-name
12115 @vindex user-mail-address
12116 @vindex org-export-select-tags
12117 @vindex org-export-exclude-tags
12119 @multitable @columnfractions 0.32 0.68
12120 @item @code{:link-up}               @tab @code{org-html-link-up}
12121 @item @code{:link-home}             @tab @code{org-html-link-home}
12122 @item @code{:language}              @tab @code{org-export-default-language}
12123 @item @code{:customtime}            @tab @code{org-display-custom-times}
12124 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
12125 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
12126 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
12127 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
12128 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
12129 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
12130 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
12131 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
12132 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
12133 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
12134 @item @code{:drawers}               @tab @code{org-export-with-drawers}
12135 @item @code{:tags}                  @tab @code{org-export-with-tags}
12136 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
12137 @item @code{:tasks}                 @tab @code{org-export-with-tasks}
12138 @item @code{:priority}              @tab @code{org-export-with-priority}
12139 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
12140 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
12141 @item @code{:latex-listings}        @tab @code{org-latex-listings}
12142 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
12143 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
12144 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
12145 @item @code{:author}                @tab @code{user-full-name}
12146 @item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
12147 @item @code{:author-info}           @tab @code{org-export-author-info}
12148 @item @code{:email-info}            @tab @code{org-export-email-info}
12149 @item @code{:creator-info}          @tab @code{org-export-creator-info}
12150 @item @code{:tables}                @tab @code{org-export-with-tables}
12151 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
12152 @item @code{:style-include-default} @tab @code{org-html-style-include-default}
12153 @item @code{:style-include-scripts} @tab @code{org-html-style-include-scripts}
12154 @item @code{:style}                 @tab @code{org-html-style}
12155 @item @code{:style-extra}           @tab @code{org-html-style-extra}
12156 @item @code{:convert-org-links}     @tab @code{org-html-link-org-files-as-html}
12157 @item @code{:inline-images}         @tab @code{org-html-inline-images}
12158 @item @code{:html-extension}        @tab @code{org-html-extension}
12159 @item @code{:html-preamble}         @tab @code{org-html-preamble}
12160 @item @code{:html-postamble}        @tab @code{org-html-postamble}
12161 @item @code{:xml-declaration}       @tab @code{org-html-xml-declaration}
12162 @item @code{:html-table-tag}        @tab @code{org-html-table-tag}
12163 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
12164 @item @code{:select-tags}           @tab @code{org-export-select-tags}
12165 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
12166 @item @code{:latex-image-options}   @tab @code{org-latex-image-default-option}
12167 @end multitable
12169 Most of the @code{org-export-with-*} variables have the same effect in
12170 both HTML and @LaTeX{} exporters, except for @code{:TeX-macros} and
12171 @code{:LaTeX-fragments} options, respectively @code{nil} and @code{t} in the
12172 @LaTeX{} export.  See @code{org-export-plist-vars} to check this list of
12173 options.
12177 @vindex org-publish-project-alist
12178 When a property is given a value in @code{org-publish-project-alist},
12179 its setting overrides the value of the corresponding user variable (if
12180 any) during publishing.  Options set within a file (@pxref{Export
12181 options}), however, override everything.
12183 @node Publishing links, Sitemap, Publishing options, Configuration
12184 @subsection Links between published files
12185 @cindex links, publishing
12187 To create a link from one Org file to another, you would use
12188 something like @samp{[[file:foo.org][The foo]]} or simply
12189 @samp{file:foo.org.} (@pxref{Hyperlinks}).  When published, this link
12190 becomes a link to @file{foo.html}.  In this way, you can interlink the
12191 pages of your "org web" project and the links will work as expected when
12192 you publish them to HTML@.  If you also publish the Org source file and want
12193 to link to that, use an @code{http:} link instead of a @code{file:} link,
12194 because @code{file:} links are converted to link to the corresponding
12195 @file{html} file.
12197 You may also link to related files, such as images.  Provided you are careful
12198 with relative file names, and provided you have also configured Org to upload
12199 the related files, these links will work too.  See @ref{Complex example}, for
12200 an example of this usage.
12202 Sometimes an Org file to be published may contain links that are
12203 only valid in your production environment, but not in the publishing
12204 location.  In this case, use the property
12206 @multitable @columnfractions 0.4 0.6
12207 @item @code{:link-validation-function}
12208 @tab Function to validate links
12209 @end multitable
12211 @noindent
12212 to define a function for checking link validity.  This function must
12213 accept two arguments, the file name and a directory relative to which
12214 the file name is interpreted in the production environment.  If this
12215 function returns @code{nil}, then the HTML generator will only insert a
12216 description into the HTML file, but no link.  One option for this
12217 function is @code{org-publish-validate-link} which checks if the given
12218 file is part of any project in @code{org-publish-project-alist}.
12220 @node Sitemap, Generating an index, Publishing links, Configuration
12221 @subsection Generating a sitemap
12222 @cindex sitemap, of published pages
12224 The following properties may be used to control publishing of
12225 a map of files for a given project.
12227 @multitable @columnfractions 0.35 0.65
12228 @item @code{:auto-sitemap}
12229 @tab When non-nil, publish a sitemap during @code{org-publish-current-project}
12230 or @code{org-publish-all}.
12232 @item @code{:sitemap-filename}
12233 @tab Filename for output of sitemap.  Defaults to @file{sitemap.org} (which
12234 becomes @file{sitemap.html}).
12236 @item @code{:sitemap-title}
12237 @tab Title of sitemap page.  Defaults to name of file.
12239 @item @code{:sitemap-function}
12240 @tab Plug-in function to use for generation of the sitemap.
12241 Defaults to @code{org-publish-org-sitemap}, which generates a plain list
12242 of links to all files in the project.
12244 @item @code{:sitemap-sort-folders}
12245 @tab Where folders should appear in the sitemap.  Set this to @code{first}
12246 (default) or @code{last} to display folders first or last,
12247 respectively.  Any other value will mix files and folders.
12249 @item @code{:sitemap-sort-files}
12250 @tab How the files are sorted in the site map.  Set this to
12251 @code{alphabetically} (default), @code{chronologically} or
12252 @code{anti-chronologically}.  @code{chronologically} sorts the files with
12253 older date first while @code{anti-chronologically} sorts the files with newer
12254 date first.  @code{alphabetically} sorts the files alphabetically.  The date of
12255 a file is retrieved with @code{org-publish-find-date}.
12257 @item @code{:sitemap-ignore-case}
12258 @tab Should sorting be case-sensitive?  Default @code{nil}.
12260 @item @code{:sitemap-file-entry-format}
12261 @tab With this option one can tell how a sitemap's entry is formatted in the
12262 sitemap.  This is a format string with some escape sequences: @code{%t} stands
12263 for the title of the file, @code{%a} stands for the author of the file and
12264 @code{%d} stands for the date of the file.  The date is retrieved with the
12265 @code{org-publish-find-date} function and formatted with
12266 @code{org-publish-sitemap-date-format}.  Default @code{%t}.
12268 @item @code{:sitemap-date-format}
12269 @tab Format string for the @code{format-time-string} function that tells how
12270 a sitemap entry's date is to be formatted.  This property bypasses
12271 @code{org-publish-sitemap-date-format} which defaults to @code{%Y-%m-%d}.
12273 @item @code{:sitemap-sans-extension}
12274 @tab When non-nil, remove filenames' extensions from the generated sitemap.
12275 Useful to have cool URIs (see @uref{http://www.w3.org/Provider/Style/URI}).
12276 Defaults to @code{nil}.
12278 @end multitable
12280 @node Generating an index,  , Sitemap, Configuration
12281 @subsection Generating an index
12282 @cindex index, in a publishing project
12284 Org mode can generate an index across the files of a publishing project.
12286 @multitable @columnfractions 0.25 0.75
12287 @item @code{:makeindex}
12288 @tab When non-nil, generate in index in the file @file{theindex.org} and
12289 publish it as @file{theindex.html}.
12290 @end multitable
12292 The file will be created when first publishing a project with the
12293 @code{:makeindex} set.  The file only contains a statement @code{#+INCLUDE:
12294 "theindex.inc"}.  You can then build around this include statement by adding
12295 a title, style information, etc.
12297 @node Uploading files, Sample configuration, Configuration, Publishing
12298 @section Uploading files
12299 @cindex rsync
12300 @cindex unison
12302 For those people already utilizing third party sync tools such as
12303 @command{rsync} or @command{unison}, it might be preferable not to use the built in
12304 @i{remote} publishing facilities of Org mode which rely heavily on
12305 Tramp.  Tramp, while very useful and powerful, tends not to be
12306 so efficient for multiple file transfer and has been known to cause problems
12307 under heavy usage.
12309 Specialized synchronization utilities offer several advantages.  In addition
12310 to timestamp comparison, they also do content and permissions/attribute
12311 checks.  For this reason you might prefer to publish your web to a local
12312 directory (possibly even @i{in place} with your Org files) and then use
12313 @file{unison} or @file{rsync} to do the synchronization with the remote host.
12315 Since Unison (for example) can be configured as to which files to transfer to
12316 a certain remote destination, it can greatly simplify the project publishing
12317 definition.  Simply keep all files in the correct location, process your Org
12318 files with @code{org-publish} and let the synchronization tool do the rest.
12319 You do not need, in this scenario, to include attachments such as @file{jpg},
12320 @file{css} or @file{gif} files in the project definition since the 3rd party
12321 tool syncs them.
12323 Publishing to a local directory is also much faster than to a remote one, so
12324 that you can afford more easily to republish entire projects.  If you set
12325 @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the main
12326 benefit of re-including any changed external files such as source example
12327 files you might include with @code{#+INCLUDE:}.  The timestamp mechanism in
12328 Org is not smart enough to detect if included files have been modified.
12330 @node Sample configuration, Triggering publication, Uploading files, Publishing
12331 @section Sample configuration
12333 Below we provide two example configurations.  The first one is a simple
12334 project publishing only a set of Org files.  The second example is
12335 more complex, with a multi-component project.
12337 @menu
12338 * Simple example::              One-component publishing
12339 * Complex example::             A multi-component publishing example
12340 @end menu
12342 @node Simple example, Complex example, Sample configuration, Sample configuration
12343 @subsection Example: simple publishing configuration
12345 This example publishes a set of Org files to the @file{public_html}
12346 directory on the local machine.
12348 @lisp
12349 (setq org-publish-project-alist
12350       '(("org"
12351          :base-directory "~/org/"
12352          :publishing-directory "~/public_html"
12353          :section-numbers nil
12354          :table-of-contents nil
12355          :style "<link rel=\"stylesheet\"
12356                 href=\"../other/mystyle.css\"
12357                 type=\"text/css\"/>")))
12358 @end lisp
12360 @node Complex example,  , Simple example, Sample configuration
12361 @subsection Example: complex publishing configuration
12363 This more complicated example publishes an entire website, including
12364 Org files converted to HTML, image files, Emacs Lisp source code, and
12365 style sheets.  The publishing directory is remote and private files are
12366 excluded.
12368 To ensure that links are preserved, care should be taken to replicate
12369 your directory structure on the web server, and to use relative file
12370 paths.  For example, if your Org files are kept in @file{~/org} and your
12371 publishable images in @file{~/images}, you would link to an image with
12373 @example
12374 file:../images/myimage.png
12375 @end example
12377 On the web server, the relative path to the image should be the
12378 same.  You can accomplish this by setting up an "images" folder in the
12379 right place on the web server, and publishing images to it.
12381 @lisp
12382 (setq org-publish-project-alist
12383       '(("orgfiles"
12384           :base-directory "~/org/"
12385           :base-extension "org"
12386           :publishing-directory "/ssh:user@@host:~/html/notebook/"
12387           :publishing-function org-publish-org-to-html
12388           :exclude "PrivatePage.org"   ;; regexp
12389           :headline-levels 3
12390           :section-numbers nil
12391           :table-of-contents nil
12392           :style "<link rel=\"stylesheet\"
12393                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
12394           :html-preamble t)
12396          ("images"
12397           :base-directory "~/images/"
12398           :base-extension "jpg\\|gif\\|png"
12399           :publishing-directory "/ssh:user@@host:~/html/images/"
12400           :publishing-function org-publish-attachment)
12402          ("other"
12403           :base-directory "~/other/"
12404           :base-extension "css\\|el"
12405           :publishing-directory "/ssh:user@@host:~/html/other/"
12406           :publishing-function org-publish-attachment)
12407          ("website" :components ("orgfiles" "images" "other"))))
12408 @end lisp
12410 @node Triggering publication,  , Sample configuration, Publishing
12411 @section Triggering publication
12413 Once properly configured, Org can publish with the following commands:
12415 @table @kbd
12416 @orgcmd{C-c C-e X,org-publish}
12417 Prompt for a specific project and publish all files that belong to it.
12418 @orgcmd{C-c C-e P,org-publish-current-project}
12419 Publish the project containing the current file.
12420 @orgcmd{C-c C-e F,org-publish-current-file}
12421 Publish only the current file.
12422 @orgcmd{C-c C-e E,org-publish-all}
12423 Publish every project.
12424 @end table
12426 @vindex org-publish-use-timestamps-flag
12427 Org uses timestamps to track when a file has changed.  The above functions
12428 normally only publish changed files.  You can override this and force
12429 publishing of all files by giving a prefix argument to any of the commands
12430 above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
12431 This may be necessary in particular if files include other files via
12432 @code{#+SETUPFILE:} or @code{#+INCLUDE:}.
12434 @comment  node-name,  next,  previous,  up
12435 @comment Working With Source Code, Miscellaneous, Publishing, Top
12437 @node Working With Source Code, Miscellaneous, Publishing, Top
12438 @chapter Working with source code
12439 @cindex Schulte, Eric
12440 @cindex Davison, Dan
12441 @cindex source code, working with
12443 Source code can be included in Org mode documents using a @samp{src} block,
12444 e.g.:
12446 @example
12447 #+BEGIN_SRC emacs-lisp
12448   (defun org-xor (a b)
12449      "Exclusive or."
12450      (if a (not b) b))
12451 #+END_SRC
12452 @end example
12454 Org mode provides a number of features for working with live source code,
12455 including editing of code blocks in their native major-mode, evaluation of
12456 code blocks, converting code blocks into source files (known as @dfn{tangling}
12457 in literate programming), and exporting code blocks and their
12458 results in several formats.  This functionality was contributed by Eric
12459 Schulte and Dan Davison, and was originally named Org-babel.
12461 The following sections describe Org mode's code block handling facilities.
12463 @menu
12464 * Structure of code blocks::    Code block syntax described
12465 * Editing source code::         Language major-mode editing
12466 * Exporting code blocks::       Export contents and/or results
12467 * Extracting source code::      Create pure source code files
12468 * Evaluating code blocks::      Place results of evaluation in the Org mode buffer
12469 * Library of Babel::            Use and contribute to a library of useful code blocks
12470 * Languages::                   List of supported code block languages
12471 * Header arguments::            Configure code block functionality
12472 * Results of evaluation::       How evaluation results are handled
12473 * Noweb reference syntax::      Literate programming in Org mode
12474 * Key bindings and useful functions::  Work quickly with code blocks
12475 * Batch execution::             Call functions from the command line
12476 @end menu
12478 @comment  node-name,  next,  previous,  up
12479 @comment  Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
12481 @node Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
12482 @section Structure of code blocks
12483 @cindex code block, structure
12484 @cindex source code, block structure
12485 @cindex #+NAME
12486 @cindex #+BEGIN_SRC
12488 Live code blocks can be specified with a @samp{src} block or
12489 inline.@footnote{Note that @samp{src} blocks may be inserted using Org mode's
12490 @ref{Easy Templates} system}  The structure of a @samp{src} block is
12492 @example
12493 #+NAME: <name>
12494 #+BEGIN_SRC <language> <switches> <header arguments>
12495   <body>
12496 #+END_SRC
12497 @end example
12499 The @code{#+NAME:} line is optional, and can be used to name the code
12500 block.  Live code blocks require that a language be specified on the
12501 @code{#+BEGIN_SRC} line.  Switches and header arguments are optional.
12502 @cindex source code, inline
12504 Live code blocks can also be specified inline using
12506 @example
12507 src_<language>@{<body>@}
12508 @end example
12512 @example
12513 src_<language>[<header arguments>]@{<body>@}
12514 @end example
12516 @table @code
12517 @item <#+NAME: name>
12518 This line associates a name with the code block.  This is similar to the
12519 @code{#+TBLNAME: NAME} lines that can be used to name tables in Org mode
12520 files.  Referencing the name of a code block makes it possible to evaluate
12521 the block from other places in the file, from other files, or from Org mode
12522 table formulas (see @ref{The spreadsheet}).  Names are assumed to be unique
12523 and the behavior of Org mode when two or more blocks share the same name is
12524 undefined.
12525 @cindex #+NAME
12526 @item <language>
12527 The language of the code in the block (see @ref{Languages}).
12528 @cindex source code, language
12529 @item <switches>
12530 Optional switches control code block export (see the discussion of switches in
12531 @ref{Literal examples})
12532 @cindex source code, switches
12533 @item <header arguments>
12534 Optional header arguments control many aspects of evaluation, export and
12535 tangling of code blocks (see @ref{Header arguments}).
12536 Header arguments can also be set on a per-buffer or per-subtree
12537 basis using properties.
12538 @item source code, header arguments
12539 @item <body>
12540 Source code in the specified language.
12541 @end table
12543 @comment  node-name,  next,  previous,  up
12544 @comment  Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
12546 @node Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
12547 @section Editing source code
12548 @cindex code block, editing
12549 @cindex source code, editing
12551 @kindex C-c '
12552 Use @kbd{C-c '} to edit the current code block.  This brings up
12553 a language major-mode edit buffer containing the body of the code
12554 block.  Saving this buffer will write the new contents back to the Org
12555 buffer.  Use @kbd{C-c '} again to exit.
12557 The @code{org-src-mode} minor mode will be active in the edit buffer.  The
12558 following variables can be used to configure the behavior of the edit
12559 buffer.  See also the customization group @code{org-edit-structure} for
12560 further configuration options.
12562 @table @code
12563 @item org-src-lang-modes
12564 If an Emacs major-mode named @code{<lang>-mode} exists, where
12565 @code{<lang>} is the language named in the header line of the code block,
12566 then the edit buffer will be placed in that major-mode.  This variable
12567 can be used to map arbitrary language names to existing major modes.
12568 @item org-src-window-setup
12569 Controls the way Emacs windows are rearranged when the edit buffer is created.
12570 @item org-src-preserve-indentation
12571 This variable is especially useful for tangling languages such as
12572 Python, in which whitespace indentation in the output is critical.
12573 @item org-src-ask-before-returning-to-edit-buffer
12574 By default, Org will ask before returning to an open edit buffer.  Set this
12575 variable to nil to switch without asking.
12576 @end table
12578 To turn on native code fontification in the @emph{Org} buffer, configure the
12579 variable @code{org-src-fontify-natively}.
12581 @comment  node-name,  next,  previous,  up
12582 @comment  Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
12584 @node Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
12585 @section Exporting code blocks
12586 @cindex code block, exporting
12587 @cindex source code, exporting
12589 It is possible to export the @emph{code} of code blocks, the @emph{results}
12590 of code block evaluation, @emph{both} the code and the results of code block
12591 evaluation, or @emph{none}.  For most languages, the default exports code.
12592 However, for some languages (e.g., @code{ditaa}) the default exports the
12593 results of code block evaluation.  For information on exporting code block
12594 bodies, see @ref{Literal examples}.
12596 The @code{:exports} header argument can be used to specify export
12597 behavior:
12599 @subsubheading Header arguments:
12600 @table @code
12601 @item :exports code
12602 The default in most languages.  The body of the code block is exported, as
12603 described in @ref{Literal examples}.
12604 @item :exports results
12605 The code block will be evaluated and the results will be placed in the
12606 Org mode buffer for export, either updating previous results of the code
12607 block located anywhere in the buffer or, if no previous results exist,
12608 placing the results immediately after the code block.  The body of the code
12609 block will not be exported.
12610 @item :exports both
12611 Both the code block and its results will be exported.
12612 @item :exports none
12613 Neither the code block nor its results will be exported.
12614 @end table
12616 It is possible to inhibit the evaluation of code blocks during export.
12617 Setting the @code{org-export-babel-evaluate} variable to @code{nil} will
12618 ensure that no code blocks are evaluated as part of the export process.  This
12619 can be useful in situations where potentially untrusted Org mode files are
12620 exported in an automated fashion, for example when Org mode is used as the
12621 markup language for a wiki.
12623 @comment  node-name,  next,  previous,  up
12624 @comment  Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
12625 @node Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
12626 @section Extracting source code
12627 @cindex tangling
12628 @cindex source code, extracting
12629 @cindex code block, extracting source code
12631 Creating pure source code files by extracting code from source blocks is
12632 referred to as ``tangling''---a term adopted from the literate programming
12633 community.  During ``tangling'' of code blocks their bodies are expanded
12634 using @code{org-babel-expand-src-block} which can expand both variable and
12635 ``noweb'' style references  (see @ref{Noweb reference syntax}).
12637 @subsubheading Header arguments
12638 @table @code
12639 @item :tangle no
12640 The default.  The code block is not included in the tangled output.
12641 @item :tangle yes
12642 Include the code block in the tangled output.  The output file name is the
12643 name of the org file with the extension @samp{.org} replaced by the extension
12644 for the block language.
12645 @item :tangle filename
12646 Include the code block in the tangled output to file @samp{filename}.
12647 @end table
12649 @kindex  C-c C-v t
12650 @subsubheading Functions
12651 @table @code
12652 @item org-babel-tangle
12653 Tangle the current file.  Bound to @kbd{C-c C-v t}.
12655 With prefix argument only tangle the current code block.
12656 @item org-babel-tangle-file
12657 Choose a file to tangle.  Bound to @kbd{C-c C-v f}.
12658 @end table
12660 @subsubheading Hooks
12661 @table @code
12662 @item org-babel-post-tangle-hook
12663 This hook is run from within code files tangled by @code{org-babel-tangle}.
12664 Example applications could include post-processing, compilation or evaluation
12665 of tangled code files.
12666 @end table
12668 @node Evaluating code blocks, Library of Babel, Extracting source code, Working With Source Code
12669 @section Evaluating code blocks
12670 @cindex code block, evaluating
12671 @cindex source code, evaluating
12672 @cindex #+RESULTS
12674 Code blocks can be evaluated@footnote{Whenever code is evaluated there is a
12675 potential for that code to do harm.  Org mode provides safeguards to ensure
12676 that code is only evaluated after explicit confirmation from the user.  For
12677 information on these safeguards (and on how to disable them) see @ref{Code
12678 evaluation security}.} and the results of evaluation optionally placed in the
12679 Org mode buffer.  The results of evaluation are placed following a line that
12680 begins by default with @code{#+RESULTS} and optionally a cache identifier
12681 and/or the name of the evaluated code block.  The default value of
12682 @code{#+RESULTS} can be changed with the customizable variable
12683 @code{org-babel-results-keyword}.
12685 By default, the evaluation facility is only enabled for Lisp code blocks
12686 specified as @code{emacs-lisp}.  However, source code blocks in many languages
12687 can be evaluated within Org mode (see @ref{Languages} for a list of supported
12688 languages and @ref{Structure of code blocks} for information on the syntax
12689 used to define a code block).
12691 @kindex C-c C-c
12692 There are a number of ways to evaluate code blocks.  The simplest is to press
12693 @kbd{C-c C-c} or @kbd{C-c C-v e} with the point on a code block@footnote{The
12694 @code{org-babel-no-eval-on-ctrl-c-ctrl-c} variable can be used to remove code
12695 evaluation from the @kbd{C-c C-c} key binding.}.  This will call the
12696 @code{org-babel-execute-src-block} function to evaluate the block and insert
12697 its results into the Org mode buffer.
12698 @cindex #+CALL
12700 It is also possible to evaluate named code blocks from anywhere in an Org
12701 mode buffer or an Org mode table.  Live code blocks located in the current
12702 Org mode buffer or in the ``Library of Babel'' (see @ref{Library of Babel})
12703 can be executed.  Named code blocks can be executed with a separate
12704 @code{#+CALL:} line or inline within a block of text.
12706 The syntax of the @code{#+CALL:} line is
12708 @example
12709 #+CALL: <name>(<arguments>)
12710 #+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
12711 @end example
12713 The syntax for inline evaluation of named code blocks is
12715 @example
12716 ... call_<name>(<arguments>) ...
12717 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
12718 @end example
12720 @table @code
12721 @item <name>
12722 The name of the code block to be evaluated (see @ref{Structure of code blocks}).
12723 @item <arguments>
12724 Arguments specified in this section will be passed to the code block.  These
12725 arguments use standard function call syntax, rather than
12726 header argument syntax.  For example, a @code{#+CALL:} line that passes the
12727 number four to a code block named @code{double}, which declares the header
12728 argument @code{:var n=2}, would be written as @code{#+CALL: double(n=4)}.
12729 @item <inside header arguments>
12730 Inside header arguments are passed through and applied to the named code
12731 block.  These arguments use header argument syntax rather than standard
12732 function call syntax.  Inside header arguments affect how the code block is
12733 evaluated.  For example, @code{[:results output]} will collect the results of
12734 everything printed to @code{STDOUT} during execution of the code block.
12735 @item <end header arguments>
12736 End header arguments are applied to the calling instance and do not affect
12737 evaluation of the named code block.  They affect how the results are
12738 incorporated into the Org mode buffer and how the call line is exported.  For
12739 example, @code{:results html} will insert the results of the call line
12740 evaluation in the Org buffer, wrapped in a @code{BEGIN_HTML:} block.
12742 For more examples of passing header arguments to @code{#+CALL:} lines see
12743 @ref{Header arguments in function calls}.
12744 @end table
12746 @node Library of Babel, Languages, Evaluating code blocks, Working With Source Code
12747 @section Library of Babel
12748 @cindex babel, library of
12749 @cindex source code, library
12750 @cindex code block, library
12752 The ``Library of Babel'' consists of code blocks that can be called from any
12753 Org mode file.  Code blocks defined in the ``Library of Babel'' can be called
12754 remotely as if they were in the current Org mode buffer (see @ref{Evaluating
12755 code blocks} for information on the syntax of remote code block evaluation).
12758 The central repository of code blocks in the ``Library of Babel'' is housed
12759 in an Org mode file located in the @samp{contrib} directory of Org mode.
12761 Users can add code blocks they believe to be generally useful to their
12762 ``Library of Babel.''  The code blocks can be stored in any Org mode file and
12763 then loaded into the library with @code{org-babel-lob-ingest}.
12766 @kindex C-c C-v i
12767 Code blocks located in any Org mode file can be loaded into the ``Library of
12768 Babel'' with the @code{org-babel-lob-ingest} function, bound to @kbd{C-c C-v
12771 @node Languages, Header arguments, Library of Babel, Working With Source Code
12772 @section Languages
12773 @cindex babel, languages
12774 @cindex source code, languages
12775 @cindex code block, languages
12777 Code blocks in the following languages are supported.
12779 @multitable @columnfractions 0.28 0.3 0.22 0.2
12780 @item @b{Language} @tab @b{Identifier} @tab @b{Language} @tab @b{Identifier}
12781 @item Asymptote @tab asymptote @tab Awk @tab awk
12782 @item Emacs Calc @tab calc @tab C @tab C
12783 @item C++ @tab C++ @tab Clojure @tab clojure
12784 @item CSS @tab css @tab ditaa @tab ditaa
12785 @item Graphviz @tab dot @tab Emacs Lisp @tab emacs-lisp
12786 @item gnuplot @tab gnuplot @tab Haskell @tab haskell
12787 @item Java @tab java @tab @tab
12788 @item Javascript @tab js @tab LaTeX @tab latex
12789 @item Ledger @tab ledger @tab Lisp @tab lisp
12790 @item Lilypond @tab lilypond @tab MATLAB @tab matlab
12791 @item Mscgen @tab mscgen @tab Objective Caml @tab ocaml
12792 @item Octave @tab octave @tab Org mode @tab org
12793 @item Oz @tab oz @tab Perl @tab perl
12794 @item Plantuml @tab plantuml @tab Python @tab python
12795 @item R @tab R @tab Ruby @tab ruby
12796 @item Sass @tab sass @tab Scheme @tab scheme
12797 @item GNU Screen @tab screen @tab shell @tab sh
12798 @item SQL @tab sql @tab SQLite @tab sqlite
12799 @end multitable
12801 Language-specific documentation is available for some languages.  If
12802 available, it can be found at
12803 @uref{http://orgmode.org/worg/org-contrib/babel/languages.html}.
12805 The @code{org-babel-load-languages} controls which languages are enabled for
12806 evaluation (by default only @code{emacs-lisp} is enabled).  This variable can
12807 be set using the customization interface or by adding code like the following
12808 to your emacs configuration.
12810 @quotation
12811 The following disables @code{emacs-lisp} evaluation and enables evaluation of
12812 @code{R} code blocks.
12813 @end quotation
12815 @lisp
12816 (org-babel-do-load-languages
12817  'org-babel-load-languages
12818  '((emacs-lisp . nil)
12819    (R . t)))
12820 @end lisp
12822 It is also possible to enable support for a language by loading the related
12823 elisp file with @code{require}.
12825 @quotation
12826 The following adds support for evaluating @code{clojure} code blocks.
12827 @end quotation
12829 @lisp
12830 (require 'ob-clojure)
12831 @end lisp
12833 @node Header arguments, Results of evaluation, Languages, Working With Source Code
12834 @section Header arguments
12835 @cindex code block, header arguments
12836 @cindex source code, block header arguments
12838 Code block functionality can be configured with header arguments.  This
12839 section provides an overview of the use of header arguments, and then
12840 describes each header argument in detail.
12842 @menu
12843 * Using header arguments::      Different ways to set header arguments
12844 * Specific header arguments::   List of header arguments
12845 @end menu
12847 @node Using header arguments, Specific header arguments, Header arguments, Header arguments
12848 @subsection Using header arguments
12850 The values of header arguments can be set in six different ways, each more
12851 specific (and having higher priority) than the last.
12852 @menu
12853 * System-wide header arguments::  Set global default values
12854 * Language-specific header arguments::  Set default values by language
12855 * Buffer-wide header arguments::  Set default values for a specific buffer
12856 * Header arguments in Org mode properties::  Set default values for a buffer or heading
12857 * Code block specific header arguments::  The most common way to set values
12858 * Header arguments in function calls::  The most specific level
12859 @end menu
12862 @node System-wide header arguments, Language-specific header arguments, Using header arguments, Using header arguments
12863 @subsubheading System-wide header arguments
12864 @vindex org-babel-default-header-args
12865 System-wide values of header arguments can be specified by customizing the
12866 @code{org-babel-default-header-args} variable:
12868 @example
12869 :session    => "none"
12870 :results    => "replace"
12871 :exports    => "code"
12872 :cache      => "no"
12873 :noweb      => "no"
12874 @end example
12876 @c @example
12877 @c   org-babel-default-header-args is a variable defined in `org-babel.el'.
12878 @c   Its value is
12879 @c   ((:session . "none")
12880 @c    (:results . "replace")
12881 @c    (:exports . "code")
12882 @c    (:cache . "no")
12883 @c    (:noweb . "no"))
12886 @c   Documentation:
12887 @c   Default arguments to use when evaluating a code block.
12888 @c @end example
12890 For example, the following example could be used to set the default value of
12891 @code{:noweb} header arguments to @code{yes}.  This would have the effect of
12892 expanding @code{:noweb} references by default when evaluating source code
12893 blocks.
12895 @lisp
12896 (setq org-babel-default-header-args
12897       (cons '(:noweb . "yes")
12898             (assq-delete-all :noweb org-babel-default-header-args)))
12899 @end lisp
12901 @node Language-specific header arguments, Buffer-wide header arguments, System-wide header arguments, Using header arguments
12902 @subsubheading Language-specific header arguments
12903 Each language can define its own set of default header arguments.  See the
12904 language-specific documentation available online at
12905 @uref{http://orgmode.org/worg/org-contrib/babel}.
12907 @node Buffer-wide header arguments, Header arguments in Org mode properties, Language-specific header arguments, Using header arguments
12908 @subsubheading Buffer-wide header arguments
12909 Buffer-wide header arguments may be specified as properties through the use
12910 of @code{#+PROPERTY:} lines placed anywhere in an Org mode file (see
12911 @ref{Property syntax}).
12913 For example the following would set @code{session} to @code{*R*}, and
12914 @code{results} to @code{silent} for every code block in the buffer, ensuring
12915 that all execution took place in the same session, and no results would be
12916 inserted into the buffer.
12918 @example
12919 #+PROPERTY: session *R*
12920 #+PROPERTY: results silent
12921 @end example
12923 @node Header arguments in Org mode properties, Code block specific header arguments, Buffer-wide header arguments, Using header arguments
12924 @subsubheading Header arguments in Org mode properties
12926 Header arguments are also read from Org mode properties (see @ref{Property
12927 syntax}), which can be set on a buffer-wide or per-heading basis.  An example
12928 of setting a header argument for all code blocks in a buffer is
12930 @example
12931 #+PROPERTY: tangle yes
12932 @end example
12934 @vindex org-use-property-inheritance
12935 When properties are used to set default header arguments, they are looked up
12936 with inheritance, regardless of the value of
12937 @code{org-use-property-inheritance}.  In the following example the value of
12938 the @code{:cache} header argument will default to @code{yes} in all code
12939 blocks in the subtree rooted at the following heading:
12941 @example
12942 * outline header
12943   :PROPERTIES:
12944   :cache:    yes
12945   :END:
12946 @end example
12948 @kindex C-c C-x p
12949 @vindex org-babel-default-header-args
12950 Properties defined in this way override the properties set in
12951 @code{org-babel-default-header-args}.  It is convenient to use the
12952 @code{org-set-property} function bound to @kbd{C-c C-x p} to set properties
12953 in Org mode documents.
12955 @node Code block specific header arguments, Header arguments in function calls, Header arguments in Org mode properties, Using header arguments
12956 @subsubheading Code block specific header arguments
12958 The most common way to assign values to header arguments is at the
12959 code block level.  This can be done by listing a sequence of header
12960 arguments and their values as part of the @code{#+BEGIN_SRC} line.
12961 Properties set in this way override both the values of
12962 @code{org-babel-default-header-args} and header arguments specified as
12963 properties.  In the following example, the @code{:results} header argument
12964 is set to @code{silent}, meaning the results of execution will not be
12965 inserted in the buffer, and the @code{:exports} header argument is set to
12966 @code{code}, meaning only the body of the code block will be
12967 preserved on export to HTML or @LaTeX{}.
12969 @example
12970 #+NAME: factorial
12971 #+BEGIN_SRC haskell :results silent :exports code :var n=0
12972 fac 0 = 1
12973 fac n = n * fac (n-1)
12974 #+END_SRC
12975 @end example
12976 Similarly, it is possible to set header arguments for inline code blocks
12978 @example
12979 src_haskell[:exports both]@{fac 5@}
12980 @end example
12982 Code block header arguments can span multiple lines using @code{#+HEADER:} or
12983 @code{#+HEADERS:} lines preceding a code block or nested between the
12984 @code{#+NAME:} line and the @code{#+BEGIN_SRC} line of a named code block.
12985 @cindex #+HEADER:
12986 @cindex #+HEADERS:
12988 Multi-line header arguments on an un-named code block:
12990 @example
12991  #+HEADERS: :var data1=1
12992  #+BEGIN_SRC emacs-lisp :var data2=2
12993    (message "data1:%S, data2:%S" data1 data2)
12994  #+END_SRC
12996  #+RESULTS:
12997  : data1:1, data2:2
12998 @end example
13000 Multi-line header arguments on a named code block:
13002 @example
13003    #+NAME: named-block
13004    #+HEADER: :var data=2
13005    #+BEGIN_SRC emacs-lisp
13006      (message "data:%S" data)
13007    #+END_SRC
13009    #+RESULTS: named-block
13010    : data:2
13011 @end example
13013 @node Header arguments in function calls,  , Code block specific header arguments, Using header arguments
13014 @comment  node-name,  next,  previous,  up
13015 @subsubheading Header arguments in function calls
13017 At the most specific level, header arguments for ``Library of Babel'' or
13018 @code{#+CALL:} lines can be set as shown in the two examples below.  For more
13019 information on the structure of @code{#+CALL:} lines see @ref{Evaluating code
13020 blocks}.
13022 The following will apply the @code{:exports results} header argument to the
13023 evaluation of the @code{#+CALL:} line.
13025 @example
13026 #+CALL: factorial(n=5) :exports results
13027 @end example
13029 The following will apply the @code{:session special} header argument to the
13030 evaluation of the @code{factorial} code block.
13032 @example
13033 #+CALL: factorial[:session special](n=5)
13034 @end example
13036 @node Specific header arguments,  , Using header arguments, Header arguments
13037 @subsection Specific header arguments
13038 Header arguments consist of an initial colon followed by the name of the
13039 argument in lowercase letters.  The following header arguments are defined:
13041 @menu
13042 * var::                         Pass arguments to code blocks
13043 * results::                     Specify the type of results and how they will
13044                                 be collected and handled
13045 * file::                        Specify a path for file output
13046 * file-desc::                   Specify a description for file results
13047 * dir::                         Specify the default (possibly remote)
13048                                 directory for code block execution
13049 * exports::                     Export code and/or results
13050 * tangle::                      Toggle tangling and specify file name
13051 * mkdirp::                      Toggle creation of parent directories of target
13052                                 files during tangling
13053 * comments::                    Toggle insertion of comments in tangled
13054                                 code files
13055 * padline::                     Control insertion of padding lines in tangled
13056                                 code files
13057 * no-expand::                   Turn off variable assignment and noweb
13058                                 expansion during tangling
13059 * session::                     Preserve the state of code evaluation
13060 * noweb::                       Toggle expansion of noweb references
13061 * noweb-ref::                   Specify block's noweb reference resolution target
13062 * noweb-sep::                   String used to separate noweb references
13063 * cache::                       Avoid re-evaluating unchanged code blocks
13064 * sep::                         Delimiter for writing tabular results outside Org
13065 * hlines::                      Handle horizontal lines in tables
13066 * colnames::                    Handle column names in tables
13067 * rownames::                    Handle row names in tables
13068 * shebang::                     Make tangled files executable
13069 * eval::                        Limit evaluation of specific code blocks
13070 * wrap::                        Mark source block evaluation results
13071 @end menu
13073 Additional header arguments are defined on a language-specific basis, see
13074 @ref{Languages}.
13076 @node var, results, Specific header arguments, Specific header arguments
13077 @subsubsection @code{:var}
13078 The @code{:var} header argument is used to pass arguments to code blocks.
13079 The specifics of how arguments are included in a code block vary by language;
13080 these are addressed in the language-specific documentation.  However, the
13081 syntax used to specify arguments is the same across all languages.  In every
13082 case, variables require a default value when they are declared.
13084 The values passed to arguments can either be literal values, references, or
13085 Emacs Lisp code (see @ref{var, Emacs Lisp evaluation of variables}).  References
13086 include anything in the Org mode file that takes a @code{#+NAME:},
13087 @code{#+TBLNAME:}, or @code{#+RESULTS:} line.  This includes tables, lists,
13088 @code{#+BEGIN_EXAMPLE} blocks, other code blocks, and the results of other
13089 code blocks.
13091 Argument values can be indexed in a manner similar to arrays (see @ref{var,
13092 Indexable variable values}).
13094 The following syntax is used to pass arguments to code blocks using the
13095 @code{:var} header argument.
13097 @example
13098 :var name=assign
13099 @end example
13101 The argument, @code{assign}, can either be a literal value, such as a string
13102 @samp{"string"} or a number @samp{9}, or a reference to a table, a list, a
13103 literal example, another code block (with or without arguments), or the
13104 results of evaluating another code block.
13106 Here are examples of passing values by reference:
13108 @table @dfn
13110 @item table
13111 an Org mode table named with either a @code{#+NAME:} or @code{#+TBLNAME:} line
13113 @example
13114 #+TBLNAME: example-table
13115 | 1 |
13116 | 2 |
13117 | 3 |
13118 | 4 |
13120 #+NAME: table-length
13121 #+BEGIN_SRC emacs-lisp :var table=example-table
13122 (length table)
13123 #+END_SRC
13125 #+RESULTS: table-length
13126 : 4
13127 @end example
13129 @item list
13130 a simple list named with a @code{#+NAME:} line (note that nesting is not
13131 carried through to the source code block)
13133 @example
13134 #+NAME: example-list
13135   - simple
13136     - not
13137     - nested
13138   - list
13140 #+BEGIN_SRC emacs-lisp :var x=example-list
13141   (print x)
13142 #+END_SRC
13144 #+RESULTS:
13145 | simple | list |
13146 @end example
13148 @item code block without arguments
13149 a code block name (from the example above), as assigned by @code{#+NAME:},
13150 optionally followed by parentheses
13152 @example
13153 #+BEGIN_SRC emacs-lisp :var length=table-length()
13154 (* 2 length)
13155 #+END_SRC
13157 #+RESULTS:
13158 : 8
13159 @end example
13161 @item code block with arguments
13162 a code block name, as assigned by @code{#+NAME:}, followed by parentheses and
13163 optional arguments passed within the parentheses following the
13164 code block name using standard function call syntax
13166 @example
13167 #+NAME: double
13168 #+BEGIN_SRC emacs-lisp :var input=8
13169 (* 2 input)
13170 #+END_SRC
13172 #+RESULTS: double
13173 : 16
13175 #+NAME: squared
13176 #+BEGIN_SRC emacs-lisp :var input=double(input=1)
13177 (* input input)
13178 #+END_SRC
13180 #+RESULTS: squared
13181 : 4
13182 @end example
13184 @item literal example
13185 a literal example block named with a @code{#+NAME:} line
13187 @example
13188 #+NAME: literal-example
13189 #+BEGIN_EXAMPLE
13190 A literal example
13191 on two lines
13192 #+END_EXAMPLE
13194 #+NAME: read-literal-example
13195 #+BEGIN_SRC emacs-lisp :var x=literal-example
13196   (concatenate 'string x " for you.")
13197 #+END_SRC
13199 #+RESULTS: read-literal-example
13200 : A literal example
13201 : on two lines for you.
13203 @end example
13205 @end table
13207 @subsubheading Alternate argument syntax
13208 It is also possible to specify arguments in a potentially more natural way
13209 using the @code{#+NAME:} line of a code block.  As in the following
13210 example, arguments can be packed inside of parentheses, separated by commas,
13211 following the source name.
13213 @example
13214 #+NAME: double(input=0, x=2)
13215 #+BEGIN_SRC emacs-lisp
13216 (* 2 (+ input x))
13217 #+END_SRC
13218 @end example
13220 @subsubheading Indexable variable values
13221 It is possible to reference portions of variable values by ``indexing'' into
13222 the variables.  Indexes are 0 based with negative values counting back from
13223 the end.  If an index is separated by @code{,}s then each subsequent section
13224 will index into the next deepest nesting or dimension of the value.  Note
13225 that this indexing occurs @emph{before} other table related header arguments
13226 like @code{:hlines}, @code{:colnames} and @code{:rownames} are applied.  The
13227 following example assigns the last cell of the first row the table
13228 @code{example-table} to the variable @code{data}:
13230 @example
13231 #+NAME: example-table
13232 | 1 | a |
13233 | 2 | b |
13234 | 3 | c |
13235 | 4 | d |
13237 #+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
13238   data
13239 #+END_SRC
13241 #+RESULTS:
13242 : a
13243 @end example
13245 Ranges of variable values can be referenced using two integers separated by a
13246 @code{:}, in which case the entire inclusive range is referenced.  For
13247 example the following assigns the middle three rows of @code{example-table}
13248 to @code{data}.
13250 @example
13251 #+NAME: example-table
13252 | 1 | a |
13253 | 2 | b |
13254 | 3 | c |
13255 | 4 | d |
13256 | 5 | 3 |
13258 #+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
13259   data
13260 #+END_SRC
13262 #+RESULTS:
13263 | 2 | b |
13264 | 3 | c |
13265 | 4 | d |
13266 @end example
13268 Additionally, an empty index, or the single character @code{*}, are both
13269 interpreted to mean the entire range and as such are equivalent to
13270 @code{0:-1}, as shown in the following example in which the entire first
13271 column is referenced.
13273 @example
13274 #+NAME: example-table
13275 | 1 | a |
13276 | 2 | b |
13277 | 3 | c |
13278 | 4 | d |
13280 #+BEGIN_SRC emacs-lisp :var data=example-table[,0]
13281   data
13282 #+END_SRC
13284 #+RESULTS:
13285 | 1 | 2 | 3 | 4 |
13286 @end example
13288 It is possible to index into the results of code blocks as well as tables.
13289 Any number of dimensions can be indexed.  Dimensions are separated from one
13290 another by commas, as shown in the following example.
13292 @example
13293 #+NAME: 3D
13294 #+BEGIN_SRC emacs-lisp
13295   '(((1  2  3)  (4  5  6)  (7  8  9))
13296     ((10 11 12) (13 14 15) (16 17 18))
13297     ((19 20 21) (22 23 24) (25 26 27)))
13298 #+END_SRC
13300 #+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
13301   data
13302 #+END_SRC
13304 #+RESULTS:
13305 | 11 | 14 | 17 |
13306 @end example
13308 @subsubheading Emacs Lisp evaluation of variables
13310 Emacs lisp code can be used to initialize variable values.  When a variable
13311 value starts with @code{(}, @code{[}, @code{'} or @code{`} it will be
13312 evaluated as Emacs Lisp and the result of the evaluation will be assigned as
13313 the variable value.  The following example demonstrates use of this
13314 evaluation to reliably pass the file-name of the Org mode buffer to a code
13315 block---note that evaluation of header arguments is guaranteed to take place
13316 in the original Org mode file, while there is no such guarantee for
13317 evaluation of the code block body.
13319 @example
13320 #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
13321   wc -w $filename
13322 #+END_SRC
13323 @end example
13325 Note that values read from tables and lists will not be evaluated as
13326 Emacs Lisp, as shown in the following example.
13328 @example
13329 #+NAME: table
13330 | (a b c) |
13332 #+HEADERS: :var data=table[0,0]
13333 #+BEGIN_SRC perl
13334   $data
13335 #+END_SRC
13337 #+RESULTS:
13338 : (a b c)
13339 @end example
13341 @node results, file, var, Specific header arguments
13342 @subsubsection @code{:results}
13344 There are three classes of @code{:results} header argument.  Only one option
13345 per class may be supplied per code block.
13347 @itemize @bullet
13348 @item
13349 @b{collection} header arguments specify how the results should be collected
13350 from the code block
13351 @item
13352 @b{type} header arguments specify what type of result the code block will
13353 return---which has implications for how they will be inserted into the
13354 Org mode buffer
13355 @item
13356 @b{handling} header arguments specify how the results of evaluating the code
13357 block should be handled.
13358 @end itemize
13360 @subsubheading Collection
13361 The following options are mutually exclusive, and specify how the results
13362 should be collected from the code block.
13364 @itemize @bullet
13365 @item @code{value}
13366 This is the default.  The result is the value of the last statement in the
13367 code block.  This header argument places the evaluation in functional
13368 mode.  Note that in some languages, e.g., Python, use of this result type
13369 requires that a @code{return} statement be included in the body of the source
13370 code block.  E.g., @code{:results value}.
13371 @item @code{output}
13372 The result is the collection of everything printed to STDOUT during the
13373 execution of the code block.  This header argument places the
13374 evaluation in scripting mode.  E.g., @code{:results output}.
13375 @end itemize
13377 @subsubheading Type
13379 The following options are mutually exclusive and specify what type of results
13380 the code block will return.  By default, results are inserted as either a
13381 table or scalar depending on their value.
13383 @itemize @bullet
13384 @item @code{table}, @code{vector}
13385 The results should be interpreted as an Org mode table.  If a single value is
13386 returned, it will be converted into a table with one row and one column.
13387 E.g., @code{:results value table}.
13388 @item @code{list}
13389 The results should be interpreted as an Org mode list.  If a single scalar
13390 value is returned it will be converted into a list with only one element.
13391 @item @code{scalar}, @code{verbatim}
13392 The results should be interpreted literally---they will not be
13393 converted into a table.  The results will be inserted into the Org mode
13394 buffer as quoted text.  E.g., @code{:results value verbatim}.
13395 @item @code{file}
13396 The results will be interpreted as the path to a file, and will be inserted
13397 into the Org mode buffer as a file link.  E.g., @code{:results value file}.
13398 @item @code{raw}
13399 The results are interpreted as raw Org mode code and are inserted directly
13400 into the buffer.  If the results look like a table they will be aligned as
13401 such by Org mode.  E.g., @code{:results value raw}.
13402 @item @code{org}
13403 The results are will be enclosed in a @code{BEGIN_SRC org} block.
13404 They are not comma-escaped by default but they will be if you hit @kbd{TAB}
13405 in the block and/or if you export the file.  E.g., @code{:results value org}.
13406 @item @code{html}
13407 Results are assumed to be HTML and will be enclosed in a @code{BEGIN_HTML}
13408 block.  E.g., @code{:results value html}.
13409 @item @code{latex}
13410 Results assumed to be @LaTeX{} and are enclosed in a @code{BEGIN_LaTeX} block.
13411 E.g., @code{:results value latex}.
13412 @item @code{code}
13413 Result are assumed to be parsable code and are enclosed in a code block.
13414 E.g., @code{:results value code}.
13415 @item @code{pp}
13416 The result is converted to pretty-printed code and is enclosed in a code
13417 block.  This option currently supports Emacs Lisp, Python, and Ruby.  E.g.,
13418 @code{:results value pp}.
13419 @item @code{drawer}
13420 The result is wrapped in a RESULTS drawer.  This can be useful for
13421 inserting @code{raw} or @code{org} syntax results in such a way that their
13422 extent is known and they can be automatically removed or replaced.
13423 @end itemize
13425 @subsubheading Handling
13426 The following results options indicate what happens with the
13427 results once they are collected.
13429 @itemize @bullet
13430 @item @code{silent}
13431 The results will be echoed in the minibuffer but will not be inserted into
13432 the Org mode buffer.  E.g., @code{:results output silent}.
13433 @item @code{replace}
13434 The default value.  Any existing results will be removed, and the new results
13435 will be inserted into the Org mode buffer in their place.  E.g.,
13436 @code{:results output replace}.
13437 @item @code{append}
13438 If there are pre-existing results of the code block then the new results will
13439 be appended to the existing results.  Otherwise the new results will be
13440 inserted as with @code{replace}.
13441 @item @code{prepend}
13442 If there are pre-existing results of the code block then the new results will
13443 be prepended to the existing results.  Otherwise the new results will be
13444 inserted as with @code{replace}.
13445 @end itemize
13447 @node file, file-desc, results, Specific header arguments
13448 @subsubsection @code{:file}
13450 The header argument @code{:file} is used to specify an external file in which
13451 to save code block results.  After code block evaluation an Org mode style
13452 @code{[[file:]]} link (see @ref{Link format}) to the file will be inserted
13453 into the Org mode buffer.  Some languages including R, gnuplot, dot, and
13454 ditaa provide special handling of the @code{:file} header argument
13455 automatically wrapping the code block body in the boilerplate code required
13456 to save output to the specified file.  This is often useful for saving
13457 graphical output of a code block to the specified file.
13459 The argument to @code{:file} should be either a string specifying the path to
13460 a file, or a list of two strings in which case the first element of the list
13461 should be the path to a file and the second a description for the link.
13463 @node file-desc, dir, file, Specific header arguments
13464 @subsubsection @code{:file-desc}
13466 The value of the @code{:file-desc} header argument is used to provide a
13467 description for file code block results which are inserted as Org mode links
13468 (see @ref{Link format}).  If the @code{:file-desc} header argument is given
13469 with no value the link path will be placed in both the ``link'' and the
13470 ``description'' portion of the Org mode link.
13472 @node dir, exports, file-desc, Specific header arguments
13473 @subsubsection @code{:dir} and remote execution
13475 While the @code{:file} header argument can be used to specify the path to the
13476 output file, @code{:dir} specifies the default directory during code block
13477 execution.  If it is absent, then the directory associated with the current
13478 buffer is used.  In other words, supplying @code{:dir path} temporarily has
13479 the same effect as changing the current directory with @kbd{M-x cd path}, and
13480 then not supplying @code{:dir}.  Under the surface, @code{:dir} simply sets
13481 the value of the Emacs variable @code{default-directory}.
13483 When using @code{:dir}, you should supply a relative path for file output
13484 (e.g., @code{:file myfile.jpg} or @code{:file results/myfile.jpg}) in which
13485 case that path will be interpreted relative to the default directory.
13487 In other words, if you want your plot to go into a folder called @file{Work}
13488 in your home directory, you could use
13490 @example
13491 #+BEGIN_SRC R :file myplot.png :dir ~/Work
13492 matplot(matrix(rnorm(100), 10), type="l")
13493 #+END_SRC
13494 @end example
13496 @subsubheading Remote execution
13497 A directory on a remote machine can be specified using tramp file syntax, in
13498 which case the code will be evaluated on the remote machine.  An example is
13500 @example
13501 #+BEGIN_SRC R :file plot.png :dir /dand@@yakuba.princeton.edu:
13502 plot(1:10, main=system("hostname", intern=TRUE))
13503 #+END_SRC
13504 @end example
13506 Text results will be returned to the local Org mode buffer as usual, and file
13507 output will be created on the remote machine with relative paths interpreted
13508 relative to the remote directory.  An Org mode link to the remote file will be
13509 created.
13511 So, in the above example a plot will be created on the remote machine,
13512 and a link of the following form will be inserted in the org buffer:
13514 @example
13515 [[file:/scp:dand@@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
13516 @end example
13518 Most of this functionality follows immediately from the fact that @code{:dir}
13519 sets the value of the Emacs variable @code{default-directory}, thanks to
13520 tramp.  Those using XEmacs, or GNU Emacs prior to version 23 may need to
13521 install tramp separately in order for these features to work correctly.
13523 @subsubheading Further points
13525 @itemize @bullet
13526 @item
13527 If @code{:dir} is used in conjunction with @code{:session}, although it will
13528 determine the starting directory for a new session as expected, no attempt is
13529 currently made to alter the directory associated with an existing session.
13530 @item
13531 @code{:dir} should typically not be used to create files during export with
13532 @code{:exports results} or @code{:exports both}.  The reason is that, in order
13533 to retain portability of exported material between machines, during export
13534 links inserted into the buffer will @emph{not} be expanded against @code{default
13535 directory}.  Therefore, if @code{default-directory} is altered using
13536 @code{:dir}, it is probable that the file will be created in a location to
13537 which the link does not point.
13538 @end itemize
13540 @node exports, tangle, dir, Specific header arguments
13541 @subsubsection @code{:exports}
13543 The @code{:exports} header argument specifies what should be included in HTML
13544 or @LaTeX{} exports of the Org mode file.
13546 @itemize @bullet
13547 @item @code{code}
13548 The default.  The body of code is included into the exported file.  E.g.,
13549 @code{:exports code}.
13550 @item @code{results}
13551 The result of evaluating the code is included in the exported file.  E.g.,
13552 @code{:exports results}.
13553 @item @code{both}
13554 Both the code and results are included in the exported file.  E.g.,
13555 @code{:exports both}.
13556 @item @code{none}
13557 Nothing is included in the exported file.  E.g., @code{:exports none}.
13558 @end itemize
13560 @node tangle, mkdirp, exports, Specific header arguments
13561 @subsubsection @code{:tangle}
13563 The @code{:tangle} header argument specifies whether or not the code
13564 block should be included in tangled extraction of source code files.
13566 @itemize @bullet
13567 @item @code{tangle}
13568 The code block is exported to a source code file named after the full path
13569 (including the directory) and file name (w/o extension) of the Org mode file.
13570 E.g., @code{:tangle yes}.
13571 @item @code{no}
13572 The default.  The code block is not exported to a source code file.
13573 E.g., @code{:tangle no}.
13574 @item other
13575 Any other string passed to the @code{:tangle} header argument is interpreted
13576 as a path (directory and file name relative to the directory of the Org mode
13577 file) to which the block will be exported.  E.g., @code{:tangle path}.
13578 @end itemize
13580 @node mkdirp, comments, tangle, Specific header arguments
13581 @subsubsection @code{:mkdirp}
13583 The @code{:mkdirp} header argument can be used to create parent directories
13584 of tangled files when missing.  This can be set to @code{yes} to enable
13585 directory creation or to @code{no} to inhibit directory creation.
13587 @node comments, padline, mkdirp, Specific header arguments
13588 @subsubsection @code{:comments}
13589 By default code blocks are tangled to source-code files without any insertion
13590 of comments beyond those which may already exist in the body of the code
13591 block.  The @code{:comments} header argument can be set as follows to control
13592 the insertion of extra comments into the tangled code file.
13594 @itemize @bullet
13595 @item @code{no}
13596 The default.  No extra comments are inserted during tangling.
13597 @item @code{link}
13598 The code block is wrapped in comments which contain pointers back to the
13599 original Org file from which the code was tangled.
13600 @item @code{yes}
13601 A synonym for ``link'' to maintain backwards compatibility.
13602 @item @code{org}
13603 Include text from the Org mode file as a comment.
13605 The text is picked from the leading context of the tangled code and is
13606 limited by the nearest headline or source block as the case may be.
13607 @item @code{both}
13608 Turns on both the ``link'' and ``org'' comment options.
13609 @item @code{noweb}
13610 Turns on the ``link'' comment option, and additionally wraps expanded noweb
13611 references in the code block body in link comments.
13612 @end itemize
13614 @node padline, no-expand, comments, Specific header arguments
13615 @subsubsection @code{:padline}
13616 Control in insertion of padding lines around code block bodies in tangled
13617 code files.  The default value is @code{yes} which results in insertion of
13618 newlines before and after each tangled code block.  The following arguments
13619 are accepted.
13621 @itemize @bullet
13622 @item @code{yes}
13623 Insert newlines before and after each code block body in tangled code files.
13624 @item @code{no}
13625 Do not insert any newline padding in tangled output.
13626 @end itemize
13628 @node no-expand, session, padline, Specific header arguments
13629 @subsubsection @code{:no-expand}
13631 By default, code blocks are expanded with @code{org-babel-expand-src-block}
13632 during tangling.  This has the effect of assigning values to variables
13633 specified with @code{:var} (see @ref{var}), and of replacing ``noweb''
13634 references (see @ref{Noweb reference syntax}) with their targets.  The
13635 @code{:no-expand} header argument can be used to turn off this behavior.
13637 @node session, noweb, no-expand, Specific header arguments
13638 @subsubsection @code{:session}
13640 The @code{:session} header argument starts a session for an interpreted
13641 language where state is preserved.
13643 By default, a session is not started.
13645 A string passed to the @code{:session} header argument will give the session
13646 a name.  This makes it possible to run concurrent sessions for each
13647 interpreted language.
13649 @node noweb, noweb-ref, session, Specific header arguments
13650 @subsubsection @code{:noweb}
13652 The @code{:noweb} header argument controls expansion of ``noweb'' syntax
13653 references (see @ref{Noweb reference syntax}) when the code block is
13654 evaluated, tangled, or exported.  The @code{:noweb} header argument can have
13655 one of the five values: @code{no}, @code{yes}, @code{tangle}, or
13656 @code{no-export} @code{strip-export}.
13658 @itemize @bullet
13659 @item @code{no}
13660 The default.  ``Noweb'' syntax references in the body of the code block will
13661 not be expanded before the code block is evaluated, tangled or exported.
13662 @item @code{yes}
13663 ``Noweb'' syntax references in the body of the code block will be
13664 expanded before the code block is evaluated, tangled or exported.
13665 @item @code{tangle}
13666 ``Noweb'' syntax references in the body of the code block will be expanded
13667 before the code block is tangled.  However, ``noweb'' syntax references will
13668 not be expanded when the code block is evaluated or exported.
13669 @item @code{no-export}
13670 ``Noweb'' syntax references in the body of the code block will be expanded
13671 before the block is evaluated or tangled.  However, ``noweb'' syntax
13672 references will not be expanded when the code block is exported.
13673 @item @code{strip-export}
13674 ``Noweb'' syntax references in the body of the code block will be expanded
13675 before the block is evaluated or tangled.  However, ``noweb'' syntax
13676 references will not be removed when the code block is exported.
13677 @item @code{eval}
13678 ``Noweb'' syntax references in the body of the code block will only be
13679 expanded before the block is evaluated.
13680 @end itemize
13682 @subsubheading Noweb prefix lines
13683 Noweb insertions are now placed behind the line prefix of the
13684 @code{<<reference>>}.
13685 This behavior is illustrated in the following example.  Because the
13686 @code{<<example>>} noweb reference appears behind the SQL comment syntax,
13687 each line of the expanded noweb reference will be commented.
13689 This code block:
13691 @example
13692 -- <<example>>
13693 @end example
13695 expands to:
13697 @example
13698 -- this is the
13699 -- multi-line body of example
13700 @end example
13702 Note that noweb replacement text that does not contain any newlines will not
13703 be affected by this change, so it is still possible to use inline noweb
13704 references.
13706 @node noweb-ref, noweb-sep, noweb, Specific header arguments
13707 @subsubsection @code{:noweb-ref}
13708 When expanding ``noweb'' style references the bodies of all code block with
13709 @emph{either} a block name matching the reference name @emph{or} a
13710 @code{:noweb-ref} header argument matching the reference name will be
13711 concatenated together to form the replacement text.
13713 By setting this header argument at the sub-tree or file level, simple code
13714 block concatenation may be achieved.  For example, when tangling the
13715 following Org mode file, the bodies of code blocks will be concatenated into
13716 the resulting pure code file@footnote{(The example needs property inheritance
13717 to be turned on for the @code{noweb-ref} property, see @ref{Property
13718 inheritance}).}.
13720 @example
13721  #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
13722    <<fullest-disk>>
13723  #+END_SRC
13724  * the mount point of the fullest disk
13725    :PROPERTIES:
13726    :noweb-ref: fullest-disk
13727    :END:
13729  ** query all mounted disks
13730  #+BEGIN_SRC sh
13731    df \
13732  #+END_SRC
13734  ** strip the header row
13735  #+BEGIN_SRC sh
13736    |sed '1d' \
13737  #+END_SRC
13739  ** sort by the percent full
13740  #+BEGIN_SRC sh
13741    |awk '@{print $5 " " $6@}'|sort -n |tail -1 \
13742  #+END_SRC
13744  ** extract the mount point
13745  #+BEGIN_SRC sh
13746    |awk '@{print $2@}'
13747  #+END_SRC
13748 @end example
13750 The @code{:noweb-sep} (see @ref{noweb-sep}) header argument holds the string
13751 used to separate accumulate noweb references like those above.  By default a
13752 newline is used.
13754 @node noweb-sep, cache, noweb-ref, Specific header arguments
13755 @subsubsection @code{:noweb-sep}
13757 The @code{:noweb-sep} header argument holds the string used to separate
13758 accumulate noweb references (see @ref{noweb-ref}).  By default a newline is
13759 used.
13761 @node cache, sep, noweb-sep, Specific header arguments
13762 @subsubsection @code{:cache}
13764 The @code{:cache} header argument controls the use of in-buffer caching of
13765 the results of evaluating code blocks.  It can be used to avoid re-evaluating
13766 unchanged code blocks.  Note that the @code{:cache} header argument will not
13767 attempt to cache results when the @code{:session} header argument is used,
13768 because the results of the code block execution may be stored in the session
13769 outside of the Org mode buffer.  The @code{:cache} header argument can have
13770 one of two values: @code{yes} or @code{no}.
13772 @itemize @bullet
13773 @item @code{no}
13774 The default.  No caching takes place, and the code block will be evaluated
13775 every time it is called.
13776 @item @code{yes}
13777 Every time the code block is run a SHA1 hash of the code and arguments
13778 passed to the block will be generated.  This hash is packed into the
13779 @code{#+RESULTS:} line and will be checked on subsequent
13780 executions of the code block.  If the code block has not
13781 changed since the last time it was evaluated, it will not be re-evaluated.
13782 @end itemize
13784 Code block caches notice if the value of a variable argument
13785 to the code block has changed.  If this is the case, the cache is
13786 invalidated and the code block is re-run.  In the following example,
13787 @code{caller} will not be re-run unless the results of @code{random} have
13788 changed since it was last run.
13790 @example
13791  #+NAME: random
13792  #+BEGIN_SRC R :cache yes
13793  runif(1)
13794  #+END_SRC
13796  #+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
13797  0.4659510825295
13799  #+NAME: caller
13800  #+BEGIN_SRC emacs-lisp :var x=random :cache yes
13802  #+END_SRC
13804  #+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
13805  0.254227238707244
13806 @end example
13808 @node sep, hlines, cache, Specific header arguments
13809 @subsubsection @code{:sep}
13811 The @code{:sep} header argument can be used to control the delimiter used
13812 when writing tabular results out to files external to Org mode.  This is used
13813 either when opening tabular results of a code block by calling the
13814 @code{org-open-at-point} function bound to @kbd{C-c C-o} on the code block,
13815 or when writing code block results to an external file (see @ref{file})
13816 header argument.
13818 By default, when @code{:sep} is not specified output tables are tab
13819 delimited.
13821 @node hlines, colnames, sep, Specific header arguments
13822 @subsubsection @code{:hlines}
13824 Tables are frequently represented with one or more horizontal lines, or
13825 hlines.  The @code{:hlines} argument to a code block accepts the
13826 values @code{yes} or @code{no}, with a default value of @code{no}.
13828 @itemize @bullet
13829 @item @code{no}
13830 Strips horizontal lines from the input table.  In most languages this is the
13831 desired effect because an @code{hline} symbol is interpreted as an unbound
13832 variable and raises an error.  Setting @code{:hlines no} or relying on the
13833 default value yields the following results.  Note that the @code{:hline}
13834 header argument has no effect for Emacs Lisp code blocks.
13836 @example
13837 #+TBLNAME: many-cols
13838 | a | b | c |
13839 |---+---+---|
13840 | d | e | f |
13841 |---+---+---|
13842 | g | h | i |
13844 #+NAME: echo-table
13845 #+BEGIN_SRC python :var tab=many-cols
13846   return tab
13847 #+END_SRC
13849 #+RESULTS: echo-table
13850 | a | b | c |
13851 | d | e | f |
13852 | g | h | i |
13853 @end example
13855 @item @code{yes}
13856 Leaves hlines in the table.  Setting @code{:hlines yes} has this effect.
13858 @example
13859 #+TBLNAME: many-cols
13860 | a | b | c |
13861 |---+---+---|
13862 | d | e | f |
13863 |---+---+---|
13864 | g | h | i |
13866 #+NAME: echo-table
13867 #+BEGIN_SRC python :var tab=many-cols :hlines yes
13868   return tab
13869 #+END_SRC
13871 #+RESULTS: echo-table
13872 | a | b | c |
13873 |---+---+---|
13874 | d | e | f |
13875 |---+---+---|
13876 | g | h | i |
13877 @end example
13878 @end itemize
13880 @node colnames, rownames, hlines, Specific header arguments
13881 @subsubsection @code{:colnames}
13883 The @code{:colnames} header argument accepts the values @code{yes},
13884 @code{no}, or @code{nil} for unassigned.  The default value is @code{nil}.
13885 Note that the behavior of the @code{:colnames} header argument may differ
13886 across languages.  For example Emacs Lisp code blocks ignore the
13887 @code{:colnames} header argument entirely given the ease with which tables
13888 with column names may be handled directly in Emacs Lisp.
13890 @itemize @bullet
13891 @item @code{nil}
13892 If an input table looks like it has column names
13893 (because its second row is an hline), then the column
13894 names will be removed from the table before
13895 processing, then reapplied to the results.
13897 @example
13898 #+TBLNAME: less-cols
13899 | a |
13900 |---|
13901 | b |
13902 | c |
13904 #+NAME: echo-table-again
13905 #+BEGIN_SRC python :var tab=less-cols
13906   return [[val + '*' for val in row] for row in tab]
13907 #+END_SRC
13909 #+RESULTS: echo-table-again
13910 | a  |
13911 |----|
13912 | b* |
13913 | c* |
13914 @end example
13916 Please note that column names are not removed before the table is indexed
13917 using variable indexing @xref{var, Indexable variable values}.
13919 @item @code{no}
13920 No column name pre-processing takes place
13922 @item @code{yes}
13923 Column names are removed and reapplied as with @code{nil} even if the table
13924 does not ``look like'' it has column names (i.e., the second row is not an
13925 hline)
13926 @end itemize
13928 @node rownames, shebang, colnames, Specific header arguments
13929 @subsubsection @code{:rownames}
13931 The @code{:rownames} header argument can take on the values @code{yes} or
13932 @code{no}, with a default value of @code{no}.  Note that Emacs Lisp code
13933 blocks ignore the @code{:rownames} header argument entirely given the ease
13934 with which tables with row names may be handled directly in Emacs Lisp.
13936 @itemize @bullet
13937 @item @code{no}
13938 No row name pre-processing will take place.
13940 @item @code{yes}
13941 The first column of the table is removed from the table before processing,
13942 and is then reapplied to the results.
13944 @example
13945 #+TBLNAME: with-rownames
13946 | one | 1 | 2 | 3 | 4 |  5 |
13947 | two | 6 | 7 | 8 | 9 | 10 |
13949 #+NAME: echo-table-once-again
13950 #+BEGIN_SRC python :var tab=with-rownames :rownames yes
13951   return [[val + 10 for val in row] for row in tab]
13952 #+END_SRC
13954 #+RESULTS: echo-table-once-again
13955 | one | 11 | 12 | 13 | 14 | 15 |
13956 | two | 16 | 17 | 18 | 19 | 20 |
13957 @end example
13959 Please note that row names are not removed before the table is indexed using
13960 variable indexing @xref{var, Indexable variable values}.
13962 @end itemize
13964 @node shebang, eval, rownames, Specific header arguments
13965 @subsubsection @code{:shebang}
13967 Setting the @code{:shebang} header argument to a string value
13968 (e.g., @code{:shebang "#!/bin/bash"}) causes the string to be inserted as the
13969 first line of any tangled file holding the code block, and the file
13970 permissions of the tangled file are set to make it executable.
13972 @node eval, wrap, shebang, Specific header arguments
13973 @subsubsection @code{:eval}
13974 The @code{:eval} header argument can be used to limit the evaluation of
13975 specific code blocks.  The @code{:eval} header argument can be useful for
13976 protecting against the evaluation of dangerous code blocks or to ensure that
13977 evaluation will require a query regardless of the value of the
13978 @code{org-confirm-babel-evaluate} variable.  The possible values of
13979 @code{:eval} and their effects are shown below.
13981 @table @code
13982 @item never or no
13983 The code block will not be evaluated under any circumstances.
13984 @item query
13985 Evaluation of the code block will require a query.
13986 @item never-export or no-export
13987 The code block will not be evaluated during export but may still be called
13988 interactively.
13989 @item query-export
13990 Evaluation of the code block during export will require a query.
13991 @end table
13993 If this header argument is not set then evaluation is determined by the value
13994 of the @code{org-confirm-babel-evaluate} variable see @ref{Code evaluation
13995 security}.
13997 @node wrap,  , eval, Specific header arguments
13998 @subsubsection @code{:wrap}
13999 The @code{:wrap} header argument is used to mark the results of source block
14000 evaluation.  The header argument can be passed a string that will be appended
14001 to @code{#+BEGIN_} and @code{#+END_}, which will then be used to wrap the
14002 results.  If not string is specified then the results will be wrapped in a
14003 @code{#+BEGIN/END_RESULTS} block.
14005 @node Results of evaluation, Noweb reference syntax, Header arguments, Working With Source Code
14006 @section Results of evaluation
14007 @cindex code block, results of evaluation
14008 @cindex source code, results of evaluation
14010 The way in which results are handled depends on whether a session is invoked,
14011 as well as on whether @code{:results value} or @code{:results output} is
14012 used.  The following table shows the table possibilities.  For a full listing
14013 of the possible results header arguments see @ref{results}.
14015 @multitable @columnfractions 0.26 0.33 0.41
14016 @item @tab @b{Non-session} @tab @b{Session}
14017 @item @code{:results value} @tab value of last expression @tab value of last expression
14018 @item @code{:results output} @tab contents of STDOUT @tab concatenation of interpreter output
14019 @end multitable
14021 Note: With @code{:results value}, the result in both @code{:session} and
14022 non-session is returned to Org mode as a table (a one- or two-dimensional
14023 vector of strings or numbers) when appropriate.
14025 @subsection Non-session
14026 @subsubsection @code{:results value}
14027 This is the default.  Internally, the value is obtained by wrapping the code
14028 in a function definition in the external language, and evaluating that
14029 function.  Therefore, code should be written as if it were the body of such a
14030 function.  In particular, note that Python does not automatically return a
14031 value from a function unless a @code{return} statement is present, and so a
14032 @samp{return} statement will usually be required in Python.
14034 This is the only one of the four evaluation contexts in which the code is
14035 automatically wrapped in a function definition.
14037 @subsubsection @code{:results output}
14038 The code is passed to the interpreter as an external process, and the
14039 contents of the standard output stream are returned as text.  (In certain
14040 languages this also contains the error output stream; this is an area for
14041 future work.)
14043 @subsection Session
14044 @subsubsection @code{:results value}
14045 The code is passed to an interpreter running as an interactive Emacs inferior
14046 process.  Only languages which provide tools for interactive evaluation of
14047 code have session support, so some language (e.g., C and ditaa) do not
14048 support the @code{:session} header argument, and in other languages (e.g.,
14049 Python and Haskell) which have limitations on the code which may be entered
14050 into interactive sessions, those limitations apply to the code in code blocks
14051 using the @code{:session} header argument as well.
14053 Unless the @code{:results output} option is supplied (see below) the result
14054 returned is the result of the last evaluation performed by the
14055 interpreter.  (This is obtained in a language-specific manner: the value of
14056 the variable @code{_} in Python and Ruby, and the value of @code{.Last.value}
14057 in R).
14059 @subsubsection @code{:results output}
14060 The code is passed to the interpreter running as an interactive Emacs
14061 inferior process.  The result returned is the concatenation of the sequence of
14062 (text) output from the interactive interpreter.  Notice that this is not
14063 necessarily the same as what would be sent to @code{STDOUT} if the same code
14064 were passed to a non-interactive interpreter running as an external
14065 process.  For example, compare the following two blocks:
14067 @example
14068 #+BEGIN_SRC python :results output
14069  print "hello"
14071  print "bye"
14072 #+END_SRC
14074 #+RESULTS:
14075 : hello
14076 : bye
14077 @end example
14079 In non-session mode, the `2' is not printed and does not appear.
14081 @example
14082 #+BEGIN_SRC python :results output :session
14083  print "hello"
14085  print "bye"
14086 #+END_SRC
14088 #+RESULTS:
14089 : hello
14090 : 2
14091 : bye
14092 @end example
14094 But in @code{:session} mode, the interactive interpreter receives input `2'
14095 and prints out its value, `2'.  (Indeed, the other print statements are
14096 unnecessary here).
14098 @node Noweb reference syntax, Key bindings and useful functions, Results of evaluation, Working With Source Code
14099 @section Noweb reference syntax
14100 @cindex code block, noweb reference
14101 @cindex syntax, noweb
14102 @cindex source code, noweb reference
14104 The ``noweb'' (see @uref{http://www.cs.tufts.edu/~nr/noweb/}) Literate
14105 Programming system allows named blocks of code to be referenced by using the
14106 familiar Noweb syntax:
14108 @example
14109 <<code-block-name>>
14110 @end example
14112 When a code block is tangled or evaluated, whether or not ``noweb''
14113 references are expanded depends upon the value of the @code{:noweb} header
14114 argument.  If @code{:noweb yes}, then a Noweb reference is expanded before
14115 evaluation.  If @code{:noweb no}, the default, then the reference is not
14116 expanded before evaluation.  See the @ref{noweb-ref} header argument for
14117 a more flexible way to resolve noweb references.
14119 It is possible to include the @emph{results} of a code block rather than the
14120 body.  This is done by appending parenthesis to the code block name which may
14121 optionally contain arguments to the code block as shown below.
14123 @example
14124 <<code-block-name(optional arguments)>>
14125 @end example
14127 Note: the default value, @code{:noweb no}, was chosen to ensure that
14128 correct code is not broken in a language, such as Ruby, where
14129 @code{<<arg>>} is a syntactically valid construct.  If @code{<<arg>>} is not
14130 syntactically valid in languages that you use, then please consider setting
14131 the default value.
14133 Note: if noweb tangling is slow in large Org mode files consider setting the
14134 @code{*org-babel-use-quick-and-dirty-noweb-expansion*} variable to true.
14135 This will result in faster noweb reference resolution at the expense of not
14136 correctly resolving inherited values of the @code{:noweb-ref} header
14137 argument.
14139 @node Key bindings and useful functions, Batch execution, Noweb reference syntax, Working With Source Code
14140 @section Key bindings and useful functions
14141 @cindex code block, key bindings
14143 Many common Org mode key sequences are re-bound depending on
14144 the context.
14146 Within a code block, the following key bindings
14147 are active:
14149 @multitable @columnfractions 0.25 0.75
14150 @kindex C-c C-c
14151 @item @kbd{C-c C-c} @tab @code{org-babel-execute-src-block}
14152 @kindex C-c C-o
14153 @item @kbd{C-c C-o} @tab @code{org-babel-open-src-block-result}
14154 @kindex C-up
14155 @item @kbd{C-@key{up}}    @tab @code{org-babel-load-in-session}
14156 @kindex M-down
14157 @item @kbd{M-@key{down}}  @tab @code{org-babel-pop-to-session}
14158 @end multitable
14160 In an Org mode buffer, the following key bindings are active:
14162 @multitable @columnfractions 0.45 0.55
14163 @kindex C-c C-v p
14164 @kindex C-c C-v C-p
14165 @item @kbd{C-c C-v p} @ @ @r{or} @ @ @kbd{C-c C-v C-p} @tab @code{org-babel-previous-src-block}
14166 @kindex C-c C-v n
14167 @kindex C-c C-v C-n
14168 @item @kbd{C-c C-v n} @ @ @r{or} @ @ @kbd{C-c C-v C-n} @tab @code{org-babel-next-src-block}
14169 @kindex C-c C-v e
14170 @kindex C-c C-v C-e
14171 @item @kbd{C-c C-v e} @ @ @r{or} @ @ @kbd{C-c C-v C-e} @tab @code{org-babel-execute-maybe}
14172 @kindex C-c C-v o
14173 @kindex C-c C-v C-o
14174 @item @kbd{C-c C-v o} @ @ @r{or} @ @ @kbd{C-c C-v C-o} @tab @code{org-babel-open-src-block-result}
14175 @kindex C-c C-v v
14176 @kindex C-c C-v C-v
14177 @item @kbd{C-c C-v v} @ @ @r{or} @ @ @kbd{C-c C-v C-v} @tab @code{org-babel-expand-src-block}
14178 @kindex C-c C-v u
14179 @kindex C-c C-v C-u
14180 @item @kbd{C-c C-v u} @ @ @r{or} @ @ @kbd{C-c C-v C-u} @tab @code{org-babel-goto-src-block-head}
14181 @kindex C-c C-v g
14182 @kindex C-c C-v C-g
14183 @item @kbd{C-c C-v g} @ @ @r{or} @ @ @kbd{C-c C-v C-g} @tab @code{org-babel-goto-named-src-block}
14184 @kindex C-c C-v r
14185 @kindex C-c C-v C-r
14186 @item @kbd{C-c C-v r} @ @ @r{or} @ @ @kbd{C-c C-v C-r} @tab @code{org-babel-goto-named-result}
14187 @kindex C-c C-v b
14188 @kindex C-c C-v C-b
14189 @item @kbd{C-c C-v b} @ @ @r{or} @ @ @kbd{C-c C-v C-b} @tab @code{org-babel-execute-buffer}
14190 @kindex C-c C-v s
14191 @kindex C-c C-v C-s
14192 @item @kbd{C-c C-v s} @ @ @r{or} @ @ @kbd{C-c C-v C-s} @tab @code{org-babel-execute-subtree}
14193 @kindex C-c C-v d
14194 @kindex C-c C-v C-d
14195 @item @kbd{C-c C-v d} @ @ @r{or} @ @ @kbd{C-c C-v C-d} @tab @code{org-babel-demarcate-block}
14196 @kindex C-c C-v t
14197 @kindex C-c C-v C-t
14198 @item @kbd{C-c C-v t} @ @ @r{or} @ @ @kbd{C-c C-v C-t} @tab @code{org-babel-tangle}
14199 @kindex C-c C-v f
14200 @kindex C-c C-v C-f
14201 @item @kbd{C-c C-v f} @ @ @r{or} @ @ @kbd{C-c C-v C-f} @tab @code{org-babel-tangle-file}
14202 @kindex C-c C-v c
14203 @kindex C-c C-v C-c
14204 @item @kbd{C-c C-v c} @ @ @r{or} @ @ @kbd{C-c C-v C-c} @tab @code{org-babel-check-src-block}
14205 @kindex C-c C-v j
14206 @kindex C-c C-v C-j
14207 @item @kbd{C-c C-v j} @ @ @r{or} @ @ @kbd{C-c C-v C-j} @tab @code{org-babel-insert-header-arg}
14208 @kindex C-c C-v l
14209 @kindex C-c C-v C-l
14210 @item @kbd{C-c C-v l} @ @ @r{or} @ @ @kbd{C-c C-v C-l} @tab @code{org-babel-load-in-session}
14211 @kindex C-c C-v i
14212 @kindex C-c C-v C-i
14213 @item @kbd{C-c C-v i} @ @ @r{or} @ @ @kbd{C-c C-v C-i} @tab @code{org-babel-lob-ingest}
14214 @kindex C-c C-v I
14215 @kindex C-c C-v C-I
14216 @item @kbd{C-c C-v I} @ @ @r{or} @ @ @kbd{C-c C-v C-I} @tab @code{org-babel-view-src-block-info}
14217 @kindex C-c C-v z
14218 @kindex C-c C-v C-z
14219 @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}
14220 @kindex C-c C-v a
14221 @kindex C-c C-v C-a
14222 @item @kbd{C-c C-v a} @ @ @r{or} @ @ @kbd{C-c C-v C-a} @tab @code{org-babel-sha1-hash}
14223 @kindex C-c C-v h
14224 @kindex C-c C-v C-h
14225 @item @kbd{C-c C-v h} @ @ @r{or} @ @ @kbd{C-c C-v C-h} @tab @code{org-babel-describe-bindings}
14226 @kindex C-c C-v x
14227 @kindex C-c C-v C-x
14228 @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}
14229 @end multitable
14231 @c When possible these keybindings were extended to work when the control key is
14232 @c kept pressed, resulting in the following additional keybindings.
14234 @c @multitable @columnfractions 0.25 0.75
14235 @c @item @kbd{C-c C-v C-a} @tab @code{org-babel-sha1-hash}
14236 @c @item @kbd{C-c C-v C-b} @tab @code{org-babel-execute-buffer}
14237 @c @item @kbd{C-c C-v C-f} @tab @code{org-babel-tangle-file}
14238 @c @item @kbd{C-c C-v C-l} @tab @code{org-babel-lob-ingest}
14239 @c @item @kbd{C-c C-v C-p} @tab @code{org-babel-expand-src-block}
14240 @c @item @kbd{C-c C-v C-s} @tab @code{org-babel-execute-subtree}
14241 @c @item @kbd{C-c C-v C-t} @tab @code{org-babel-tangle}
14242 @c @item @kbd{C-c C-v C-z} @tab @code{org-babel-switch-to-session}
14243 @c @end multitable
14245 @node Batch execution,  , Key bindings and useful functions, Working With Source Code
14246 @section Batch execution
14247 @cindex code block, batch execution
14248 @cindex source code, batch execution
14250 It is possible to call functions from the command line.  This shell
14251 script calls @code{org-babel-tangle} on every one of its arguments.
14253 Be sure to adjust the paths to fit your system.
14255 @example
14256 #!/bin/sh
14257 # -*- mode: shell-script -*-
14259 # tangle files with org-mode
14261 DIR=`pwd`
14262 FILES=""
14264 # wrap each argument in the code required to call tangle on it
14265 for i in $@@; do
14266     FILES="$FILES \"$i\""
14267 done
14269 emacs -Q --batch \
14270 --eval "(progn
14271 (add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\"))
14272 (add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\" t))
14273 (require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle)
14274 (mapc (lambda (file)
14275        (find-file (expand-file-name file \"$DIR\"))
14276        (org-babel-tangle)
14277        (kill-buffer)) '($FILES)))" 2>&1 |grep tangled
14278 @end example
14280 @node Miscellaneous, Hacking, Working With Source Code, Top
14281 @chapter Miscellaneous
14283 @menu
14284 * Completion::                  M-TAB knows what you need
14285 * Easy Templates::              Quick insertion of structural elements
14286 * Speed keys::                  Electric commands at the beginning of a headline
14287 * Code evaluation security::    Org mode files evaluate inline code
14288 * Customization::               Adapting Org to your taste
14289 * In-buffer settings::          Overview of the #+KEYWORDS
14290 * The very busy C-c C-c key::   When in doubt, press C-c C-c
14291 * Clean view::                  Getting rid of leading stars in the outline
14292 * TTY keys::                    Using Org on a tty
14293 * Interaction::                 Other Emacs packages
14294 * org-crypt.el::                Encrypting Org files
14295 @end menu
14298 @node Completion, Easy Templates, Miscellaneous, Miscellaneous
14299 @section Completion
14300 @cindex completion, of @TeX{} symbols
14301 @cindex completion, of TODO keywords
14302 @cindex completion, of dictionary words
14303 @cindex completion, of option keywords
14304 @cindex completion, of tags
14305 @cindex completion, of property keys
14306 @cindex completion, of link abbreviations
14307 @cindex @TeX{} symbol completion
14308 @cindex TODO keywords completion
14309 @cindex dictionary word completion
14310 @cindex option keyword completion
14311 @cindex tag completion
14312 @cindex link abbreviations, completion of
14314 Emacs would not be Emacs without completion, and Org mode uses it whenever it
14315 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
14316 some of the completion prompts, you can specify your preference by setting at
14317 most one of the variables @code{org-completion-use-iswitchb}
14318 @code{org-completion-use-ido}.
14320 Org supports in-buffer completion.  This type of completion does
14321 not make use of the minibuffer.  You simply type a few letters into
14322 the buffer and use the key to complete text right there.
14324 @table @kbd
14325 @kindex M-@key{TAB}
14326 @item M-@key{TAB}
14327 Complete word at point
14328 @itemize @bullet
14329 @item
14330 At the beginning of a headline, complete TODO keywords.
14331 @item
14332 After @samp{\}, complete @TeX{} symbols supported by the exporter.
14333 @item
14334 After @samp{*}, complete headlines in the current buffer so that they
14335 can be used in search links like @samp{[[*find this headline]]}.
14336 @item
14337 After @samp{:} in a headline, complete tags.  The list of tags is taken
14338 from the variable @code{org-tag-alist} (possibly set through the
14339 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
14340 dynamically from all tags used in the current buffer.
14341 @item
14342 After @samp{:} and not in a headline, complete property keys.  The list
14343 of keys is constructed dynamically from all keys used in the current
14344 buffer.
14345 @item
14346 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
14347 @item
14348 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
14349 @samp{OPTIONS} which set file-specific options for Org mode.  When the
14350 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
14351 will insert example settings for this keyword.
14352 @item
14353 In the line after @samp{#+STARTUP: }, complete startup keywords,
14354 i.e., valid keys for this line.
14355 @item
14356 Elsewhere, complete dictionary words using Ispell.
14357 @end itemize
14358 @end table
14360 @node Easy Templates, Speed keys, Completion, Miscellaneous
14361 @section Easy Templates
14362 @cindex template insertion
14363 @cindex insertion, of templates
14365 Org mode supports insertion of empty structural elements (like
14366 @code{#+BEGIN_SRC} and @code{#+END_SRC} pairs) with just a few key
14367 strokes.  This is achieved through a native template expansion mechanism.
14368 Note that Emacs has several other template mechanisms which could be used in
14369 a similar way, for example @file{yasnippet}.
14371 To insert a structural element, type a @samp{<}, followed by a template
14372 selector and @kbd{@key{TAB}}.  Completion takes effect only when the above
14373 keystrokes are typed on a line by itself.
14375 The following template selectors are currently supported.
14377 @multitable @columnfractions 0.1 0.9
14378 @item @kbd{s} @tab @code{#+BEGIN_SRC     ... #+END_SRC}
14379 @item @kbd{e} @tab @code{#+BEGIN_EXAMPLE ... #+END_EXAMPLE}
14380 @item @kbd{q} @tab @code{#+BEGIN_QUOTE   ... #+END_QUOTE}
14381 @item @kbd{v} @tab @code{#+BEGIN_VERSE   ... #+END_VERSE}
14382 @item @kbd{c} @tab @code{#+BEGIN_CENTER  ... #+END_CENTER}
14383 @item @kbd{l} @tab @code{#+BEGIN_LaTeX   ... #+END_LaTeX}
14384 @item @kbd{L} @tab @code{#+LaTeX:}
14385 @item @kbd{h} @tab @code{#+BEGIN_HTML    ... #+END_HTML}
14386 @item @kbd{H} @tab @code{#+HTML:}
14387 @item @kbd{a} @tab @code{#+BEGIN_ASCII   ... #+END_ASCII}
14388 @item @kbd{A} @tab @code{#+ASCII:}
14389 @item @kbd{i} @tab @code{#+INDEX:} line
14390 @item @kbd{I} @tab @code{#+INCLUDE:} line
14391 @end multitable
14393 For example, on an empty line, typing "<e" and then pressing TAB, will expand
14394 into a complete EXAMPLE template.
14396 You can install additional templates by customizing the variable
14397 @code{org-structure-template-alist}.  See the docstring of the variable for
14398 additional details.
14400 @node Speed keys, Code evaluation security, Easy Templates, Miscellaneous
14401 @section Speed keys
14402 @cindex speed keys
14403 @vindex org-use-speed-commands
14404 @vindex org-speed-commands-user
14406 Single keys can be made to execute commands when the cursor is at the
14407 beginning of a headline, i.e., before the first star.  Configure the variable
14408 @code{org-use-speed-commands} to activate this feature.  There is a
14409 pre-defined list of commands, and you can add more such commands using the
14410 variable @code{org-speed-commands-user}.  Speed keys do not only speed up
14411 navigation and other commands, but they also provide an alternative way to
14412 execute commands bound to keys that are not or not easily available on a TTY,
14413 or on a small mobile device with a limited keyboard.
14415 To see which commands are available, activate the feature and press @kbd{?}
14416 with the cursor at the beginning of a headline.
14418 @node Code evaluation security, Customization, Speed keys, Miscellaneous
14419 @section Code evaluation and security issues
14421 Org provides tools to work with the code snippets, including evaluating them.
14423 Running code on your machine always comes with a security risk.  Badly
14424 written or malicious code can be executed on purpose or by accident.  Org has
14425 default settings which will only evaluate such code if you give explicit
14426 permission to do so, and as a casual user of these features you should leave
14427 these precautions intact.
14429 For people who regularly work with such code, the confirmation prompts can
14430 become annoying, and you might want to turn them off.  This can be done, but
14431 you must be aware of the risks that are involved.
14433 Code evaluation can happen under the following circumstances:
14435 @table @i
14436 @item Source code blocks
14437 Source code blocks can be evaluated during export, or when pressing @kbd{C-c
14438 C-c} in the block.  The most important thing to realize here is that Org mode
14439 files which contain code snippets are, in a certain sense, like executable
14440 files.  So you should accept them and load them into Emacs only from trusted
14441 sources---just like you would do with a program you install on your computer.
14443 Make sure you know what you are doing before customizing the variables
14444 which take off the default security brakes.
14446 @defopt org-confirm-babel-evaluate
14447 When t (the default), the user is asked before every code block evaluation.
14448 When nil, the user is not asked.  When set to a function, it is called with
14449 two arguments (language and body of the code block) and should return t to
14450 ask and nil not to ask.
14451 @end defopt
14453 For example, here is how to execute "ditaa" code (which is considered safe)
14454 without asking:
14456 @example
14457 (defun my-org-confirm-babel-evaluate (lang body)
14458   (not (string= lang "ditaa")))  ; don't ask for ditaa
14459 (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
14460 @end example
14462 @item Following @code{shell} and @code{elisp} links
14463 Org has two link types that can directly evaluate code (@pxref{External
14464 links}).  These links can be problematic because the code to be evaluated is
14465 not visible.
14467 @defopt org-confirm-shell-link-function
14468 Function to queries user about shell link execution.
14469 @end defopt
14470 @defopt org-confirm-elisp-link-function
14471 Functions to query user for Emacs Lisp link execution.
14472 @end defopt
14474 @item Formulas in tables
14475 Formulas in tables (@pxref{The spreadsheet}) are code that is evaluated
14476 either by the @i{calc} interpreter, or by the @i{Emacs Lisp} interpreter.
14477 @end table
14479 @node Customization, In-buffer settings, Code evaluation security, Miscellaneous
14480 @section Customization
14481 @cindex customization
14482 @cindex options, for customization
14483 @cindex variables, for customization
14485 There are more than 500 variables that can be used to customize
14486 Org.  For the sake of compactness of the manual, I am not
14487 describing the variables here.  A structured overview of customization
14488 variables is available with @kbd{M-x org-customize}.  Or select
14489 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
14490 settings can also be activated on a per-file basis, by putting special
14491 lines into the buffer (@pxref{In-buffer settings}).
14493 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
14494 @section Summary of in-buffer settings
14495 @cindex in-buffer settings
14496 @cindex special keywords
14498 Org mode uses special lines in the buffer to define settings on a
14499 per-file basis.  These lines start with a @samp{#+} followed by a
14500 keyword, a colon, and then individual words defining a setting.  Several
14501 setting words can be in the same line, but you can also have multiple
14502 lines for the keyword.  While these settings are described throughout
14503 the manual, here is a summary.  After changing any of those lines in the
14504 buffer, press @kbd{C-c C-c} with the cursor still in the line to
14505 activate the changes immediately.  Otherwise they become effective only
14506 when the file is visited again in a new Emacs session.
14508 @vindex org-archive-location
14509 @table @kbd
14510 @item #+ARCHIVE: %s_done::
14511 This line sets the archive location for the agenda file.  It applies for
14512 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
14513 of the file.  The first such line also applies to any entries before it.
14514 The corresponding variable is @code{org-archive-location}.
14515 @item #+CATEGORY:
14516 This line sets the category for the agenda file.  The category applies
14517 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
14518 end of the file.  The first such line also applies to any entries before it.
14519 @item #+COLUMNS: %25ITEM .....
14520 @cindex property, COLUMNS
14521 Set the default format for columns view.  This format applies when
14522 columns view is invoked in locations where no @code{COLUMNS} property
14523 applies.
14524 @item #+CONSTANTS: name1=value1 ...
14525 @vindex org-table-formula-constants
14526 @vindex org-table-formula
14527 Set file-local values for constants to be used in table formulas.  This
14528 line sets the local variable @code{org-table-formula-constants-local}.
14529 The global version of this variable is
14530 @code{org-table-formula-constants}.
14531 @item #+FILETAGS: :tag1:tag2:tag3:
14532 Set tags that can be inherited by any entry in the file, including the
14533 top-level entries.
14534 @item #+DRAWERS: NAME1 .....
14535 @vindex org-drawers
14536 Set the file-local set of additional drawers.  The corresponding global
14537 variable is @code{org-drawers}.
14538 @item #+LINK:  linkword replace
14539 @vindex org-link-abbrev-alist
14540 These lines (several are allowed) specify link abbreviations.
14541 @xref{Link abbreviations}.  The corresponding variable is
14542 @code{org-link-abbrev-alist}.
14543 @item #+PRIORITIES: highest lowest default
14544 @vindex org-highest-priority
14545 @vindex org-lowest-priority
14546 @vindex org-default-priority
14547 This line sets the limits and the default for the priorities.  All three
14548 must be either letters A--Z or numbers 0--9.  The highest priority must
14549 have a lower ASCII number than the lowest priority.
14550 @item #+PROPERTY: Property_Name Value
14551 This line sets a default inheritance value for entries in the current
14552 buffer, most useful for specifying the allowed values of a property.
14553 @cindex #+SETUPFILE
14554 @item #+SETUPFILE: file
14555 This line defines a file that holds more in-buffer setup.  Normally this is
14556 entirely ignored.  Only when the buffer is parsed for option-setting lines
14557 (i.e., when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
14558 settings line, or when exporting), then the contents of this file are parsed
14559 as if they had been included in the buffer.  In particular, the file can be
14560 any other Org mode file with internal setup.  You can visit the file the
14561 cursor is in the line with @kbd{C-c '}.
14562 @item #+STARTUP:
14563 @cindex #+STARTUP:
14564 This line sets options to be used at startup of Org mode, when an
14565 Org file is being visited.
14567 The first set of options deals with the initial visibility of the outline
14568 tree.  The corresponding variable for global default settings is
14569 @code{org-startup-folded}, with a default value @code{t}, which means
14570 @code{overview}.
14571 @vindex org-startup-folded
14572 @cindex @code{overview}, STARTUP keyword
14573 @cindex @code{content}, STARTUP keyword
14574 @cindex @code{showall}, STARTUP keyword
14575 @cindex @code{showeverything}, STARTUP keyword
14576 @example
14577 overview         @r{top-level headlines only}
14578 content          @r{all headlines}
14579 showall          @r{no folding of any entries}
14580 showeverything   @r{show even drawer contents}
14581 @end example
14583 @vindex org-startup-indented
14584 @cindex @code{indent}, STARTUP keyword
14585 @cindex @code{noindent}, STARTUP keyword
14586 Dynamic virtual indentation is controlled by the variable
14587 @code{org-startup-indented}@footnote{Emacs 23 and Org mode 6.29 are required}
14588 @example
14589 indent     @r{start with @code{org-indent-mode} turned on}
14590 noindent   @r{start with @code{org-indent-mode} turned off}
14591 @end example
14593 @vindex org-startup-align-all-tables
14594 Then there are options for aligning tables upon visiting a file.  This
14595 is useful in files containing narrowed table columns.  The corresponding
14596 variable is @code{org-startup-align-all-tables}, with a default value
14597 @code{nil}.
14598 @cindex @code{align}, STARTUP keyword
14599 @cindex @code{noalign}, STARTUP keyword
14600 @example
14601 align      @r{align all tables}
14602 noalign    @r{don't align tables on startup}
14603 @end example
14605 @vindex org-startup-with-inline-images
14606 When visiting a file, inline images can be automatically displayed.  The
14607 corresponding variable is @code{org-startup-with-inline-images}, with a
14608 default value @code{nil} to avoid delays when visiting a file.
14609 @cindex @code{inlineimages}, STARTUP keyword
14610 @cindex @code{noinlineimages}, STARTUP keyword
14611 @example
14612 inlineimages   @r{show inline images}
14613 noinlineimages @r{don't show inline images on startup}
14614 @end example
14616 @vindex org-startup-with-latex-preview
14617 When visiting a file, @LaTeX{} fragments can be converted to images
14618 automatically.  The variable @code{org-startup-with-latex-preview} which
14619 controls this behavior, is set to @code{nil} by default to avoid delays on
14620 startup.
14621 @cindex @code{latexpreview}, STARTUP keyword
14622 @cindex @code{nolatexpreview}, STARTUP keyword
14623 @example
14624 latexpreview   @r{preview @LaTeX{} fragments}
14625 nolatexpreview @r{don't preview @LaTeX{} fragments}
14626 @end example
14628 @vindex org-log-done
14629 @vindex org-log-note-clock-out
14630 @vindex org-log-repeat
14631 Logging the closing and reopening of TODO items and clock intervals can be
14632 configured using these options (see variables @code{org-log-done},
14633 @code{org-log-note-clock-out} and @code{org-log-repeat})
14634 @cindex @code{logdone}, STARTUP keyword
14635 @cindex @code{lognotedone}, STARTUP keyword
14636 @cindex @code{nologdone}, STARTUP keyword
14637 @cindex @code{lognoteclock-out}, STARTUP keyword
14638 @cindex @code{nolognoteclock-out}, STARTUP keyword
14639 @cindex @code{logrepeat}, STARTUP keyword
14640 @cindex @code{lognoterepeat}, STARTUP keyword
14641 @cindex @code{nologrepeat}, STARTUP keyword
14642 @cindex @code{logreschedule}, STARTUP keyword
14643 @cindex @code{lognotereschedule}, STARTUP keyword
14644 @cindex @code{nologreschedule}, STARTUP keyword
14645 @cindex @code{logredeadline}, STARTUP keyword
14646 @cindex @code{lognoteredeadline}, STARTUP keyword
14647 @cindex @code{nologredeadline}, STARTUP keyword
14648 @cindex @code{logrefile}, STARTUP keyword
14649 @cindex @code{lognoterefile}, STARTUP keyword
14650 @cindex @code{nologrefile}, STARTUP keyword
14651 @cindex @code{logdrawer}, STARTUP keyword
14652 @cindex @code{nologdrawer}, STARTUP keyword
14653 @cindex @code{logstatesreversed}, STARTUP keyword
14654 @cindex @code{nologstatesreversed}, STARTUP keyword
14655 @example
14656 logdone             @r{record a timestamp when an item is marked DONE}
14657 lognotedone         @r{record timestamp and a note when DONE}
14658 nologdone           @r{don't record when items are marked DONE}
14659 logrepeat           @r{record a time when reinstating a repeating item}
14660 lognoterepeat       @r{record a note when reinstating a repeating item}
14661 nologrepeat         @r{do not record when reinstating repeating item}
14662 lognoteclock-out    @r{record a note when clocking out}
14663 nolognoteclock-out  @r{don't record a note when clocking out}
14664 logreschedule       @r{record a timestamp when scheduling time changes}
14665 lognotereschedule   @r{record a note when scheduling time changes}
14666 nologreschedule     @r{do not record when a scheduling date changes}
14667 logredeadline       @r{record a timestamp when deadline changes}
14668 lognoteredeadline   @r{record a note when deadline changes}
14669 nologredeadline     @r{do not record when a deadline date changes}
14670 logrefile           @r{record a timestamp when refiling}
14671 lognoterefile       @r{record a note when refiling}
14672 nologrefile         @r{do not record when refiling}
14673 logdrawer           @r{store log into drawer}
14674 nologdrawer         @r{store log outside of drawer}
14675 logstatesreversed   @r{reverse the order of states notes}
14676 nologstatesreversed @r{do not reverse the order of states notes}
14677 @end example
14679 @vindex org-hide-leading-stars
14680 @vindex org-odd-levels-only
14681 Here are the options for hiding leading stars in outline headings, and for
14682 indenting outlines.  The corresponding variables are
14683 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
14684 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
14685 @cindex @code{hidestars}, STARTUP keyword
14686 @cindex @code{showstars}, STARTUP keyword
14687 @cindex @code{odd}, STARTUP keyword
14688 @cindex @code{even}, STARTUP keyword
14689 @example
14690 hidestars  @r{make all but one of the stars starting a headline invisible.}
14691 showstars  @r{show all stars starting a headline}
14692 indent     @r{virtual indentation according to outline level}
14693 noindent   @r{no virtual indentation according to outline level}
14694 odd        @r{allow only odd outline levels (1,3,...)}
14695 oddeven    @r{allow all outline levels}
14696 @end example
14698 @vindex org-put-time-stamp-overlays
14699 @vindex org-time-stamp-overlay-formats
14700 To turn on custom format overlays over timestamps (variables
14701 @code{org-put-time-stamp-overlays} and
14702 @code{org-time-stamp-overlay-formats}), use
14703 @cindex @code{customtime}, STARTUP keyword
14704 @example
14705 customtime @r{overlay custom time format}
14706 @end example
14708 @vindex constants-unit-system
14709 The following options influence the table spreadsheet (variable
14710 @code{constants-unit-system}).
14711 @cindex @code{constcgs}, STARTUP keyword
14712 @cindex @code{constSI}, STARTUP keyword
14713 @example
14714 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
14715 constSI    @r{@file{constants.el} should use the SI unit system}
14716 @end example
14718 @vindex org-footnote-define-inline
14719 @vindex org-footnote-auto-label
14720 @vindex org-footnote-auto-adjust
14721 To influence footnote settings, use the following keywords.  The
14722 corresponding variables are @code{org-footnote-define-inline},
14723 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
14724 @cindex @code{fninline}, STARTUP keyword
14725 @cindex @code{nofninline}, STARTUP keyword
14726 @cindex @code{fnlocal}, STARTUP keyword
14727 @cindex @code{fnprompt}, STARTUP keyword
14728 @cindex @code{fnauto}, STARTUP keyword
14729 @cindex @code{fnconfirm}, STARTUP keyword
14730 @cindex @code{fnplain}, STARTUP keyword
14731 @cindex @code{fnadjust}, STARTUP keyword
14732 @cindex @code{nofnadjust}, STARTUP keyword
14733 @example
14734 fninline    @r{define footnotes inline}
14735 fnnoinline  @r{define footnotes in separate section}
14736 fnlocal     @r{define footnotes near first reference, but not inline}
14737 fnprompt    @r{prompt for footnote labels}
14738 fnauto      @r{create @code{[fn:1]}-like labels automatically (default)}
14739 fnconfirm   @r{offer automatic label for editing or confirmation}
14740 fnplain     @r{create @code{[1]}-like labels automatically}
14741 fnadjust    @r{automatically renumber and sort footnotes}
14742 nofnadjust  @r{do not renumber and sort automatically}
14743 @end example
14745 @cindex org-hide-block-startup
14746 To hide blocks on startup, use these keywords.  The corresponding variable is
14747 @code{org-hide-block-startup}.
14748 @cindex @code{hideblocks}, STARTUP keyword
14749 @cindex @code{nohideblocks}, STARTUP keyword
14750 @example
14751 hideblocks   @r{Hide all begin/end blocks on startup}
14752 nohideblocks @r{Do not hide blocks on startup}
14753 @end example
14755 @cindex org-pretty-entities
14756 The display of entities as UTF-8 characters is governed by the variable
14757 @code{org-pretty-entities} and the keywords
14758 @cindex @code{entitiespretty}, STARTUP keyword
14759 @cindex @code{entitiesplain}, STARTUP keyword
14760 @example
14761 entitiespretty  @r{Show entities as UTF-8 characters where possible}
14762 entitiesplain   @r{Leave entities plain}
14763 @end example
14765 @item #+TAGS:  TAG1(c1) TAG2(c2)
14766 @vindex org-tag-alist
14767 These lines (several such lines are allowed) specify the valid tags in
14768 this file, and (potentially) the corresponding @emph{fast tag selection}
14769 keys.  The corresponding variable is @code{org-tag-alist}.
14770 @item #+TBLFM:
14771 This line contains the formulas for the table directly above the line.
14772 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
14773 @itemx #+OPTIONS:, #+BIND:,
14774 @itemx #+DESCRIPTION:, #+KEYWORDS:,
14775 @itemx #+LaTeX_HEADER:, #+HTML_STYLE:, #+HTML_LINK_UP:, #+HTML_LINK_HOME:,
14776 @itemx #+SELECT_TAGS:, #+EXCLUDE_TAGS:
14777 These lines provide settings for exporting files.  For more details see
14778 @ref{Export options}.
14779 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
14780 @vindex org-todo-keywords
14781 These lines set the TODO keywords and their interpretation in the
14782 current file.  The corresponding variable is @code{org-todo-keywords}.
14783 @end table
14785 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
14786 @section The very busy C-c C-c key
14787 @kindex C-c C-c
14788 @cindex C-c C-c, overview
14790 The key @kbd{C-c C-c} has many purposes in Org, which are all
14791 mentioned scattered throughout this manual.  One specific function of
14792 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
14793 other circumstances it means something like @emph{``Hey Org, look
14794 here and update according to what you see here''}.  Here is a summary of
14795 what this means in different contexts.
14797 @itemize @minus
14798 @item
14799 If there are highlights in the buffer from the creation of a sparse
14800 tree, or from clock display, remove these highlights.
14801 @item
14802 If the cursor is in one of the special @code{#+KEYWORD} lines, this
14803 triggers scanning the buffer for these lines and updating the
14804 information.
14805 @item
14806 If the cursor is inside a table, realign the table.  This command
14807 works even if the automatic table editor has been turned off.
14808 @item
14809 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
14810 the entire table.
14811 @item
14812 If the current buffer is a capture buffer, close the note and file it.
14813 With a prefix argument, file it, without further interaction, to the
14814 default location.
14815 @item
14816 If the cursor is on a @code{<<<target>>>}, update radio targets and
14817 corresponding links in this buffer.
14818 @item
14819 If the cursor is in a property line or at the start or end of a property
14820 drawer, offer property commands.
14821 @item
14822 If the cursor is at a footnote reference, go to the corresponding
14823 definition, and vice versa.
14824 @item
14825 If the cursor is on a statistics cookie, update it.
14826 @item
14827 If the cursor is in a plain list item with a checkbox, toggle the status
14828 of the checkbox.
14829 @item
14830 If the cursor is on a numbered item in a plain list, renumber the
14831 ordered list.
14832 @item
14833 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
14834 block is updated.
14835 @item
14836 If the cursor is at a timestamp, fix the day name in the timestamp.
14837 @end itemize
14839 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
14840 @section A cleaner outline view
14841 @cindex hiding leading stars
14842 @cindex dynamic indentation
14843 @cindex odd-levels-only outlines
14844 @cindex clean outline view
14846 Some people find it noisy and distracting that the Org headlines start with a
14847 potentially large number of stars, and that text below the headlines is not
14848 indented.  While this is no problem when writing a @emph{book-like} document
14849 where the outline headings are really section headings, in a more
14850 @emph{list-oriented} outline, indented structure is a lot cleaner:
14852 @example
14853 @group
14854 * Top level headline             |    * Top level headline
14855 ** Second level                  |      * Second level
14856 *** 3rd level                    |        * 3rd level
14857 some text                        |          some text
14858 *** 3rd level                    |        * 3rd level
14859 more text                        |          more text
14860 * Another top level headline     |    * Another top level headline
14861 @end group
14862 @end example
14864 @noindent
14866 If you are using at least Emacs 23.2@footnote{Emacs 23.1 can actually crash
14867 with @code{org-indent-mode}} and version 6.29 of Org, this kind of view can
14868 be achieved dynamically at display time using @code{org-indent-mode}.  In
14869 this minor mode, all lines are prefixed for display with the necessary amount
14870 of space@footnote{@code{org-indent-mode} also sets the @code{wrap-prefix}
14871 property, such that @code{visual-line-mode} (or purely setting
14872 @code{word-wrap}) wraps long lines (including headlines) correctly indented.
14873 }.  Also headlines are prefixed with additional stars, so that the amount of
14874 indentation shifts by two@footnote{See the variable
14875 @code{org-indent-indentation-per-level}.}  spaces per level.  All headline
14876 stars but the last one are made invisible using the @code{org-hide}
14877 face@footnote{Turning on @code{org-indent-mode} sets
14878 @code{org-hide-leading-stars} to @code{t} and @code{org-adapt-indentation} to
14879 @code{nil}.}; see below under @samp{2.} for more information on how this
14880 works.  You can turn on @code{org-indent-mode} for all files by customizing
14881 the variable @code{org-startup-indented}, or you can turn it on for
14882 individual files using
14884 @example
14885 #+STARTUP: indent
14886 @end example
14888 If you want a similar effect in an earlier version of Emacs and/or Org, or if
14889 you want the indentation to be hard space characters so that the plain text
14890 file looks as similar as possible to the Emacs display, Org supports you in
14891 the following way:
14893 @enumerate
14894 @item
14895 @emph{Indentation of text below headlines}@*
14896 You may indent text below each headline to make the left boundary line up
14897 with the headline, like
14899 @example
14900 *** 3rd level
14901     more text, now indented
14902 @end example
14904 @vindex org-adapt-indentation
14905 Org supports this with paragraph filling, line wrapping, and structure
14906 editing@footnote{See also the variable @code{org-adapt-indentation}.},
14907 preserving or adapting the indentation as appropriate.
14909 @item
14910 @vindex org-hide-leading-stars
14911 @emph{Hiding leading stars}@* You can modify the display in such a way that
14912 all leading stars become invisible.  To do this in a global way, configure
14913 the variable @code{org-hide-leading-stars} or change this on a per-file basis
14914 with
14916 @example
14917 #+STARTUP: hidestars
14918 #+STARTUP: showstars
14919 @end example
14921 With hidden stars, the tree becomes:
14923 @example
14924 @group
14925 * Top level headline
14926  * Second level
14927   * 3rd level
14928   ...
14929 @end group
14930 @end example
14932 @noindent
14933 @vindex org-hide @r{(face)}
14934 The leading stars are not truly replaced by whitespace, they are only
14935 fontified with the face @code{org-hide} that uses the background color as
14936 font color.  If you are not using either white or black background, you may
14937 have to customize this face to get the wanted effect.  Another possibility is
14938 to set this font such that the extra stars are @i{almost} invisible, for
14939 example using the color @code{grey90} on a white background.
14941 @item
14942 @vindex org-odd-levels-only
14943 Things become cleaner still if you skip all the even levels and use only odd
14944 levels 1, 3, 5..., effectively adding two stars to go from one outline level
14945 to the next@footnote{When you need to specify a level for a property search
14946 or refile targets, @samp{LEVEL=2} will correspond to 3 stars, etc.}.  In this
14947 way we get the outline view shown at the beginning of this section.  In order
14948 to make the structure editing and export commands handle this convention
14949 correctly, configure the variable @code{org-odd-levels-only}, or set this on
14950 a per-file basis with one of the following lines:
14952 @example
14953 #+STARTUP: odd
14954 #+STARTUP: oddeven
14955 @end example
14957 You can convert an Org file from single-star-per-level to the
14958 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
14959 RET} in that file.  The reverse operation is @kbd{M-x
14960 org-convert-to-oddeven-levels}.
14961 @end enumerate
14963 @node TTY keys, Interaction, Clean view, Miscellaneous
14964 @section Using Org on a tty
14965 @cindex tty key bindings
14967 Because Org contains a large number of commands, by default many of
14968 Org's core commands are bound to keys that are generally not
14969 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
14970 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
14971 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
14972 these commands on a tty when special keys are unavailable, the following
14973 alternative bindings can be used.  The tty bindings below will likely be
14974 more cumbersome; you may find for some of the bindings below that a
14975 customized workaround suits you better.  For example, changing a timestamp
14976 is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
14977 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
14979 @multitable @columnfractions 0.15 0.2 0.1 0.2
14980 @item @b{Default} @tab @b{Alternative 1} @tab @b{Speed key} @tab @b{Alternative 2}
14981 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab @kbd{C} @tab
14982 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{l} @tab @kbd{@key{Esc} @key{left}}
14983 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab @kbd{L} @tab
14984 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{r} @tab @kbd{@key{Esc} @key{right}}
14985 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab @kbd{R} @tab
14986 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{up}}
14987 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab @kbd{U} @tab
14988 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{down}}
14989 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab @kbd{D} @tab
14990 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab @kbd{ } @tab
14991 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{RET}}
14992 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab @kbd{ } @tab
14993 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab @kbd{ } @tab
14994 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab @kbd{ } @tab
14995 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab @kbd{ } @tab
14996 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab @kbd{ } @tab
14997 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab @kbd{ } @tab
14998 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab @kbd{ } @tab
14999 @end multitable
15002 @node Interaction, org-crypt.el, TTY keys, Miscellaneous
15003 @section Interaction with other packages
15004 @cindex packages, interaction with other
15005 Org lives in the world of GNU Emacs and interacts in various ways
15006 with other code out there.
15008 @menu
15009 * Cooperation::                 Packages Org cooperates with
15010 * Conflicts::                   Packages that lead to conflicts
15011 @end menu
15013 @node Cooperation, Conflicts, Interaction, Interaction
15014 @subsection Packages that Org cooperates with
15016 @table @asis
15017 @cindex @file{calc.el}
15018 @cindex Gillespie, Dave
15019 @item @file{calc.el} by Dave Gillespie
15020 Org uses the Calc package for implementing spreadsheet
15021 functionality in its tables (@pxref{The spreadsheet}).  Org
15022 checks for the availability of Calc by looking for the function
15023 @code{calc-eval} which will have been autoloaded during setup if Calc has
15024 been installed properly.  As of Emacs 22, Calc is part of the Emacs
15025 distribution.  Another possibility for interaction between the two
15026 packages is using Calc for embedded calculations.  @xref{Embedded Mode,
15027 , Embedded Mode, calc, GNU Emacs Calc Manual}.
15028 @item @file{constants.el} by Carsten Dominik
15029 @cindex @file{constants.el}
15030 @cindex Dominik, Carsten
15031 @vindex org-table-formula-constants
15032 In a table formula (@pxref{The spreadsheet}), it is possible to use
15033 names for natural constants or units.  Instead of defining your own
15034 constants in the variable @code{org-table-formula-constants}, install
15035 the @file{constants} package which defines a large number of constants
15036 and units, and lets you use unit prefixes like @samp{M} for
15037 @samp{Mega}, etc.  You will need version 2.0 of this package, available
15038 at @url{http://www.astro.uva.nl/~dominik/Tools}.  Org checks for
15039 the function @code{constants-get}, which has to be autoloaded in your
15040 setup.  See the installation instructions in the file
15041 @file{constants.el}.
15042 @item @file{cdlatex.el} by Carsten Dominik
15043 @cindex @file{cdlatex.el}
15044 @cindex Dominik, Carsten
15045 Org mode can make use of the CD@LaTeX{} package to efficiently enter
15046 @LaTeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
15047 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
15048 @cindex @file{imenu.el}
15049 Imenu allows menu access to an index of items in a file.  Org mode
15050 supports Imenu---all you need to do to get the index is the following:
15051 @lisp
15052 (add-hook 'org-mode-hook
15053           (lambda () (imenu-add-to-menubar "Imenu")))
15054 @end lisp
15055 @vindex org-imenu-depth
15056 By default the index is two levels deep---you can modify the depth using
15057 the option @code{org-imenu-depth}.
15058 @item @file{remember.el} by John Wiegley
15059 @cindex @file{remember.el}
15060 @cindex Wiegley, John
15061 Org used to use this package for capture, but no longer does.
15062 @item @file{speedbar.el} by Eric M. Ludlam
15063 @cindex @file{speedbar.el}
15064 @cindex Ludlam, Eric M.
15065 Speedbar is a package that creates a special frame displaying files and
15066 index items in files.  Org mode supports Speedbar and allows you to
15067 drill into Org files directly from the Speedbar.  It also allows you to
15068 restrict the scope of agenda commands to a file or a subtree by using
15069 the command @kbd{<} in the Speedbar frame.
15070 @cindex @file{table.el}
15071 @item @file{table.el} by Takaaki Ota
15072 @kindex C-c C-c
15073 @cindex table editor, @file{table.el}
15074 @cindex @file{table.el}
15075 @cindex Ota, Takaaki
15077 Complex ASCII tables with automatic line wrapping, column- and row-spanning,
15078 and alignment can be created using the Emacs table package by Takaaki Ota
15079 (@uref{http://sourceforge.net/projects/table}, and also part of Emacs 22).
15080 Org mode will recognize these tables and export them properly.  Because of
15081 interference with other Org mode functionality, you unfortunately cannot edit
15082 these tables directly in the buffer.  Instead, you need to use the command
15083 @kbd{C-c '} to edit them, similar to source code snippets.
15085 @table @kbd
15086 @orgcmd{C-c ',org-edit-special}
15087 Edit a @file{table.el} table.  Works when the cursor is in a table.el table.
15089 @orgcmd{C-c ~,org-table-create-with-table.el}
15090 Insert a @file{table.el} table.  If there is already a table at point, this
15091 command converts it between the @file{table.el} format and the Org mode
15092 format.  See the documentation string of the command
15093 @code{org-convert-table} for the restrictions under which this is
15094 possible.
15095 @end table
15096 @file{table.el} is part of Emacs since Emacs 22.
15097 @item @file{footnote.el} by Steven L. Baur
15098 @cindex @file{footnote.el}
15099 @cindex Baur, Steven L.
15100 Org mode recognizes numerical footnotes as provided by this package.
15101 However, Org mode also has its own footnote support (@pxref{Footnotes}),
15102 which makes using @file{footnote.el} unnecessary.
15103 @end table
15105 @node Conflicts,  , Cooperation, Interaction
15106 @subsection Packages that lead to conflicts with Org mode
15108 @table @asis
15110 @cindex @code{shift-selection-mode}
15111 @vindex org-support-shift-select
15112 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
15113 cursor motions combined with the shift key should start or enlarge regions.
15114 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
15115 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
15116 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
15117 special contexts don't do anything, but you can customize the variable
15118 @code{org-support-shift-select}.  Org mode then tries to accommodate shift
15119 selection by (i) using it outside of the special contexts where special
15120 commands apply, and by (ii) extending an existing active region even if the
15121 cursor moves across a special context.
15123 @item @file{CUA.el} by Kim. F. Storm
15124 @cindex @file{CUA.el}
15125 @cindex Storm, Kim. F.
15126 @vindex org-replace-disputed-keys
15127 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
15128 (as well as @code{pc-select-mode} and @code{s-region-mode}) to select and extend the
15129 region.  In fact, Emacs 23 has this built-in in the form of
15130 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
15131 23, you probably don't want to use another package for this purpose.  However,
15132 if you prefer to leave these keys to a different package while working in
15133 Org mode, configure the variable @code{org-replace-disputed-keys}.  When set,
15134 Org will move the following key bindings in Org files, and in the agenda
15135 buffer (but not during date selection).
15137 @example
15138 S-UP      @result{}  M-p             S-DOWN     @result{}  M-n
15139 S-LEFT    @result{}  M--             S-RIGHT    @result{}  M-+
15140 C-S-LEFT  @result{}  M-S--           C-S-RIGHT  @result{}  M-S-+
15141 @end example
15143 @vindex org-disputed-keys
15144 Yes, these are unfortunately more difficult to remember.  If you want
15145 to have other replacement keys, look at the variable
15146 @code{org-disputed-keys}.
15148 @item @file{filladapt.el} by Kyle Jones
15149 @cindex @file{filladapt.el}
15151 Org mode tries to do the right thing when filling paragraphs, list items and
15152 other elements.  Many users reported they had problems using both
15153 @file{filladapt.el} and Org mode, so a safe thing to do is to disable it like
15154 this:
15156 @lisp
15157 (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
15158 @end lisp
15160 @item @file{yasnippet.el}
15161 @cindex @file{yasnippet.el}
15162 The way Org mode binds the TAB key (binding to @code{[tab]} instead of
15163 @code{"\t"}) overrules YASnippet's access to this key.  The following code
15164 fixed this problem:
15166 @lisp
15167 (add-hook 'org-mode-hook
15168           (lambda ()
15169             (org-set-local 'yas/trigger-key [tab])
15170             (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
15171 @end lisp
15173 The latest version of yasnippet doesn't play well with Org mode.  If the
15174 above code does not fix the conflict, start by defining the following
15175 function:
15177 @lisp
15178 (defun yas/org-very-safe-expand ()
15179   (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
15180 @end lisp
15182 Then, tell Org mode what to do with the new function:
15184 @lisp
15185 (add-hook 'org-mode-hook
15186           (lambda ()
15187             (make-variable-buffer-local 'yas/trigger-key)
15188             (setq yas/trigger-key [tab])
15189             (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
15190             (define-key yas/keymap [tab] 'yas/next-field)))
15191 @end lisp
15193 @item @file{windmove.el} by Hovav Shacham
15194 @cindex @file{windmove.el}
15195 This package also uses the @kbd{S-<cursor>} keys, so everything written
15196 in the paragraph above about CUA mode also applies here.  If you want make
15197 the windmove function active in locations where Org mode does not have
15198 special functionality on @kbd{S-@key{cursor}}, add this to your
15199 configuration:
15201 @lisp
15202 ;; Make windmove work in org-mode:
15203 (add-hook 'org-shiftup-final-hook 'windmove-up)
15204 (add-hook 'org-shiftleft-final-hook 'windmove-left)
15205 (add-hook 'org-shiftdown-final-hook 'windmove-down)
15206 (add-hook 'org-shiftright-final-hook 'windmove-right)
15207 @end lisp
15209 @item @file{viper.el} by Michael Kifer
15210 @cindex @file{viper.el}
15211 @kindex C-c /
15212 Viper uses @kbd{C-c /} and therefore makes this key not access the
15213 corresponding Org mode command @code{org-sparse-tree}.  You need to find
15214 another key for this command, or override the key in
15215 @code{viper-vi-global-user-map} with
15217 @lisp
15218 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
15219 @end lisp
15221 @end table
15223 @node org-crypt.el,  , Interaction, Miscellaneous
15224 @section org-crypt.el
15225 @cindex @file{org-crypt.el}
15226 @cindex @code{org-decrypt-entry}
15228 Org-crypt will encrypt the text of an entry, but not the headline, or
15229 properties.  Org-crypt uses the Emacs EasyPG library to encrypt and decrypt
15230 files.
15232 Any text below a headline that has a @samp{:crypt:} tag will be automatically
15233 be encrypted when the file is saved.  If you want to use a different tag just
15234 customize the @code{org-crypt-tag-matcher} setting.
15236 To use org-crypt it is suggested that you have the following in your
15237 @file{.emacs}:
15239 @example
15240 (require 'org-crypt)
15241 (org-crypt-use-before-save-magic)
15242 (setq org-tags-exclude-from-inheritance (quote ("crypt")))
15244 (setq org-crypt-key nil)
15245   ;; GPG key to use for encryption
15246   ;; Either the Key ID or set to nil to use symmetric encryption.
15248 (setq auto-save-default nil)
15249   ;; Auto-saving does not cooperate with org-crypt.el: so you need
15250   ;; to turn it off if you plan to use org-crypt.el quite often.
15251   ;; Otherwise, you'll get an (annoying) message each time you
15252   ;; start Org.
15254   ;; To turn it off only locally, you can insert this:
15255   ;;
15256   ;; # -*- buffer-auto-save-file-name: nil; -*-
15257 @end example
15259 Excluding the crypt tag from inheritance prevents already encrypted text
15260 being encrypted again.
15262 @node Hacking, MobileOrg, Miscellaneous, Top
15263 @appendix Hacking
15264 @cindex hacking
15266 This appendix covers some aspects where users can extend the functionality of
15267 Org.
15269 @menu
15270 * Hooks::                       How to reach into Org's internals
15271 * Add-on packages::             Available extensions
15272 * Adding hyperlink types::      New custom link types
15273 * Context-sensitive commands::  How to add functionality to such commands
15274 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
15275 * Dynamic blocks::              Automatically filled blocks
15276 * Special agenda views::        Customized views
15277 * Extracting agenda information::  Postprocessing of agenda information
15278 * Using the property API::      Writing programs that use entry properties
15279 * Using the mapping API::       Mapping over all or selected entries
15280 @end menu
15282 @node Hooks, Add-on packages, Hacking, Hacking
15283 @section Hooks
15284 @cindex hooks
15286 Org has a large number of hook variables that can be used to add
15287 functionality.  This appendix about hacking is going to illustrate the
15288 use of some of them.  A complete list of all hooks with documentation is
15289 maintained by the Worg project and can be found at
15290 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
15292 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
15293 @section Add-on packages
15294 @cindex add-on packages
15296 A large number of add-on packages have been written by various authors.
15297 These packages are not part of Emacs, but they are distributed as contributed
15298 packages with the separate release available at the Org mode home page at
15299 @uref{http://orgmode.org}.  The list of contributed packages, along with
15300 documentation about each package, is maintained by the Worg project at
15301 @uref{http://orgmode.org/worg/org-contrib/}.
15305 @node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
15306 @section Adding hyperlink types
15307 @cindex hyperlinks, adding new types
15309 Org has a large number of hyperlink types built-in
15310 (@pxref{Hyperlinks}).  If you would like to add new link types, Org
15311 provides an interface for doing so.  Let's look at an example file,
15312 @file{org-man.el}, that will add support for creating links like
15313 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
15314 Emacs:
15316 @lisp
15317 ;;; org-man.el - Support for links to manpages in Org
15319 (require 'org)
15321 (org-add-link-type "man" 'org-man-open)
15322 (add-hook 'org-store-link-functions 'org-man-store-link)
15324 (defcustom org-man-command 'man
15325   "The Emacs command to be used to display a man page."
15326   :group 'org-link
15327   :type '(choice (const man) (const woman)))
15329 (defun org-man-open (path)
15330   "Visit the manpage on PATH.
15331 PATH should be a topic that can be thrown at the man command."
15332   (funcall org-man-command path))
15334 (defun org-man-store-link ()
15335   "Store a link to a manpage."
15336   (when (memq major-mode '(Man-mode woman-mode))
15337     ;; This is a man page, we do make this link
15338     (let* ((page (org-man-get-page-name))
15339            (link (concat "man:" page))
15340            (description (format "Manpage for %s" page)))
15341       (org-store-link-props
15342        :type "man"
15343        :link link
15344        :description description))))
15346 (defun org-man-get-page-name ()
15347   "Extract the page name from the buffer name."
15348   ;; This works for both `Man-mode' and `woman-mode'.
15349   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
15350       (match-string 1 (buffer-name))
15351     (error "Cannot create link to this man page")))
15353 (provide 'org-man)
15355 ;;; org-man.el ends here
15356 @end lisp
15358 @noindent
15359 You would activate this new link type in @file{.emacs} with
15361 @lisp
15362 (require 'org-man)
15363 @end lisp
15365 @noindent
15366 Let's go through the file and see what it does.
15367 @enumerate
15368 @item
15369 It does @code{(require 'org)} to make sure that @file{org.el} has been
15370 loaded.
15371 @item
15372 The next line calls @code{org-add-link-type} to define a new link type
15373 with prefix @samp{man}.  The call also contains the name of a function
15374 that will be called to follow such a link.
15375 @item
15376 @vindex org-store-link-functions
15377 The next line adds a function to @code{org-store-link-functions}, in
15378 order to allow the command @kbd{C-c l} to record a useful link in a
15379 buffer displaying a man page.
15380 @end enumerate
15382 The rest of the file defines the necessary variables and functions.
15383 First there is a customization variable that determines which Emacs
15384 command should be used to display man pages.  There are two options,
15385 @code{man} and @code{woman}.  Then the function to follow a link is
15386 defined.  It gets the link path as an argument---in this case the link
15387 path is just a topic for the manual command.  The function calls the
15388 value of @code{org-man-command} to display the man page.
15390 Finally the function @code{org-man-store-link} is defined.  When you try
15391 to store a link with @kbd{C-c l}, this function will be called to
15392 try to make a link.  The function must first decide if it is supposed to
15393 create the link for this buffer type; we do this by checking the value
15394 of the variable @code{major-mode}.  If not, the function must exit and
15395 return the value @code{nil}.  If yes, the link is created by getting the
15396 manual topic from the buffer name and prefixing it with the string
15397 @samp{man:}.  Then it must call the command @code{org-store-link-props}
15398 and set the @code{:type} and @code{:link} properties.  Optionally you
15399 can also set the @code{:description} property to provide a default for
15400 the link description when the link is later inserted into an Org
15401 buffer with @kbd{C-c C-l}.
15403 When it makes sense for your new link type, you may also define a function
15404 @code{org-PREFIX-complete-link} that implements special (e.g., completion)
15405 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
15406 not accept any arguments, and return the full link with prefix.
15408 @node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
15409 @section Context-sensitive commands
15410 @cindex context-sensitive commands, hooks
15411 @cindex add-ons, context-sensitive commands
15412 @vindex org-ctrl-c-ctrl-c-hook
15414 Org has several commands that act differently depending on context.  The most
15415 important example is the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
15416 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
15418 Add-ons can tap into this functionality by providing a function that detects
15419 special context for that add-on and executes functionality appropriate for
15420 the context.  Here is an example from Dan Davison's @file{org-R.el} which
15421 allows you to evaluate commands based on the @file{R} programming language
15422 @footnote{@file{org-R.el} has been replaced by the Org mode functionality
15423 described in @ref{Working With Source Code} and is now obsolete.}.  For this
15424 package, special contexts are lines that start with @code{#+R:} or
15425 @code{#+RR:}.
15427 @lisp
15428 (defun org-R-apply-maybe ()
15429   "Detect if this is context for org-R and execute R commands."
15430   (if (save-excursion
15431         (beginning-of-line 1)
15432         (looking-at "#\\+RR?:"))
15433       (progn (call-interactively 'org-R-apply)
15434              t) ;; to signal that we took action
15435     nil)) ;; to signal that we did not
15437 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
15438 @end lisp
15440 The function first checks if the cursor is in such a line.  If that is the
15441 case, @code{org-R-apply} is called and the function returns @code{t} to
15442 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
15443 contexts.  If the function finds it should do nothing locally, it returns
15444 @code{nil} so that other, similar functions can have a try.
15447 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
15448 @section Tables and lists in arbitrary syntax
15449 @cindex tables, in other modes
15450 @cindex lists, in other modes
15451 @cindex Orgtbl mode
15453 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
15454 frequent feature request has been to make it work with native tables in
15455 specific languages, for example @LaTeX{}.  However, this is extremely
15456 hard to do in a general way, would lead to a customization nightmare,
15457 and would take away much of the simplicity of the Orgtbl mode table
15458 editor.
15460 This appendix describes a different approach.  We keep the Orgtbl mode
15461 table in its native format (the @i{source table}), and use a custom
15462 function to @i{translate} the table to the correct syntax, and to
15463 @i{install} it in the right location (the @i{target table}).  This puts
15464 the burden of writing conversion functions on the user, but it allows
15465 for a very flexible system.
15467 Bastien added the ability to do the same with lists, in Orgstruct mode.  You
15468 can use Org's facilities to edit and structure lists by turning
15469 @code{orgstruct-mode} on, then locally exporting such lists in another format
15470 (HTML, @LaTeX{} or Texinfo.)
15473 @menu
15474 * Radio tables::                Sending and receiving radio tables
15475 * A @LaTeX{} example::          Step by step, almost a tutorial
15476 * Translator functions::        Copy and modify
15477 * Radio lists::                 Doing the same for lists
15478 @end menu
15480 @node Radio tables, A @LaTeX{} example, Tables in arbitrary syntax, Tables in arbitrary syntax
15481 @subsection Radio tables
15482 @cindex radio tables
15484 To define the location of the target table, you first need to create two
15485 lines that are comments in the current mode, but contain magic words for
15486 Orgtbl mode to find.  Orgtbl mode will insert the translated table
15487 between these lines, replacing whatever was there before.  For example:
15489 @example
15490 /* BEGIN RECEIVE ORGTBL table_name */
15491 /* END RECEIVE ORGTBL table_name */
15492 @end example
15494 @noindent
15495 Just above the source table, we put a special line that tells
15496 Orgtbl mode how to translate this table and where to install it.  For
15497 example:
15498 @cindex #+ORGTBL
15499 @example
15500 #+ORGTBL: SEND table_name translation_function arguments....
15501 @end example
15503 @noindent
15504 @code{table_name} is the reference name for the table that is also used
15505 in the receiver lines.  @code{translation_function} is the Lisp function
15506 that does the translation.  Furthermore, the line can contain a list of
15507 arguments (alternating key and value) at the end.  The arguments will be
15508 passed as a property list to the translation function for
15509 interpretation.  A few standard parameters are already recognized and
15510 acted upon before the translation function is called:
15512 @table @code
15513 @item :skip N
15514 Skip the first N lines of the table.  Hlines do count as separate lines for
15515 this parameter!
15517 @item :skipcols (n1 n2 ...)
15518 List of columns that should be skipped.  If the table has a column with
15519 calculation marks, that column is automatically discarded as well.
15520 Please note that the translator function sees the table @emph{after} the
15521 removal of these columns, the function never knows that there have been
15522 additional columns.
15524 @item :no-escape t
15525 When non-nil, do not escape special characters @code{&%#_^} when exporting
15526 the table.  The default value is nil.
15527 @end table
15529 @noindent
15530 The one problem remaining is how to keep the source table in the buffer
15531 without disturbing the normal workings of the file, for example during
15532 compilation of a C file or processing of a @LaTeX{} file.  There are a
15533 number of different solutions:
15535 @itemize @bullet
15536 @item
15537 The table could be placed in a block comment if that is supported by the
15538 language.  For example, in C mode you could wrap the table between
15539 @samp{/*} and @samp{*/} lines.
15540 @item
15541 Sometimes it is possible to put the table after some kind of @i{END}
15542 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
15543 in @LaTeX{}.
15544 @item
15545 You can just comment the table line-by-line whenever you want to process
15546 the file, and uncomment it whenever you need to edit the table.  This
15547 only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment}
15548 makes this comment-toggling very easy, in particular if you bind it to a
15549 key.
15550 @end itemize
15552 @node A @LaTeX{} example, Translator functions, Radio tables, Tables in arbitrary syntax
15553 @subsection A @LaTeX{} example of radio tables
15554 @cindex @LaTeX{}, and Orgtbl mode
15556 The best way to wrap the source table in @LaTeX{} is to use the
15557 @code{comment} environment provided by @file{comment.sty}.  It has to be
15558 activated by placing @code{\usepackage@{comment@}} into the document
15559 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
15560 default this works only for @LaTeX{}, HTML, and Texinfo.  Configure the
15561 variable @code{orgtbl-radio-tables} to install templates for other
15562 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
15563 be prompted for a table name, let's say we use @samp{salesfigures}.  You
15564 will then get the following template:
15566 @cindex #+ORGTBL, SEND
15567 @example
15568 % BEGIN RECEIVE ORGTBL salesfigures
15569 % END RECEIVE ORGTBL salesfigures
15570 \begin@{comment@}
15571 #+ORGTBL: SEND salesfigures orgtbl-to-latex
15572 | | |
15573 \end@{comment@}
15574 @end example
15576 @noindent
15577 @vindex @LaTeX{}-verbatim-environments
15578 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
15579 @code{orgtbl-to-latex} to convert the table into @LaTeX{} and to put it
15580 into the receiver location with name @code{salesfigures}.  You may now
15581 fill in the table---feel free to use the spreadsheet features@footnote{If
15582 the @samp{#+TBLFM} line contains an odd number of dollar characters,
15583 this may cause problems with font-lock in @LaTeX{} mode.  As shown in the
15584 example you can fix this by adding an extra line inside the
15585 @code{comment} environment that is used to balance the dollar
15586 expressions.  If you are using AUC@TeX{} with the font-latex library, a
15587 much better solution is to add the @code{comment} environment to the
15588 variable @code{LaTeX-verbatim-environments}.}:
15590 @example
15591 % BEGIN RECEIVE ORGTBL salesfigures
15592 % END RECEIVE ORGTBL salesfigures
15593 \begin@{comment@}
15594 #+ORGTBL: SEND salesfigures orgtbl-to-latex
15595 | Month | Days | Nr sold | per day |
15596 |-------+------+---------+---------|
15597 | Jan   |   23 |      55 |     2.4 |
15598 | Feb   |   21 |      16 |     0.8 |
15599 | March |   22 |     278 |    12.6 |
15600 #+TBLFM: $4=$3/$2;%.1f
15601 % $ (optional extra dollar to keep font-lock happy, see footnote)
15602 \end@{comment@}
15603 @end example
15605 @noindent
15606 When you are done, press @kbd{C-c C-c} in the table to get the converted
15607 table inserted between the two marker lines.
15609 Now let's assume you want to make the table header by hand, because you
15610 want to control how columns are aligned, etc.  In this case we make sure
15611 that the table translator skips the first 2 lines of the source
15612 table, and tell the command to work as a @i{splice}, i.e., to not produce
15613 header and footer commands of the target table:
15615 @example
15616 \begin@{tabular@}@{lrrr@}
15617 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
15618 % BEGIN RECEIVE ORGTBL salesfigures
15619 % END RECEIVE ORGTBL salesfigures
15620 \end@{tabular@}
15622 \begin@{comment@}
15623 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
15624 | Month | Days | Nr sold | per day |
15625 |-------+------+---------+---------|
15626 | Jan   |   23 |      55 |     2.4 |
15627 | Feb   |   21 |      16 |     0.8 |
15628 | March |   22 |     278 |    12.6 |
15629 #+TBLFM: $4=$3/$2;%.1f
15630 \end@{comment@}
15631 @end example
15633 The @LaTeX{} translator function @code{orgtbl-to-latex} is already part of
15634 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
15635 and marks horizontal lines with @code{\hline}.  Furthermore, it
15636 interprets the following parameters (see also @pxref{Translator functions}):
15638 @table @code
15639 @item :splice nil/t
15640 When set to t, return only table body lines, don't wrap them into a
15641 tabular environment.  Default is nil.
15643 @item :fmt fmt
15644 A format to be used to wrap each field, it should contain @code{%s} for the
15645 original field value.  For example, to wrap each field value in dollars,
15646 you could use @code{:fmt "$%s$"}.  This may also be a property list with
15647 column numbers and formats, for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
15648 A function of one argument can be used in place of the strings; the
15649 function must return a formatted string.
15651 @item :efmt efmt
15652 Use this format to print numbers with exponentials.  The format should
15653 have @code{%s} twice for inserting mantissa and exponent, for example
15654 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
15655 may also be a property list with column numbers and formats, for example
15656 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
15657 @code{efmt} has been applied to a value, @code{fmt} will also be
15658 applied.  Similar to @code{fmt}, functions of two arguments can be
15659 supplied instead of strings.
15660 @end table
15662 @node Translator functions, Radio lists, A @LaTeX{} example, Tables in arbitrary syntax
15663 @subsection Translator functions
15664 @cindex HTML, and Orgtbl mode
15665 @cindex translator function
15667 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
15668 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
15669 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
15670 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
15671 code that produces tables during HTML export.}, these all use a generic
15672 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
15673 itself is a very short function that computes the column definitions for the
15674 @code{tabular} environment, defines a few field and line separators and then
15675 hands processing over to the generic translator.  Here is the entire code:
15677 @lisp
15678 @group
15679 (defun orgtbl-to-latex (table params)
15680   "Convert the Orgtbl mode TABLE to LaTeX."
15681   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
15682                                org-table-last-alignment ""))
15683          (params2
15684           (list
15685            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
15686            :tend "\\end@{tabular@}"
15687            :lstart "" :lend " \\\\" :sep " & "
15688            :efmt "%s\\,(%s)" :hline "\\hline")))
15689     (orgtbl-to-generic table (org-combine-plists params2 params))))
15690 @end group
15691 @end lisp
15693 As you can see, the properties passed into the function (variable
15694 @var{PARAMS}) are combined with the ones newly defined in the function
15695 (variable @var{PARAMS2}).  The ones passed into the function (i.e., the
15696 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
15697 would like to use the @LaTeX{} translator, but wanted the line endings to
15698 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
15699 overrule the default with
15701 @example
15702 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
15703 @end example
15705 For a new language, you can either write your own converter function in
15706 analogy with the @LaTeX{} translator, or you can use the generic function
15707 directly.  For example, if you have a language where a table is started
15708 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
15709 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
15710 separator is a TAB, you could call the generic translator like this (on
15711 a single line!):
15713 @example
15714 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
15715                               :lstart "!BL! " :lend " !EL!" :sep "\t"
15716 @end example
15718 @noindent
15719 Please check the documentation string of the function
15720 @code{orgtbl-to-generic} for a full list of parameters understood by
15721 that function, and remember that you can pass each of them into
15722 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
15723 using the generic function.
15725 Of course you can also write a completely new function doing complicated
15726 things the generic translator cannot do.  A translator function takes
15727 two arguments.  The first argument is the table, a list of lines, each
15728 line either the symbol @code{hline} or a list of fields.  The second
15729 argument is the property list containing all parameters specified in the
15730 @samp{#+ORGTBL: SEND} line.  The function must return a single string
15731 containing the formatted table.  If you write a generally useful
15732 translator, please post it on @email{emacs-orgmode@@gnu.org} so that
15733 others can benefit from your work.
15735 @node Radio lists,  , Translator functions, Tables in arbitrary syntax
15736 @subsection Radio lists
15737 @cindex radio lists
15738 @cindex org-list-insert-radio-list
15740 Sending and receiving radio lists works exactly the same way as sending and
15741 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
15742 insert radio list templates in HTML, @LaTeX{} and Texinfo modes by calling
15743 @code{org-list-insert-radio-list}.
15745 Here are the differences with radio tables:
15747 @itemize @minus
15748 @item
15749 Orgstruct mode must be active.
15750 @item
15751 Use the @code{ORGLST} keyword instead of @code{ORGTBL}.
15752 @item
15753 The available translation functions for radio lists don't take
15754 parameters.
15755 @item
15756 @kbd{C-c C-c} will work when pressed on the first item of the list.
15757 @end itemize
15759 Here is a @LaTeX{} example.  Let's say that you have this in your
15760 @LaTeX{} file:
15762 @cindex #+ORGLST
15763 @example
15764 % BEGIN RECEIVE ORGLST to-buy
15765 % END RECEIVE ORGLST to-buy
15766 \begin@{comment@}
15767 #+ORGLST: SEND to-buy org-list-to-latex
15768 - a new house
15769 - a new computer
15770   + a new keyboard
15771   + a new mouse
15772 - a new life
15773 \end@{comment@}
15774 @end example
15776 Pressing @kbd{C-c C-c} on @code{a new house} and will insert the converted
15777 @LaTeX{} list between the two marker lines.
15779 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
15780 @section Dynamic blocks
15781 @cindex dynamic blocks
15783 Org documents can contain @emph{dynamic blocks}.  These are
15784 specially marked regions that are updated by some user-written function.
15785 A good example for such a block is the clock table inserted by the
15786 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
15788 Dynamic blocks are enclosed by a BEGIN-END structure that assigns a name
15789 to the block and can also specify parameters for the function producing
15790 the content of the block.
15792 @cindex #+BEGIN:dynamic block
15793 @example
15794 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
15796 #+END:
15797 @end example
15799 Dynamic blocks are updated with the following commands
15801 @table @kbd
15802 @orgcmd{C-c C-x C-u,org-dblock-update}
15803 Update dynamic block at point.
15804 @orgkey{C-u C-c C-x C-u}
15805 Update all dynamic blocks in the current file.
15806 @end table
15808 Updating a dynamic block means to remove all the text between BEGIN and
15809 END, parse the BEGIN line for parameters and then call the specific
15810 writer function for this block to insert the new content.  If you want
15811 to use the original content in the writer function, you can use the
15812 extra parameter @code{:content}.
15814 For a block with name @code{myblock}, the writer function is
15815 @code{org-dblock-write:myblock} with as only parameter a property list
15816 with the parameters given in the begin line.  Here is a trivial example
15817 of a block that keeps track of when the block update function was last
15818 run:
15820 @example
15821 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
15823 #+END:
15824 @end example
15826 @noindent
15827 The corresponding block writer function could look like this:
15829 @lisp
15830 (defun org-dblock-write:block-update-time (params)
15831   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
15832     (insert "Last block update at: "
15833             (format-time-string fmt (current-time)))))
15834 @end lisp
15836 If you want to make sure that all dynamic blocks are always up-to-date,
15837 you could add the function @code{org-update-all-dblocks} to a hook, for
15838 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
15839 written in a way such that it does nothing in buffers that are not in
15840 @code{org-mode}.
15842 You can narrow the current buffer to the current dynamic block (like any
15843 other block) with @code{org-narrow-to-block}.
15845 @node Special agenda views, Extracting agenda information, Dynamic blocks, Hacking
15846 @section Special agenda views
15847 @cindex agenda views, user-defined
15849 @vindex org-agenda-skip-function
15850 @vindex org-agenda-skip-function-global
15851 Org provides a special hook that can be used to narrow down the selection
15852 made by these agenda views: @code{agenda}, @code{todo}, @code{alltodo},
15853 @code{tags}, @code{tags-todo}, @code{tags-tree}.  You may specify a function
15854 that is used at each match to verify if the match should indeed be part of
15855 the agenda view, and if not, how much should be skipped.  You can specify a
15856 global condition that will be applied to all agenda views, this condition
15857 would be stored in the variable @code{org-agenda-skip-function-global}.  More
15858 commonly, such a definition is applied only to specific custom searches,
15859 using @code{org-agenda-skip-function}.
15861 Let's say you want to produce a list of projects that contain a WAITING
15862 tag anywhere in the project tree.  Let's further assume that you have
15863 marked all tree headings that define a project with the TODO keyword
15864 PROJECT@.  In this case you would run a TODO search for the keyword
15865 PROJECT, but skip the match unless there is a WAITING tag anywhere in
15866 the subtree belonging to the project line.
15868 To achieve this, you must write a function that searches the subtree for
15869 the tag.  If the tag is found, the function must return @code{nil} to
15870 indicate that this match should not be skipped.  If there is no such
15871 tag, return the location of the end of the subtree, to indicate that
15872 search should continue from there.
15874 @lisp
15875 (defun my-skip-unless-waiting ()
15876   "Skip trees that are not waiting"
15877   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
15878     (if (re-search-forward ":waiting:" subtree-end t)
15879         nil          ; tag found, do not skip
15880       subtree-end))) ; tag not found, continue after end of subtree
15881 @end lisp
15883 Now you may use this function in an agenda custom command, for example
15884 like this:
15886 @lisp
15887 (org-add-agenda-custom-command
15888  '("b" todo "PROJECT"
15889    ((org-agenda-skip-function 'my-skip-unless-waiting)
15890     (org-agenda-overriding-header "Projects waiting for something: "))))
15891 @end lisp
15893 @vindex org-agenda-overriding-header
15894 Note that this also binds @code{org-agenda-overriding-header} to get a
15895 meaningful header in the agenda view.
15897 @vindex org-odd-levels-only
15898 @vindex org-agenda-skip-function
15899 A general way to create custom searches is to base them on a search for
15900 entries with a certain level limit.  If you want to study all entries with
15901 your custom search function, simply do a search for
15902 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
15903 level number corresponds to order in the hierarchy, not to the number of
15904 stars.}, and then use @code{org-agenda-skip-function} to select the entries
15905 you really want to have.
15907 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
15908 particular, you may use the functions @code{org-agenda-skip-entry-if}
15909 and @code{org-agenda-skip-subtree-if} in this form, for example:
15911 @table @code
15912 @item (org-agenda-skip-entry-if 'scheduled)
15913 Skip current entry if it has been scheduled.
15914 @item (org-agenda-skip-entry-if 'notscheduled)
15915 Skip current entry if it has not been scheduled.
15916 @item (org-agenda-skip-entry-if 'deadline)
15917 Skip current entry if it has a deadline.
15918 @item (org-agenda-skip-entry-if 'scheduled 'deadline)
15919 Skip current entry if it has a deadline, or if it is scheduled.
15920 @item (org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))
15921 Skip current entry if the TODO keyword is TODO or WAITING.
15922 @item (org-agenda-skip-entry-if 'todo 'done)
15923 Skip current entry if the TODO keyword marks a DONE state.
15924 @item (org-agenda-skip-entry-if 'timestamp)
15925 Skip current entry if it has any timestamp, may also be deadline or scheduled.
15926 @anchor{x-agenda-skip-entry-regexp}
15927 @item (org-agenda-skip-entry-if 'regexp "regular expression")
15928 Skip current entry if the regular expression matches in the entry.
15929 @item (org-agenda-skip-entry-if 'notregexp "regular expression")
15930 Skip current entry unless the regular expression matches.
15931 @item (org-agenda-skip-subtree-if 'regexp "regular expression")
15932 Same as above, but check and skip the entire subtree.
15933 @end table
15935 Therefore we could also have written the search for WAITING projects
15936 like this, even without defining a special function:
15938 @lisp
15939 (org-add-agenda-custom-command
15940  '("b" todo "PROJECT"
15941    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
15942                                 'regexp ":waiting:"))
15943     (org-agenda-overriding-header "Projects waiting for something: "))))
15944 @end lisp
15946 @node Extracting agenda information, Using the property API, Special agenda views, Hacking
15947 @section Extracting agenda information
15948 @cindex agenda, pipe
15949 @cindex Scripts, for agenda processing
15951 @vindex org-agenda-custom-commands
15952 Org provides commands to access agenda information for the command
15953 line in Emacs batch mode.  This extracted information can be sent
15954 directly to a printer, or it can be read by a program that does further
15955 processing of the data.  The first of these commands is the function
15956 @code{org-batch-agenda}, that produces an agenda view and sends it as
15957 ASCII text to STDOUT@.  The command takes a single string as parameter.
15958 If the string has length 1, it is used as a key to one of the commands
15959 you have configured in @code{org-agenda-custom-commands}, basically any
15960 key you can use after @kbd{C-c a}.  For example, to directly print the
15961 current TODO list, you could use
15963 @example
15964 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
15965 @end example
15967 If the parameter is a string with 2 or more characters, it is used as a
15968 tags/TODO match string.  For example, to print your local shopping list
15969 (all items with the tag @samp{shop}, but excluding the tag
15970 @samp{NewYork}), you could use
15972 @example
15973 emacs -batch -l ~/.emacs                                      \
15974       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
15975 @end example
15977 @noindent
15978 You may also modify parameters on the fly like this:
15980 @example
15981 emacs -batch -l ~/.emacs                                      \
15982    -eval '(org-batch-agenda "a"                               \
15983             org-agenda-span (quote month)                     \
15984             org-agenda-include-diary nil                      \
15985             org-agenda-files (quote ("~/org/project.org")))'  \
15986    | lpr
15987 @end example
15989 @noindent
15990 which will produce a 30-day agenda, fully restricted to the Org file
15991 @file{~/org/projects.org}, not even including the diary.
15993 If you want to process the agenda data in more sophisticated ways, you
15994 can use the command @code{org-batch-agenda-csv} to get a comma-separated
15995 list of values for each agenda item.  Each line in the output will
15996 contain a number of fields separated by commas.  The fields in a line
15997 are:
15999 @example
16000 category     @r{The category of the item}
16001 head         @r{The headline, without TODO keyword, TAGS and PRIORITY}
16002 type         @r{The type of the agenda entry, can be}
16003                 todo               @r{selected in TODO match}
16004                 tagsmatch          @r{selected in tags match}
16005                 diary              @r{imported from diary}
16006                 deadline           @r{a deadline}
16007                 scheduled          @r{scheduled}
16008                 timestamp          @r{appointment, selected by timestamp}
16009                 closed             @r{entry was closed on date}
16010                 upcoming-deadline  @r{warning about nearing deadline}
16011                 past-scheduled     @r{forwarded scheduled item}
16012                 block              @r{entry has date block including date}
16013 todo         @r{The TODO keyword, if any}
16014 tags         @r{All tags including inherited ones, separated by colons}
16015 date         @r{The relevant date, like 2007-2-14}
16016 time         @r{The time, like 15:00-16:50}
16017 extra        @r{String with extra planning info}
16018 priority-l   @r{The priority letter if any was given}
16019 priority-n   @r{The computed numerical priority}
16020 @end example
16022 @noindent
16023 Time and date will only be given if a timestamp (or deadline/scheduled)
16024 led to the selection of the item.
16026 A CSV list like this is very easy to use in a post-processing script.
16027 For example, here is a Perl program that gets the TODO list from
16028 Emacs/Org and prints all the items, preceded by a checkbox:
16030 @example
16031 #!/usr/bin/perl
16033 # define the Emacs command to run
16034 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
16036 # run it and capture the output
16037 $agenda = qx@{$cmd 2>/dev/null@};
16039 # loop over all lines
16040 foreach $line (split(/\n/,$agenda)) @{
16041   # get the individual values
16042   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
16043    $priority_l,$priority_n) = split(/,/,$line);
16044   # process and print
16045   print "[ ] $head\n";
16047 @end example
16049 @node Using the property API, Using the mapping API, Extracting agenda information, Hacking
16050 @section Using the property API
16051 @cindex API, for properties
16052 @cindex properties, API
16054 Here is a description of the functions that can be used to work with
16055 properties.
16057 @defun org-entry-properties &optional pom which
16058 Get all properties of the entry at point-or-marker POM.@*
16059 This includes the TODO keyword, the tags, time strings for deadline,
16060 scheduled, and clocking, and any additional properties defined in the
16061 entry.  The return value is an alist.  Keys may occur multiple times
16062 if the property key was used several times.@*
16063 POM may also be nil, in which case the current entry is used.
16064 If WHICH is nil or `all', get all properties.  If WHICH is
16065 `special' or `standard', only get that subclass.
16066 @end defun
16067 @vindex org-use-property-inheritance
16068 @findex org-insert-property-drawer
16069 @defun org-entry-get pom property &optional inherit
16070 Get value of PROPERTY for entry at point-or-marker POM@.  By default,
16071 this only looks at properties defined locally in the entry.  If INHERIT
16072 is non-nil and the entry does not have the property, then also check
16073 higher levels of the hierarchy.  If INHERIT is the symbol
16074 @code{selective}, use inheritance if and only if the setting of
16075 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
16076 @end defun
16078 @defun org-entry-delete pom property
16079 Delete the property PROPERTY from entry at point-or-marker POM.
16080 @end defun
16082 @defun org-entry-put pom property value
16083 Set PROPERTY to VALUE for entry at point-or-marker POM.
16084 @end defun
16086 @defun org-buffer-property-keys &optional include-specials
16087 Get all property keys in the current buffer.
16088 @end defun
16090 @defun org-insert-property-drawer
16091 Insert a property drawer for the current entry.  Also
16092 @end defun
16094 @defun org-entry-put-multivalued-property pom property &rest values
16095 Set PROPERTY at point-or-marker POM to VALUES@.  VALUES should be a list of
16096 strings.  They will be concatenated, with spaces as separators.
16097 @end defun
16099 @defun org-entry-get-multivalued-property pom property
16100 Treat the value of the property PROPERTY as a whitespace-separated list of
16101 values and return the values as a list of strings.
16102 @end defun
16104 @defun org-entry-add-to-multivalued-property pom property value
16105 Treat the value of the property PROPERTY as a whitespace-separated list of
16106 values and make sure that VALUE is in this list.
16107 @end defun
16109 @defun org-entry-remove-from-multivalued-property pom property value
16110 Treat the value of the property PROPERTY as a whitespace-separated list of
16111 values and make sure that VALUE is @emph{not} in this list.
16112 @end defun
16114 @defun org-entry-member-in-multivalued-property pom property value
16115 Treat the value of the property PROPERTY as a whitespace-separated list of
16116 values and check if VALUE is in this list.
16117 @end defun
16119 @defopt org-property-allowed-value-functions
16120 Hook for functions supplying allowed values for a specific property.
16121 The functions must take a single argument, the name of the property, and
16122 return a flat list of allowed values.  If @samp{:ETC} is one of
16123 the values, use the values as completion help, but allow also other values
16124 to be entered.  The functions must return @code{nil} if they are not
16125 responsible for this property.
16126 @end defopt
16128 @node Using the mapping API,  , Using the property API, Hacking
16129 @section Using the mapping API
16130 @cindex API, for mapping
16131 @cindex mapping entries, API
16133 Org has sophisticated mapping capabilities to find all entries satisfying
16134 certain criteria.  Internally, this functionality is used to produce agenda
16135 views, but there is also an API that can be used to execute arbitrary
16136 functions for each or selected entries.  The main entry point for this API
16139 @defun org-map-entries func &optional match scope &rest skip
16140 Call FUNC at each headline selected by MATCH in SCOPE.
16142 FUNC is a function or a Lisp form.  The function will be called without
16143 arguments, with the cursor positioned at the beginning of the headline.
16144 The return values of all calls to the function will be collected and
16145 returned as a list.
16147 The call to FUNC will be wrapped into a save-excursion form, so FUNC
16148 does not need to preserve point.  After evaluation, the cursor will be
16149 moved to the end of the line (presumably of the headline of the
16150 processed entry) and search continues from there.  Under some
16151 circumstances, this may not produce the wanted results.  For example,
16152 if you have removed (e.g., archived) the current (sub)tree it could
16153 mean that the next entry will be skipped entirely.  In such cases, you
16154 can specify the position from where search should continue by making
16155 FUNC set the variable `org-map-continue-from' to the desired buffer
16156 position.
16158 MATCH is a tags/property/todo match as it is used in the agenda match view.
16159 Only headlines that are matched by this query will be considered during
16160 the iteration.  When MATCH is nil or t, all headlines will be
16161 visited by the iteration.
16163 SCOPE determines the scope of this command.  It can be any of:
16165 @example
16166 nil     @r{the current buffer, respecting the restriction if any}
16167 tree    @r{the subtree started with the entry at point}
16168 region  @r{The entries within the active region, if any}
16169 file    @r{the current buffer, without restriction}
16170 file-with-archives
16171         @r{the current buffer, and any archives associated with it}
16172 agenda  @r{all agenda files}
16173 agenda-with-archives
16174         @r{all agenda files with any archive files associated with them}
16175 (file1 file2 ...)
16176         @r{if this is a list, all files in the list will be scanned}
16177 @end example
16178 @noindent
16179 The remaining args are treated as settings for the skipping facilities of
16180 the scanner.  The following items can be given here:
16182 @vindex org-agenda-skip-function
16183 @example
16184 archive   @r{skip trees with the archive tag}
16185 comment   @r{skip trees with the COMMENT keyword}
16186 function or Lisp form
16187           @r{will be used as value for @code{org-agenda-skip-function},}
16188           @r{so whenever the function returns t, FUNC}
16189           @r{will not be called for that entry and search will}
16190           @r{continue from the point where the function leaves it}
16191 @end example
16192 @end defun
16194 The function given to that mapping routine can really do anything you like.
16195 It can use the property API (@pxref{Using the property API}) to gather more
16196 information about the entry, or in order to change metadata in the entry.
16197 Here are a couple of functions that might be handy:
16199 @defun org-todo &optional arg
16200 Change the TODO state of the entry.  See the docstring of the functions for
16201 the many possible values for the argument ARG.
16202 @end defun
16204 @defun org-priority &optional action
16205 Change the priority of the entry.  See the docstring of this function for the
16206 possible values for ACTION.
16207 @end defun
16209 @defun org-toggle-tag tag &optional onoff
16210 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
16211 or @code{off} will not toggle tag, but ensure that it is either on or off.
16212 @end defun
16214 @defun org-promote
16215 Promote the current entry.
16216 @end defun
16218 @defun org-demote
16219 Demote the current entry.
16220 @end defun
16222 Here is a simple example that will turn all entries in the current file with
16223 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
16224 Entries in comment trees and in archive trees will be ignored.
16226 @lisp
16227 (org-map-entries
16228  '(org-todo "UPCOMING")
16229  "+TOMORROW" 'file 'archive 'comment)
16230 @end lisp
16232 The following example counts the number of entries with TODO keyword
16233 @code{WAITING}, in all agenda files.
16235 @lisp
16236 (length (org-map-entries t "/+WAITING" 'agenda))
16237 @end lisp
16239 @node MobileOrg, History and Acknowledgments, Hacking, Top
16240 @appendix MobileOrg
16241 @cindex iPhone
16242 @cindex MobileOrg
16244 @i{MobileOrg} is the name of the mobile companion app for Org mode, currently
16245 available for iOS and for Android.  @i{MobileOrg} offers offline viewing and
16246 capture support for an Org mode system rooted on a ``real'' computer.  It
16247 does also allow you to record changes to existing entries.
16248 The @uref{http://mobileorg.ncogni.to/, iOS implementation} for the
16249 @i{iPhone/iPod Touch/iPad} series of devices, was developed by Richard
16250 Moreland.  Android users should check out
16251 @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android}
16252 by Matt Jones.  The two implementations are not identical but offer similar
16253 features.
16255 This appendix describes the support Org has for creating agenda views in a
16256 format that can be displayed by @i{MobileOrg}, and for integrating notes
16257 captured and changes made by @i{MobileOrg} into the main system.
16259 For changing tags and TODO states in MobileOrg, you should have set up the
16260 customization variables @code{org-todo-keywords} and @code{org-tags-alist} to
16261 cover all important tags and TODO keywords, even if individual files use only
16262 part of these.  MobileOrg will also offer you states and tags set up with
16263 in-buffer settings, but it will understand the logistics of TODO state
16264 @i{sets} (@pxref{Per-file keywords}) and @i{mutually exclusive} tags
16265 (@pxref{Setting tags}) only for those set in these variables.
16267 @menu
16268 * Setting up the staging area::  Where to interact with the mobile device
16269 * Pushing to MobileOrg::        Uploading Org files and agendas
16270 * Pulling from MobileOrg::      Integrating captured and flagged items
16271 @end menu
16273 @node Setting up the staging area, Pushing to MobileOrg, MobileOrg, MobileOrg
16274 @section Setting up the staging area
16276 MobileOrg needs to interact with Emacs through a directory on a server.  If you
16277 are using a public server, you should consider to encrypt the files that are
16278 uploaded to the server.  This can be done with Org mode 7.02 and with
16279 @i{MobileOrg 1.5} (iPhone version), and you need an @file{openssl}
16280 installation on your system.  To turn on encryption, set a password in
16281 @i{MobileOrg} and, on the Emacs side, configure the variable
16282 @code{org-mobile-use-encryption}@footnote{If you can safely store the
16283 password in your Emacs setup, you might also want to configure
16284 @code{org-mobile-encryption-password}.  Please read the docstring of that
16285 variable.  Note that encryption will apply only to the contents of the
16286 @file{.org} files.  The file names themselves will remain visible.}.
16288 The easiest way to create that directory is to use a free
16289 @uref{http://dropbox.com,Dropbox.com} account@footnote{If you cannot use
16290 Dropbox, or if your version of MobileOrg does not support it, you can use a
16291 webdav server.  For more information, check out the documentation of MobileOrg and also this
16292 @uref{http://orgmode.org/worg/org-faq.html#mobileorg_webdav, FAQ entry}.}.
16293 When MobileOrg first connects to your Dropbox, it will create a directory
16294 @i{MobileOrg} inside the Dropbox.  After the directory has been created, tell
16295 Emacs about it:
16297 @lisp
16298 (setq org-mobile-directory "~/Dropbox/MobileOrg")
16299 @end lisp
16301 Org mode has commands to put files for @i{MobileOrg} into that directory,
16302 and to read captured notes from there.
16304 @node Pushing to MobileOrg, Pulling from MobileOrg, Setting up the staging area, MobileOrg
16305 @section Pushing to MobileOrg
16307 This operation copies all files currently listed in @code{org-mobile-files}
16308 to the directory @code{org-mobile-directory}.  By default this list contains
16309 all agenda files (as listed in @code{org-agenda-files}), but additional files
16310 can be included by customizing @code{org-mobile-files}.  File names will be
16311 staged with paths relative to @code{org-directory}, so all files should be
16312 inside this directory@footnote{Symbolic links in @code{org-directory} need to
16313 have the same name than their targets.}.
16315 The push operation also creates a special Org file @file{agendas.org} with
16316 all custom agenda view defined by the user@footnote{While creating the
16317 agendas, Org mode will force ID properties on all referenced entries, so that
16318 these entries can be uniquely identified if @i{MobileOrg} flags them for
16319 further action.  If you do not want to get these properties in so many
16320 entries, you can set the variable @code{org-mobile-force-id-on-agenda-items}
16321 to @code{nil}.  Org mode will then rely on outline paths, in the hope that
16322 these will be unique enough.}.
16324 Finally, Org writes the file @file{index.org}, containing links to all other
16325 files.  @i{MobileOrg} first reads this file from the server, and then
16326 downloads all agendas and Org files listed in it.  To speed up the download,
16327 MobileOrg will only read files whose checksums@footnote{Checksums are stored
16328 automatically in the file @file{checksums.dat}} have changed.
16330 @node Pulling from MobileOrg,  , Pushing to MobileOrg, MobileOrg
16331 @section Pulling from MobileOrg
16333 When @i{MobileOrg} synchronizes with the server, it not only pulls the Org
16334 files for viewing.  It also appends captured entries and pointers to flagged
16335 and changed entries to the file @file{mobileorg.org} on the server.  Org has
16336 a @emph{pull} operation that integrates this information into an inbox file
16337 and operates on the pointers to flagged entries.  Here is how it works:
16339 @enumerate
16340 @item
16341 Org moves all entries found in
16342 @file{mobileorg.org}@footnote{@file{mobileorg.org} will be empty after this
16343 operation.} and appends them to the file pointed to by the variable
16344 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing event
16345 will be a top-level entry in the inbox file.
16346 @item
16347 After moving the entries, Org will attempt to implement the changes made in
16348 @i{MobileOrg}.  Some changes are applied directly and without user
16349 interaction.  Examples are all changes to tags, TODO state, headline and body
16350 text that can be cleanly applied.  Entries that have been flagged for further
16351 action will receive a tag @code{:FLAGGED:}, so that they can be easily found
16352 again.  When there is a problem finding an entry or applying the change, the
16353 pointer entry will remain in the inbox and will be marked with an error
16354 message.  You need to later resolve these issues by hand.
16355 @item
16356 Org will then generate an agenda view with all flagged entries.  The user
16357 should then go through these entries and do whatever actions are necessary.
16358 If a note has been stored while flagging an entry in @i{MobileOrg}, that note
16359 will be displayed in the echo area when the cursor is on the corresponding
16360 agenda line.
16361 @table @kbd
16362 @kindex ?
16363 @item ?
16364 Pressing @kbd{?} in that special agenda will display the full flagging note in
16365 another window and also push it onto the kill ring.  So you could use @kbd{?
16366 z C-y C-c C-c} to store that flagging note as a normal note in the entry.
16367 Pressing @kbd{?} twice in succession will offer to remove the
16368 @code{:FLAGGED:} tag along with the recorded flagging note (which is stored
16369 in a property).  In this way you indicate that the intended processing for
16370 this flagged entry is finished.
16371 @end table
16372 @end enumerate
16374 @kindex C-c a ?
16375 If you are not able to process all flagged entries directly, you can always
16376 return to this agenda view@footnote{Note, however, that there is a subtle
16377 difference.  The view created automatically by @kbd{M-x org-mobile-pull
16378 @key{RET}} is guaranteed to search all files that have been addressed by the
16379 last pull.  This might include a file that is not currently in your list of
16380 agenda files.  If you later use @kbd{C-c a ?} to regenerate the view, only
16381 the current agenda files will be searched.} using @kbd{C-c a ?}.
16383 @node History and Acknowledgments, GNU Free Documentation License, MobileOrg, Top
16384 @appendix History and acknowledgments
16385 @cindex acknowledgments
16386 @cindex history
16387 @cindex thanks
16389 @section From Carsten
16391 Org was born in 2003, out of frustration over the user interface of the Emacs
16392 Outline mode.  I was trying to organize my notes and projects, and using
16393 Emacs seemed to be the natural way to go.  However, having to remember eleven
16394 different commands with two or three keys per command, only to hide and show
16395 parts of the outline tree, that seemed entirely unacceptable to me.  Also,
16396 when using outlines to take notes, I constantly wanted to restructure the
16397 tree, organizing it parallel to my thoughts and plans.  @emph{Visibility
16398 cycling} and @emph{structure editing} were originally implemented in the
16399 package @file{outline-magic.el}, but quickly moved to the more general
16400 @file{org.el}.  As this environment became comfortable for project planning,
16401 the next step was adding @emph{TODO entries}, basic @emph{timestamps}, and
16402 @emph{table support}.  These areas highlighted the two main goals that Org
16403 still has today: to be a new, outline-based, plain text mode with innovative
16404 and intuitive editing features, and to incorporate project planning
16405 functionality directly into a notes file.
16407 Since the first release, literally thousands of emails to me or to
16408 @email{emacs-orgmode@@gnu.org} have provided a constant stream of bug
16409 reports, feedback, new ideas, and sometimes patches and add-on code.
16410 Many thanks to everyone who has helped to improve this package.  I am
16411 trying to keep here a list of the people who had significant influence
16412 in shaping one or more aspects of Org.  The list may not be
16413 complete, if I have forgotten someone, please accept my apologies and
16414 let me know.
16416 Before I get to this list, a few special mentions are in order:
16418 @table @i
16419 @item Bastien Guerry
16420 Bastien has written a large number of extensions to Org (most of them
16421 integrated into the core by now), including the @LaTeX{} exporter and the plain
16422 list parser.  His support during the early days, when he basically acted as
16423 co-maintainer, was central to the success of this project.  Bastien also
16424 invented Worg, helped establishing the Web presence of Org, and sponsored
16425 hosting costs for the orgmode.org website.
16426 @item Eric Schulte and Dan Davison
16427 Eric and Dan are jointly responsible for the Org-babel system, which turns
16428 Org into a multi-language environment for evaluating code and doing literate
16429 programming and reproducible research.
16430 @item John Wiegley
16431 John has contributed a number of great ideas and patches directly to Org,
16432 including the attachment system (@file{org-attach.el}), integration with
16433 Apple Mail (@file{org-mac-message.el}), hierarchical dependencies of TODO
16434 items, habit tracking (@file{org-habits.el}), and encryption
16435 (@file{org-crypt.el}).  Also, the capture system is really an extended copy
16436 of his great @file{remember.el}.
16437 @item Sebastian Rose
16438 Without Sebastian, the HTML/XHTML publishing of Org would be the pitiful work
16439 of an ignorant amateur.  Sebastian has pushed this part of Org onto a much
16440 higher level.  He also wrote @file{org-info.js}, a Java script for displaying
16441 webpages derived from Org using an Info-like or a folding interface with
16442 single-key navigation.
16443 @end table
16445 @noindent See below for the full list of contributions!  Again, please
16446 let me know what I am missing here!
16448 @section From Bastien
16450 I (Bastien) have been maintaining Org since January 2011.  This appendix
16451 would not be complete without adding a few more acknowledgements and thanks
16452 to Carsten's ones above.
16454 I am first grateful to Carsten for his trust while handing me over the
16455 maintainership of Org.  His support as been great since day one of this new
16456 adventure, and it helped a lot.
16458 When I took over maintainership, I knew I would have to make Org more
16459 collaborative than ever, as I would have to rely on people that are more
16460 knowledgeable than I am on many parts of the code.  Here is a list of the
16461 persons I could rely on, they should really be considered co-maintainers,
16462 either of the code or the community:
16464 @table @i
16465 @item Eric Schulte
16466 Eric is maintaining the Babel parts of Org.  His reactivity here kept me away
16467 from worrying about possible bugs here and let me focus on other parts.
16469 @item Nicolas Goaziou
16470 Nicolas is maintaining the consistency of the deepest parts of Org.  His work
16471 on @file{org-element.el} and @file{org-export.el} has been outstanding, and
16472 opened the doors for many new ideas and features.
16474 @item Jambunathan K
16475 Jambunathan contributed the ODT exporter, definitely a killer feature of
16476 Org mode.  He also contributed the new HTML exporter, which is another core
16477 feature of Org.  Here too, I knew I could rely on him to fix bugs in these
16478 areas and to patiently explain the users what was the problems and solutions.
16480 @item Achim Gratz
16481 Achim rewrote the building process of Org, turning some @emph{ad hoc} tools
16482 into a flexible and conceptually clean process.  He patiently coped with the
16483 many hiccups that such a change can create for users.
16485 @item Nick Dokos
16486 The Org mode mailing list would not be such a nice place without Nick, who
16487 patiently helped users so many times.  It is impossible to overestimate such
16488 a great help, and the list would not be so active without him.
16489 @end table
16491 I received support from so many users that it is clearly impossible to be
16492 fair when shortlisting a few of them, but Org's history would not be
16493 complete if the ones above were not mentioned in this manual.
16495 @section List of contributions
16497 @itemize @bullet
16499 @item
16500 @i{Russel Adams} came up with the idea for drawers.
16501 @item
16502 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
16503 @item
16504 @i{Christophe Bataillon} created the great unicorn logo that we use on the
16505 Org mode website.
16506 @item
16507 @i{Alex Bochannek} provided a patch for rounding timestamps.
16508 @item
16509 @i{Jan Böcker} wrote @file{org-docview.el}.
16510 @item
16511 @i{Brad Bozarth} showed how to pull RSS feed data into Org mode files.
16512 @item
16513 @i{Tom Breton} wrote @file{org-choose.el}.
16514 @item
16515 @i{Charles Cave}'s suggestion sparked the implementation of templates
16516 for Remember, which are now templates for capture.
16517 @item
16518 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
16519 specified time.
16520 @item
16521 @i{Gregory Chernov} patched support for Lisp forms into table
16522 calculations and improved XEmacs compatibility, in particular by porting
16523 @file{nouline.el} to XEmacs.
16524 @item
16525 @i{Sacha Chua} suggested copying some linking code from Planner.
16526 @item
16527 @i{Baoqiu Cui} contributed the DocBook exporter.  It has been deleted from
16528 Org 8.0: you can now export to Texinfo and export the @code{.texi} file to
16529 DocBook using @code{makeinfo}.
16530 @item
16531 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
16532 came up with the idea of properties, and that there should be an API for
16533 them.
16534 @item
16535 @i{Nick Dokos} tracked down several nasty bugs.
16536 @item
16537 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
16538 inspired some of the early development, including HTML export.  He also
16539 asked for a way to narrow wide table columns.
16540 @item
16541 @i{Thomas S. Dye} contributed documentation on Worg and helped integrating
16542 the Org-Babel documentation into the manual.
16543 @item
16544 @i{Christian Egli} converted the documentation into Texinfo format, inspired
16545 the agenda, patched CSS formatting into the HTML exporter, and wrote
16546 @file{org-taskjuggler.el}, which has been rewritten by Nicolas Goaziou as
16547 @file{ox-taskjuggler.el} for Org 8.0.
16548 @item
16549 @i{David Emery} provided a patch for custom CSS support in exported
16550 HTML agendas.
16551 @item
16552 @i{Nic Ferrier} contributed mailcap and XOXO support.
16553 @item
16554 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
16555 @item
16556 @i{John Foerch} figured out how to make incremental search show context
16557 around a match in a hidden outline tree.
16558 @item
16559 @i{Raimar Finken} wrote @file{org-git-line.el}.
16560 @item
16561 @i{Mikael Fornius} works as a mailing list moderator.
16562 @item
16563 @i{Austin Frank} works as a mailing list moderator.
16564 @item
16565 @i{Eric Fraga} drove the development of BEAMER export with ideas and
16566 testing.
16567 @item
16568 @i{Barry Gidden} did proofreading the manual in preparation for the book
16569 publication through Network Theory Ltd.
16570 @item
16571 @i{Niels Giesen} had the idea to automatically archive DONE trees.
16572 @item
16573 @i{Nicolas Goaziou} rewrote much of the plain list code.
16574 @item
16575 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
16576 @item
16577 @i{Brian Gough} of Network Theory Ltd publishes the Org mode manual as a
16578 book.
16579 @item
16580 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
16581 task state change logging, and the clocktable.  His clear explanations have
16582 been critical when we started to adopt the Git version control system.
16583 @item
16584 @i{Manuel Hermenegildo} has contributed various ideas, small fixes and
16585 patches.
16586 @item
16587 @i{Phil Jackson} wrote @file{org-irc.el}.
16588 @item
16589 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
16590 folded entries, and column view for properties.
16591 @item
16592 @i{Matt Jones} wrote @i{MobileOrg Android}.
16593 @item
16594 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
16595 @item
16596 @i{Shidai Liu} ("Leo") asked for embedded @LaTeX{} and tested it.  He also
16597 provided frequent feedback and some patches.
16598 @item
16599 @i{Matt Lundin} has proposed last-row references for table formulas and named
16600 invisible anchors.  He has also worked a lot on the FAQ.
16601 @item
16602 @i{David Maus} wrote @file{org-atom.el}, maintains the issues file for Org,
16603 and is a prolific contributor on the mailing list with competent replies,
16604 small fixes and patches.
16605 @item
16606 @i{Jason F. McBrayer} suggested agenda export to CSV format.
16607 @item
16608 @i{Max Mikhanosha} came up with the idea of refiling.
16609 @item
16610 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
16611 basis.
16612 @item
16613 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
16614 happy.
16615 @item
16616 @i{Richard Moreland} wrote @i{MobileOrg} for the iPhone.
16617 @item
16618 @i{Rick Moynihan} proposed allowing multiple TODO sequences in a file
16619 and being able to quickly restrict the agenda to a subtree.
16620 @item
16621 @i{Todd Neal} provided patches for links to Info files and Elisp forms.
16622 @item
16623 @i{Greg Newman} refreshed the unicorn logo into its current form.
16624 @item
16625 @i{Tim O'Callaghan} suggested in-file links, search options for general
16626 file links, and TAGS.
16627 @item
16628 @i{Osamu Okano} wrote @file{orgcard2ref.pl}, a Perl program to create a text
16629 version of the reference card.
16630 @item
16631 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
16632 into Japanese.
16633 @item
16634 @i{Oliver Oppitz} suggested multi-state TODO items.
16635 @item
16636 @i{Scott Otterson} sparked the introduction of descriptive text for
16637 links, among other things.
16638 @item
16639 @i{Pete Phillips} helped during the development of the TAGS feature, and
16640 provided frequent feedback.
16641 @item
16642 @i{Martin Pohlack} provided the code snippet to bundle character insertion
16643 into bundles of 20 for undo.
16644 @item
16645 @i{T.V. Raman} reported bugs and suggested improvements.
16646 @item
16647 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
16648 control.
16649 @item
16650 @i{Paul Rivier} provided the basic implementation of named footnotes.  He
16651 also acted as mailing list moderator for some time.
16652 @item
16653 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
16654 @item
16655 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
16656 conflict with @file{allout.el}.
16657 @item
16658 @i{Jason Riedy} generalized the send-receive mechanism for Orgtbl tables with
16659 extensive patches.
16660 @item
16661 @i{Philip Rooke} created the Org reference card, provided lots
16662 of feedback, developed and applied standards to the Org documentation.
16663 @item
16664 @i{Christian Schlauer} proposed angular brackets around links, among
16665 other things.
16666 @item
16667 @i{Paul Sexton} wrote @file{org-ctags.el}.
16668 @item
16669 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
16670 @file{organizer-mode.el}.
16671 @item
16672 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
16673 examples, and remote highlighting for referenced code lines.
16674 @item
16675 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
16676 now packaged into Org's @file{contrib} directory.
16677 @item
16678 @i{Daniel Sinder} came up with the idea of internal archiving by locking
16679 subtrees.
16680 @item
16681 @i{Dale Smith} proposed link abbreviations.
16682 @item
16683 @i{James TD Smith} has contributed a large number of patches for useful
16684 tweaks and features.
16685 @item
16686 @i{Adam Spiers} asked for global linking commands, inspired the link
16687 extension system, added support for mairix, and proposed the mapping API.
16688 @item
16689 @i{Ulf Stegemann} created the table to translate special symbols to HTML,
16690 @LaTeX{}, UTF-8, Latin-1 and ASCII.
16691 @item
16692 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
16693 with links transformation to Org syntax.
16694 @item
16695 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
16696 chapter about publishing.
16697 @item
16698 @i{Jambunathan K} contributed the ODT exporter.
16699 @item
16700 @i{Sebastien Vauban} reported many issues with @LaTeX{} and BEAMER export and
16701 enabled source code highlighting in Gnus.
16702 @item
16703 @i{Stefan Vollmar} organized a video-recorded talk at the
16704 Max-Planck-Institute for Neurology.  He also inspired the creation of a
16705 concept index for HTML export.
16706 @item
16707 @i{J@"urgen Vollmer} contributed code generating the table of contents
16708 in HTML output.
16709 @item
16710 @i{Samuel Wales} has provided important feedback and bug reports.
16711 @item
16712 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
16713 keyword.
16714 @item
16715 @i{David Wainberg} suggested archiving, and improvements to the linking
16716 system.
16717 @item
16718 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
16719 linking to Gnus.
16720 @item
16721 @i{Roland Winkler} requested additional key bindings to make Org
16722 work on a tty.
16723 @item
16724 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
16725 and contributed various ideas and code snippets.
16726 @end itemize
16729 @node GNU Free Documentation License, Main Index, History and Acknowledgments, Top
16730 @appendix GNU Free Documentation License
16731 @include doclicense.texi
16734 @node Main Index, Key Index, GNU Free Documentation License, Top
16735 @unnumbered Concept index
16737 @printindex cp
16739 @node Key Index, Command and Function Index, Main Index, Top
16740 @unnumbered Key index
16742 @printindex ky
16744 @node Command and Function Index, Variable Index, Key Index, Top
16745 @unnumbered Command and function index
16747 @printindex fn
16749 @node Variable Index,  , Command and Function Index, Top
16750 @unnumbered Variable index
16752 This is not a complete index of variables and faces, only the ones that are
16753 mentioned in the manual.  For a more complete list, use @kbd{M-x
16754 org-customize @key{RET}} and then click yourself through the tree.
16756 @printindex vr
16758 @bye
16760 @c Local variables:
16761 @c fill-column: 77
16762 @c indent-tabs-mode: nil
16763 @c paragraph-start:    "\b\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|\f\\|[  ]*$"
16764 @c paragraph-separate: "\b\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|[       \f]*$"
16765 @c End:
16768 @c  LocalWords:  webdavhost pre